documentation.d.ts 3.9 MB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260426142624263426442654266426742684269427042714272427342744275427642774278427942804281428242834284428542864287428842894290429142924293429442954296429742984299430043014302430343044305430643074308430943104311431243134314431543164317431843194320432143224323432443254326432743284329433043314332433343344335433643374338433943404341434243434344434543464347434843494350435143524353435443554356435743584359436043614362436343644365436643674368436943704371437243734374437543764377437843794380438143824383438443854386438743884389439043914392439343944395439643974398439944004401440244034404440544064407440844094410441144124413441444154416441744184419442044214422442344244425442644274428442944304431443244334434443544364437443844394440444144424443444444454446444744484449445044514452445344544455445644574458445944604461446244634464446544664467446844694470447144724473447444754476447744784479448044814482448344844485448644874488448944904491449244934494449544964497449844994500450145024503450445054506450745084509451045114512451345144515451645174518451945204521452245234524452545264527452845294530453145324533453445354536453745384539454045414542454345444545454645474548454945504551455245534554455545564557455845594560456145624563456445654566456745684569457045714572457345744575457645774578457945804581458245834584458545864587458845894590459145924593459445954596459745984599460046014602460346044605460646074608460946104611461246134614461546164617461846194620462146224623462446254626462746284629463046314632463346344635463646374638463946404641464246434644464546464647464846494650465146524653465446554656465746584659466046614662466346644665466646674668466946704671467246734674467546764677467846794680468146824683468446854686468746884689469046914692469346944695469646974698469947004701470247034704470547064707470847094710471147124713471447154716471747184719472047214722472347244725472647274728472947304731473247334734473547364737473847394740474147424743474447454746474747484749475047514752475347544755475647574758475947604761476247634764476547664767476847694770477147724773477447754776477747784779478047814782478347844785478647874788478947904791479247934794479547964797479847994800480148024803480448054806480748084809481048114812481348144815481648174818481948204821482248234824482548264827482848294830483148324833483448354836483748384839484048414842484348444845484648474848484948504851485248534854485548564857485848594860486148624863486448654866486748684869487048714872487348744875487648774878487948804881488248834884488548864887488848894890489148924893489448954896489748984899490049014902490349044905490649074908490949104911491249134914491549164917491849194920492149224923492449254926492749284929493049314932493349344935493649374938493949404941494249434944494549464947494849494950495149524953495449554956495749584959496049614962496349644965496649674968496949704971497249734974497549764977497849794980498149824983498449854986498749884989499049914992499349944995499649974998499950005001500250035004500550065007500850095010501150125013501450155016501750185019502050215022502350245025502650275028502950305031503250335034503550365037503850395040504150425043504450455046504750485049505050515052505350545055505650575058505950605061506250635064506550665067506850695070507150725073507450755076507750785079508050815082508350845085508650875088508950905091509250935094509550965097509850995100510151025103510451055106510751085109511051115112511351145115511651175118511951205121512251235124512551265127512851295130513151325133513451355136513751385139514051415142514351445145514651475148514951505151515251535154515551565157515851595160516151625163516451655166516751685169517051715172517351745175517651775178517951805181518251835184518551865187518851895190519151925193519451955196519751985199520052015202520352045205520652075208520952105211521252135214521552165217521852195220522152225223522452255226522752285229523052315232523352345235523652375238523952405241524252435244524552465247524852495250525152525253525452555256525752585259526052615262526352645265526652675268526952705271527252735274527552765277527852795280528152825283528452855286528752885289529052915292529352945295529652975298529953005301530253035304530553065307530853095310531153125313531453155316531753185319532053215322532353245325532653275328532953305331533253335334533553365337533853395340534153425343534453455346534753485349535053515352535353545355535653575358535953605361536253635364536553665367536853695370537153725373537453755376537753785379538053815382538353845385538653875388538953905391539253935394539553965397539853995400540154025403540454055406540754085409541054115412541354145415541654175418541954205421542254235424542554265427542854295430543154325433543454355436543754385439544054415442544354445445544654475448544954505451545254535454545554565457545854595460546154625463546454655466546754685469547054715472547354745475547654775478547954805481548254835484548554865487548854895490549154925493549454955496549754985499550055015502550355045505550655075508550955105511551255135514551555165517551855195520552155225523552455255526552755285529553055315532553355345535553655375538553955405541554255435544554555465547554855495550555155525553555455555556555755585559556055615562556355645565556655675568556955705571557255735574557555765577557855795580558155825583558455855586558755885589559055915592559355945595559655975598559956005601560256035604560556065607560856095610561156125613561456155616561756185619562056215622562356245625562656275628562956305631563256335634563556365637563856395640564156425643564456455646564756485649565056515652565356545655565656575658565956605661566256635664566556665667566856695670567156725673567456755676567756785679568056815682568356845685568656875688568956905691569256935694569556965697569856995700570157025703570457055706570757085709571057115712571357145715571657175718571957205721572257235724572557265727572857295730573157325733573457355736573757385739574057415742574357445745574657475748574957505751575257535754575557565757575857595760576157625763576457655766576757685769577057715772577357745775577657775778577957805781578257835784578557865787578857895790579157925793579457955796579757985799580058015802580358045805580658075808580958105811581258135814581558165817581858195820582158225823582458255826582758285829583058315832583358345835583658375838583958405841584258435844584558465847584858495850585158525853585458555856585758585859586058615862586358645865586658675868586958705871587258735874587558765877587858795880588158825883588458855886588758885889589058915892589358945895589658975898589959005901590259035904590559065907590859095910591159125913591459155916591759185919592059215922592359245925592659275928592959305931593259335934593559365937593859395940594159425943594459455946594759485949595059515952595359545955595659575958595959605961596259635964596559665967596859695970597159725973597459755976597759785979598059815982598359845985598659875988598959905991599259935994599559965997599859996000600160026003600460056006600760086009601060116012601360146015601660176018601960206021602260236024602560266027602860296030603160326033603460356036603760386039604060416042604360446045604660476048604960506051605260536054605560566057605860596060606160626063606460656066606760686069607060716072607360746075607660776078607960806081608260836084608560866087608860896090609160926093609460956096609760986099610061016102610361046105610661076108610961106111611261136114611561166117611861196120612161226123612461256126612761286129613061316132613361346135613661376138613961406141614261436144614561466147614861496150615161526153615461556156615761586159616061616162616361646165616661676168616961706171617261736174617561766177617861796180618161826183618461856186618761886189619061916192619361946195619661976198619962006201620262036204620562066207620862096210621162126213621462156216621762186219622062216222622362246225622662276228622962306231623262336234623562366237623862396240624162426243624462456246624762486249625062516252625362546255625662576258625962606261626262636264626562666267626862696270627162726273627462756276627762786279628062816282628362846285628662876288628962906291629262936294629562966297629862996300630163026303630463056306630763086309631063116312631363146315631663176318631963206321632263236324632563266327632863296330633163326333633463356336633763386339634063416342634363446345634663476348634963506351635263536354635563566357635863596360636163626363636463656366636763686369637063716372637363746375637663776378637963806381638263836384638563866387638863896390639163926393639463956396639763986399640064016402640364046405640664076408640964106411641264136414641564166417641864196420642164226423642464256426642764286429643064316432643364346435643664376438643964406441644264436444644564466447644864496450645164526453645464556456645764586459646064616462646364646465646664676468646964706471647264736474647564766477647864796480648164826483648464856486648764886489649064916492649364946495649664976498649965006501650265036504650565066507650865096510651165126513651465156516651765186519652065216522652365246525652665276528652965306531653265336534653565366537653865396540654165426543654465456546654765486549655065516552655365546555655665576558655965606561656265636564656565666567656865696570657165726573657465756576657765786579658065816582658365846585658665876588658965906591659265936594659565966597659865996600660166026603660466056606660766086609661066116612661366146615661666176618661966206621662266236624662566266627662866296630663166326633663466356636663766386639664066416642664366446645664666476648664966506651665266536654665566566657665866596660666166626663666466656666666766686669667066716672667366746675667666776678667966806681668266836684668566866687668866896690669166926693669466956696669766986699670067016702670367046705670667076708670967106711671267136714671567166717671867196720672167226723672467256726672767286729673067316732673367346735673667376738673967406741674267436744674567466747674867496750675167526753675467556756675767586759676067616762676367646765676667676768676967706771677267736774677567766777677867796780678167826783678467856786678767886789679067916792679367946795679667976798679968006801680268036804680568066807680868096810681168126813681468156816681768186819682068216822682368246825682668276828682968306831683268336834683568366837683868396840684168426843684468456846684768486849685068516852685368546855685668576858685968606861686268636864686568666867686868696870687168726873687468756876687768786879688068816882688368846885688668876888688968906891689268936894689568966897689868996900690169026903690469056906690769086909691069116912691369146915691669176918691969206921692269236924692569266927692869296930693169326933693469356936693769386939694069416942694369446945694669476948694969506951695269536954695569566957695869596960696169626963696469656966696769686969697069716972697369746975697669776978697969806981698269836984698569866987698869896990699169926993699469956996699769986999700070017002700370047005700670077008700970107011701270137014701570167017701870197020702170227023702470257026702770287029703070317032703370347035703670377038703970407041704270437044704570467047704870497050705170527053705470557056705770587059706070617062706370647065706670677068706970707071707270737074707570767077707870797080708170827083708470857086708770887089709070917092709370947095709670977098709971007101710271037104710571067107710871097110711171127113711471157116711771187119712071217122712371247125712671277128712971307131713271337134713571367137713871397140714171427143714471457146714771487149715071517152715371547155715671577158715971607161716271637164716571667167716871697170717171727173717471757176717771787179718071817182718371847185718671877188718971907191719271937194719571967197719871997200720172027203720472057206720772087209721072117212721372147215721672177218721972207221722272237224722572267227722872297230723172327233723472357236723772387239724072417242724372447245724672477248724972507251725272537254725572567257725872597260726172627263726472657266726772687269727072717272727372747275727672777278727972807281728272837284728572867287728872897290729172927293729472957296729772987299730073017302730373047305730673077308730973107311731273137314731573167317731873197320732173227323732473257326732773287329733073317332733373347335733673377338733973407341734273437344734573467347734873497350735173527353735473557356735773587359736073617362736373647365736673677368736973707371737273737374737573767377737873797380738173827383738473857386738773887389739073917392739373947395739673977398739974007401740274037404740574067407740874097410741174127413741474157416741774187419742074217422742374247425742674277428742974307431743274337434743574367437743874397440744174427443744474457446744774487449745074517452745374547455745674577458745974607461746274637464746574667467746874697470747174727473747474757476747774787479748074817482748374847485748674877488748974907491749274937494749574967497749874997500750175027503750475057506750775087509751075117512751375147515751675177518751975207521752275237524752575267527752875297530753175327533753475357536753775387539754075417542754375447545754675477548754975507551755275537554755575567557755875597560756175627563756475657566756775687569757075717572757375747575757675777578757975807581758275837584758575867587758875897590759175927593759475957596759775987599760076017602760376047605760676077608760976107611761276137614761576167617761876197620762176227623762476257626762776287629763076317632763376347635763676377638763976407641764276437644764576467647764876497650765176527653765476557656765776587659766076617662766376647665766676677668766976707671767276737674767576767677767876797680768176827683768476857686768776887689769076917692769376947695769676977698769977007701770277037704770577067707770877097710771177127713771477157716771777187719772077217722772377247725772677277728772977307731773277337734773577367737773877397740774177427743774477457746774777487749775077517752775377547755775677577758775977607761776277637764776577667767776877697770777177727773777477757776777777787779778077817782778377847785778677877788778977907791779277937794779577967797779877997800780178027803780478057806780778087809781078117812781378147815781678177818781978207821782278237824782578267827782878297830783178327833783478357836783778387839784078417842784378447845784678477848784978507851785278537854785578567857785878597860786178627863786478657866786778687869787078717872787378747875787678777878787978807881788278837884788578867887788878897890789178927893789478957896789778987899790079017902790379047905790679077908790979107911791279137914791579167917791879197920792179227923792479257926792779287929793079317932793379347935793679377938793979407941794279437944794579467947794879497950795179527953795479557956795779587959796079617962796379647965796679677968796979707971797279737974797579767977797879797980798179827983798479857986798779887989799079917992799379947995799679977998799980008001800280038004800580068007800880098010801180128013801480158016801780188019802080218022802380248025802680278028802980308031803280338034803580368037803880398040804180428043804480458046804780488049805080518052805380548055805680578058805980608061806280638064806580668067806880698070807180728073807480758076807780788079808080818082808380848085808680878088808980908091809280938094809580968097809880998100810181028103810481058106810781088109811081118112811381148115811681178118811981208121812281238124812581268127812881298130813181328133813481358136813781388139814081418142814381448145814681478148814981508151815281538154815581568157815881598160816181628163816481658166816781688169817081718172817381748175817681778178817981808181818281838184818581868187818881898190819181928193819481958196819781988199820082018202820382048205820682078208820982108211821282138214821582168217821882198220822182228223822482258226822782288229823082318232823382348235823682378238823982408241824282438244824582468247824882498250825182528253825482558256825782588259826082618262826382648265826682678268826982708271827282738274827582768277827882798280828182828283828482858286828782888289829082918292829382948295829682978298829983008301830283038304830583068307830883098310831183128313831483158316831783188319832083218322832383248325832683278328832983308331833283338334833583368337833883398340834183428343834483458346834783488349835083518352835383548355835683578358835983608361836283638364836583668367836883698370837183728373837483758376837783788379838083818382838383848385838683878388838983908391839283938394839583968397839883998400840184028403840484058406840784088409841084118412841384148415841684178418841984208421842284238424842584268427842884298430843184328433843484358436843784388439844084418442844384448445844684478448844984508451845284538454845584568457845884598460846184628463846484658466846784688469847084718472847384748475847684778478847984808481848284838484848584868487848884898490849184928493849484958496849784988499850085018502850385048505850685078508850985108511851285138514851585168517851885198520852185228523852485258526852785288529853085318532853385348535853685378538853985408541854285438544854585468547854885498550855185528553855485558556855785588559856085618562856385648565856685678568856985708571857285738574857585768577857885798580858185828583858485858586858785888589859085918592859385948595859685978598859986008601860286038604860586068607860886098610861186128613861486158616861786188619862086218622862386248625862686278628862986308631863286338634863586368637863886398640864186428643864486458646864786488649865086518652865386548655865686578658865986608661866286638664866586668667866886698670867186728673867486758676867786788679868086818682868386848685868686878688868986908691869286938694869586968697869886998700870187028703870487058706870787088709871087118712871387148715871687178718871987208721872287238724872587268727872887298730873187328733873487358736873787388739874087418742874387448745874687478748874987508751875287538754875587568757875887598760876187628763876487658766876787688769877087718772877387748775877687778778877987808781878287838784878587868787878887898790879187928793879487958796879787988799880088018802880388048805880688078808880988108811881288138814881588168817881888198820882188228823882488258826882788288829883088318832883388348835883688378838883988408841884288438844884588468847884888498850885188528853885488558856885788588859886088618862886388648865886688678868886988708871887288738874887588768877887888798880888188828883888488858886888788888889889088918892889388948895889688978898889989008901890289038904890589068907890889098910891189128913891489158916891789188919892089218922892389248925892689278928892989308931893289338934893589368937893889398940894189428943894489458946894789488949895089518952895389548955895689578958895989608961896289638964896589668967896889698970897189728973897489758976897789788979898089818982898389848985898689878988898989908991899289938994899589968997899889999000900190029003900490059006900790089009901090119012901390149015901690179018901990209021902290239024902590269027902890299030903190329033903490359036903790389039904090419042904390449045904690479048904990509051905290539054905590569057905890599060906190629063906490659066906790689069907090719072907390749075907690779078907990809081908290839084908590869087908890899090909190929093909490959096909790989099910091019102910391049105910691079108910991109111911291139114911591169117911891199120912191229123912491259126912791289129913091319132913391349135913691379138913991409141914291439144914591469147914891499150915191529153915491559156915791589159916091619162916391649165916691679168916991709171917291739174917591769177917891799180918191829183918491859186918791889189919091919192919391949195919691979198919992009201920292039204920592069207920892099210921192129213921492159216921792189219922092219222922392249225922692279228922992309231923292339234923592369237923892399240924192429243924492459246924792489249925092519252925392549255925692579258925992609261926292639264926592669267926892699270927192729273927492759276927792789279928092819282928392849285928692879288928992909291929292939294929592969297929892999300930193029303930493059306930793089309931093119312931393149315931693179318931993209321932293239324932593269327932893299330933193329333933493359336933793389339934093419342934393449345934693479348934993509351935293539354935593569357935893599360936193629363936493659366936793689369937093719372937393749375937693779378937993809381938293839384938593869387938893899390939193929393939493959396939793989399940094019402940394049405940694079408940994109411941294139414941594169417941894199420942194229423942494259426942794289429943094319432943394349435943694379438943994409441944294439444944594469447944894499450945194529453945494559456945794589459946094619462946394649465946694679468946994709471947294739474947594769477947894799480948194829483948494859486948794889489949094919492949394949495949694979498949995009501950295039504950595069507950895099510951195129513951495159516951795189519952095219522952395249525952695279528952995309531953295339534953595369537953895399540954195429543954495459546954795489549955095519552955395549555955695579558955995609561956295639564956595669567956895699570957195729573957495759576957795789579958095819582958395849585958695879588958995909591959295939594959595969597959895999600960196029603960496059606960796089609961096119612961396149615961696179618961996209621962296239624962596269627962896299630963196329633963496359636963796389639964096419642964396449645964696479648964996509651965296539654965596569657965896599660966196629663966496659666966796689669967096719672967396749675967696779678967996809681968296839684968596869687968896899690969196929693969496959696969796989699970097019702970397049705970697079708970997109711971297139714971597169717971897199720972197229723972497259726972797289729973097319732973397349735973697379738973997409741974297439744974597469747974897499750975197529753975497559756975797589759976097619762976397649765976697679768976997709771977297739774977597769777977897799780978197829783978497859786978797889789979097919792979397949795979697979798979998009801980298039804980598069807980898099810981198129813981498159816981798189819982098219822982398249825982698279828982998309831983298339834983598369837983898399840984198429843984498459846984798489849985098519852985398549855985698579858985998609861986298639864986598669867986898699870987198729873987498759876987798789879988098819882988398849885988698879888988998909891989298939894989598969897989898999900990199029903990499059906990799089909991099119912991399149915991699179918991999209921992299239924992599269927992899299930993199329933993499359936993799389939994099419942994399449945994699479948994999509951995299539954995599569957995899599960996199629963996499659966996799689969997099719972997399749975997699779978997999809981998299839984998599869987998899899990999199929993999499959996999799989999100001000110002100031000410005100061000710008100091001010011100121001310014100151001610017100181001910020100211002210023100241002510026100271002810029100301003110032100331003410035100361003710038100391004010041100421004310044100451004610047100481004910050100511005210053100541005510056100571005810059100601006110062100631006410065100661006710068100691007010071100721007310074100751007610077100781007910080100811008210083100841008510086100871008810089100901009110092100931009410095100961009710098100991010010101101021010310104101051010610107101081010910110101111011210113101141011510116101171011810119101201012110122101231012410125101261012710128101291013010131101321013310134101351013610137101381013910140101411014210143101441014510146101471014810149101501015110152101531015410155101561015710158101591016010161101621016310164101651016610167101681016910170101711017210173101741017510176101771017810179101801018110182101831018410185101861018710188101891019010191101921019310194101951019610197101981019910200102011020210203102041020510206102071020810209102101021110212102131021410215102161021710218102191022010221102221022310224102251022610227102281022910230102311023210233102341023510236102371023810239102401024110242102431024410245102461024710248102491025010251102521025310254102551025610257102581025910260102611026210263102641026510266102671026810269102701027110272102731027410275102761027710278102791028010281102821028310284102851028610287102881028910290102911029210293102941029510296102971029810299103001030110302103031030410305103061030710308103091031010311103121031310314103151031610317103181031910320103211032210323103241032510326103271032810329103301033110332103331033410335103361033710338103391034010341103421034310344103451034610347103481034910350103511035210353103541035510356103571035810359103601036110362103631036410365103661036710368103691037010371103721037310374103751037610377103781037910380103811038210383103841038510386103871038810389103901039110392103931039410395103961039710398103991040010401104021040310404104051040610407104081040910410104111041210413104141041510416104171041810419104201042110422104231042410425104261042710428104291043010431104321043310434104351043610437104381043910440104411044210443104441044510446104471044810449104501045110452104531045410455104561045710458104591046010461104621046310464104651046610467104681046910470104711047210473104741047510476104771047810479104801048110482104831048410485104861048710488104891049010491104921049310494104951049610497104981049910500105011050210503105041050510506105071050810509105101051110512105131051410515105161051710518105191052010521105221052310524105251052610527105281052910530105311053210533105341053510536105371053810539105401054110542105431054410545105461054710548105491055010551105521055310554105551055610557105581055910560105611056210563105641056510566105671056810569105701057110572105731057410575105761057710578105791058010581105821058310584105851058610587105881058910590105911059210593105941059510596105971059810599106001060110602106031060410605106061060710608106091061010611106121061310614106151061610617106181061910620106211062210623106241062510626106271062810629106301063110632106331063410635106361063710638106391064010641106421064310644106451064610647106481064910650106511065210653106541065510656106571065810659106601066110662106631066410665106661066710668106691067010671106721067310674106751067610677106781067910680106811068210683106841068510686106871068810689106901069110692106931069410695106961069710698106991070010701107021070310704107051070610707107081070910710107111071210713107141071510716107171071810719107201072110722107231072410725107261072710728107291073010731107321073310734107351073610737107381073910740107411074210743107441074510746107471074810749107501075110752107531075410755107561075710758107591076010761107621076310764107651076610767107681076910770107711077210773107741077510776107771077810779107801078110782107831078410785107861078710788107891079010791107921079310794107951079610797107981079910800108011080210803108041080510806108071080810809108101081110812108131081410815108161081710818108191082010821108221082310824108251082610827108281082910830108311083210833108341083510836108371083810839108401084110842108431084410845108461084710848108491085010851108521085310854108551085610857108581085910860108611086210863108641086510866108671086810869108701087110872108731087410875108761087710878108791088010881108821088310884108851088610887108881088910890108911089210893108941089510896108971089810899109001090110902109031090410905109061090710908109091091010911109121091310914109151091610917109181091910920109211092210923109241092510926109271092810929109301093110932109331093410935109361093710938109391094010941109421094310944109451094610947109481094910950109511095210953109541095510956109571095810959109601096110962109631096410965109661096710968109691097010971109721097310974109751097610977109781097910980109811098210983109841098510986109871098810989109901099110992109931099410995109961099710998109991100011001110021100311004110051100611007110081100911010110111101211013110141101511016110171101811019110201102111022110231102411025110261102711028110291103011031110321103311034110351103611037110381103911040110411104211043110441104511046110471104811049110501105111052110531105411055110561105711058110591106011061110621106311064110651106611067110681106911070110711107211073110741107511076110771107811079110801108111082110831108411085110861108711088110891109011091110921109311094110951109611097110981109911100111011110211103111041110511106111071110811109111101111111112111131111411115111161111711118111191112011121111221112311124111251112611127111281112911130111311113211133111341113511136111371113811139111401114111142111431114411145111461114711148111491115011151111521115311154111551115611157111581115911160111611116211163111641116511166111671116811169111701117111172111731117411175111761117711178111791118011181111821118311184111851118611187111881118911190111911119211193111941119511196111971119811199112001120111202112031120411205112061120711208112091121011211112121121311214112151121611217112181121911220112211122211223112241122511226112271122811229112301123111232112331123411235112361123711238112391124011241112421124311244112451124611247112481124911250112511125211253112541125511256112571125811259112601126111262112631126411265112661126711268112691127011271112721127311274112751127611277112781127911280112811128211283112841128511286112871128811289112901129111292112931129411295112961129711298112991130011301113021130311304113051130611307113081130911310113111131211313113141131511316113171131811319113201132111322113231132411325113261132711328113291133011331113321133311334113351133611337113381133911340113411134211343113441134511346113471134811349113501135111352113531135411355113561135711358113591136011361113621136311364113651136611367113681136911370113711137211373113741137511376113771137811379113801138111382113831138411385113861138711388113891139011391113921139311394113951139611397113981139911400114011140211403114041140511406114071140811409114101141111412114131141411415114161141711418114191142011421114221142311424114251142611427114281142911430114311143211433114341143511436114371143811439114401144111442114431144411445114461144711448114491145011451114521145311454114551145611457114581145911460114611146211463114641146511466114671146811469114701147111472114731147411475114761147711478114791148011481114821148311484114851148611487114881148911490114911149211493114941149511496114971149811499115001150111502115031150411505115061150711508115091151011511115121151311514115151151611517115181151911520115211152211523115241152511526115271152811529115301153111532115331153411535115361153711538115391154011541115421154311544115451154611547115481154911550115511155211553115541155511556115571155811559115601156111562115631156411565115661156711568115691157011571115721157311574115751157611577115781157911580115811158211583115841158511586115871158811589115901159111592115931159411595115961159711598115991160011601116021160311604116051160611607116081160911610116111161211613116141161511616116171161811619116201162111622116231162411625116261162711628116291163011631116321163311634116351163611637116381163911640116411164211643116441164511646116471164811649116501165111652116531165411655116561165711658116591166011661116621166311664116651166611667116681166911670116711167211673116741167511676116771167811679116801168111682116831168411685116861168711688116891169011691116921169311694116951169611697116981169911700117011170211703117041170511706117071170811709117101171111712117131171411715117161171711718117191172011721117221172311724117251172611727117281172911730117311173211733117341173511736117371173811739117401174111742117431174411745117461174711748117491175011751117521175311754117551175611757117581175911760117611176211763117641176511766117671176811769117701177111772117731177411775117761177711778117791178011781117821178311784117851178611787117881178911790117911179211793117941179511796117971179811799118001180111802118031180411805118061180711808118091181011811118121181311814118151181611817118181181911820118211182211823118241182511826118271182811829118301183111832118331183411835118361183711838118391184011841118421184311844118451184611847118481184911850118511185211853118541185511856118571185811859118601186111862118631186411865118661186711868118691187011871118721187311874118751187611877118781187911880118811188211883118841188511886118871188811889118901189111892118931189411895118961189711898118991190011901119021190311904119051190611907119081190911910119111191211913119141191511916119171191811919119201192111922119231192411925119261192711928119291193011931119321193311934119351193611937119381193911940119411194211943119441194511946119471194811949119501195111952119531195411955119561195711958119591196011961119621196311964119651196611967119681196911970119711197211973119741197511976119771197811979119801198111982119831198411985119861198711988119891199011991119921199311994119951199611997119981199912000120011200212003120041200512006120071200812009120101201112012120131201412015120161201712018120191202012021120221202312024120251202612027120281202912030120311203212033120341203512036120371203812039120401204112042120431204412045120461204712048120491205012051120521205312054120551205612057120581205912060120611206212063120641206512066120671206812069120701207112072120731207412075120761207712078120791208012081120821208312084120851208612087120881208912090120911209212093120941209512096120971209812099121001210112102121031210412105121061210712108121091211012111121121211312114121151211612117121181211912120121211212212123121241212512126121271212812129121301213112132121331213412135121361213712138121391214012141121421214312144121451214612147121481214912150121511215212153121541215512156121571215812159121601216112162121631216412165121661216712168121691217012171121721217312174121751217612177121781217912180121811218212183121841218512186121871218812189121901219112192121931219412195121961219712198121991220012201122021220312204122051220612207122081220912210122111221212213122141221512216122171221812219122201222112222122231222412225122261222712228122291223012231122321223312234122351223612237122381223912240122411224212243122441224512246122471224812249122501225112252122531225412255122561225712258122591226012261122621226312264122651226612267122681226912270122711227212273122741227512276122771227812279122801228112282122831228412285122861228712288122891229012291122921229312294122951229612297122981229912300123011230212303123041230512306123071230812309123101231112312123131231412315123161231712318123191232012321123221232312324123251232612327123281232912330123311233212333123341233512336123371233812339123401234112342123431234412345123461234712348123491235012351123521235312354123551235612357123581235912360123611236212363123641236512366123671236812369123701237112372123731237412375123761237712378123791238012381123821238312384123851238612387123881238912390123911239212393123941239512396123971239812399124001240112402124031240412405124061240712408124091241012411124121241312414124151241612417124181241912420124211242212423124241242512426124271242812429124301243112432124331243412435124361243712438124391244012441124421244312444124451244612447124481244912450124511245212453124541245512456124571245812459124601246112462124631246412465124661246712468124691247012471124721247312474124751247612477124781247912480124811248212483124841248512486124871248812489124901249112492124931249412495124961249712498124991250012501125021250312504125051250612507125081250912510125111251212513125141251512516125171251812519125201252112522125231252412525125261252712528125291253012531125321253312534125351253612537125381253912540125411254212543125441254512546125471254812549125501255112552125531255412555125561255712558125591256012561125621256312564125651256612567125681256912570125711257212573125741257512576125771257812579125801258112582125831258412585125861258712588125891259012591125921259312594125951259612597125981259912600126011260212603126041260512606126071260812609126101261112612126131261412615126161261712618126191262012621126221262312624126251262612627126281262912630126311263212633126341263512636126371263812639126401264112642126431264412645126461264712648126491265012651126521265312654126551265612657126581265912660126611266212663126641266512666126671266812669126701267112672126731267412675126761267712678126791268012681126821268312684126851268612687126881268912690126911269212693126941269512696126971269812699127001270112702127031270412705127061270712708127091271012711127121271312714127151271612717127181271912720127211272212723127241272512726127271272812729127301273112732127331273412735127361273712738127391274012741127421274312744127451274612747127481274912750127511275212753127541275512756127571275812759127601276112762127631276412765127661276712768127691277012771127721277312774127751277612777127781277912780127811278212783127841278512786127871278812789127901279112792127931279412795127961279712798127991280012801128021280312804128051280612807128081280912810128111281212813128141281512816128171281812819128201282112822128231282412825128261282712828128291283012831128321283312834128351283612837128381283912840128411284212843128441284512846128471284812849128501285112852128531285412855128561285712858128591286012861128621286312864128651286612867128681286912870128711287212873128741287512876128771287812879128801288112882128831288412885128861288712888128891289012891128921289312894128951289612897128981289912900129011290212903129041290512906129071290812909129101291112912129131291412915129161291712918129191292012921129221292312924129251292612927129281292912930129311293212933129341293512936129371293812939129401294112942129431294412945129461294712948129491295012951129521295312954129551295612957129581295912960129611296212963129641296512966129671296812969129701297112972129731297412975129761297712978129791298012981129821298312984129851298612987129881298912990129911299212993129941299512996129971299812999130001300113002130031300413005130061300713008130091301013011130121301313014130151301613017130181301913020130211302213023130241302513026130271302813029130301303113032130331303413035130361303713038130391304013041130421304313044130451304613047130481304913050130511305213053130541305513056130571305813059130601306113062130631306413065130661306713068130691307013071130721307313074130751307613077130781307913080130811308213083130841308513086130871308813089130901309113092130931309413095130961309713098130991310013101131021310313104131051310613107131081310913110131111311213113131141311513116131171311813119131201312113122131231312413125131261312713128131291313013131131321313313134131351313613137131381313913140131411314213143131441314513146131471314813149131501315113152131531315413155131561315713158131591316013161131621316313164131651316613167131681316913170131711317213173131741317513176131771317813179131801318113182131831318413185131861318713188131891319013191131921319313194131951319613197131981319913200132011320213203132041320513206132071320813209132101321113212132131321413215132161321713218132191322013221132221322313224132251322613227132281322913230132311323213233132341323513236132371323813239132401324113242132431324413245132461324713248132491325013251132521325313254132551325613257132581325913260132611326213263132641326513266132671326813269132701327113272132731327413275132761327713278132791328013281132821328313284132851328613287132881328913290132911329213293132941329513296132971329813299133001330113302133031330413305133061330713308133091331013311133121331313314133151331613317133181331913320133211332213323133241332513326133271332813329133301333113332133331333413335133361333713338133391334013341133421334313344133451334613347133481334913350133511335213353133541335513356133571335813359133601336113362133631336413365133661336713368133691337013371133721337313374133751337613377133781337913380133811338213383133841338513386133871338813389133901339113392133931339413395133961339713398133991340013401134021340313404134051340613407134081340913410134111341213413134141341513416134171341813419134201342113422134231342413425134261342713428134291343013431134321343313434134351343613437134381343913440134411344213443134441344513446134471344813449134501345113452134531345413455134561345713458134591346013461134621346313464134651346613467134681346913470134711347213473134741347513476134771347813479134801348113482134831348413485134861348713488134891349013491134921349313494134951349613497134981349913500135011350213503135041350513506135071350813509135101351113512135131351413515135161351713518135191352013521135221352313524135251352613527135281352913530135311353213533135341353513536135371353813539135401354113542135431354413545135461354713548135491355013551135521355313554135551355613557135581355913560135611356213563135641356513566135671356813569135701357113572135731357413575135761357713578135791358013581135821358313584135851358613587135881358913590135911359213593135941359513596135971359813599136001360113602136031360413605136061360713608136091361013611136121361313614136151361613617136181361913620136211362213623136241362513626136271362813629136301363113632136331363413635136361363713638136391364013641136421364313644136451364613647136481364913650136511365213653136541365513656136571365813659136601366113662136631366413665136661366713668136691367013671136721367313674136751367613677136781367913680136811368213683136841368513686136871368813689136901369113692136931369413695136961369713698136991370013701137021370313704137051370613707137081370913710137111371213713137141371513716137171371813719137201372113722137231372413725137261372713728137291373013731137321373313734137351373613737137381373913740137411374213743137441374513746137471374813749137501375113752137531375413755137561375713758137591376013761137621376313764137651376613767137681376913770137711377213773137741377513776137771377813779137801378113782137831378413785137861378713788137891379013791137921379313794137951379613797137981379913800138011380213803138041380513806138071380813809138101381113812138131381413815138161381713818138191382013821138221382313824138251382613827138281382913830138311383213833138341383513836138371383813839138401384113842138431384413845138461384713848138491385013851138521385313854138551385613857138581385913860138611386213863138641386513866138671386813869138701387113872138731387413875138761387713878138791388013881138821388313884138851388613887138881388913890138911389213893138941389513896138971389813899139001390113902139031390413905139061390713908139091391013911139121391313914139151391613917139181391913920139211392213923139241392513926139271392813929139301393113932139331393413935139361393713938139391394013941139421394313944139451394613947139481394913950139511395213953139541395513956139571395813959139601396113962139631396413965139661396713968139691397013971139721397313974139751397613977139781397913980139811398213983139841398513986139871398813989139901399113992139931399413995139961399713998139991400014001140021400314004140051400614007140081400914010140111401214013140141401514016140171401814019140201402114022140231402414025140261402714028140291403014031140321403314034140351403614037140381403914040140411404214043140441404514046140471404814049140501405114052140531405414055140561405714058140591406014061140621406314064140651406614067140681406914070140711407214073140741407514076140771407814079140801408114082140831408414085140861408714088140891409014091140921409314094140951409614097140981409914100141011410214103141041410514106141071410814109141101411114112141131411414115141161411714118141191412014121141221412314124141251412614127141281412914130141311413214133141341413514136141371413814139141401414114142141431414414145141461414714148141491415014151141521415314154141551415614157141581415914160141611416214163141641416514166141671416814169141701417114172141731417414175141761417714178141791418014181141821418314184141851418614187141881418914190141911419214193141941419514196141971419814199142001420114202142031420414205142061420714208142091421014211142121421314214142151421614217142181421914220142211422214223142241422514226142271422814229142301423114232142331423414235142361423714238142391424014241142421424314244142451424614247142481424914250142511425214253142541425514256142571425814259142601426114262142631426414265142661426714268142691427014271142721427314274142751427614277142781427914280142811428214283142841428514286142871428814289142901429114292142931429414295142961429714298142991430014301143021430314304143051430614307143081430914310143111431214313143141431514316143171431814319143201432114322143231432414325143261432714328143291433014331143321433314334143351433614337143381433914340143411434214343143441434514346143471434814349143501435114352143531435414355143561435714358143591436014361143621436314364143651436614367143681436914370143711437214373143741437514376143771437814379143801438114382143831438414385143861438714388143891439014391143921439314394143951439614397143981439914400144011440214403144041440514406144071440814409144101441114412144131441414415144161441714418144191442014421144221442314424144251442614427144281442914430144311443214433144341443514436144371443814439144401444114442144431444414445144461444714448144491445014451144521445314454144551445614457144581445914460144611446214463144641446514466144671446814469144701447114472144731447414475144761447714478144791448014481144821448314484144851448614487144881448914490144911449214493144941449514496144971449814499145001450114502145031450414505145061450714508145091451014511145121451314514145151451614517145181451914520145211452214523145241452514526145271452814529145301453114532145331453414535145361453714538145391454014541145421454314544145451454614547145481454914550145511455214553145541455514556145571455814559145601456114562145631456414565145661456714568145691457014571145721457314574145751457614577145781457914580145811458214583145841458514586145871458814589145901459114592145931459414595145961459714598145991460014601146021460314604146051460614607146081460914610146111461214613146141461514616146171461814619146201462114622146231462414625146261462714628146291463014631146321463314634146351463614637146381463914640146411464214643146441464514646146471464814649146501465114652146531465414655146561465714658146591466014661146621466314664146651466614667146681466914670146711467214673146741467514676146771467814679146801468114682146831468414685146861468714688146891469014691146921469314694146951469614697146981469914700147011470214703147041470514706147071470814709147101471114712147131471414715147161471714718147191472014721147221472314724147251472614727147281472914730147311473214733147341473514736147371473814739147401474114742147431474414745147461474714748147491475014751147521475314754147551475614757147581475914760147611476214763147641476514766147671476814769147701477114772147731477414775147761477714778147791478014781147821478314784147851478614787147881478914790147911479214793147941479514796147971479814799148001480114802148031480414805148061480714808148091481014811148121481314814148151481614817148181481914820148211482214823148241482514826148271482814829148301483114832148331483414835148361483714838148391484014841148421484314844148451484614847148481484914850148511485214853148541485514856148571485814859148601486114862148631486414865148661486714868148691487014871148721487314874148751487614877148781487914880148811488214883148841488514886148871488814889148901489114892148931489414895148961489714898148991490014901149021490314904149051490614907149081490914910149111491214913149141491514916149171491814919149201492114922149231492414925149261492714928149291493014931149321493314934149351493614937149381493914940149411494214943149441494514946149471494814949149501495114952149531495414955149561495714958149591496014961149621496314964149651496614967149681496914970149711497214973149741497514976149771497814979149801498114982149831498414985149861498714988149891499014991149921499314994149951499614997149981499915000150011500215003150041500515006150071500815009150101501115012150131501415015150161501715018150191502015021150221502315024150251502615027150281502915030150311503215033150341503515036150371503815039150401504115042150431504415045150461504715048150491505015051150521505315054150551505615057150581505915060150611506215063150641506515066150671506815069150701507115072150731507415075150761507715078150791508015081150821508315084150851508615087150881508915090150911509215093150941509515096150971509815099151001510115102151031510415105151061510715108151091511015111151121511315114151151511615117151181511915120151211512215123151241512515126151271512815129151301513115132151331513415135151361513715138151391514015141151421514315144151451514615147151481514915150151511515215153151541515515156151571515815159151601516115162151631516415165151661516715168151691517015171151721517315174151751517615177151781517915180151811518215183151841518515186151871518815189151901519115192151931519415195151961519715198151991520015201152021520315204152051520615207152081520915210152111521215213152141521515216152171521815219152201522115222152231522415225152261522715228152291523015231152321523315234152351523615237152381523915240152411524215243152441524515246152471524815249152501525115252152531525415255152561525715258152591526015261152621526315264152651526615267152681526915270152711527215273152741527515276152771527815279152801528115282152831528415285152861528715288152891529015291152921529315294152951529615297152981529915300153011530215303153041530515306153071530815309153101531115312153131531415315153161531715318153191532015321153221532315324153251532615327153281532915330153311533215333153341533515336153371533815339153401534115342153431534415345153461534715348153491535015351153521535315354153551535615357153581535915360153611536215363153641536515366153671536815369153701537115372153731537415375153761537715378153791538015381153821538315384153851538615387153881538915390153911539215393153941539515396153971539815399154001540115402154031540415405154061540715408154091541015411154121541315414154151541615417154181541915420154211542215423154241542515426154271542815429154301543115432154331543415435154361543715438154391544015441154421544315444154451544615447154481544915450154511545215453154541545515456154571545815459154601546115462154631546415465154661546715468154691547015471154721547315474154751547615477154781547915480154811548215483154841548515486154871548815489154901549115492154931549415495154961549715498154991550015501155021550315504155051550615507155081550915510155111551215513155141551515516155171551815519155201552115522155231552415525155261552715528155291553015531155321553315534155351553615537155381553915540155411554215543155441554515546155471554815549155501555115552155531555415555155561555715558155591556015561155621556315564155651556615567155681556915570155711557215573155741557515576155771557815579155801558115582155831558415585155861558715588155891559015591155921559315594155951559615597155981559915600156011560215603156041560515606156071560815609156101561115612156131561415615156161561715618156191562015621156221562315624156251562615627156281562915630156311563215633156341563515636156371563815639156401564115642156431564415645156461564715648156491565015651156521565315654156551565615657156581565915660156611566215663156641566515666156671566815669156701567115672156731567415675156761567715678156791568015681156821568315684156851568615687156881568915690156911569215693156941569515696156971569815699157001570115702157031570415705157061570715708157091571015711157121571315714157151571615717157181571915720157211572215723157241572515726157271572815729157301573115732157331573415735157361573715738157391574015741157421574315744157451574615747157481574915750157511575215753157541575515756157571575815759157601576115762157631576415765157661576715768157691577015771157721577315774157751577615777157781577915780157811578215783157841578515786157871578815789157901579115792157931579415795157961579715798157991580015801158021580315804158051580615807158081580915810158111581215813158141581515816158171581815819158201582115822158231582415825158261582715828158291583015831158321583315834158351583615837158381583915840158411584215843158441584515846158471584815849158501585115852158531585415855158561585715858158591586015861158621586315864158651586615867158681586915870158711587215873158741587515876158771587815879158801588115882158831588415885158861588715888158891589015891158921589315894158951589615897158981589915900159011590215903159041590515906159071590815909159101591115912159131591415915159161591715918159191592015921159221592315924159251592615927159281592915930159311593215933159341593515936159371593815939159401594115942159431594415945159461594715948159491595015951159521595315954159551595615957159581595915960159611596215963159641596515966159671596815969159701597115972159731597415975159761597715978159791598015981159821598315984159851598615987159881598915990159911599215993159941599515996159971599815999160001600116002160031600416005160061600716008160091601016011160121601316014160151601616017160181601916020160211602216023160241602516026160271602816029160301603116032160331603416035160361603716038160391604016041160421604316044160451604616047160481604916050160511605216053160541605516056160571605816059160601606116062160631606416065160661606716068160691607016071160721607316074160751607616077160781607916080160811608216083160841608516086160871608816089160901609116092160931609416095160961609716098160991610016101161021610316104161051610616107161081610916110161111611216113161141611516116161171611816119161201612116122161231612416125161261612716128161291613016131161321613316134161351613616137161381613916140161411614216143161441614516146161471614816149161501615116152161531615416155161561615716158161591616016161161621616316164161651616616167161681616916170161711617216173161741617516176161771617816179161801618116182161831618416185161861618716188161891619016191161921619316194161951619616197161981619916200162011620216203162041620516206162071620816209162101621116212162131621416215162161621716218162191622016221162221622316224162251622616227162281622916230162311623216233162341623516236162371623816239162401624116242162431624416245162461624716248162491625016251162521625316254162551625616257162581625916260162611626216263162641626516266162671626816269162701627116272162731627416275162761627716278162791628016281162821628316284162851628616287162881628916290162911629216293162941629516296162971629816299163001630116302163031630416305163061630716308163091631016311163121631316314163151631616317163181631916320163211632216323163241632516326163271632816329163301633116332163331633416335163361633716338163391634016341163421634316344163451634616347163481634916350163511635216353163541635516356163571635816359163601636116362163631636416365163661636716368163691637016371163721637316374163751637616377163781637916380163811638216383163841638516386163871638816389163901639116392163931639416395163961639716398163991640016401164021640316404164051640616407164081640916410164111641216413164141641516416164171641816419164201642116422164231642416425164261642716428164291643016431164321643316434164351643616437164381643916440164411644216443164441644516446164471644816449164501645116452164531645416455164561645716458164591646016461164621646316464164651646616467164681646916470164711647216473164741647516476164771647816479164801648116482164831648416485164861648716488164891649016491164921649316494164951649616497164981649916500165011650216503165041650516506165071650816509165101651116512165131651416515165161651716518165191652016521165221652316524165251652616527165281652916530165311653216533165341653516536165371653816539165401654116542165431654416545165461654716548165491655016551165521655316554165551655616557165581655916560165611656216563165641656516566165671656816569165701657116572165731657416575165761657716578165791658016581165821658316584165851658616587165881658916590165911659216593165941659516596165971659816599166001660116602166031660416605166061660716608166091661016611166121661316614166151661616617166181661916620166211662216623166241662516626166271662816629166301663116632166331663416635166361663716638166391664016641166421664316644166451664616647166481664916650166511665216653166541665516656166571665816659166601666116662166631666416665166661666716668166691667016671166721667316674166751667616677166781667916680166811668216683166841668516686166871668816689166901669116692166931669416695166961669716698166991670016701167021670316704167051670616707167081670916710167111671216713167141671516716167171671816719167201672116722167231672416725167261672716728167291673016731167321673316734167351673616737167381673916740167411674216743167441674516746167471674816749167501675116752167531675416755167561675716758167591676016761167621676316764167651676616767167681676916770167711677216773167741677516776167771677816779167801678116782167831678416785167861678716788167891679016791167921679316794167951679616797167981679916800168011680216803168041680516806168071680816809168101681116812168131681416815168161681716818168191682016821168221682316824168251682616827168281682916830168311683216833168341683516836168371683816839168401684116842168431684416845168461684716848168491685016851168521685316854168551685616857168581685916860168611686216863168641686516866168671686816869168701687116872168731687416875168761687716878168791688016881168821688316884168851688616887168881688916890168911689216893168941689516896168971689816899169001690116902169031690416905169061690716908169091691016911169121691316914169151691616917169181691916920169211692216923169241692516926169271692816929169301693116932169331693416935169361693716938169391694016941169421694316944169451694616947169481694916950169511695216953169541695516956169571695816959169601696116962169631696416965169661696716968169691697016971169721697316974169751697616977169781697916980169811698216983169841698516986169871698816989169901699116992169931699416995169961699716998169991700017001170021700317004170051700617007170081700917010170111701217013170141701517016170171701817019170201702117022170231702417025170261702717028170291703017031170321703317034170351703617037170381703917040170411704217043170441704517046170471704817049170501705117052170531705417055170561705717058170591706017061170621706317064170651706617067170681706917070170711707217073170741707517076170771707817079170801708117082170831708417085170861708717088170891709017091170921709317094170951709617097170981709917100171011710217103171041710517106171071710817109171101711117112171131711417115171161711717118171191712017121171221712317124171251712617127171281712917130171311713217133171341713517136171371713817139171401714117142171431714417145171461714717148171491715017151171521715317154171551715617157171581715917160171611716217163171641716517166171671716817169171701717117172171731717417175171761717717178171791718017181171821718317184171851718617187171881718917190171911719217193171941719517196171971719817199172001720117202172031720417205172061720717208172091721017211172121721317214172151721617217172181721917220172211722217223172241722517226172271722817229172301723117232172331723417235172361723717238172391724017241172421724317244172451724617247172481724917250172511725217253172541725517256172571725817259172601726117262172631726417265172661726717268172691727017271172721727317274172751727617277172781727917280172811728217283172841728517286172871728817289172901729117292172931729417295172961729717298172991730017301173021730317304173051730617307173081730917310173111731217313173141731517316173171731817319173201732117322173231732417325173261732717328173291733017331173321733317334173351733617337173381733917340173411734217343173441734517346173471734817349173501735117352173531735417355173561735717358173591736017361173621736317364173651736617367173681736917370173711737217373173741737517376173771737817379173801738117382173831738417385173861738717388173891739017391173921739317394173951739617397173981739917400174011740217403174041740517406174071740817409174101741117412174131741417415174161741717418174191742017421174221742317424174251742617427174281742917430174311743217433174341743517436174371743817439174401744117442174431744417445174461744717448174491745017451174521745317454174551745617457174581745917460174611746217463174641746517466174671746817469174701747117472174731747417475174761747717478174791748017481174821748317484174851748617487174881748917490174911749217493174941749517496174971749817499175001750117502175031750417505175061750717508175091751017511175121751317514175151751617517175181751917520175211752217523175241752517526175271752817529175301753117532175331753417535175361753717538175391754017541175421754317544175451754617547175481754917550175511755217553175541755517556175571755817559175601756117562175631756417565175661756717568175691757017571175721757317574175751757617577175781757917580175811758217583175841758517586175871758817589175901759117592175931759417595175961759717598175991760017601176021760317604176051760617607176081760917610176111761217613176141761517616176171761817619176201762117622176231762417625176261762717628176291763017631176321763317634176351763617637176381763917640176411764217643176441764517646176471764817649176501765117652176531765417655176561765717658176591766017661176621766317664176651766617667176681766917670176711767217673176741767517676176771767817679176801768117682176831768417685176861768717688176891769017691176921769317694176951769617697176981769917700177011770217703177041770517706177071770817709177101771117712177131771417715177161771717718177191772017721177221772317724177251772617727177281772917730177311773217733177341773517736177371773817739177401774117742177431774417745177461774717748177491775017751177521775317754177551775617757177581775917760177611776217763177641776517766177671776817769177701777117772177731777417775177761777717778177791778017781177821778317784177851778617787177881778917790177911779217793177941779517796177971779817799178001780117802178031780417805178061780717808178091781017811178121781317814178151781617817178181781917820178211782217823178241782517826178271782817829178301783117832178331783417835178361783717838178391784017841178421784317844178451784617847178481784917850178511785217853178541785517856178571785817859178601786117862178631786417865178661786717868178691787017871178721787317874178751787617877178781787917880178811788217883178841788517886178871788817889178901789117892178931789417895178961789717898178991790017901179021790317904179051790617907179081790917910179111791217913179141791517916179171791817919179201792117922179231792417925179261792717928179291793017931179321793317934179351793617937179381793917940179411794217943179441794517946179471794817949179501795117952179531795417955179561795717958179591796017961179621796317964179651796617967179681796917970179711797217973179741797517976179771797817979179801798117982179831798417985179861798717988179891799017991179921799317994179951799617997179981799918000180011800218003180041800518006180071800818009180101801118012180131801418015180161801718018180191802018021180221802318024180251802618027180281802918030180311803218033180341803518036180371803818039180401804118042180431804418045180461804718048180491805018051180521805318054180551805618057180581805918060180611806218063180641806518066180671806818069180701807118072180731807418075180761807718078180791808018081180821808318084180851808618087180881808918090180911809218093180941809518096180971809818099181001810118102181031810418105181061810718108181091811018111181121811318114181151811618117181181811918120181211812218123181241812518126181271812818129181301813118132181331813418135181361813718138181391814018141181421814318144181451814618147181481814918150181511815218153181541815518156181571815818159181601816118162181631816418165181661816718168181691817018171181721817318174181751817618177181781817918180181811818218183181841818518186181871818818189181901819118192181931819418195181961819718198181991820018201182021820318204182051820618207182081820918210182111821218213182141821518216182171821818219182201822118222182231822418225182261822718228182291823018231182321823318234182351823618237182381823918240182411824218243182441824518246182471824818249182501825118252182531825418255182561825718258182591826018261182621826318264182651826618267182681826918270182711827218273182741827518276182771827818279182801828118282182831828418285182861828718288182891829018291182921829318294182951829618297182981829918300183011830218303183041830518306183071830818309183101831118312183131831418315183161831718318183191832018321183221832318324183251832618327183281832918330183311833218333183341833518336183371833818339183401834118342183431834418345183461834718348183491835018351183521835318354183551835618357183581835918360183611836218363183641836518366183671836818369183701837118372183731837418375183761837718378183791838018381183821838318384183851838618387183881838918390183911839218393183941839518396183971839818399184001840118402184031840418405184061840718408184091841018411184121841318414184151841618417184181841918420184211842218423184241842518426184271842818429184301843118432184331843418435184361843718438184391844018441184421844318444184451844618447184481844918450184511845218453184541845518456184571845818459184601846118462184631846418465184661846718468184691847018471184721847318474184751847618477184781847918480184811848218483184841848518486184871848818489184901849118492184931849418495184961849718498184991850018501185021850318504185051850618507185081850918510185111851218513185141851518516185171851818519185201852118522185231852418525185261852718528185291853018531185321853318534185351853618537185381853918540185411854218543185441854518546185471854818549185501855118552185531855418555185561855718558185591856018561185621856318564185651856618567185681856918570185711857218573185741857518576185771857818579185801858118582185831858418585185861858718588185891859018591185921859318594185951859618597185981859918600186011860218603186041860518606186071860818609186101861118612186131861418615186161861718618186191862018621186221862318624186251862618627186281862918630186311863218633186341863518636186371863818639186401864118642186431864418645186461864718648186491865018651186521865318654186551865618657186581865918660186611866218663186641866518666186671866818669186701867118672186731867418675186761867718678186791868018681186821868318684186851868618687186881868918690186911869218693186941869518696186971869818699187001870118702187031870418705187061870718708187091871018711187121871318714187151871618717187181871918720187211872218723187241872518726187271872818729187301873118732187331873418735187361873718738187391874018741187421874318744187451874618747187481874918750187511875218753187541875518756187571875818759187601876118762187631876418765187661876718768187691877018771187721877318774187751877618777187781877918780187811878218783187841878518786187871878818789187901879118792187931879418795187961879718798187991880018801188021880318804188051880618807188081880918810188111881218813188141881518816188171881818819188201882118822188231882418825188261882718828188291883018831188321883318834188351883618837188381883918840188411884218843188441884518846188471884818849188501885118852188531885418855188561885718858188591886018861188621886318864188651886618867188681886918870188711887218873188741887518876188771887818879188801888118882188831888418885188861888718888188891889018891188921889318894188951889618897188981889918900189011890218903189041890518906189071890818909189101891118912189131891418915189161891718918189191892018921189221892318924189251892618927189281892918930189311893218933189341893518936189371893818939189401894118942189431894418945189461894718948189491895018951189521895318954189551895618957189581895918960189611896218963189641896518966189671896818969189701897118972189731897418975189761897718978189791898018981189821898318984189851898618987189881898918990189911899218993189941899518996189971899818999190001900119002190031900419005190061900719008190091901019011190121901319014190151901619017190181901919020190211902219023190241902519026190271902819029190301903119032190331903419035190361903719038190391904019041190421904319044190451904619047190481904919050190511905219053190541905519056190571905819059190601906119062190631906419065190661906719068190691907019071190721907319074190751907619077190781907919080190811908219083190841908519086190871908819089190901909119092190931909419095190961909719098190991910019101191021910319104191051910619107191081910919110191111911219113191141911519116191171911819119191201912119122191231912419125191261912719128191291913019131191321913319134191351913619137191381913919140191411914219143191441914519146191471914819149191501915119152191531915419155191561915719158191591916019161191621916319164191651916619167191681916919170191711917219173191741917519176191771917819179191801918119182191831918419185191861918719188191891919019191191921919319194191951919619197191981919919200192011920219203192041920519206192071920819209192101921119212192131921419215192161921719218192191922019221192221922319224192251922619227192281922919230192311923219233192341923519236192371923819239192401924119242192431924419245192461924719248192491925019251192521925319254192551925619257192581925919260192611926219263192641926519266192671926819269192701927119272192731927419275192761927719278192791928019281192821928319284192851928619287192881928919290192911929219293192941929519296192971929819299193001930119302193031930419305193061930719308193091931019311193121931319314193151931619317193181931919320193211932219323193241932519326193271932819329193301933119332193331933419335193361933719338193391934019341193421934319344193451934619347193481934919350193511935219353193541935519356193571935819359193601936119362193631936419365193661936719368193691937019371193721937319374193751937619377193781937919380193811938219383193841938519386193871938819389193901939119392193931939419395193961939719398193991940019401194021940319404194051940619407194081940919410194111941219413194141941519416194171941819419194201942119422194231942419425194261942719428194291943019431194321943319434194351943619437194381943919440194411944219443194441944519446194471944819449194501945119452194531945419455194561945719458194591946019461194621946319464194651946619467194681946919470194711947219473194741947519476194771947819479194801948119482194831948419485194861948719488194891949019491194921949319494194951949619497194981949919500195011950219503195041950519506195071950819509195101951119512195131951419515195161951719518195191952019521195221952319524195251952619527195281952919530195311953219533195341953519536195371953819539195401954119542195431954419545195461954719548195491955019551195521955319554195551955619557195581955919560195611956219563195641956519566195671956819569195701957119572195731957419575195761957719578195791958019581195821958319584195851958619587195881958919590195911959219593195941959519596195971959819599196001960119602196031960419605196061960719608196091961019611196121961319614196151961619617196181961919620196211962219623196241962519626196271962819629196301963119632196331963419635196361963719638196391964019641196421964319644196451964619647196481964919650196511965219653196541965519656196571965819659196601966119662196631966419665196661966719668196691967019671196721967319674196751967619677196781967919680196811968219683196841968519686196871968819689196901969119692196931969419695196961969719698196991970019701197021970319704197051970619707197081970919710197111971219713197141971519716197171971819719197201972119722197231972419725197261972719728197291973019731197321973319734197351973619737197381973919740197411974219743197441974519746197471974819749197501975119752197531975419755197561975719758197591976019761197621976319764197651976619767197681976919770197711977219773197741977519776197771977819779197801978119782197831978419785197861978719788197891979019791197921979319794197951979619797197981979919800198011980219803198041980519806198071980819809198101981119812198131981419815198161981719818198191982019821198221982319824198251982619827198281982919830198311983219833198341983519836198371983819839198401984119842198431984419845198461984719848198491985019851198521985319854198551985619857198581985919860198611986219863198641986519866198671986819869198701987119872198731987419875198761987719878198791988019881198821988319884198851988619887198881988919890198911989219893198941989519896198971989819899199001990119902199031990419905199061990719908199091991019911199121991319914199151991619917199181991919920199211992219923199241992519926199271992819929199301993119932199331993419935199361993719938199391994019941199421994319944199451994619947199481994919950199511995219953199541995519956199571995819959199601996119962199631996419965199661996719968199691997019971199721997319974199751997619977199781997919980199811998219983199841998519986199871998819989199901999119992199931999419995199961999719998199992000020001200022000320004200052000620007200082000920010200112001220013200142001520016200172001820019200202002120022200232002420025200262002720028200292003020031200322003320034200352003620037200382003920040200412004220043200442004520046200472004820049200502005120052200532005420055200562005720058200592006020061200622006320064200652006620067200682006920070200712007220073200742007520076200772007820079200802008120082200832008420085200862008720088200892009020091200922009320094200952009620097200982009920100201012010220103201042010520106201072010820109201102011120112201132011420115201162011720118201192012020121201222012320124201252012620127201282012920130201312013220133201342013520136201372013820139201402014120142201432014420145201462014720148201492015020151201522015320154201552015620157201582015920160201612016220163201642016520166201672016820169201702017120172201732017420175201762017720178201792018020181201822018320184201852018620187201882018920190201912019220193201942019520196201972019820199202002020120202202032020420205202062020720208202092021020211202122021320214202152021620217202182021920220202212022220223202242022520226202272022820229202302023120232202332023420235202362023720238202392024020241202422024320244202452024620247202482024920250202512025220253202542025520256202572025820259202602026120262202632026420265202662026720268202692027020271202722027320274202752027620277202782027920280202812028220283202842028520286202872028820289202902029120292202932029420295202962029720298202992030020301203022030320304203052030620307203082030920310203112031220313203142031520316203172031820319203202032120322203232032420325203262032720328203292033020331203322033320334203352033620337203382033920340203412034220343203442034520346203472034820349203502035120352203532035420355203562035720358203592036020361203622036320364203652036620367203682036920370203712037220373203742037520376203772037820379203802038120382203832038420385203862038720388203892039020391203922039320394203952039620397203982039920400204012040220403204042040520406204072040820409204102041120412204132041420415204162041720418204192042020421204222042320424204252042620427204282042920430204312043220433204342043520436204372043820439204402044120442204432044420445204462044720448204492045020451204522045320454204552045620457204582045920460204612046220463204642046520466204672046820469204702047120472204732047420475204762047720478204792048020481204822048320484204852048620487204882048920490204912049220493204942049520496204972049820499205002050120502205032050420505205062050720508205092051020511205122051320514205152051620517205182051920520205212052220523205242052520526205272052820529205302053120532205332053420535205362053720538205392054020541205422054320544205452054620547205482054920550205512055220553205542055520556205572055820559205602056120562205632056420565205662056720568205692057020571205722057320574205752057620577205782057920580205812058220583205842058520586205872058820589205902059120592205932059420595205962059720598205992060020601206022060320604206052060620607206082060920610206112061220613206142061520616206172061820619206202062120622206232062420625206262062720628206292063020631206322063320634206352063620637206382063920640206412064220643206442064520646206472064820649206502065120652206532065420655206562065720658206592066020661206622066320664206652066620667206682066920670206712067220673206742067520676206772067820679206802068120682206832068420685206862068720688206892069020691206922069320694206952069620697206982069920700207012070220703207042070520706207072070820709207102071120712207132071420715207162071720718207192072020721207222072320724207252072620727207282072920730207312073220733207342073520736207372073820739207402074120742207432074420745207462074720748207492075020751207522075320754207552075620757207582075920760207612076220763207642076520766207672076820769207702077120772207732077420775207762077720778207792078020781207822078320784207852078620787207882078920790207912079220793207942079520796207972079820799208002080120802208032080420805208062080720808208092081020811208122081320814208152081620817208182081920820208212082220823208242082520826208272082820829208302083120832208332083420835208362083720838208392084020841208422084320844208452084620847208482084920850208512085220853208542085520856208572085820859208602086120862208632086420865208662086720868208692087020871208722087320874208752087620877208782087920880208812088220883208842088520886208872088820889208902089120892208932089420895208962089720898208992090020901209022090320904209052090620907209082090920910209112091220913209142091520916209172091820919209202092120922209232092420925209262092720928209292093020931209322093320934209352093620937209382093920940209412094220943209442094520946209472094820949209502095120952209532095420955209562095720958209592096020961209622096320964209652096620967209682096920970209712097220973209742097520976209772097820979209802098120982209832098420985209862098720988209892099020991209922099320994209952099620997209982099921000210012100221003210042100521006210072100821009210102101121012210132101421015210162101721018210192102021021210222102321024210252102621027210282102921030210312103221033210342103521036210372103821039210402104121042210432104421045210462104721048210492105021051210522105321054210552105621057210582105921060210612106221063210642106521066210672106821069210702107121072210732107421075210762107721078210792108021081210822108321084210852108621087210882108921090210912109221093210942109521096210972109821099211002110121102211032110421105211062110721108211092111021111211122111321114211152111621117211182111921120211212112221123211242112521126211272112821129211302113121132211332113421135211362113721138211392114021141211422114321144211452114621147211482114921150211512115221153211542115521156211572115821159211602116121162211632116421165211662116721168211692117021171211722117321174211752117621177211782117921180211812118221183211842118521186211872118821189211902119121192211932119421195211962119721198211992120021201212022120321204212052120621207212082120921210212112121221213212142121521216212172121821219212202122121222212232122421225212262122721228212292123021231212322123321234212352123621237212382123921240212412124221243212442124521246212472124821249212502125121252212532125421255212562125721258212592126021261212622126321264212652126621267212682126921270212712127221273212742127521276212772127821279212802128121282212832128421285212862128721288212892129021291212922129321294212952129621297212982129921300213012130221303213042130521306213072130821309213102131121312213132131421315213162131721318213192132021321213222132321324213252132621327213282132921330213312133221333213342133521336213372133821339213402134121342213432134421345213462134721348213492135021351213522135321354213552135621357213582135921360213612136221363213642136521366213672136821369213702137121372213732137421375213762137721378213792138021381213822138321384213852138621387213882138921390213912139221393213942139521396213972139821399214002140121402214032140421405214062140721408214092141021411214122141321414214152141621417214182141921420214212142221423214242142521426214272142821429214302143121432214332143421435214362143721438214392144021441214422144321444214452144621447214482144921450214512145221453214542145521456214572145821459214602146121462214632146421465214662146721468214692147021471214722147321474214752147621477214782147921480214812148221483214842148521486214872148821489214902149121492214932149421495214962149721498214992150021501215022150321504215052150621507215082150921510215112151221513215142151521516215172151821519215202152121522215232152421525215262152721528215292153021531215322153321534215352153621537215382153921540215412154221543215442154521546215472154821549215502155121552215532155421555215562155721558215592156021561215622156321564215652156621567215682156921570215712157221573215742157521576215772157821579215802158121582215832158421585215862158721588215892159021591215922159321594215952159621597215982159921600216012160221603216042160521606216072160821609216102161121612216132161421615216162161721618216192162021621216222162321624216252162621627216282162921630216312163221633216342163521636216372163821639216402164121642216432164421645216462164721648216492165021651216522165321654216552165621657216582165921660216612166221663216642166521666216672166821669216702167121672216732167421675216762167721678216792168021681216822168321684216852168621687216882168921690216912169221693216942169521696216972169821699217002170121702217032170421705217062170721708217092171021711217122171321714217152171621717217182171921720217212172221723217242172521726217272172821729217302173121732217332173421735217362173721738217392174021741217422174321744217452174621747217482174921750217512175221753217542175521756217572175821759217602176121762217632176421765217662176721768217692177021771217722177321774217752177621777217782177921780217812178221783217842178521786217872178821789217902179121792217932179421795217962179721798217992180021801218022180321804218052180621807218082180921810218112181221813218142181521816218172181821819218202182121822218232182421825218262182721828218292183021831218322183321834218352183621837218382183921840218412184221843218442184521846218472184821849218502185121852218532185421855218562185721858218592186021861218622186321864218652186621867218682186921870218712187221873218742187521876218772187821879218802188121882218832188421885218862188721888218892189021891218922189321894218952189621897218982189921900219012190221903219042190521906219072190821909219102191121912219132191421915219162191721918219192192021921219222192321924219252192621927219282192921930219312193221933219342193521936219372193821939219402194121942219432194421945219462194721948219492195021951219522195321954219552195621957219582195921960219612196221963219642196521966219672196821969219702197121972219732197421975219762197721978219792198021981219822198321984219852198621987219882198921990219912199221993219942199521996219972199821999220002200122002220032200422005220062200722008220092201022011220122201322014220152201622017220182201922020220212202222023220242202522026220272202822029220302203122032220332203422035220362203722038220392204022041220422204322044220452204622047220482204922050220512205222053220542205522056220572205822059220602206122062220632206422065220662206722068220692207022071220722207322074220752207622077220782207922080220812208222083220842208522086220872208822089220902209122092220932209422095220962209722098220992210022101221022210322104221052210622107221082210922110221112211222113221142211522116221172211822119221202212122122221232212422125221262212722128221292213022131221322213322134221352213622137221382213922140221412214222143221442214522146221472214822149221502215122152221532215422155221562215722158221592216022161221622216322164221652216622167221682216922170221712217222173221742217522176221772217822179221802218122182221832218422185221862218722188221892219022191221922219322194221952219622197221982219922200222012220222203222042220522206222072220822209222102221122212222132221422215222162221722218222192222022221222222222322224222252222622227222282222922230222312223222233222342223522236222372223822239222402224122242222432224422245222462224722248222492225022251222522225322254222552225622257222582225922260222612226222263222642226522266222672226822269222702227122272222732227422275222762227722278222792228022281222822228322284222852228622287222882228922290222912229222293222942229522296222972229822299223002230122302223032230422305223062230722308223092231022311223122231322314223152231622317223182231922320223212232222323223242232522326223272232822329223302233122332223332233422335223362233722338223392234022341223422234322344223452234622347223482234922350223512235222353223542235522356223572235822359223602236122362223632236422365223662236722368223692237022371223722237322374223752237622377223782237922380223812238222383223842238522386223872238822389223902239122392223932239422395223962239722398223992240022401224022240322404224052240622407224082240922410224112241222413224142241522416224172241822419224202242122422224232242422425224262242722428224292243022431224322243322434224352243622437224382243922440224412244222443224442244522446224472244822449224502245122452224532245422455224562245722458224592246022461224622246322464224652246622467224682246922470224712247222473224742247522476224772247822479224802248122482224832248422485224862248722488224892249022491224922249322494224952249622497224982249922500225012250222503225042250522506225072250822509225102251122512225132251422515225162251722518225192252022521225222252322524225252252622527225282252922530225312253222533225342253522536225372253822539225402254122542225432254422545225462254722548225492255022551225522255322554225552255622557225582255922560225612256222563225642256522566225672256822569225702257122572225732257422575225762257722578225792258022581225822258322584225852258622587225882258922590225912259222593225942259522596225972259822599226002260122602226032260422605226062260722608226092261022611226122261322614226152261622617226182261922620226212262222623226242262522626226272262822629226302263122632226332263422635226362263722638226392264022641226422264322644226452264622647226482264922650226512265222653226542265522656226572265822659226602266122662226632266422665226662266722668226692267022671226722267322674226752267622677226782267922680226812268222683226842268522686226872268822689226902269122692226932269422695226962269722698226992270022701227022270322704227052270622707227082270922710227112271222713227142271522716227172271822719227202272122722227232272422725227262272722728227292273022731227322273322734227352273622737227382273922740227412274222743227442274522746227472274822749227502275122752227532275422755227562275722758227592276022761227622276322764227652276622767227682276922770227712277222773227742277522776227772277822779227802278122782227832278422785227862278722788227892279022791227922279322794227952279622797227982279922800228012280222803228042280522806228072280822809228102281122812228132281422815228162281722818228192282022821228222282322824228252282622827228282282922830228312283222833228342283522836228372283822839228402284122842228432284422845228462284722848228492285022851228522285322854228552285622857228582285922860228612286222863228642286522866228672286822869228702287122872228732287422875228762287722878228792288022881228822288322884228852288622887228882288922890228912289222893228942289522896228972289822899229002290122902229032290422905229062290722908229092291022911229122291322914229152291622917229182291922920229212292222923229242292522926229272292822929229302293122932229332293422935229362293722938229392294022941229422294322944229452294622947229482294922950229512295222953229542295522956229572295822959229602296122962229632296422965229662296722968229692297022971229722297322974229752297622977229782297922980229812298222983229842298522986229872298822989229902299122992229932299422995229962299722998229992300023001230022300323004230052300623007230082300923010230112301223013230142301523016230172301823019230202302123022230232302423025230262302723028230292303023031230322303323034230352303623037230382303923040230412304223043230442304523046230472304823049230502305123052230532305423055230562305723058230592306023061230622306323064230652306623067230682306923070230712307223073230742307523076230772307823079230802308123082230832308423085230862308723088230892309023091230922309323094230952309623097230982309923100231012310223103231042310523106231072310823109231102311123112231132311423115231162311723118231192312023121231222312323124231252312623127231282312923130231312313223133231342313523136231372313823139231402314123142231432314423145231462314723148231492315023151231522315323154231552315623157231582315923160231612316223163231642316523166231672316823169231702317123172231732317423175231762317723178231792318023181231822318323184231852318623187231882318923190231912319223193231942319523196231972319823199232002320123202232032320423205232062320723208232092321023211232122321323214232152321623217232182321923220232212322223223232242322523226232272322823229232302323123232232332323423235232362323723238232392324023241232422324323244232452324623247232482324923250232512325223253232542325523256232572325823259232602326123262232632326423265232662326723268232692327023271232722327323274232752327623277232782327923280232812328223283232842328523286232872328823289232902329123292232932329423295232962329723298232992330023301233022330323304233052330623307233082330923310233112331223313233142331523316233172331823319233202332123322233232332423325233262332723328233292333023331233322333323334233352333623337233382333923340233412334223343233442334523346233472334823349233502335123352233532335423355233562335723358233592336023361233622336323364233652336623367233682336923370233712337223373233742337523376233772337823379233802338123382233832338423385233862338723388233892339023391233922339323394233952339623397233982339923400234012340223403234042340523406234072340823409234102341123412234132341423415234162341723418234192342023421234222342323424234252342623427234282342923430234312343223433234342343523436234372343823439234402344123442234432344423445234462344723448234492345023451234522345323454234552345623457234582345923460234612346223463234642346523466234672346823469234702347123472234732347423475234762347723478234792348023481234822348323484234852348623487234882348923490234912349223493234942349523496234972349823499235002350123502235032350423505235062350723508235092351023511235122351323514235152351623517235182351923520235212352223523235242352523526235272352823529235302353123532235332353423535235362353723538235392354023541235422354323544235452354623547235482354923550235512355223553235542355523556235572355823559235602356123562235632356423565235662356723568235692357023571235722357323574235752357623577235782357923580235812358223583235842358523586235872358823589235902359123592235932359423595235962359723598235992360023601236022360323604236052360623607236082360923610236112361223613236142361523616236172361823619236202362123622236232362423625236262362723628236292363023631236322363323634236352363623637236382363923640236412364223643236442364523646236472364823649236502365123652236532365423655236562365723658236592366023661236622366323664236652366623667236682366923670236712367223673236742367523676236772367823679236802368123682236832368423685236862368723688236892369023691236922369323694236952369623697236982369923700237012370223703237042370523706237072370823709237102371123712237132371423715237162371723718237192372023721237222372323724237252372623727237282372923730237312373223733237342373523736237372373823739237402374123742237432374423745237462374723748237492375023751237522375323754237552375623757237582375923760237612376223763237642376523766237672376823769237702377123772237732377423775237762377723778237792378023781237822378323784237852378623787237882378923790237912379223793237942379523796237972379823799238002380123802238032380423805238062380723808238092381023811238122381323814238152381623817238182381923820238212382223823238242382523826238272382823829238302383123832238332383423835238362383723838238392384023841238422384323844238452384623847238482384923850238512385223853238542385523856238572385823859238602386123862238632386423865238662386723868238692387023871238722387323874238752387623877238782387923880238812388223883238842388523886238872388823889238902389123892238932389423895238962389723898238992390023901239022390323904239052390623907239082390923910239112391223913239142391523916239172391823919239202392123922239232392423925239262392723928239292393023931239322393323934239352393623937239382393923940239412394223943239442394523946239472394823949239502395123952239532395423955239562395723958239592396023961239622396323964239652396623967239682396923970239712397223973239742397523976239772397823979239802398123982239832398423985239862398723988239892399023991239922399323994239952399623997239982399924000240012400224003240042400524006240072400824009240102401124012240132401424015240162401724018240192402024021240222402324024240252402624027240282402924030240312403224033240342403524036240372403824039240402404124042240432404424045240462404724048240492405024051240522405324054240552405624057240582405924060240612406224063240642406524066240672406824069240702407124072240732407424075240762407724078240792408024081240822408324084240852408624087240882408924090240912409224093240942409524096240972409824099241002410124102241032410424105241062410724108241092411024111241122411324114241152411624117241182411924120241212412224123241242412524126241272412824129241302413124132241332413424135241362413724138241392414024141241422414324144241452414624147241482414924150241512415224153241542415524156241572415824159241602416124162241632416424165241662416724168241692417024171241722417324174241752417624177241782417924180241812418224183241842418524186241872418824189241902419124192241932419424195241962419724198241992420024201242022420324204242052420624207242082420924210242112421224213242142421524216242172421824219242202422124222242232422424225242262422724228242292423024231242322423324234242352423624237242382423924240242412424224243242442424524246242472424824249242502425124252242532425424255242562425724258242592426024261242622426324264242652426624267242682426924270242712427224273242742427524276242772427824279242802428124282242832428424285242862428724288242892429024291242922429324294242952429624297242982429924300243012430224303243042430524306243072430824309243102431124312243132431424315243162431724318243192432024321243222432324324243252432624327243282432924330243312433224333243342433524336243372433824339243402434124342243432434424345243462434724348243492435024351243522435324354243552435624357243582435924360243612436224363243642436524366243672436824369243702437124372243732437424375243762437724378243792438024381243822438324384243852438624387243882438924390243912439224393243942439524396243972439824399244002440124402244032440424405244062440724408244092441024411244122441324414244152441624417244182441924420244212442224423244242442524426244272442824429244302443124432244332443424435244362443724438244392444024441244422444324444244452444624447244482444924450244512445224453244542445524456244572445824459244602446124462244632446424465244662446724468244692447024471244722447324474244752447624477244782447924480244812448224483244842448524486244872448824489244902449124492244932449424495244962449724498244992450024501245022450324504245052450624507245082450924510245112451224513245142451524516245172451824519245202452124522245232452424525245262452724528245292453024531245322453324534245352453624537245382453924540245412454224543245442454524546245472454824549245502455124552245532455424555245562455724558245592456024561245622456324564245652456624567245682456924570245712457224573245742457524576245772457824579245802458124582245832458424585245862458724588245892459024591245922459324594245952459624597245982459924600246012460224603246042460524606246072460824609246102461124612246132461424615246162461724618246192462024621246222462324624246252462624627246282462924630246312463224633246342463524636246372463824639246402464124642246432464424645246462464724648246492465024651246522465324654246552465624657246582465924660246612466224663246642466524666246672466824669246702467124672246732467424675246762467724678246792468024681246822468324684246852468624687246882468924690246912469224693246942469524696246972469824699247002470124702247032470424705247062470724708247092471024711247122471324714247152471624717247182471924720247212472224723247242472524726247272472824729247302473124732247332473424735247362473724738247392474024741247422474324744247452474624747247482474924750247512475224753247542475524756247572475824759247602476124762247632476424765247662476724768247692477024771247722477324774247752477624777247782477924780247812478224783247842478524786247872478824789247902479124792247932479424795247962479724798247992480024801248022480324804248052480624807248082480924810248112481224813248142481524816248172481824819248202482124822248232482424825248262482724828248292483024831248322483324834248352483624837248382483924840248412484224843248442484524846248472484824849248502485124852248532485424855248562485724858248592486024861248622486324864248652486624867248682486924870248712487224873248742487524876248772487824879248802488124882248832488424885248862488724888248892489024891248922489324894248952489624897248982489924900249012490224903249042490524906249072490824909249102491124912249132491424915249162491724918249192492024921249222492324924249252492624927249282492924930249312493224933249342493524936249372493824939249402494124942249432494424945249462494724948249492495024951249522495324954249552495624957249582495924960249612496224963249642496524966249672496824969249702497124972249732497424975249762497724978249792498024981249822498324984249852498624987249882498924990249912499224993249942499524996249972499824999250002500125002250032500425005250062500725008250092501025011250122501325014250152501625017250182501925020250212502225023250242502525026250272502825029250302503125032250332503425035250362503725038250392504025041250422504325044250452504625047250482504925050250512505225053250542505525056250572505825059250602506125062250632506425065250662506725068250692507025071250722507325074250752507625077250782507925080250812508225083250842508525086250872508825089250902509125092250932509425095250962509725098250992510025101251022510325104251052510625107251082510925110251112511225113251142511525116251172511825119251202512125122251232512425125251262512725128251292513025131251322513325134251352513625137251382513925140251412514225143251442514525146251472514825149251502515125152251532515425155251562515725158251592516025161251622516325164251652516625167251682516925170251712517225173251742517525176251772517825179251802518125182251832518425185251862518725188251892519025191251922519325194251952519625197251982519925200252012520225203252042520525206252072520825209252102521125212252132521425215252162521725218252192522025221252222522325224252252522625227252282522925230252312523225233252342523525236252372523825239252402524125242252432524425245252462524725248252492525025251252522525325254252552525625257252582525925260252612526225263252642526525266252672526825269252702527125272252732527425275252762527725278252792528025281252822528325284252852528625287252882528925290252912529225293252942529525296252972529825299253002530125302253032530425305253062530725308253092531025311253122531325314253152531625317253182531925320253212532225323253242532525326253272532825329253302533125332253332533425335253362533725338253392534025341253422534325344253452534625347253482534925350253512535225353253542535525356253572535825359253602536125362253632536425365253662536725368253692537025371253722537325374253752537625377253782537925380253812538225383253842538525386253872538825389253902539125392253932539425395253962539725398253992540025401254022540325404254052540625407254082540925410254112541225413254142541525416254172541825419254202542125422254232542425425254262542725428254292543025431254322543325434254352543625437254382543925440254412544225443254442544525446254472544825449254502545125452254532545425455254562545725458254592546025461254622546325464254652546625467254682546925470254712547225473254742547525476254772547825479254802548125482254832548425485254862548725488254892549025491254922549325494254952549625497254982549925500255012550225503255042550525506255072550825509255102551125512255132551425515255162551725518255192552025521255222552325524255252552625527255282552925530255312553225533255342553525536255372553825539255402554125542255432554425545255462554725548255492555025551255522555325554255552555625557255582555925560255612556225563255642556525566255672556825569255702557125572255732557425575255762557725578255792558025581255822558325584255852558625587255882558925590255912559225593255942559525596255972559825599256002560125602256032560425605256062560725608256092561025611256122561325614256152561625617256182561925620256212562225623256242562525626256272562825629256302563125632256332563425635256362563725638256392564025641256422564325644256452564625647256482564925650256512565225653256542565525656256572565825659256602566125662256632566425665256662566725668256692567025671256722567325674256752567625677256782567925680256812568225683256842568525686256872568825689256902569125692256932569425695256962569725698256992570025701257022570325704257052570625707257082570925710257112571225713257142571525716257172571825719257202572125722257232572425725257262572725728257292573025731257322573325734257352573625737257382573925740257412574225743257442574525746257472574825749257502575125752257532575425755257562575725758257592576025761257622576325764257652576625767257682576925770257712577225773257742577525776257772577825779257802578125782257832578425785257862578725788257892579025791257922579325794257952579625797257982579925800258012580225803258042580525806258072580825809258102581125812258132581425815258162581725818258192582025821258222582325824258252582625827258282582925830258312583225833258342583525836258372583825839258402584125842258432584425845258462584725848258492585025851258522585325854258552585625857258582585925860258612586225863258642586525866258672586825869258702587125872258732587425875258762587725878258792588025881258822588325884258852588625887258882588925890258912589225893258942589525896258972589825899259002590125902259032590425905259062590725908259092591025911259122591325914259152591625917259182591925920259212592225923259242592525926259272592825929259302593125932259332593425935259362593725938259392594025941259422594325944259452594625947259482594925950259512595225953259542595525956259572595825959259602596125962259632596425965259662596725968259692597025971259722597325974259752597625977259782597925980259812598225983259842598525986259872598825989259902599125992259932599425995259962599725998259992600026001260022600326004260052600626007260082600926010260112601226013260142601526016260172601826019260202602126022260232602426025260262602726028260292603026031260322603326034260352603626037260382603926040260412604226043260442604526046260472604826049260502605126052260532605426055260562605726058260592606026061260622606326064260652606626067260682606926070260712607226073260742607526076260772607826079260802608126082260832608426085260862608726088260892609026091260922609326094260952609626097260982609926100261012610226103261042610526106261072610826109261102611126112261132611426115261162611726118261192612026121261222612326124261252612626127261282612926130261312613226133261342613526136261372613826139261402614126142261432614426145261462614726148261492615026151261522615326154261552615626157261582615926160261612616226163261642616526166261672616826169261702617126172261732617426175261762617726178261792618026181261822618326184261852618626187261882618926190261912619226193261942619526196261972619826199262002620126202262032620426205262062620726208262092621026211262122621326214262152621626217262182621926220262212622226223262242622526226262272622826229262302623126232262332623426235262362623726238262392624026241262422624326244262452624626247262482624926250262512625226253262542625526256262572625826259262602626126262262632626426265262662626726268262692627026271262722627326274262752627626277262782627926280262812628226283262842628526286262872628826289262902629126292262932629426295262962629726298262992630026301263022630326304263052630626307263082630926310263112631226313263142631526316263172631826319263202632126322263232632426325263262632726328263292633026331263322633326334263352633626337263382633926340263412634226343263442634526346263472634826349263502635126352263532635426355263562635726358263592636026361263622636326364263652636626367263682636926370263712637226373263742637526376263772637826379263802638126382263832638426385263862638726388263892639026391263922639326394263952639626397263982639926400264012640226403264042640526406264072640826409264102641126412264132641426415264162641726418264192642026421264222642326424264252642626427264282642926430264312643226433264342643526436264372643826439264402644126442264432644426445264462644726448264492645026451264522645326454264552645626457264582645926460264612646226463264642646526466264672646826469264702647126472264732647426475264762647726478264792648026481264822648326484264852648626487264882648926490264912649226493264942649526496264972649826499265002650126502265032650426505265062650726508265092651026511265122651326514265152651626517265182651926520265212652226523265242652526526265272652826529265302653126532265332653426535265362653726538265392654026541265422654326544265452654626547265482654926550265512655226553265542655526556265572655826559265602656126562265632656426565265662656726568265692657026571265722657326574265752657626577265782657926580265812658226583265842658526586265872658826589265902659126592265932659426595265962659726598265992660026601266022660326604266052660626607266082660926610266112661226613266142661526616266172661826619266202662126622266232662426625266262662726628266292663026631266322663326634266352663626637266382663926640266412664226643266442664526646266472664826649266502665126652266532665426655266562665726658266592666026661266622666326664266652666626667266682666926670266712667226673266742667526676266772667826679266802668126682266832668426685266862668726688266892669026691266922669326694266952669626697266982669926700267012670226703267042670526706267072670826709267102671126712267132671426715267162671726718267192672026721267222672326724267252672626727267282672926730267312673226733267342673526736267372673826739267402674126742267432674426745267462674726748267492675026751267522675326754267552675626757267582675926760267612676226763267642676526766267672676826769267702677126772267732677426775267762677726778267792678026781267822678326784267852678626787267882678926790267912679226793267942679526796267972679826799268002680126802268032680426805268062680726808268092681026811268122681326814268152681626817268182681926820268212682226823268242682526826268272682826829268302683126832268332683426835268362683726838268392684026841268422684326844268452684626847268482684926850268512685226853268542685526856268572685826859268602686126862268632686426865268662686726868268692687026871268722687326874268752687626877268782687926880268812688226883268842688526886268872688826889268902689126892268932689426895268962689726898268992690026901269022690326904269052690626907269082690926910269112691226913269142691526916269172691826919269202692126922269232692426925269262692726928269292693026931269322693326934269352693626937269382693926940269412694226943269442694526946269472694826949269502695126952269532695426955269562695726958269592696026961269622696326964269652696626967269682696926970269712697226973269742697526976269772697826979269802698126982269832698426985269862698726988269892699026991269922699326994269952699626997269982699927000270012700227003270042700527006270072700827009270102701127012270132701427015270162701727018270192702027021270222702327024270252702627027270282702927030270312703227033270342703527036270372703827039270402704127042270432704427045270462704727048270492705027051270522705327054270552705627057270582705927060270612706227063270642706527066270672706827069270702707127072270732707427075270762707727078270792708027081270822708327084270852708627087270882708927090270912709227093270942709527096270972709827099271002710127102271032710427105271062710727108271092711027111271122711327114271152711627117271182711927120271212712227123271242712527126271272712827129271302713127132271332713427135271362713727138271392714027141271422714327144271452714627147271482714927150271512715227153271542715527156271572715827159271602716127162271632716427165271662716727168271692717027171271722717327174271752717627177271782717927180271812718227183271842718527186271872718827189271902719127192271932719427195271962719727198271992720027201272022720327204272052720627207272082720927210272112721227213272142721527216272172721827219272202722127222272232722427225272262722727228272292723027231272322723327234272352723627237272382723927240272412724227243272442724527246272472724827249272502725127252272532725427255272562725727258272592726027261272622726327264272652726627267272682726927270272712727227273272742727527276272772727827279272802728127282272832728427285272862728727288272892729027291272922729327294272952729627297272982729927300273012730227303273042730527306273072730827309273102731127312273132731427315273162731727318273192732027321273222732327324273252732627327273282732927330273312733227333273342733527336273372733827339273402734127342273432734427345273462734727348273492735027351273522735327354273552735627357273582735927360273612736227363273642736527366273672736827369273702737127372273732737427375273762737727378273792738027381273822738327384273852738627387273882738927390273912739227393273942739527396273972739827399274002740127402274032740427405274062740727408274092741027411274122741327414274152741627417274182741927420274212742227423274242742527426274272742827429274302743127432274332743427435274362743727438274392744027441274422744327444274452744627447274482744927450274512745227453274542745527456274572745827459274602746127462274632746427465274662746727468274692747027471274722747327474274752747627477274782747927480274812748227483274842748527486274872748827489274902749127492274932749427495274962749727498274992750027501275022750327504275052750627507275082750927510275112751227513275142751527516275172751827519275202752127522275232752427525275262752727528275292753027531275322753327534275352753627537275382753927540275412754227543275442754527546275472754827549275502755127552275532755427555275562755727558275592756027561275622756327564275652756627567275682756927570275712757227573275742757527576275772757827579275802758127582275832758427585275862758727588275892759027591275922759327594275952759627597275982759927600276012760227603276042760527606276072760827609276102761127612276132761427615276162761727618276192762027621276222762327624276252762627627276282762927630276312763227633276342763527636276372763827639276402764127642276432764427645276462764727648276492765027651276522765327654276552765627657276582765927660276612766227663276642766527666276672766827669276702767127672276732767427675276762767727678276792768027681276822768327684276852768627687276882768927690276912769227693276942769527696276972769827699277002770127702277032770427705277062770727708277092771027711277122771327714277152771627717277182771927720277212772227723277242772527726277272772827729277302773127732277332773427735277362773727738277392774027741277422774327744277452774627747277482774927750277512775227753277542775527756277572775827759277602776127762277632776427765277662776727768277692777027771277722777327774277752777627777277782777927780277812778227783277842778527786277872778827789277902779127792277932779427795277962779727798277992780027801278022780327804278052780627807278082780927810278112781227813278142781527816278172781827819278202782127822278232782427825278262782727828278292783027831278322783327834278352783627837278382783927840278412784227843278442784527846278472784827849278502785127852278532785427855278562785727858278592786027861278622786327864278652786627867278682786927870278712787227873278742787527876278772787827879278802788127882278832788427885278862788727888278892789027891278922789327894278952789627897278982789927900279012790227903279042790527906279072790827909279102791127912279132791427915279162791727918279192792027921279222792327924279252792627927279282792927930279312793227933279342793527936279372793827939279402794127942279432794427945279462794727948279492795027951279522795327954279552795627957279582795927960279612796227963279642796527966279672796827969279702797127972279732797427975279762797727978279792798027981279822798327984279852798627987279882798927990279912799227993279942799527996279972799827999280002800128002280032800428005280062800728008280092801028011280122801328014280152801628017280182801928020280212802228023280242802528026280272802828029280302803128032280332803428035280362803728038280392804028041280422804328044280452804628047280482804928050280512805228053280542805528056280572805828059280602806128062280632806428065280662806728068280692807028071280722807328074280752807628077280782807928080280812808228083280842808528086280872808828089280902809128092280932809428095280962809728098280992810028101281022810328104281052810628107281082810928110281112811228113281142811528116281172811828119281202812128122281232812428125281262812728128281292813028131281322813328134281352813628137281382813928140281412814228143281442814528146281472814828149281502815128152281532815428155281562815728158281592816028161281622816328164281652816628167281682816928170281712817228173281742817528176281772817828179281802818128182281832818428185281862818728188281892819028191281922819328194281952819628197281982819928200282012820228203282042820528206282072820828209282102821128212282132821428215282162821728218282192822028221282222822328224282252822628227282282822928230282312823228233282342823528236282372823828239282402824128242282432824428245282462824728248282492825028251282522825328254282552825628257282582825928260282612826228263282642826528266282672826828269282702827128272282732827428275282762827728278282792828028281282822828328284282852828628287282882828928290282912829228293282942829528296282972829828299283002830128302283032830428305283062830728308283092831028311283122831328314283152831628317283182831928320283212832228323283242832528326283272832828329283302833128332283332833428335283362833728338283392834028341283422834328344283452834628347283482834928350283512835228353283542835528356283572835828359283602836128362283632836428365283662836728368283692837028371283722837328374283752837628377283782837928380283812838228383283842838528386283872838828389283902839128392283932839428395283962839728398283992840028401284022840328404284052840628407284082840928410284112841228413284142841528416284172841828419284202842128422284232842428425284262842728428284292843028431284322843328434284352843628437284382843928440284412844228443284442844528446284472844828449284502845128452284532845428455284562845728458284592846028461284622846328464284652846628467284682846928470284712847228473284742847528476284772847828479284802848128482284832848428485284862848728488284892849028491284922849328494284952849628497284982849928500285012850228503285042850528506285072850828509285102851128512285132851428515285162851728518285192852028521285222852328524285252852628527285282852928530285312853228533285342853528536285372853828539285402854128542285432854428545285462854728548285492855028551285522855328554285552855628557285582855928560285612856228563285642856528566285672856828569285702857128572285732857428575285762857728578285792858028581285822858328584285852858628587285882858928590285912859228593285942859528596285972859828599286002860128602286032860428605286062860728608286092861028611286122861328614286152861628617286182861928620286212862228623286242862528626286272862828629286302863128632286332863428635286362863728638286392864028641286422864328644286452864628647286482864928650286512865228653286542865528656286572865828659286602866128662286632866428665286662866728668286692867028671286722867328674286752867628677286782867928680286812868228683286842868528686286872868828689286902869128692286932869428695286962869728698286992870028701287022870328704287052870628707287082870928710287112871228713287142871528716287172871828719287202872128722287232872428725287262872728728287292873028731287322873328734287352873628737287382873928740287412874228743287442874528746287472874828749287502875128752287532875428755287562875728758287592876028761287622876328764287652876628767287682876928770287712877228773287742877528776287772877828779287802878128782287832878428785287862878728788287892879028791287922879328794287952879628797287982879928800288012880228803288042880528806288072880828809288102881128812288132881428815288162881728818288192882028821288222882328824288252882628827288282882928830288312883228833288342883528836288372883828839288402884128842288432884428845288462884728848288492885028851288522885328854288552885628857288582885928860288612886228863288642886528866288672886828869288702887128872288732887428875288762887728878288792888028881288822888328884288852888628887288882888928890288912889228893288942889528896288972889828899289002890128902289032890428905289062890728908289092891028911289122891328914289152891628917289182891928920289212892228923289242892528926289272892828929289302893128932289332893428935289362893728938289392894028941289422894328944289452894628947289482894928950289512895228953289542895528956289572895828959289602896128962289632896428965289662896728968289692897028971289722897328974289752897628977289782897928980289812898228983289842898528986289872898828989289902899128992289932899428995289962899728998289992900029001290022900329004290052900629007290082900929010290112901229013290142901529016290172901829019290202902129022290232902429025290262902729028290292903029031290322903329034290352903629037290382903929040290412904229043290442904529046290472904829049290502905129052290532905429055290562905729058290592906029061290622906329064290652906629067290682906929070290712907229073290742907529076290772907829079290802908129082290832908429085290862908729088290892909029091290922909329094290952909629097290982909929100291012910229103291042910529106291072910829109291102911129112291132911429115291162911729118291192912029121291222912329124291252912629127291282912929130291312913229133291342913529136291372913829139291402914129142291432914429145291462914729148291492915029151291522915329154291552915629157291582915929160291612916229163291642916529166291672916829169291702917129172291732917429175291762917729178291792918029181291822918329184291852918629187291882918929190291912919229193291942919529196291972919829199292002920129202292032920429205292062920729208292092921029211292122921329214292152921629217292182921929220292212922229223292242922529226292272922829229292302923129232292332923429235292362923729238292392924029241292422924329244292452924629247292482924929250292512925229253292542925529256292572925829259292602926129262292632926429265292662926729268292692927029271292722927329274292752927629277292782927929280292812928229283292842928529286292872928829289292902929129292292932929429295292962929729298292992930029301293022930329304293052930629307293082930929310293112931229313293142931529316293172931829319293202932129322293232932429325293262932729328293292933029331293322933329334293352933629337293382933929340293412934229343293442934529346293472934829349293502935129352293532935429355293562935729358293592936029361293622936329364293652936629367293682936929370293712937229373293742937529376293772937829379293802938129382293832938429385293862938729388293892939029391293922939329394293952939629397293982939929400294012940229403294042940529406294072940829409294102941129412294132941429415294162941729418294192942029421294222942329424294252942629427294282942929430294312943229433294342943529436294372943829439294402944129442294432944429445294462944729448294492945029451294522945329454294552945629457294582945929460294612946229463294642946529466294672946829469294702947129472294732947429475294762947729478294792948029481294822948329484294852948629487294882948929490294912949229493294942949529496294972949829499295002950129502295032950429505295062950729508295092951029511295122951329514295152951629517295182951929520295212952229523295242952529526295272952829529295302953129532295332953429535295362953729538295392954029541295422954329544295452954629547295482954929550295512955229553295542955529556295572955829559295602956129562295632956429565295662956729568295692957029571295722957329574295752957629577295782957929580295812958229583295842958529586295872958829589295902959129592295932959429595295962959729598295992960029601296022960329604296052960629607296082960929610296112961229613296142961529616296172961829619296202962129622296232962429625296262962729628296292963029631296322963329634296352963629637296382963929640296412964229643296442964529646296472964829649296502965129652296532965429655296562965729658296592966029661296622966329664296652966629667296682966929670296712967229673296742967529676296772967829679296802968129682296832968429685296862968729688296892969029691296922969329694296952969629697296982969929700297012970229703297042970529706297072970829709297102971129712297132971429715297162971729718297192972029721297222972329724297252972629727297282972929730297312973229733297342973529736297372973829739297402974129742297432974429745297462974729748297492975029751297522975329754297552975629757297582975929760297612976229763297642976529766297672976829769297702977129772297732977429775297762977729778297792978029781297822978329784297852978629787297882978929790297912979229793297942979529796297972979829799298002980129802298032980429805298062980729808298092981029811298122981329814298152981629817298182981929820298212982229823298242982529826298272982829829298302983129832298332983429835298362983729838298392984029841298422984329844298452984629847298482984929850298512985229853298542985529856298572985829859298602986129862298632986429865298662986729868298692987029871298722987329874298752987629877298782987929880298812988229883298842988529886298872988829889298902989129892298932989429895298962989729898298992990029901299022990329904299052990629907299082990929910299112991229913299142991529916299172991829919299202992129922299232992429925299262992729928299292993029931299322993329934299352993629937299382993929940299412994229943299442994529946299472994829949299502995129952299532995429955299562995729958299592996029961299622996329964299652996629967299682996929970299712997229973299742997529976299772997829979299802998129982299832998429985299862998729988299892999029991299922999329994299952999629997299982999930000300013000230003300043000530006300073000830009300103001130012300133001430015300163001730018300193002030021300223002330024300253002630027300283002930030300313003230033300343003530036300373003830039300403004130042300433004430045300463004730048300493005030051300523005330054300553005630057300583005930060300613006230063300643006530066300673006830069300703007130072300733007430075300763007730078300793008030081300823008330084300853008630087300883008930090300913009230093300943009530096300973009830099301003010130102301033010430105301063010730108301093011030111301123011330114301153011630117301183011930120301213012230123301243012530126301273012830129301303013130132301333013430135301363013730138301393014030141301423014330144301453014630147301483014930150301513015230153301543015530156301573015830159301603016130162301633016430165301663016730168301693017030171301723017330174301753017630177301783017930180301813018230183301843018530186301873018830189301903019130192301933019430195301963019730198301993020030201302023020330204302053020630207302083020930210302113021230213302143021530216302173021830219302203022130222302233022430225302263022730228302293023030231302323023330234302353023630237302383023930240302413024230243302443024530246302473024830249302503025130252302533025430255302563025730258302593026030261302623026330264302653026630267302683026930270302713027230273302743027530276302773027830279302803028130282302833028430285302863028730288302893029030291302923029330294302953029630297302983029930300303013030230303303043030530306303073030830309303103031130312303133031430315303163031730318303193032030321303223032330324303253032630327303283032930330303313033230333303343033530336303373033830339303403034130342303433034430345303463034730348303493035030351303523035330354303553035630357303583035930360303613036230363303643036530366303673036830369303703037130372303733037430375303763037730378303793038030381303823038330384303853038630387303883038930390303913039230393303943039530396303973039830399304003040130402304033040430405304063040730408304093041030411304123041330414304153041630417304183041930420304213042230423304243042530426304273042830429304303043130432304333043430435304363043730438304393044030441304423044330444304453044630447304483044930450304513045230453304543045530456304573045830459304603046130462304633046430465304663046730468304693047030471304723047330474304753047630477304783047930480304813048230483304843048530486304873048830489304903049130492304933049430495304963049730498304993050030501305023050330504305053050630507305083050930510305113051230513305143051530516305173051830519305203052130522305233052430525305263052730528305293053030531305323053330534305353053630537305383053930540305413054230543305443054530546305473054830549305503055130552305533055430555305563055730558305593056030561305623056330564305653056630567305683056930570305713057230573305743057530576305773057830579305803058130582305833058430585305863058730588305893059030591305923059330594305953059630597305983059930600306013060230603306043060530606306073060830609306103061130612306133061430615306163061730618306193062030621306223062330624306253062630627306283062930630306313063230633306343063530636306373063830639306403064130642306433064430645306463064730648306493065030651306523065330654306553065630657306583065930660306613066230663306643066530666306673066830669306703067130672306733067430675306763067730678306793068030681306823068330684306853068630687306883068930690306913069230693306943069530696306973069830699307003070130702307033070430705307063070730708307093071030711307123071330714307153071630717307183071930720307213072230723307243072530726307273072830729307303073130732307333073430735307363073730738307393074030741307423074330744307453074630747307483074930750307513075230753307543075530756307573075830759307603076130762307633076430765307663076730768307693077030771307723077330774307753077630777307783077930780307813078230783307843078530786307873078830789307903079130792307933079430795307963079730798307993080030801308023080330804308053080630807308083080930810308113081230813308143081530816308173081830819308203082130822308233082430825308263082730828308293083030831308323083330834308353083630837308383083930840308413084230843308443084530846308473084830849308503085130852308533085430855308563085730858308593086030861308623086330864308653086630867308683086930870308713087230873308743087530876308773087830879308803088130882308833088430885308863088730888308893089030891308923089330894308953089630897308983089930900309013090230903309043090530906309073090830909309103091130912309133091430915309163091730918309193092030921309223092330924309253092630927309283092930930309313093230933309343093530936309373093830939309403094130942309433094430945309463094730948309493095030951309523095330954309553095630957309583095930960309613096230963309643096530966309673096830969309703097130972309733097430975309763097730978309793098030981309823098330984309853098630987309883098930990309913099230993309943099530996309973099830999310003100131002310033100431005310063100731008310093101031011310123101331014310153101631017310183101931020310213102231023310243102531026310273102831029310303103131032310333103431035310363103731038310393104031041310423104331044310453104631047310483104931050310513105231053310543105531056310573105831059310603106131062310633106431065310663106731068310693107031071310723107331074310753107631077310783107931080310813108231083310843108531086310873108831089310903109131092310933109431095310963109731098310993110031101311023110331104311053110631107311083110931110311113111231113311143111531116311173111831119311203112131122311233112431125311263112731128311293113031131311323113331134311353113631137311383113931140311413114231143311443114531146311473114831149311503115131152311533115431155311563115731158311593116031161311623116331164311653116631167311683116931170311713117231173311743117531176311773117831179311803118131182311833118431185311863118731188311893119031191311923119331194311953119631197311983119931200312013120231203312043120531206312073120831209312103121131212312133121431215312163121731218312193122031221312223122331224312253122631227312283122931230312313123231233312343123531236312373123831239312403124131242312433124431245312463124731248312493125031251312523125331254312553125631257312583125931260312613126231263312643126531266312673126831269312703127131272312733127431275312763127731278312793128031281312823128331284312853128631287312883128931290312913129231293312943129531296312973129831299313003130131302313033130431305313063130731308313093131031311313123131331314313153131631317313183131931320313213132231323313243132531326313273132831329313303133131332313333133431335313363133731338313393134031341313423134331344313453134631347313483134931350313513135231353313543135531356313573135831359313603136131362313633136431365313663136731368313693137031371313723137331374313753137631377313783137931380313813138231383313843138531386313873138831389313903139131392313933139431395313963139731398313993140031401314023140331404314053140631407314083140931410314113141231413314143141531416314173141831419314203142131422314233142431425314263142731428314293143031431314323143331434314353143631437314383143931440314413144231443314443144531446314473144831449314503145131452314533145431455314563145731458314593146031461314623146331464314653146631467314683146931470314713147231473314743147531476314773147831479314803148131482314833148431485314863148731488314893149031491314923149331494314953149631497314983149931500315013150231503315043150531506315073150831509315103151131512315133151431515315163151731518315193152031521315223152331524315253152631527315283152931530315313153231533315343153531536315373153831539315403154131542315433154431545315463154731548315493155031551315523155331554315553155631557315583155931560315613156231563315643156531566315673156831569315703157131572315733157431575315763157731578315793158031581315823158331584315853158631587315883158931590315913159231593315943159531596315973159831599316003160131602316033160431605316063160731608316093161031611316123161331614316153161631617316183161931620316213162231623316243162531626316273162831629316303163131632316333163431635316363163731638316393164031641316423164331644316453164631647316483164931650316513165231653316543165531656316573165831659316603166131662316633166431665316663166731668316693167031671316723167331674316753167631677316783167931680316813168231683316843168531686316873168831689316903169131692316933169431695316963169731698316993170031701317023170331704317053170631707317083170931710317113171231713317143171531716317173171831719317203172131722317233172431725317263172731728317293173031731317323173331734317353173631737317383173931740317413174231743317443174531746317473174831749317503175131752317533175431755317563175731758317593176031761317623176331764317653176631767317683176931770317713177231773317743177531776317773177831779317803178131782317833178431785317863178731788317893179031791317923179331794317953179631797317983179931800318013180231803318043180531806318073180831809318103181131812318133181431815318163181731818318193182031821318223182331824318253182631827318283182931830318313183231833318343183531836318373183831839318403184131842318433184431845318463184731848318493185031851318523185331854318553185631857318583185931860318613186231863318643186531866318673186831869318703187131872318733187431875318763187731878318793188031881318823188331884318853188631887318883188931890318913189231893318943189531896318973189831899319003190131902319033190431905319063190731908319093191031911319123191331914319153191631917319183191931920319213192231923319243192531926319273192831929319303193131932319333193431935319363193731938319393194031941319423194331944319453194631947319483194931950319513195231953319543195531956319573195831959319603196131962319633196431965319663196731968319693197031971319723197331974319753197631977319783197931980319813198231983319843198531986319873198831989319903199131992319933199431995319963199731998319993200032001320023200332004320053200632007320083200932010320113201232013320143201532016320173201832019320203202132022320233202432025320263202732028320293203032031320323203332034320353203632037320383203932040320413204232043320443204532046320473204832049320503205132052320533205432055320563205732058320593206032061320623206332064320653206632067320683206932070320713207232073320743207532076320773207832079320803208132082320833208432085320863208732088320893209032091320923209332094320953209632097320983209932100321013210232103321043210532106321073210832109321103211132112321133211432115321163211732118321193212032121321223212332124321253212632127321283212932130321313213232133321343213532136321373213832139321403214132142321433214432145321463214732148321493215032151321523215332154321553215632157321583215932160321613216232163321643216532166321673216832169321703217132172321733217432175321763217732178321793218032181321823218332184321853218632187321883218932190321913219232193321943219532196321973219832199322003220132202322033220432205322063220732208322093221032211322123221332214322153221632217322183221932220322213222232223322243222532226322273222832229322303223132232322333223432235322363223732238322393224032241322423224332244322453224632247322483224932250322513225232253322543225532256322573225832259322603226132262322633226432265322663226732268322693227032271322723227332274322753227632277322783227932280322813228232283322843228532286322873228832289322903229132292322933229432295322963229732298322993230032301323023230332304323053230632307323083230932310323113231232313323143231532316323173231832319323203232132322323233232432325323263232732328323293233032331323323233332334323353233632337323383233932340323413234232343323443234532346323473234832349323503235132352323533235432355323563235732358323593236032361323623236332364323653236632367323683236932370323713237232373323743237532376323773237832379323803238132382323833238432385323863238732388323893239032391323923239332394323953239632397323983239932400324013240232403324043240532406324073240832409324103241132412324133241432415324163241732418324193242032421324223242332424324253242632427324283242932430324313243232433324343243532436324373243832439324403244132442324433244432445324463244732448324493245032451324523245332454324553245632457324583245932460324613246232463324643246532466324673246832469324703247132472324733247432475324763247732478324793248032481324823248332484324853248632487324883248932490324913249232493324943249532496324973249832499325003250132502325033250432505325063250732508325093251032511325123251332514325153251632517325183251932520325213252232523325243252532526325273252832529325303253132532325333253432535325363253732538325393254032541325423254332544325453254632547325483254932550325513255232553325543255532556325573255832559325603256132562325633256432565325663256732568325693257032571325723257332574325753257632577325783257932580325813258232583325843258532586325873258832589325903259132592325933259432595325963259732598325993260032601326023260332604326053260632607326083260932610326113261232613326143261532616326173261832619326203262132622326233262432625326263262732628326293263032631326323263332634326353263632637326383263932640326413264232643326443264532646326473264832649326503265132652326533265432655326563265732658326593266032661326623266332664326653266632667326683266932670326713267232673326743267532676326773267832679326803268132682326833268432685326863268732688326893269032691326923269332694326953269632697326983269932700327013270232703327043270532706327073270832709327103271132712327133271432715327163271732718327193272032721327223272332724327253272632727327283272932730327313273232733327343273532736327373273832739327403274132742327433274432745327463274732748327493275032751327523275332754327553275632757327583275932760327613276232763327643276532766327673276832769327703277132772327733277432775327763277732778327793278032781327823278332784327853278632787327883278932790327913279232793327943279532796327973279832799328003280132802328033280432805328063280732808328093281032811328123281332814328153281632817328183281932820328213282232823328243282532826328273282832829328303283132832328333283432835328363283732838328393284032841328423284332844328453284632847328483284932850328513285232853328543285532856328573285832859328603286132862328633286432865328663286732868328693287032871328723287332874328753287632877328783287932880328813288232883328843288532886328873288832889328903289132892328933289432895328963289732898328993290032901329023290332904329053290632907329083290932910329113291232913329143291532916329173291832919329203292132922329233292432925329263292732928329293293032931329323293332934329353293632937329383293932940329413294232943329443294532946329473294832949329503295132952329533295432955329563295732958329593296032961329623296332964329653296632967329683296932970329713297232973329743297532976329773297832979329803298132982329833298432985329863298732988329893299032991329923299332994329953299632997329983299933000330013300233003330043300533006330073300833009330103301133012330133301433015330163301733018330193302033021330223302333024330253302633027330283302933030330313303233033330343303533036330373303833039330403304133042330433304433045330463304733048330493305033051330523305333054330553305633057330583305933060330613306233063330643306533066330673306833069330703307133072330733307433075330763307733078330793308033081330823308333084330853308633087330883308933090330913309233093330943309533096330973309833099331003310133102331033310433105331063310733108331093311033111331123311333114331153311633117331183311933120331213312233123331243312533126331273312833129331303313133132331333313433135331363313733138331393314033141331423314333144331453314633147331483314933150331513315233153331543315533156331573315833159331603316133162331633316433165331663316733168331693317033171331723317333174331753317633177331783317933180331813318233183331843318533186331873318833189331903319133192331933319433195331963319733198331993320033201332023320333204332053320633207332083320933210332113321233213332143321533216332173321833219332203322133222332233322433225332263322733228332293323033231332323323333234332353323633237332383323933240332413324233243332443324533246332473324833249332503325133252332533325433255332563325733258332593326033261332623326333264332653326633267332683326933270332713327233273332743327533276332773327833279332803328133282332833328433285332863328733288332893329033291332923329333294332953329633297332983329933300333013330233303333043330533306333073330833309333103331133312333133331433315333163331733318333193332033321333223332333324333253332633327333283332933330333313333233333333343333533336333373333833339333403334133342333433334433345333463334733348333493335033351333523335333354333553335633357333583335933360333613336233363333643336533366333673336833369333703337133372333733337433375333763337733378333793338033381333823338333384333853338633387333883338933390333913339233393333943339533396333973339833399334003340133402334033340433405334063340733408334093341033411334123341333414334153341633417334183341933420334213342233423334243342533426334273342833429334303343133432334333343433435334363343733438334393344033441334423344333444334453344633447334483344933450334513345233453334543345533456334573345833459334603346133462334633346433465334663346733468334693347033471334723347333474334753347633477334783347933480334813348233483334843348533486334873348833489334903349133492334933349433495334963349733498334993350033501335023350333504335053350633507335083350933510335113351233513335143351533516335173351833519335203352133522335233352433525335263352733528335293353033531335323353333534335353353633537335383353933540335413354233543335443354533546335473354833549335503355133552335533355433555335563355733558335593356033561335623356333564335653356633567335683356933570335713357233573335743357533576335773357833579335803358133582335833358433585335863358733588335893359033591335923359333594335953359633597335983359933600336013360233603336043360533606336073360833609336103361133612336133361433615336163361733618336193362033621336223362333624336253362633627336283362933630336313363233633336343363533636336373363833639336403364133642336433364433645336463364733648336493365033651336523365333654336553365633657336583365933660336613366233663336643366533666336673366833669336703367133672336733367433675336763367733678336793368033681336823368333684336853368633687336883368933690336913369233693336943369533696336973369833699337003370133702337033370433705337063370733708337093371033711337123371333714337153371633717337183371933720337213372233723337243372533726337273372833729337303373133732337333373433735337363373733738337393374033741337423374333744337453374633747337483374933750337513375233753337543375533756337573375833759337603376133762337633376433765337663376733768337693377033771337723377333774337753377633777337783377933780337813378233783337843378533786337873378833789337903379133792337933379433795337963379733798337993380033801338023380333804338053380633807338083380933810338113381233813338143381533816338173381833819338203382133822338233382433825338263382733828338293383033831338323383333834338353383633837338383383933840338413384233843338443384533846338473384833849338503385133852338533385433855338563385733858338593386033861338623386333864338653386633867338683386933870338713387233873338743387533876338773387833879338803388133882338833388433885338863388733888338893389033891338923389333894338953389633897338983389933900339013390233903339043390533906339073390833909339103391133912339133391433915339163391733918339193392033921339223392333924339253392633927339283392933930339313393233933339343393533936339373393833939339403394133942339433394433945339463394733948339493395033951339523395333954339553395633957339583395933960339613396233963339643396533966339673396833969339703397133972339733397433975339763397733978339793398033981339823398333984339853398633987339883398933990339913399233993339943399533996339973399833999340003400134002340033400434005340063400734008340093401034011340123401334014340153401634017340183401934020340213402234023340243402534026340273402834029340303403134032340333403434035340363403734038340393404034041340423404334044340453404634047340483404934050340513405234053340543405534056340573405834059340603406134062340633406434065340663406734068340693407034071340723407334074340753407634077340783407934080340813408234083340843408534086340873408834089340903409134092340933409434095340963409734098340993410034101341023410334104341053410634107341083410934110341113411234113341143411534116341173411834119341203412134122341233412434125341263412734128341293413034131341323413334134341353413634137341383413934140341413414234143341443414534146341473414834149341503415134152341533415434155341563415734158341593416034161341623416334164341653416634167341683416934170341713417234173341743417534176341773417834179341803418134182341833418434185341863418734188341893419034191341923419334194341953419634197341983419934200342013420234203342043420534206342073420834209342103421134212342133421434215342163421734218342193422034221342223422334224342253422634227342283422934230342313423234233342343423534236342373423834239342403424134242342433424434245342463424734248342493425034251342523425334254342553425634257342583425934260342613426234263342643426534266342673426834269342703427134272342733427434275342763427734278342793428034281342823428334284342853428634287342883428934290342913429234293342943429534296342973429834299343003430134302343033430434305343063430734308343093431034311343123431334314343153431634317343183431934320343213432234323343243432534326343273432834329343303433134332343333433434335343363433734338343393434034341343423434334344343453434634347343483434934350343513435234353343543435534356343573435834359343603436134362343633436434365343663436734368343693437034371343723437334374343753437634377343783437934380343813438234383343843438534386343873438834389343903439134392343933439434395343963439734398343993440034401344023440334404344053440634407344083440934410344113441234413344143441534416344173441834419344203442134422344233442434425344263442734428344293443034431344323443334434344353443634437344383443934440344413444234443344443444534446344473444834449344503445134452344533445434455344563445734458344593446034461344623446334464344653446634467344683446934470344713447234473344743447534476344773447834479344803448134482344833448434485344863448734488344893449034491344923449334494344953449634497344983449934500345013450234503345043450534506345073450834509345103451134512345133451434515345163451734518345193452034521345223452334524345253452634527345283452934530345313453234533345343453534536345373453834539345403454134542345433454434545345463454734548345493455034551345523455334554345553455634557345583455934560345613456234563345643456534566345673456834569345703457134572345733457434575345763457734578345793458034581345823458334584345853458634587345883458934590345913459234593345943459534596345973459834599346003460134602346033460434605346063460734608346093461034611346123461334614346153461634617346183461934620346213462234623346243462534626346273462834629346303463134632346333463434635346363463734638346393464034641346423464334644346453464634647346483464934650346513465234653346543465534656346573465834659346603466134662346633466434665346663466734668346693467034671346723467334674346753467634677346783467934680346813468234683346843468534686346873468834689346903469134692346933469434695346963469734698346993470034701347023470334704347053470634707347083470934710347113471234713347143471534716347173471834719347203472134722347233472434725347263472734728347293473034731347323473334734347353473634737347383473934740347413474234743347443474534746347473474834749347503475134752347533475434755347563475734758347593476034761347623476334764347653476634767347683476934770347713477234773347743477534776347773477834779347803478134782347833478434785347863478734788347893479034791347923479334794347953479634797347983479934800348013480234803348043480534806348073480834809348103481134812348133481434815348163481734818348193482034821348223482334824348253482634827348283482934830348313483234833348343483534836348373483834839348403484134842348433484434845348463484734848348493485034851348523485334854348553485634857348583485934860348613486234863348643486534866348673486834869348703487134872348733487434875348763487734878348793488034881348823488334884348853488634887348883488934890348913489234893348943489534896348973489834899349003490134902349033490434905349063490734908349093491034911349123491334914349153491634917349183491934920349213492234923349243492534926349273492834929349303493134932349333493434935349363493734938349393494034941349423494334944349453494634947349483494934950349513495234953349543495534956349573495834959349603496134962349633496434965349663496734968349693497034971349723497334974349753497634977349783497934980349813498234983349843498534986349873498834989349903499134992349933499434995349963499734998349993500035001350023500335004350053500635007350083500935010350113501235013350143501535016350173501835019350203502135022350233502435025350263502735028350293503035031350323503335034350353503635037350383503935040350413504235043350443504535046350473504835049350503505135052350533505435055350563505735058350593506035061350623506335064350653506635067350683506935070350713507235073350743507535076350773507835079350803508135082350833508435085350863508735088350893509035091350923509335094350953509635097350983509935100351013510235103351043510535106351073510835109351103511135112351133511435115351163511735118351193512035121351223512335124351253512635127351283512935130351313513235133351343513535136351373513835139351403514135142351433514435145351463514735148351493515035151351523515335154351553515635157351583515935160351613516235163351643516535166351673516835169351703517135172351733517435175351763517735178351793518035181351823518335184351853518635187351883518935190351913519235193351943519535196351973519835199352003520135202352033520435205352063520735208352093521035211352123521335214352153521635217352183521935220352213522235223352243522535226352273522835229352303523135232352333523435235352363523735238352393524035241352423524335244352453524635247352483524935250352513525235253352543525535256352573525835259352603526135262352633526435265352663526735268352693527035271352723527335274352753527635277352783527935280352813528235283352843528535286352873528835289352903529135292352933529435295352963529735298352993530035301353023530335304353053530635307353083530935310353113531235313353143531535316353173531835319353203532135322353233532435325353263532735328353293533035331353323533335334353353533635337353383533935340353413534235343353443534535346353473534835349353503535135352353533535435355353563535735358353593536035361353623536335364353653536635367353683536935370353713537235373353743537535376353773537835379353803538135382353833538435385353863538735388353893539035391353923539335394353953539635397353983539935400354013540235403354043540535406354073540835409354103541135412354133541435415354163541735418354193542035421354223542335424354253542635427354283542935430354313543235433354343543535436354373543835439354403544135442354433544435445354463544735448354493545035451354523545335454354553545635457354583545935460354613546235463354643546535466354673546835469354703547135472354733547435475354763547735478354793548035481354823548335484354853548635487354883548935490354913549235493354943549535496354973549835499355003550135502355033550435505355063550735508355093551035511355123551335514355153551635517355183551935520355213552235523355243552535526355273552835529355303553135532355333553435535355363553735538355393554035541355423554335544355453554635547355483554935550355513555235553355543555535556355573555835559355603556135562355633556435565355663556735568355693557035571355723557335574355753557635577355783557935580355813558235583355843558535586355873558835589355903559135592355933559435595355963559735598355993560035601356023560335604356053560635607356083560935610356113561235613356143561535616356173561835619356203562135622356233562435625356263562735628356293563035631356323563335634356353563635637356383563935640356413564235643356443564535646356473564835649356503565135652356533565435655356563565735658356593566035661356623566335664356653566635667356683566935670356713567235673356743567535676356773567835679356803568135682356833568435685356863568735688356893569035691356923569335694356953569635697356983569935700357013570235703357043570535706357073570835709357103571135712357133571435715357163571735718357193572035721357223572335724357253572635727357283572935730357313573235733357343573535736357373573835739357403574135742357433574435745357463574735748357493575035751357523575335754357553575635757357583575935760357613576235763357643576535766357673576835769357703577135772357733577435775357763577735778357793578035781357823578335784357853578635787357883578935790357913579235793357943579535796357973579835799358003580135802358033580435805358063580735808358093581035811358123581335814358153581635817358183581935820358213582235823358243582535826358273582835829358303583135832358333583435835358363583735838358393584035841358423584335844358453584635847358483584935850358513585235853358543585535856358573585835859358603586135862358633586435865358663586735868358693587035871358723587335874358753587635877358783587935880358813588235883358843588535886358873588835889358903589135892358933589435895358963589735898358993590035901359023590335904359053590635907359083590935910359113591235913359143591535916359173591835919359203592135922359233592435925359263592735928359293593035931359323593335934359353593635937359383593935940359413594235943359443594535946359473594835949359503595135952359533595435955359563595735958359593596035961359623596335964359653596635967359683596935970359713597235973359743597535976359773597835979359803598135982359833598435985359863598735988359893599035991359923599335994359953599635997359983599936000360013600236003360043600536006360073600836009360103601136012360133601436015360163601736018360193602036021360223602336024360253602636027360283602936030360313603236033360343603536036360373603836039360403604136042360433604436045360463604736048360493605036051360523605336054360553605636057360583605936060360613606236063360643606536066360673606836069360703607136072360733607436075360763607736078360793608036081360823608336084360853608636087360883608936090360913609236093360943609536096360973609836099361003610136102361033610436105361063610736108361093611036111361123611336114361153611636117361183611936120361213612236123361243612536126361273612836129361303613136132361333613436135361363613736138361393614036141361423614336144361453614636147361483614936150361513615236153361543615536156361573615836159361603616136162361633616436165361663616736168361693617036171361723617336174361753617636177361783617936180361813618236183361843618536186361873618836189361903619136192361933619436195361963619736198361993620036201362023620336204362053620636207362083620936210362113621236213362143621536216362173621836219362203622136222362233622436225362263622736228362293623036231362323623336234362353623636237362383623936240362413624236243362443624536246362473624836249362503625136252362533625436255362563625736258362593626036261362623626336264362653626636267362683626936270362713627236273362743627536276362773627836279362803628136282362833628436285362863628736288362893629036291362923629336294362953629636297362983629936300363013630236303363043630536306363073630836309363103631136312363133631436315363163631736318363193632036321363223632336324363253632636327363283632936330363313633236333363343633536336363373633836339363403634136342363433634436345363463634736348363493635036351363523635336354363553635636357363583635936360363613636236363363643636536366363673636836369363703637136372363733637436375363763637736378363793638036381363823638336384363853638636387363883638936390363913639236393363943639536396363973639836399364003640136402364033640436405364063640736408364093641036411364123641336414364153641636417364183641936420364213642236423364243642536426364273642836429364303643136432364333643436435364363643736438364393644036441364423644336444364453644636447364483644936450364513645236453364543645536456364573645836459364603646136462364633646436465364663646736468364693647036471364723647336474364753647636477364783647936480364813648236483364843648536486364873648836489364903649136492364933649436495364963649736498364993650036501365023650336504365053650636507365083650936510365113651236513365143651536516365173651836519365203652136522365233652436525365263652736528365293653036531365323653336534365353653636537365383653936540365413654236543365443654536546365473654836549365503655136552365533655436555365563655736558365593656036561365623656336564365653656636567365683656936570365713657236573365743657536576365773657836579365803658136582365833658436585365863658736588365893659036591365923659336594365953659636597365983659936600366013660236603366043660536606366073660836609366103661136612366133661436615366163661736618366193662036621366223662336624366253662636627366283662936630366313663236633366343663536636366373663836639366403664136642366433664436645366463664736648366493665036651366523665336654366553665636657366583665936660366613666236663366643666536666366673666836669366703667136672366733667436675366763667736678366793668036681366823668336684366853668636687366883668936690366913669236693366943669536696366973669836699367003670136702367033670436705367063670736708367093671036711367123671336714367153671636717367183671936720367213672236723367243672536726367273672836729367303673136732367333673436735367363673736738367393674036741367423674336744367453674636747367483674936750367513675236753367543675536756367573675836759367603676136762367633676436765367663676736768367693677036771367723677336774367753677636777367783677936780367813678236783367843678536786367873678836789367903679136792367933679436795367963679736798367993680036801368023680336804368053680636807368083680936810368113681236813368143681536816368173681836819368203682136822368233682436825368263682736828368293683036831368323683336834368353683636837368383683936840368413684236843368443684536846368473684836849368503685136852368533685436855368563685736858368593686036861368623686336864368653686636867368683686936870368713687236873368743687536876368773687836879368803688136882368833688436885368863688736888368893689036891368923689336894368953689636897368983689936900369013690236903369043690536906369073690836909369103691136912369133691436915369163691736918369193692036921369223692336924369253692636927369283692936930369313693236933369343693536936369373693836939369403694136942369433694436945369463694736948369493695036951369523695336954369553695636957369583695936960369613696236963369643696536966369673696836969369703697136972369733697436975369763697736978369793698036981369823698336984369853698636987369883698936990369913699236993369943699536996369973699836999370003700137002370033700437005370063700737008370093701037011370123701337014370153701637017370183701937020370213702237023370243702537026370273702837029370303703137032370333703437035370363703737038370393704037041370423704337044370453704637047370483704937050370513705237053370543705537056370573705837059370603706137062370633706437065370663706737068370693707037071370723707337074370753707637077370783707937080370813708237083370843708537086370873708837089370903709137092370933709437095370963709737098370993710037101371023710337104371053710637107371083710937110371113711237113371143711537116371173711837119371203712137122371233712437125371263712737128371293713037131371323713337134371353713637137371383713937140371413714237143371443714537146371473714837149371503715137152371533715437155371563715737158371593716037161371623716337164371653716637167371683716937170371713717237173371743717537176371773717837179371803718137182371833718437185371863718737188371893719037191371923719337194371953719637197371983719937200372013720237203372043720537206372073720837209372103721137212372133721437215372163721737218372193722037221372223722337224372253722637227372283722937230372313723237233372343723537236372373723837239372403724137242372433724437245372463724737248372493725037251372523725337254372553725637257372583725937260372613726237263372643726537266372673726837269372703727137272372733727437275372763727737278372793728037281372823728337284372853728637287372883728937290372913729237293372943729537296372973729837299373003730137302373033730437305373063730737308373093731037311373123731337314373153731637317373183731937320373213732237323373243732537326373273732837329373303733137332373333733437335373363733737338373393734037341373423734337344373453734637347373483734937350373513735237353373543735537356373573735837359373603736137362373633736437365373663736737368373693737037371373723737337374373753737637377373783737937380373813738237383373843738537386373873738837389373903739137392373933739437395373963739737398373993740037401374023740337404374053740637407374083740937410374113741237413374143741537416374173741837419374203742137422374233742437425374263742737428374293743037431374323743337434374353743637437374383743937440374413744237443374443744537446374473744837449374503745137452374533745437455374563745737458374593746037461374623746337464374653746637467374683746937470374713747237473374743747537476374773747837479374803748137482374833748437485374863748737488374893749037491374923749337494374953749637497374983749937500375013750237503375043750537506375073750837509375103751137512375133751437515375163751737518375193752037521375223752337524375253752637527375283752937530375313753237533375343753537536375373753837539375403754137542375433754437545375463754737548375493755037551375523755337554375553755637557375583755937560375613756237563375643756537566375673756837569375703757137572375733757437575375763757737578375793758037581375823758337584375853758637587375883758937590375913759237593375943759537596375973759837599376003760137602376033760437605376063760737608376093761037611376123761337614376153761637617376183761937620376213762237623376243762537626376273762837629376303763137632376333763437635376363763737638376393764037641376423764337644376453764637647376483764937650376513765237653376543765537656376573765837659376603766137662376633766437665376663766737668376693767037671376723767337674376753767637677376783767937680376813768237683376843768537686376873768837689376903769137692376933769437695376963769737698376993770037701377023770337704377053770637707377083770937710377113771237713377143771537716377173771837719377203772137722377233772437725377263772737728377293773037731377323773337734377353773637737377383773937740377413774237743377443774537746377473774837749377503775137752377533775437755377563775737758377593776037761377623776337764377653776637767377683776937770377713777237773377743777537776377773777837779377803778137782377833778437785377863778737788377893779037791377923779337794377953779637797377983779937800378013780237803378043780537806378073780837809378103781137812378133781437815378163781737818378193782037821378223782337824378253782637827378283782937830378313783237833378343783537836378373783837839378403784137842378433784437845378463784737848378493785037851378523785337854378553785637857378583785937860378613786237863378643786537866378673786837869378703787137872378733787437875378763787737878378793788037881378823788337884378853788637887378883788937890378913789237893378943789537896378973789837899379003790137902379033790437905379063790737908379093791037911379123791337914379153791637917379183791937920379213792237923379243792537926379273792837929379303793137932379333793437935379363793737938379393794037941379423794337944379453794637947379483794937950379513795237953379543795537956379573795837959379603796137962379633796437965379663796737968379693797037971379723797337974379753797637977379783797937980379813798237983379843798537986379873798837989379903799137992379933799437995379963799737998379993800038001380023800338004380053800638007380083800938010380113801238013380143801538016380173801838019380203802138022380233802438025380263802738028380293803038031380323803338034380353803638037380383803938040380413804238043380443804538046380473804838049380503805138052380533805438055380563805738058380593806038061380623806338064380653806638067380683806938070380713807238073380743807538076380773807838079380803808138082380833808438085380863808738088380893809038091380923809338094380953809638097380983809938100381013810238103381043810538106381073810838109381103811138112381133811438115381163811738118381193812038121381223812338124381253812638127381283812938130381313813238133381343813538136381373813838139381403814138142381433814438145381463814738148381493815038151381523815338154381553815638157381583815938160381613816238163381643816538166381673816838169381703817138172381733817438175381763817738178381793818038181381823818338184381853818638187381883818938190381913819238193381943819538196381973819838199382003820138202382033820438205382063820738208382093821038211382123821338214382153821638217382183821938220382213822238223382243822538226382273822838229382303823138232382333823438235382363823738238382393824038241382423824338244382453824638247382483824938250382513825238253382543825538256382573825838259382603826138262382633826438265382663826738268382693827038271382723827338274382753827638277382783827938280382813828238283382843828538286382873828838289382903829138292382933829438295382963829738298382993830038301383023830338304383053830638307383083830938310383113831238313383143831538316383173831838319383203832138322383233832438325383263832738328383293833038331383323833338334383353833638337383383833938340383413834238343383443834538346383473834838349383503835138352383533835438355383563835738358383593836038361383623836338364383653836638367383683836938370383713837238373383743837538376383773837838379383803838138382383833838438385383863838738388383893839038391383923839338394383953839638397383983839938400384013840238403384043840538406384073840838409384103841138412384133841438415384163841738418384193842038421384223842338424384253842638427384283842938430384313843238433384343843538436384373843838439384403844138442384433844438445384463844738448384493845038451384523845338454384553845638457384583845938460384613846238463384643846538466384673846838469384703847138472384733847438475384763847738478384793848038481384823848338484384853848638487384883848938490384913849238493384943849538496384973849838499385003850138502385033850438505385063850738508385093851038511385123851338514385153851638517385183851938520385213852238523385243852538526385273852838529385303853138532385333853438535385363853738538385393854038541385423854338544385453854638547385483854938550385513855238553385543855538556385573855838559385603856138562385633856438565385663856738568385693857038571385723857338574385753857638577385783857938580385813858238583385843858538586385873858838589385903859138592385933859438595385963859738598385993860038601386023860338604386053860638607386083860938610386113861238613386143861538616386173861838619386203862138622386233862438625386263862738628386293863038631386323863338634386353863638637386383863938640386413864238643386443864538646386473864838649386503865138652386533865438655386563865738658386593866038661386623866338664386653866638667386683866938670386713867238673386743867538676386773867838679386803868138682386833868438685386863868738688386893869038691386923869338694386953869638697386983869938700387013870238703387043870538706387073870838709387103871138712387133871438715387163871738718387193872038721387223872338724387253872638727387283872938730387313873238733387343873538736387373873838739387403874138742387433874438745387463874738748387493875038751387523875338754387553875638757387583875938760387613876238763387643876538766387673876838769387703877138772387733877438775387763877738778387793878038781387823878338784387853878638787387883878938790387913879238793387943879538796387973879838799388003880138802388033880438805388063880738808388093881038811388123881338814388153881638817388183881938820388213882238823388243882538826388273882838829388303883138832388333883438835388363883738838388393884038841388423884338844388453884638847388483884938850388513885238853388543885538856388573885838859388603886138862388633886438865388663886738868388693887038871388723887338874388753887638877388783887938880388813888238883388843888538886388873888838889388903889138892388933889438895388963889738898388993890038901389023890338904389053890638907389083890938910389113891238913389143891538916389173891838919389203892138922389233892438925389263892738928389293893038931389323893338934389353893638937389383893938940389413894238943389443894538946389473894838949389503895138952389533895438955389563895738958389593896038961389623896338964389653896638967389683896938970389713897238973389743897538976389773897838979389803898138982389833898438985389863898738988389893899038991389923899338994389953899638997389983899939000390013900239003390043900539006390073900839009390103901139012390133901439015390163901739018390193902039021390223902339024390253902639027390283902939030390313903239033390343903539036390373903839039390403904139042390433904439045390463904739048390493905039051390523905339054390553905639057390583905939060390613906239063390643906539066390673906839069390703907139072390733907439075390763907739078390793908039081390823908339084390853908639087390883908939090390913909239093390943909539096390973909839099391003910139102391033910439105391063910739108391093911039111391123911339114391153911639117391183911939120391213912239123391243912539126391273912839129391303913139132391333913439135391363913739138391393914039141391423914339144391453914639147391483914939150391513915239153391543915539156391573915839159391603916139162391633916439165391663916739168391693917039171391723917339174391753917639177391783917939180391813918239183391843918539186391873918839189391903919139192391933919439195391963919739198391993920039201392023920339204392053920639207392083920939210392113921239213392143921539216392173921839219392203922139222392233922439225392263922739228392293923039231392323923339234392353923639237392383923939240392413924239243392443924539246392473924839249392503925139252392533925439255392563925739258392593926039261392623926339264392653926639267392683926939270392713927239273392743927539276392773927839279392803928139282392833928439285392863928739288392893929039291392923929339294392953929639297392983929939300393013930239303393043930539306393073930839309393103931139312393133931439315393163931739318393193932039321393223932339324393253932639327393283932939330393313933239333393343933539336393373933839339393403934139342393433934439345393463934739348393493935039351393523935339354393553935639357393583935939360393613936239363393643936539366393673936839369393703937139372393733937439375393763937739378393793938039381393823938339384393853938639387393883938939390393913939239393393943939539396393973939839399394003940139402394033940439405394063940739408394093941039411394123941339414394153941639417394183941939420394213942239423394243942539426394273942839429394303943139432394333943439435394363943739438394393944039441394423944339444394453944639447394483944939450394513945239453394543945539456394573945839459394603946139462394633946439465394663946739468394693947039471394723947339474394753947639477394783947939480394813948239483394843948539486394873948839489394903949139492394933949439495394963949739498394993950039501395023950339504395053950639507395083950939510395113951239513395143951539516395173951839519395203952139522395233952439525395263952739528395293953039531395323953339534395353953639537395383953939540395413954239543395443954539546395473954839549395503955139552395533955439555395563955739558395593956039561395623956339564395653956639567395683956939570395713957239573395743957539576395773957839579395803958139582395833958439585395863958739588395893959039591395923959339594395953959639597395983959939600396013960239603396043960539606396073960839609396103961139612396133961439615396163961739618396193962039621396223962339624396253962639627396283962939630396313963239633396343963539636396373963839639396403964139642396433964439645396463964739648396493965039651396523965339654396553965639657396583965939660396613966239663396643966539666396673966839669396703967139672396733967439675396763967739678396793968039681396823968339684396853968639687396883968939690396913969239693396943969539696396973969839699397003970139702397033970439705397063970739708397093971039711397123971339714397153971639717397183971939720397213972239723397243972539726397273972839729397303973139732397333973439735397363973739738397393974039741397423974339744397453974639747397483974939750397513975239753397543975539756397573975839759397603976139762397633976439765397663976739768397693977039771397723977339774397753977639777397783977939780397813978239783397843978539786397873978839789397903979139792397933979439795397963979739798397993980039801398023980339804398053980639807398083980939810398113981239813398143981539816398173981839819398203982139822398233982439825398263982739828398293983039831398323983339834398353983639837398383983939840398413984239843398443984539846398473984839849398503985139852398533985439855398563985739858398593986039861398623986339864398653986639867398683986939870398713987239873398743987539876398773987839879398803988139882398833988439885398863988739888398893989039891398923989339894398953989639897398983989939900399013990239903399043990539906399073990839909399103991139912399133991439915399163991739918399193992039921399223992339924399253992639927399283992939930399313993239933399343993539936399373993839939399403994139942399433994439945399463994739948399493995039951399523995339954399553995639957399583995939960399613996239963399643996539966399673996839969399703997139972399733997439975399763997739978399793998039981399823998339984399853998639987399883998939990399913999239993399943999539996399973999839999400004000140002400034000440005400064000740008400094001040011400124001340014400154001640017400184001940020400214002240023400244002540026400274002840029400304003140032400334003440035400364003740038400394004040041400424004340044400454004640047400484004940050400514005240053400544005540056400574005840059400604006140062400634006440065400664006740068400694007040071400724007340074400754007640077400784007940080400814008240083400844008540086400874008840089400904009140092400934009440095400964009740098400994010040101401024010340104401054010640107401084010940110401114011240113401144011540116401174011840119401204012140122401234012440125401264012740128401294013040131401324013340134401354013640137401384013940140401414014240143401444014540146401474014840149401504015140152401534015440155401564015740158401594016040161401624016340164401654016640167401684016940170401714017240173401744017540176401774017840179401804018140182401834018440185401864018740188401894019040191401924019340194401954019640197401984019940200402014020240203402044020540206402074020840209402104021140212402134021440215402164021740218402194022040221402224022340224402254022640227402284022940230402314023240233402344023540236402374023840239402404024140242402434024440245402464024740248402494025040251402524025340254402554025640257402584025940260402614026240263402644026540266402674026840269402704027140272402734027440275402764027740278402794028040281402824028340284402854028640287402884028940290402914029240293402944029540296402974029840299403004030140302403034030440305403064030740308403094031040311403124031340314403154031640317403184031940320403214032240323403244032540326403274032840329403304033140332403334033440335403364033740338403394034040341403424034340344403454034640347403484034940350403514035240353403544035540356403574035840359403604036140362403634036440365403664036740368403694037040371403724037340374403754037640377403784037940380403814038240383403844038540386403874038840389403904039140392403934039440395403964039740398403994040040401404024040340404404054040640407404084040940410404114041240413404144041540416404174041840419404204042140422404234042440425404264042740428404294043040431404324043340434404354043640437404384043940440404414044240443404444044540446404474044840449404504045140452404534045440455404564045740458404594046040461404624046340464404654046640467404684046940470404714047240473404744047540476404774047840479404804048140482404834048440485404864048740488404894049040491404924049340494404954049640497404984049940500405014050240503405044050540506405074050840509405104051140512405134051440515405164051740518405194052040521405224052340524405254052640527405284052940530405314053240533405344053540536405374053840539405404054140542405434054440545405464054740548405494055040551405524055340554405554055640557405584055940560405614056240563405644056540566405674056840569405704057140572405734057440575405764057740578405794058040581405824058340584405854058640587405884058940590405914059240593405944059540596405974059840599406004060140602406034060440605406064060740608406094061040611406124061340614406154061640617406184061940620406214062240623406244062540626406274062840629406304063140632406334063440635406364063740638406394064040641406424064340644406454064640647406484064940650406514065240653406544065540656406574065840659406604066140662406634066440665406664066740668406694067040671406724067340674406754067640677406784067940680406814068240683406844068540686406874068840689406904069140692406934069440695406964069740698406994070040701407024070340704407054070640707407084070940710407114071240713407144071540716407174071840719407204072140722407234072440725407264072740728407294073040731407324073340734407354073640737407384073940740407414074240743407444074540746407474074840749407504075140752407534075440755407564075740758407594076040761407624076340764407654076640767407684076940770407714077240773407744077540776407774077840779407804078140782407834078440785407864078740788407894079040791407924079340794407954079640797407984079940800408014080240803408044080540806408074080840809408104081140812408134081440815408164081740818408194082040821408224082340824408254082640827408284082940830408314083240833408344083540836408374083840839408404084140842408434084440845408464084740848408494085040851408524085340854408554085640857408584085940860408614086240863408644086540866408674086840869408704087140872408734087440875408764087740878408794088040881408824088340884408854088640887408884088940890408914089240893408944089540896408974089840899409004090140902409034090440905409064090740908409094091040911409124091340914409154091640917409184091940920409214092240923409244092540926409274092840929409304093140932409334093440935409364093740938409394094040941409424094340944409454094640947409484094940950409514095240953409544095540956409574095840959409604096140962409634096440965409664096740968409694097040971409724097340974409754097640977409784097940980409814098240983409844098540986409874098840989409904099140992409934099440995409964099740998409994100041001410024100341004410054100641007410084100941010410114101241013410144101541016410174101841019410204102141022410234102441025410264102741028410294103041031410324103341034410354103641037410384103941040410414104241043410444104541046410474104841049410504105141052410534105441055410564105741058410594106041061410624106341064410654106641067410684106941070410714107241073410744107541076410774107841079410804108141082410834108441085410864108741088410894109041091410924109341094410954109641097410984109941100411014110241103411044110541106411074110841109411104111141112411134111441115411164111741118411194112041121411224112341124411254112641127411284112941130411314113241133411344113541136411374113841139411404114141142411434114441145411464114741148411494115041151411524115341154411554115641157411584115941160411614116241163411644116541166411674116841169411704117141172411734117441175411764117741178411794118041181411824118341184411854118641187411884118941190411914119241193411944119541196411974119841199412004120141202412034120441205412064120741208412094121041211412124121341214412154121641217412184121941220412214122241223412244122541226412274122841229412304123141232412334123441235412364123741238412394124041241412424124341244412454124641247412484124941250412514125241253412544125541256412574125841259412604126141262412634126441265412664126741268412694127041271412724127341274412754127641277412784127941280412814128241283412844128541286412874128841289412904129141292412934129441295412964129741298412994130041301413024130341304413054130641307413084130941310413114131241313413144131541316413174131841319413204132141322413234132441325413264132741328413294133041331413324133341334413354133641337413384133941340413414134241343413444134541346413474134841349413504135141352413534135441355413564135741358413594136041361413624136341364413654136641367413684136941370413714137241373413744137541376413774137841379413804138141382413834138441385413864138741388413894139041391413924139341394413954139641397413984139941400414014140241403414044140541406414074140841409414104141141412414134141441415414164141741418414194142041421414224142341424414254142641427414284142941430414314143241433414344143541436414374143841439414404144141442414434144441445414464144741448414494145041451414524145341454414554145641457414584145941460414614146241463414644146541466414674146841469414704147141472414734147441475414764147741478414794148041481414824148341484414854148641487414884148941490414914149241493414944149541496414974149841499415004150141502415034150441505415064150741508415094151041511415124151341514415154151641517415184151941520415214152241523415244152541526415274152841529415304153141532415334153441535415364153741538415394154041541415424154341544415454154641547415484154941550415514155241553415544155541556415574155841559415604156141562415634156441565415664156741568415694157041571415724157341574415754157641577415784157941580415814158241583415844158541586415874158841589415904159141592415934159441595415964159741598415994160041601416024160341604416054160641607416084160941610416114161241613416144161541616416174161841619416204162141622416234162441625416264162741628416294163041631416324163341634416354163641637416384163941640416414164241643416444164541646416474164841649416504165141652416534165441655416564165741658416594166041661416624166341664416654166641667416684166941670416714167241673416744167541676416774167841679416804168141682416834168441685416864168741688416894169041691416924169341694416954169641697416984169941700417014170241703417044170541706417074170841709417104171141712417134171441715417164171741718417194172041721417224172341724417254172641727417284172941730417314173241733417344173541736417374173841739417404174141742417434174441745417464174741748417494175041751417524175341754417554175641757417584175941760417614176241763417644176541766417674176841769417704177141772417734177441775417764177741778417794178041781417824178341784417854178641787417884178941790417914179241793417944179541796417974179841799418004180141802418034180441805418064180741808418094181041811418124181341814418154181641817418184181941820418214182241823418244182541826418274182841829418304183141832418334183441835418364183741838418394184041841418424184341844418454184641847418484184941850418514185241853418544185541856418574185841859418604186141862418634186441865418664186741868418694187041871418724187341874418754187641877418784187941880418814188241883418844188541886418874188841889418904189141892418934189441895418964189741898418994190041901419024190341904419054190641907419084190941910419114191241913419144191541916419174191841919419204192141922419234192441925419264192741928419294193041931419324193341934419354193641937419384193941940419414194241943419444194541946419474194841949419504195141952419534195441955419564195741958419594196041961419624196341964419654196641967419684196941970419714197241973419744197541976419774197841979419804198141982419834198441985419864198741988419894199041991419924199341994419954199641997419984199942000420014200242003420044200542006420074200842009420104201142012420134201442015420164201742018420194202042021420224202342024420254202642027420284202942030420314203242033420344203542036420374203842039420404204142042420434204442045420464204742048420494205042051420524205342054420554205642057420584205942060420614206242063420644206542066420674206842069420704207142072420734207442075420764207742078420794208042081420824208342084420854208642087420884208942090420914209242093420944209542096420974209842099421004210142102421034210442105421064210742108421094211042111421124211342114421154211642117421184211942120421214212242123421244212542126421274212842129421304213142132421334213442135421364213742138421394214042141421424214342144421454214642147421484214942150421514215242153421544215542156421574215842159421604216142162421634216442165421664216742168421694217042171421724217342174421754217642177421784217942180421814218242183421844218542186421874218842189421904219142192421934219442195421964219742198421994220042201422024220342204422054220642207422084220942210422114221242213422144221542216422174221842219422204222142222422234222442225422264222742228422294223042231422324223342234422354223642237422384223942240422414224242243422444224542246422474224842249422504225142252422534225442255422564225742258422594226042261422624226342264422654226642267422684226942270422714227242273422744227542276422774227842279422804228142282422834228442285422864228742288422894229042291422924229342294422954229642297422984229942300423014230242303423044230542306423074230842309423104231142312423134231442315423164231742318423194232042321423224232342324423254232642327423284232942330423314233242333423344233542336423374233842339423404234142342423434234442345423464234742348423494235042351423524235342354423554235642357423584235942360423614236242363423644236542366423674236842369423704237142372423734237442375423764237742378423794238042381423824238342384423854238642387423884238942390423914239242393423944239542396423974239842399424004240142402424034240442405424064240742408424094241042411424124241342414424154241642417424184241942420424214242242423424244242542426424274242842429424304243142432424334243442435424364243742438424394244042441424424244342444424454244642447424484244942450424514245242453424544245542456424574245842459424604246142462424634246442465424664246742468424694247042471424724247342474424754247642477424784247942480424814248242483424844248542486424874248842489424904249142492424934249442495424964249742498424994250042501425024250342504425054250642507425084250942510425114251242513425144251542516425174251842519425204252142522425234252442525425264252742528425294253042531425324253342534425354253642537425384253942540425414254242543425444254542546425474254842549425504255142552425534255442555425564255742558425594256042561425624256342564425654256642567425684256942570425714257242573425744257542576425774257842579425804258142582425834258442585425864258742588425894259042591425924259342594425954259642597425984259942600426014260242603426044260542606426074260842609426104261142612426134261442615426164261742618426194262042621426224262342624426254262642627426284262942630426314263242633426344263542636426374263842639426404264142642426434264442645426464264742648426494265042651426524265342654426554265642657426584265942660426614266242663426644266542666426674266842669426704267142672426734267442675426764267742678426794268042681426824268342684426854268642687426884268942690426914269242693426944269542696426974269842699427004270142702427034270442705427064270742708427094271042711427124271342714427154271642717427184271942720427214272242723427244272542726427274272842729427304273142732427334273442735427364273742738427394274042741427424274342744427454274642747427484274942750427514275242753427544275542756427574275842759427604276142762427634276442765427664276742768427694277042771427724277342774427754277642777427784277942780427814278242783427844278542786427874278842789427904279142792427934279442795427964279742798427994280042801428024280342804428054280642807428084280942810428114281242813428144281542816428174281842819428204282142822428234282442825428264282742828428294283042831428324283342834428354283642837428384283942840428414284242843428444284542846428474284842849428504285142852428534285442855428564285742858428594286042861428624286342864428654286642867428684286942870428714287242873428744287542876428774287842879428804288142882428834288442885428864288742888428894289042891428924289342894428954289642897428984289942900429014290242903429044290542906429074290842909429104291142912429134291442915429164291742918429194292042921429224292342924429254292642927429284292942930429314293242933429344293542936429374293842939429404294142942429434294442945429464294742948429494295042951429524295342954429554295642957429584295942960429614296242963429644296542966429674296842969429704297142972429734297442975429764297742978429794298042981429824298342984429854298642987429884298942990429914299242993429944299542996429974299842999430004300143002430034300443005430064300743008430094301043011430124301343014430154301643017430184301943020430214302243023430244302543026430274302843029430304303143032430334303443035430364303743038430394304043041430424304343044430454304643047430484304943050430514305243053430544305543056430574305843059430604306143062430634306443065430664306743068430694307043071430724307343074430754307643077430784307943080430814308243083430844308543086430874308843089430904309143092430934309443095430964309743098430994310043101431024310343104431054310643107431084310943110431114311243113431144311543116431174311843119431204312143122431234312443125431264312743128431294313043131431324313343134431354313643137431384313943140431414314243143431444314543146431474314843149431504315143152431534315443155431564315743158431594316043161431624316343164431654316643167431684316943170431714317243173431744317543176431774317843179431804318143182431834318443185431864318743188431894319043191431924319343194431954319643197431984319943200432014320243203432044320543206432074320843209432104321143212432134321443215432164321743218432194322043221432224322343224432254322643227432284322943230432314323243233432344323543236432374323843239432404324143242432434324443245432464324743248432494325043251432524325343254432554325643257432584325943260432614326243263432644326543266432674326843269432704327143272432734327443275432764327743278432794328043281432824328343284432854328643287432884328943290432914329243293432944329543296432974329843299433004330143302433034330443305433064330743308433094331043311433124331343314433154331643317433184331943320433214332243323433244332543326433274332843329433304333143332433334333443335433364333743338433394334043341433424334343344433454334643347433484334943350433514335243353433544335543356433574335843359433604336143362433634336443365433664336743368433694337043371433724337343374433754337643377433784337943380433814338243383433844338543386433874338843389433904339143392433934339443395433964339743398433994340043401434024340343404434054340643407434084340943410434114341243413434144341543416434174341843419434204342143422434234342443425434264342743428434294343043431434324343343434434354343643437434384343943440434414344243443434444344543446434474344843449434504345143452434534345443455434564345743458434594346043461434624346343464434654346643467434684346943470434714347243473434744347543476434774347843479434804348143482434834348443485434864348743488434894349043491434924349343494434954349643497434984349943500435014350243503435044350543506435074350843509435104351143512435134351443515435164351743518435194352043521435224352343524435254352643527435284352943530435314353243533435344353543536435374353843539435404354143542435434354443545435464354743548435494355043551435524355343554435554355643557435584355943560435614356243563435644356543566435674356843569435704357143572435734357443575435764357743578435794358043581435824358343584435854358643587435884358943590435914359243593435944359543596435974359843599436004360143602436034360443605436064360743608436094361043611436124361343614436154361643617436184361943620436214362243623436244362543626436274362843629436304363143632436334363443635436364363743638436394364043641436424364343644436454364643647436484364943650436514365243653436544365543656436574365843659436604366143662436634366443665436664366743668436694367043671436724367343674436754367643677436784367943680436814368243683436844368543686436874368843689436904369143692436934369443695436964369743698436994370043701437024370343704437054370643707437084370943710437114371243713437144371543716437174371843719437204372143722437234372443725437264372743728437294373043731437324373343734437354373643737437384373943740437414374243743437444374543746437474374843749437504375143752437534375443755437564375743758437594376043761437624376343764437654376643767437684376943770437714377243773437744377543776437774377843779437804378143782437834378443785437864378743788437894379043791437924379343794437954379643797437984379943800438014380243803438044380543806438074380843809438104381143812438134381443815438164381743818438194382043821438224382343824438254382643827438284382943830438314383243833438344383543836438374383843839438404384143842438434384443845438464384743848438494385043851438524385343854438554385643857438584385943860438614386243863438644386543866438674386843869438704387143872438734387443875438764387743878438794388043881438824388343884438854388643887438884388943890438914389243893438944389543896438974389843899439004390143902439034390443905439064390743908439094391043911439124391343914439154391643917439184391943920439214392243923439244392543926439274392843929439304393143932439334393443935439364393743938439394394043941439424394343944439454394643947439484394943950439514395243953439544395543956439574395843959439604396143962439634396443965439664396743968439694397043971439724397343974439754397643977439784397943980439814398243983439844398543986439874398843989439904399143992439934399443995439964399743998439994400044001440024400344004440054400644007440084400944010440114401244013440144401544016440174401844019440204402144022440234402444025440264402744028440294403044031440324403344034440354403644037440384403944040440414404244043440444404544046440474404844049440504405144052440534405444055440564405744058440594406044061440624406344064440654406644067440684406944070440714407244073440744407544076440774407844079440804408144082440834408444085440864408744088440894409044091440924409344094440954409644097440984409944100441014410244103441044410544106441074410844109441104411144112441134411444115441164411744118441194412044121441224412344124441254412644127441284412944130441314413244133441344413544136441374413844139441404414144142441434414444145441464414744148441494415044151441524415344154441554415644157441584415944160441614416244163441644416544166441674416844169441704417144172441734417444175441764417744178441794418044181441824418344184441854418644187441884418944190441914419244193441944419544196441974419844199442004420144202442034420444205442064420744208442094421044211442124421344214442154421644217442184421944220442214422244223442244422544226442274422844229442304423144232442334423444235442364423744238442394424044241442424424344244442454424644247442484424944250442514425244253442544425544256442574425844259442604426144262442634426444265442664426744268442694427044271442724427344274442754427644277442784427944280442814428244283442844428544286442874428844289442904429144292442934429444295442964429744298442994430044301443024430344304443054430644307443084430944310443114431244313443144431544316443174431844319443204432144322443234432444325443264432744328443294433044331443324433344334443354433644337443384433944340443414434244343443444434544346443474434844349443504435144352443534435444355443564435744358443594436044361443624436344364443654436644367443684436944370443714437244373443744437544376443774437844379443804438144382443834438444385443864438744388443894439044391443924439344394443954439644397443984439944400444014440244403444044440544406444074440844409444104441144412444134441444415444164441744418444194442044421444224442344424444254442644427444284442944430444314443244433444344443544436444374443844439444404444144442444434444444445444464444744448444494445044451444524445344454444554445644457444584445944460444614446244463444644446544466444674446844469444704447144472444734447444475444764447744478444794448044481444824448344484444854448644487444884448944490444914449244493444944449544496444974449844499445004450144502445034450444505445064450744508445094451044511445124451344514445154451644517445184451944520445214452244523445244452544526445274452844529445304453144532445334453444535445364453744538445394454044541445424454344544445454454644547445484454944550445514455244553445544455544556445574455844559445604456144562445634456444565445664456744568445694457044571445724457344574445754457644577445784457944580445814458244583445844458544586445874458844589445904459144592445934459444595445964459744598445994460044601446024460344604446054460644607446084460944610446114461244613446144461544616446174461844619446204462144622446234462444625446264462744628446294463044631446324463344634446354463644637446384463944640446414464244643446444464544646446474464844649446504465144652446534465444655446564465744658446594466044661446624466344664446654466644667446684466944670446714467244673446744467544676446774467844679446804468144682446834468444685446864468744688446894469044691446924469344694446954469644697446984469944700447014470244703447044470544706447074470844709447104471144712447134471444715447164471744718447194472044721447224472344724447254472644727447284472944730447314473244733447344473544736447374473844739447404474144742447434474444745447464474744748447494475044751447524475344754447554475644757447584475944760447614476244763447644476544766447674476844769447704477144772447734477444775447764477744778447794478044781447824478344784447854478644787447884478944790447914479244793447944479544796447974479844799448004480144802448034480444805448064480744808448094481044811448124481344814448154481644817448184481944820448214482244823448244482544826448274482844829448304483144832448334483444835448364483744838448394484044841448424484344844448454484644847448484484944850448514485244853448544485544856448574485844859448604486144862448634486444865448664486744868448694487044871448724487344874448754487644877448784487944880448814488244883448844488544886448874488844889448904489144892448934489444895448964489744898448994490044901449024490344904449054490644907449084490944910449114491244913449144491544916449174491844919449204492144922449234492444925449264492744928449294493044931449324493344934449354493644937449384493944940449414494244943449444494544946449474494844949449504495144952449534495444955449564495744958449594496044961449624496344964449654496644967449684496944970449714497244973449744497544976449774497844979449804498144982449834498444985449864498744988449894499044991449924499344994449954499644997449984499945000450014500245003450044500545006450074500845009450104501145012450134501445015450164501745018450194502045021450224502345024450254502645027450284502945030450314503245033450344503545036450374503845039450404504145042450434504445045450464504745048450494505045051450524505345054450554505645057450584505945060450614506245063450644506545066450674506845069450704507145072450734507445075450764507745078450794508045081450824508345084450854508645087450884508945090450914509245093450944509545096450974509845099451004510145102451034510445105451064510745108451094511045111451124511345114451154511645117451184511945120451214512245123451244512545126451274512845129451304513145132451334513445135451364513745138451394514045141451424514345144451454514645147451484514945150451514515245153451544515545156451574515845159451604516145162451634516445165451664516745168451694517045171451724517345174451754517645177451784517945180451814518245183451844518545186451874518845189451904519145192451934519445195451964519745198451994520045201452024520345204452054520645207452084520945210452114521245213452144521545216452174521845219452204522145222452234522445225452264522745228452294523045231452324523345234452354523645237452384523945240452414524245243452444524545246452474524845249452504525145252452534525445255452564525745258452594526045261452624526345264452654526645267452684526945270452714527245273452744527545276452774527845279452804528145282452834528445285452864528745288452894529045291452924529345294452954529645297452984529945300453014530245303453044530545306453074530845309453104531145312453134531445315453164531745318453194532045321453224532345324453254532645327453284532945330453314533245333453344533545336453374533845339453404534145342453434534445345453464534745348453494535045351453524535345354453554535645357453584535945360453614536245363453644536545366453674536845369453704537145372453734537445375453764537745378453794538045381453824538345384453854538645387453884538945390453914539245393453944539545396453974539845399454004540145402454034540445405454064540745408454094541045411454124541345414454154541645417454184541945420454214542245423454244542545426454274542845429454304543145432454334543445435454364543745438454394544045441454424544345444454454544645447454484544945450454514545245453454544545545456454574545845459454604546145462454634546445465454664546745468454694547045471454724547345474454754547645477454784547945480454814548245483454844548545486454874548845489454904549145492454934549445495454964549745498454994550045501455024550345504455054550645507455084550945510455114551245513455144551545516455174551845519455204552145522455234552445525455264552745528455294553045531455324553345534455354553645537455384553945540455414554245543455444554545546455474554845549455504555145552455534555445555455564555745558455594556045561455624556345564455654556645567455684556945570455714557245573455744557545576455774557845579455804558145582455834558445585455864558745588455894559045591455924559345594455954559645597455984559945600456014560245603456044560545606456074560845609456104561145612456134561445615456164561745618456194562045621456224562345624456254562645627456284562945630456314563245633456344563545636456374563845639456404564145642456434564445645456464564745648456494565045651456524565345654456554565645657456584565945660456614566245663456644566545666456674566845669456704567145672456734567445675456764567745678456794568045681456824568345684456854568645687456884568945690456914569245693456944569545696456974569845699457004570145702457034570445705457064570745708457094571045711457124571345714457154571645717457184571945720457214572245723457244572545726457274572845729457304573145732457334573445735457364573745738457394574045741457424574345744457454574645747457484574945750457514575245753457544575545756457574575845759457604576145762457634576445765457664576745768457694577045771457724577345774457754577645777457784577945780457814578245783457844578545786457874578845789457904579145792457934579445795457964579745798457994580045801458024580345804458054580645807458084580945810458114581245813458144581545816458174581845819458204582145822458234582445825458264582745828458294583045831458324583345834458354583645837458384583945840458414584245843458444584545846458474584845849458504585145852458534585445855458564585745858458594586045861458624586345864458654586645867458684586945870458714587245873458744587545876458774587845879458804588145882458834588445885458864588745888458894589045891458924589345894458954589645897458984589945900459014590245903459044590545906459074590845909459104591145912459134591445915459164591745918459194592045921459224592345924459254592645927459284592945930459314593245933459344593545936459374593845939459404594145942459434594445945459464594745948459494595045951459524595345954459554595645957459584595945960459614596245963459644596545966459674596845969459704597145972459734597445975459764597745978459794598045981459824598345984459854598645987459884598945990459914599245993459944599545996459974599845999460004600146002460034600446005460064600746008460094601046011460124601346014460154601646017460184601946020460214602246023460244602546026460274602846029460304603146032460334603446035460364603746038460394604046041460424604346044460454604646047460484604946050460514605246053460544605546056460574605846059460604606146062460634606446065460664606746068460694607046071460724607346074460754607646077460784607946080460814608246083460844608546086460874608846089460904609146092460934609446095460964609746098460994610046101461024610346104461054610646107461084610946110461114611246113461144611546116461174611846119461204612146122461234612446125461264612746128461294613046131461324613346134461354613646137461384613946140461414614246143461444614546146461474614846149461504615146152461534615446155461564615746158461594616046161461624616346164461654616646167461684616946170461714617246173461744617546176461774617846179461804618146182461834618446185461864618746188461894619046191461924619346194461954619646197461984619946200462014620246203462044620546206462074620846209462104621146212462134621446215462164621746218462194622046221462224622346224462254622646227462284622946230462314623246233462344623546236462374623846239462404624146242462434624446245462464624746248462494625046251462524625346254462554625646257462584625946260462614626246263462644626546266462674626846269462704627146272462734627446275462764627746278462794628046281462824628346284462854628646287462884628946290462914629246293462944629546296462974629846299463004630146302463034630446305463064630746308463094631046311463124631346314463154631646317463184631946320463214632246323463244632546326463274632846329463304633146332463334633446335463364633746338463394634046341463424634346344463454634646347463484634946350463514635246353463544635546356463574635846359463604636146362463634636446365463664636746368463694637046371463724637346374463754637646377463784637946380463814638246383463844638546386463874638846389463904639146392463934639446395463964639746398463994640046401464024640346404464054640646407464084640946410464114641246413464144641546416464174641846419464204642146422464234642446425464264642746428464294643046431464324643346434464354643646437464384643946440464414644246443464444644546446464474644846449464504645146452464534645446455464564645746458464594646046461464624646346464464654646646467464684646946470464714647246473464744647546476464774647846479464804648146482464834648446485464864648746488464894649046491464924649346494464954649646497464984649946500465014650246503465044650546506465074650846509465104651146512465134651446515465164651746518465194652046521465224652346524465254652646527465284652946530465314653246533465344653546536465374653846539465404654146542465434654446545465464654746548465494655046551465524655346554465554655646557465584655946560465614656246563465644656546566465674656846569465704657146572465734657446575465764657746578465794658046581465824658346584465854658646587465884658946590465914659246593465944659546596465974659846599466004660146602466034660446605466064660746608466094661046611466124661346614466154661646617466184661946620466214662246623466244662546626466274662846629466304663146632466334663446635466364663746638466394664046641466424664346644466454664646647466484664946650466514665246653466544665546656466574665846659466604666146662466634666446665466664666746668466694667046671466724667346674466754667646677466784667946680466814668246683466844668546686466874668846689466904669146692466934669446695466964669746698466994670046701467024670346704467054670646707467084670946710467114671246713467144671546716467174671846719467204672146722467234672446725467264672746728467294673046731467324673346734467354673646737467384673946740467414674246743467444674546746467474674846749467504675146752467534675446755467564675746758467594676046761467624676346764467654676646767467684676946770467714677246773467744677546776467774677846779467804678146782467834678446785467864678746788467894679046791467924679346794467954679646797467984679946800468014680246803468044680546806468074680846809468104681146812468134681446815468164681746818468194682046821468224682346824468254682646827468284682946830468314683246833468344683546836468374683846839468404684146842468434684446845468464684746848468494685046851468524685346854468554685646857468584685946860468614686246863468644686546866468674686846869468704687146872468734687446875468764687746878468794688046881468824688346884468854688646887468884688946890468914689246893468944689546896468974689846899469004690146902469034690446905469064690746908469094691046911469124691346914469154691646917469184691946920469214692246923469244692546926469274692846929469304693146932469334693446935469364693746938469394694046941469424694346944469454694646947469484694946950469514695246953469544695546956469574695846959469604696146962469634696446965469664696746968469694697046971469724697346974469754697646977469784697946980469814698246983469844698546986469874698846989469904699146992469934699446995469964699746998469994700047001470024700347004470054700647007470084700947010470114701247013470144701547016470174701847019470204702147022470234702447025470264702747028470294703047031470324703347034470354703647037470384703947040470414704247043470444704547046470474704847049470504705147052470534705447055470564705747058470594706047061470624706347064470654706647067470684706947070470714707247073470744707547076470774707847079470804708147082470834708447085470864708747088470894709047091470924709347094470954709647097470984709947100471014710247103471044710547106471074710847109471104711147112471134711447115471164711747118471194712047121471224712347124471254712647127471284712947130471314713247133471344713547136471374713847139471404714147142471434714447145471464714747148471494715047151471524715347154471554715647157471584715947160471614716247163471644716547166471674716847169471704717147172471734717447175471764717747178471794718047181471824718347184471854718647187471884718947190471914719247193471944719547196471974719847199472004720147202472034720447205472064720747208472094721047211472124721347214472154721647217472184721947220472214722247223472244722547226472274722847229472304723147232472334723447235472364723747238472394724047241472424724347244472454724647247472484724947250472514725247253472544725547256472574725847259472604726147262472634726447265472664726747268472694727047271472724727347274472754727647277472784727947280472814728247283472844728547286472874728847289472904729147292472934729447295472964729747298472994730047301473024730347304473054730647307473084730947310473114731247313473144731547316473174731847319473204732147322473234732447325473264732747328473294733047331473324733347334473354733647337473384733947340473414734247343473444734547346473474734847349473504735147352473534735447355473564735747358473594736047361473624736347364473654736647367473684736947370473714737247373473744737547376473774737847379473804738147382473834738447385473864738747388473894739047391473924739347394473954739647397473984739947400474014740247403474044740547406474074740847409474104741147412474134741447415474164741747418474194742047421474224742347424474254742647427474284742947430474314743247433474344743547436474374743847439474404744147442474434744447445474464744747448474494745047451474524745347454474554745647457474584745947460474614746247463474644746547466474674746847469474704747147472474734747447475474764747747478474794748047481474824748347484474854748647487474884748947490474914749247493474944749547496474974749847499475004750147502475034750447505475064750747508475094751047511475124751347514475154751647517475184751947520475214752247523475244752547526475274752847529475304753147532475334753447535475364753747538475394754047541475424754347544475454754647547475484754947550475514755247553475544755547556475574755847559475604756147562475634756447565475664756747568475694757047571475724757347574475754757647577475784757947580475814758247583475844758547586475874758847589475904759147592475934759447595475964759747598475994760047601476024760347604476054760647607476084760947610476114761247613476144761547616476174761847619476204762147622476234762447625476264762747628476294763047631476324763347634476354763647637476384763947640476414764247643476444764547646476474764847649476504765147652476534765447655476564765747658476594766047661476624766347664476654766647667476684766947670476714767247673476744767547676476774767847679476804768147682476834768447685476864768747688476894769047691476924769347694476954769647697476984769947700477014770247703477044770547706477074770847709477104771147712477134771447715477164771747718477194772047721477224772347724477254772647727477284772947730477314773247733477344773547736477374773847739477404774147742477434774447745477464774747748477494775047751477524775347754477554775647757477584775947760477614776247763477644776547766477674776847769477704777147772477734777447775477764777747778477794778047781477824778347784477854778647787477884778947790477914779247793477944779547796477974779847799478004780147802478034780447805478064780747808478094781047811478124781347814478154781647817478184781947820478214782247823478244782547826478274782847829478304783147832478334783447835478364783747838478394784047841478424784347844478454784647847478484784947850478514785247853478544785547856478574785847859478604786147862478634786447865478664786747868478694787047871478724787347874478754787647877478784787947880478814788247883478844788547886478874788847889478904789147892478934789447895478964789747898478994790047901479024790347904479054790647907479084790947910479114791247913479144791547916479174791847919479204792147922479234792447925479264792747928479294793047931479324793347934479354793647937479384793947940479414794247943479444794547946479474794847949479504795147952479534795447955479564795747958479594796047961479624796347964479654796647967479684796947970479714797247973479744797547976479774797847979479804798147982479834798447985479864798747988479894799047991479924799347994479954799647997479984799948000480014800248003480044800548006480074800848009480104801148012480134801448015480164801748018480194802048021480224802348024480254802648027480284802948030480314803248033480344803548036480374803848039480404804148042480434804448045480464804748048480494805048051480524805348054480554805648057480584805948060480614806248063480644806548066480674806848069480704807148072480734807448075480764807748078480794808048081480824808348084480854808648087480884808948090480914809248093480944809548096480974809848099481004810148102481034810448105481064810748108481094811048111481124811348114481154811648117481184811948120481214812248123481244812548126481274812848129481304813148132481334813448135481364813748138481394814048141481424814348144481454814648147481484814948150481514815248153481544815548156481574815848159481604816148162481634816448165481664816748168481694817048171481724817348174481754817648177481784817948180481814818248183481844818548186481874818848189481904819148192481934819448195481964819748198481994820048201482024820348204482054820648207482084820948210482114821248213482144821548216482174821848219482204822148222482234822448225482264822748228482294823048231482324823348234482354823648237482384823948240482414824248243482444824548246482474824848249482504825148252482534825448255482564825748258482594826048261482624826348264482654826648267482684826948270482714827248273482744827548276482774827848279482804828148282482834828448285482864828748288482894829048291482924829348294482954829648297482984829948300483014830248303483044830548306483074830848309483104831148312483134831448315483164831748318483194832048321483224832348324483254832648327483284832948330483314833248333483344833548336483374833848339483404834148342483434834448345483464834748348483494835048351483524835348354483554835648357483584835948360483614836248363483644836548366483674836848369483704837148372483734837448375483764837748378483794838048381483824838348384483854838648387483884838948390483914839248393483944839548396483974839848399484004840148402484034840448405484064840748408484094841048411484124841348414484154841648417484184841948420484214842248423484244842548426484274842848429484304843148432484334843448435484364843748438484394844048441484424844348444484454844648447484484844948450484514845248453484544845548456484574845848459484604846148462484634846448465484664846748468484694847048471484724847348474484754847648477484784847948480484814848248483484844848548486484874848848489484904849148492484934849448495484964849748498484994850048501485024850348504485054850648507485084850948510485114851248513485144851548516485174851848519485204852148522485234852448525485264852748528485294853048531485324853348534485354853648537485384853948540485414854248543485444854548546485474854848549485504855148552485534855448555485564855748558485594856048561485624856348564485654856648567485684856948570485714857248573485744857548576485774857848579485804858148582485834858448585485864858748588485894859048591485924859348594485954859648597485984859948600486014860248603486044860548606486074860848609486104861148612486134861448615486164861748618486194862048621486224862348624486254862648627486284862948630486314863248633486344863548636486374863848639486404864148642486434864448645486464864748648486494865048651486524865348654486554865648657486584865948660486614866248663486644866548666486674866848669486704867148672486734867448675486764867748678486794868048681486824868348684486854868648687486884868948690486914869248693486944869548696486974869848699487004870148702487034870448705487064870748708487094871048711487124871348714487154871648717487184871948720487214872248723487244872548726487274872848729487304873148732487334873448735487364873748738487394874048741487424874348744487454874648747487484874948750487514875248753487544875548756487574875848759487604876148762487634876448765487664876748768487694877048771487724877348774487754877648777487784877948780487814878248783487844878548786487874878848789487904879148792487934879448795487964879748798487994880048801488024880348804488054880648807488084880948810488114881248813488144881548816488174881848819488204882148822488234882448825488264882748828488294883048831488324883348834488354883648837488384883948840488414884248843488444884548846488474884848849488504885148852488534885448855488564885748858488594886048861488624886348864488654886648867488684886948870488714887248873488744887548876488774887848879488804888148882488834888448885488864888748888488894889048891488924889348894488954889648897488984889948900489014890248903489044890548906489074890848909489104891148912489134891448915489164891748918489194892048921489224892348924489254892648927489284892948930489314893248933489344893548936489374893848939489404894148942489434894448945489464894748948489494895048951489524895348954489554895648957489584895948960489614896248963489644896548966489674896848969489704897148972489734897448975489764897748978489794898048981489824898348984489854898648987489884898948990489914899248993489944899548996489974899848999490004900149002490034900449005490064900749008490094901049011490124901349014490154901649017490184901949020490214902249023490244902549026490274902849029490304903149032490334903449035490364903749038490394904049041490424904349044490454904649047490484904949050490514905249053490544905549056490574905849059490604906149062490634906449065490664906749068490694907049071490724907349074490754907649077490784907949080490814908249083490844908549086490874908849089490904909149092490934909449095490964909749098490994910049101491024910349104491054910649107491084910949110491114911249113491144911549116491174911849119491204912149122491234912449125491264912749128491294913049131491324913349134491354913649137491384913949140491414914249143491444914549146491474914849149491504915149152491534915449155491564915749158491594916049161491624916349164491654916649167491684916949170491714917249173491744917549176491774917849179491804918149182491834918449185491864918749188491894919049191491924919349194491954919649197491984919949200492014920249203492044920549206492074920849209492104921149212492134921449215492164921749218492194922049221492224922349224492254922649227492284922949230492314923249233492344923549236492374923849239492404924149242492434924449245492464924749248492494925049251492524925349254492554925649257492584925949260492614926249263492644926549266492674926849269492704927149272492734927449275492764927749278492794928049281492824928349284492854928649287492884928949290492914929249293492944929549296492974929849299493004930149302493034930449305493064930749308493094931049311493124931349314493154931649317493184931949320493214932249323493244932549326493274932849329493304933149332493334933449335493364933749338493394934049341493424934349344493454934649347493484934949350493514935249353493544935549356493574935849359493604936149362493634936449365493664936749368493694937049371493724937349374493754937649377493784937949380493814938249383493844938549386493874938849389493904939149392493934939449395493964939749398493994940049401494024940349404494054940649407494084940949410494114941249413494144941549416494174941849419494204942149422494234942449425494264942749428494294943049431494324943349434494354943649437494384943949440494414944249443494444944549446494474944849449494504945149452494534945449455494564945749458494594946049461494624946349464494654946649467494684946949470494714947249473494744947549476494774947849479494804948149482494834948449485494864948749488494894949049491494924949349494494954949649497494984949949500495014950249503495044950549506495074950849509495104951149512495134951449515495164951749518495194952049521495224952349524495254952649527495284952949530495314953249533495344953549536495374953849539495404954149542495434954449545495464954749548495494955049551495524955349554495554955649557495584955949560495614956249563495644956549566495674956849569495704957149572495734957449575495764957749578495794958049581495824958349584495854958649587495884958949590495914959249593495944959549596495974959849599496004960149602496034960449605496064960749608496094961049611496124961349614496154961649617496184961949620496214962249623496244962549626496274962849629496304963149632496334963449635496364963749638496394964049641496424964349644496454964649647496484964949650496514965249653496544965549656496574965849659496604966149662496634966449665496664966749668496694967049671496724967349674496754967649677496784967949680496814968249683496844968549686496874968849689496904969149692496934969449695496964969749698496994970049701497024970349704497054970649707497084970949710497114971249713497144971549716497174971849719497204972149722497234972449725497264972749728497294973049731497324973349734497354973649737497384973949740497414974249743497444974549746497474974849749497504975149752497534975449755497564975749758497594976049761497624976349764497654976649767497684976949770497714977249773497744977549776497774977849779497804978149782497834978449785497864978749788497894979049791497924979349794497954979649797497984979949800498014980249803498044980549806498074980849809498104981149812498134981449815498164981749818498194982049821498224982349824498254982649827498284982949830498314983249833498344983549836498374983849839498404984149842498434984449845498464984749848498494985049851498524985349854498554985649857498584985949860498614986249863498644986549866498674986849869498704987149872498734987449875498764987749878498794988049881498824988349884498854988649887498884988949890498914989249893498944989549896498974989849899499004990149902499034990449905499064990749908499094991049911499124991349914499154991649917499184991949920499214992249923499244992549926499274992849929499304993149932499334993449935499364993749938499394994049941499424994349944499454994649947499484994949950499514995249953499544995549956499574995849959499604996149962499634996449965499664996749968499694997049971499724997349974499754997649977499784997949980499814998249983499844998549986499874998849989499904999149992499934999449995499964999749998499995000050001500025000350004500055000650007500085000950010500115001250013500145001550016500175001850019500205002150022500235002450025500265002750028500295003050031500325003350034500355003650037500385003950040500415004250043500445004550046500475004850049500505005150052500535005450055500565005750058500595006050061500625006350064500655006650067500685006950070500715007250073500745007550076500775007850079500805008150082500835008450085500865008750088500895009050091500925009350094500955009650097500985009950100501015010250103501045010550106501075010850109501105011150112501135011450115501165011750118501195012050121501225012350124501255012650127501285012950130501315013250133501345013550136501375013850139501405014150142501435014450145501465014750148501495015050151501525015350154501555015650157501585015950160501615016250163501645016550166501675016850169501705017150172501735017450175501765017750178501795018050181501825018350184501855018650187501885018950190501915019250193501945019550196501975019850199502005020150202502035020450205502065020750208502095021050211502125021350214502155021650217502185021950220502215022250223502245022550226502275022850229502305023150232502335023450235502365023750238502395024050241502425024350244502455024650247502485024950250502515025250253502545025550256502575025850259502605026150262502635026450265502665026750268502695027050271502725027350274502755027650277502785027950280502815028250283502845028550286502875028850289502905029150292502935029450295502965029750298502995030050301503025030350304503055030650307503085030950310503115031250313503145031550316503175031850319503205032150322503235032450325503265032750328503295033050331503325033350334503355033650337503385033950340503415034250343503445034550346503475034850349503505035150352503535035450355503565035750358503595036050361503625036350364503655036650367503685036950370503715037250373503745037550376503775037850379503805038150382503835038450385503865038750388503895039050391503925039350394503955039650397503985039950400504015040250403504045040550406504075040850409504105041150412504135041450415504165041750418504195042050421504225042350424504255042650427504285042950430504315043250433504345043550436504375043850439504405044150442504435044450445504465044750448504495045050451504525045350454504555045650457504585045950460504615046250463504645046550466504675046850469504705047150472504735047450475504765047750478504795048050481504825048350484504855048650487504885048950490504915049250493504945049550496504975049850499505005050150502505035050450505505065050750508505095051050511505125051350514505155051650517505185051950520505215052250523505245052550526505275052850529505305053150532505335053450535505365053750538505395054050541505425054350544505455054650547505485054950550505515055250553505545055550556505575055850559505605056150562505635056450565505665056750568505695057050571505725057350574505755057650577505785057950580505815058250583505845058550586505875058850589505905059150592505935059450595505965059750598505995060050601506025060350604506055060650607506085060950610506115061250613506145061550616506175061850619506205062150622506235062450625506265062750628506295063050631506325063350634506355063650637506385063950640506415064250643506445064550646506475064850649506505065150652506535065450655506565065750658506595066050661506625066350664506655066650667506685066950670506715067250673506745067550676506775067850679506805068150682506835068450685506865068750688506895069050691506925069350694506955069650697506985069950700507015070250703507045070550706507075070850709507105071150712507135071450715507165071750718507195072050721507225072350724507255072650727507285072950730507315073250733507345073550736507375073850739507405074150742507435074450745507465074750748507495075050751507525075350754507555075650757507585075950760507615076250763507645076550766507675076850769507705077150772507735077450775507765077750778507795078050781507825078350784507855078650787507885078950790507915079250793507945079550796507975079850799508005080150802508035080450805508065080750808508095081050811508125081350814508155081650817508185081950820508215082250823508245082550826508275082850829508305083150832508335083450835508365083750838508395084050841508425084350844508455084650847508485084950850508515085250853508545085550856508575085850859508605086150862508635086450865508665086750868508695087050871508725087350874508755087650877508785087950880508815088250883508845088550886508875088850889508905089150892508935089450895508965089750898508995090050901509025090350904509055090650907509085090950910509115091250913509145091550916509175091850919509205092150922509235092450925509265092750928509295093050931509325093350934509355093650937509385093950940509415094250943509445094550946509475094850949509505095150952509535095450955509565095750958509595096050961509625096350964509655096650967509685096950970509715097250973509745097550976509775097850979509805098150982509835098450985509865098750988509895099050991509925099350994509955099650997509985099951000510015100251003510045100551006510075100851009510105101151012510135101451015510165101751018510195102051021510225102351024510255102651027510285102951030510315103251033510345103551036510375103851039510405104151042510435104451045510465104751048510495105051051510525105351054510555105651057510585105951060510615106251063510645106551066510675106851069510705107151072510735107451075510765107751078510795108051081510825108351084510855108651087510885108951090510915109251093510945109551096510975109851099511005110151102511035110451105511065110751108511095111051111511125111351114511155111651117511185111951120511215112251123511245112551126511275112851129511305113151132511335113451135511365113751138511395114051141511425114351144511455114651147511485114951150511515115251153511545115551156511575115851159511605116151162511635116451165511665116751168511695117051171511725117351174511755117651177511785117951180511815118251183511845118551186511875118851189511905119151192511935119451195511965119751198511995120051201512025120351204512055120651207512085120951210512115121251213512145121551216512175121851219512205122151222512235122451225512265122751228512295123051231512325123351234512355123651237512385123951240512415124251243512445124551246512475124851249512505125151252512535125451255512565125751258512595126051261512625126351264512655126651267512685126951270512715127251273512745127551276512775127851279512805128151282512835128451285512865128751288512895129051291512925129351294512955129651297512985129951300513015130251303513045130551306513075130851309513105131151312513135131451315513165131751318513195132051321513225132351324513255132651327513285132951330513315133251333513345133551336513375133851339513405134151342513435134451345513465134751348513495135051351513525135351354513555135651357513585135951360513615136251363513645136551366513675136851369513705137151372513735137451375513765137751378513795138051381513825138351384513855138651387513885138951390513915139251393513945139551396513975139851399514005140151402514035140451405514065140751408514095141051411514125141351414514155141651417514185141951420514215142251423514245142551426514275142851429514305143151432514335143451435514365143751438514395144051441514425144351444514455144651447514485144951450514515145251453514545145551456514575145851459514605146151462514635146451465514665146751468514695147051471514725147351474514755147651477514785147951480514815148251483514845148551486514875148851489514905149151492514935149451495514965149751498514995150051501515025150351504515055150651507515085150951510515115151251513515145151551516515175151851519515205152151522515235152451525515265152751528515295153051531515325153351534515355153651537515385153951540515415154251543515445154551546515475154851549515505155151552515535155451555515565155751558515595156051561515625156351564515655156651567515685156951570515715157251573515745157551576515775157851579515805158151582515835158451585515865158751588515895159051591515925159351594515955159651597515985159951600516015160251603516045160551606516075160851609516105161151612516135161451615516165161751618516195162051621516225162351624516255162651627516285162951630516315163251633516345163551636516375163851639516405164151642516435164451645516465164751648516495165051651516525165351654516555165651657516585165951660516615166251663516645166551666516675166851669516705167151672516735167451675516765167751678516795168051681516825168351684516855168651687516885168951690516915169251693516945169551696516975169851699517005170151702517035170451705517065170751708517095171051711517125171351714517155171651717517185171951720517215172251723517245172551726517275172851729517305173151732517335173451735517365173751738517395174051741517425174351744517455174651747517485174951750517515175251753517545175551756517575175851759517605176151762517635176451765517665176751768517695177051771517725177351774517755177651777517785177951780517815178251783517845178551786517875178851789517905179151792517935179451795517965179751798517995180051801518025180351804518055180651807518085180951810518115181251813518145181551816518175181851819518205182151822518235182451825518265182751828518295183051831518325183351834518355183651837518385183951840518415184251843518445184551846518475184851849518505185151852518535185451855518565185751858518595186051861518625186351864518655186651867518685186951870518715187251873518745187551876518775187851879518805188151882518835188451885518865188751888518895189051891518925189351894518955189651897518985189951900519015190251903519045190551906519075190851909519105191151912519135191451915519165191751918519195192051921519225192351924519255192651927519285192951930519315193251933519345193551936519375193851939519405194151942519435194451945519465194751948519495195051951519525195351954519555195651957519585195951960519615196251963519645196551966519675196851969519705197151972519735197451975519765197751978519795198051981519825198351984519855198651987519885198951990519915199251993519945199551996519975199851999520005200152002520035200452005520065200752008520095201052011520125201352014520155201652017520185201952020520215202252023520245202552026520275202852029520305203152032520335203452035520365203752038520395204052041520425204352044520455204652047520485204952050520515205252053520545205552056520575205852059520605206152062520635206452065520665206752068520695207052071520725207352074520755207652077520785207952080520815208252083520845208552086520875208852089520905209152092520935209452095520965209752098520995210052101521025210352104521055210652107521085210952110521115211252113521145211552116521175211852119521205212152122521235212452125521265212752128521295213052131521325213352134521355213652137521385213952140521415214252143521445214552146521475214852149521505215152152521535215452155521565215752158521595216052161521625216352164521655216652167521685216952170521715217252173521745217552176521775217852179521805218152182521835218452185521865218752188521895219052191521925219352194521955219652197521985219952200522015220252203522045220552206522075220852209522105221152212522135221452215522165221752218522195222052221522225222352224522255222652227522285222952230522315223252233522345223552236522375223852239522405224152242522435224452245522465224752248522495225052251522525225352254522555225652257522585225952260522615226252263522645226552266522675226852269522705227152272522735227452275522765227752278522795228052281522825228352284522855228652287522885228952290522915229252293522945229552296522975229852299523005230152302523035230452305523065230752308523095231052311523125231352314523155231652317523185231952320523215232252323523245232552326523275232852329523305233152332523335233452335523365233752338523395234052341523425234352344523455234652347523485234952350523515235252353523545235552356523575235852359523605236152362523635236452365523665236752368523695237052371523725237352374523755237652377523785237952380523815238252383523845238552386523875238852389523905239152392523935239452395523965239752398523995240052401524025240352404524055240652407524085240952410524115241252413524145241552416524175241852419524205242152422524235242452425524265242752428524295243052431524325243352434524355243652437524385243952440524415244252443524445244552446524475244852449524505245152452524535245452455524565245752458524595246052461524625246352464524655246652467524685246952470524715247252473524745247552476524775247852479524805248152482524835248452485524865248752488524895249052491524925249352494524955249652497524985249952500525015250252503525045250552506525075250852509525105251152512525135251452515525165251752518525195252052521525225252352524525255252652527525285252952530525315253252533525345253552536525375253852539525405254152542525435254452545525465254752548525495255052551525525255352554525555255652557525585255952560525615256252563525645256552566525675256852569525705257152572525735257452575525765257752578525795258052581525825258352584525855258652587525885258952590525915259252593525945259552596525975259852599526005260152602526035260452605526065260752608526095261052611526125261352614526155261652617526185261952620526215262252623526245262552626526275262852629526305263152632526335263452635526365263752638526395264052641526425264352644526455264652647526485264952650526515265252653526545265552656526575265852659526605266152662526635266452665526665266752668526695267052671526725267352674526755267652677526785267952680526815268252683526845268552686526875268852689526905269152692526935269452695526965269752698526995270052701527025270352704527055270652707527085270952710527115271252713527145271552716527175271852719527205272152722527235272452725527265272752728527295273052731527325273352734527355273652737527385273952740527415274252743527445274552746527475274852749527505275152752527535275452755527565275752758527595276052761527625276352764527655276652767527685276952770527715277252773527745277552776527775277852779527805278152782527835278452785527865278752788527895279052791527925279352794527955279652797527985279952800528015280252803528045280552806528075280852809528105281152812528135281452815528165281752818528195282052821528225282352824528255282652827528285282952830528315283252833528345283552836528375283852839528405284152842528435284452845528465284752848528495285052851528525285352854528555285652857528585285952860528615286252863528645286552866528675286852869528705287152872528735287452875528765287752878528795288052881528825288352884528855288652887528885288952890528915289252893528945289552896528975289852899529005290152902529035290452905529065290752908529095291052911529125291352914529155291652917529185291952920529215292252923529245292552926529275292852929529305293152932529335293452935529365293752938529395294052941529425294352944529455294652947529485294952950529515295252953529545295552956529575295852959529605296152962529635296452965529665296752968529695297052971529725297352974529755297652977529785297952980529815298252983529845298552986529875298852989529905299152992529935299452995529965299752998529995300053001530025300353004530055300653007530085300953010530115301253013530145301553016530175301853019530205302153022530235302453025530265302753028530295303053031530325303353034530355303653037530385303953040530415304253043530445304553046530475304853049530505305153052530535305453055530565305753058530595306053061530625306353064530655306653067530685306953070530715307253073530745307553076530775307853079530805308153082530835308453085530865308753088530895309053091530925309353094530955309653097530985309953100531015310253103531045310553106531075310853109531105311153112531135311453115531165311753118531195312053121531225312353124531255312653127531285312953130531315313253133531345313553136531375313853139531405314153142531435314453145531465314753148531495315053151531525315353154531555315653157531585315953160531615316253163531645316553166531675316853169531705317153172531735317453175531765317753178531795318053181531825318353184531855318653187531885318953190531915319253193531945319553196531975319853199532005320153202532035320453205532065320753208532095321053211532125321353214532155321653217532185321953220532215322253223532245322553226532275322853229532305323153232532335323453235532365323753238532395324053241532425324353244532455324653247532485324953250532515325253253532545325553256532575325853259532605326153262532635326453265532665326753268532695327053271532725327353274532755327653277532785327953280532815328253283532845328553286532875328853289532905329153292532935329453295532965329753298532995330053301533025330353304533055330653307533085330953310533115331253313533145331553316533175331853319533205332153322533235332453325533265332753328533295333053331533325333353334533355333653337533385333953340533415334253343533445334553346533475334853349533505335153352533535335453355533565335753358533595336053361533625336353364533655336653367533685336953370533715337253373533745337553376533775337853379533805338153382533835338453385533865338753388533895339053391533925339353394533955339653397533985339953400534015340253403534045340553406534075340853409534105341153412534135341453415534165341753418534195342053421534225342353424534255342653427534285342953430534315343253433534345343553436534375343853439534405344153442534435344453445534465344753448534495345053451534525345353454534555345653457534585345953460534615346253463534645346553466534675346853469534705347153472534735347453475534765347753478534795348053481534825348353484534855348653487534885348953490534915349253493534945349553496534975349853499535005350153502535035350453505535065350753508535095351053511535125351353514535155351653517535185351953520535215352253523535245352553526535275352853529535305353153532535335353453535535365353753538535395354053541535425354353544535455354653547535485354953550535515355253553535545355553556535575355853559535605356153562535635356453565535665356753568535695357053571535725357353574535755357653577535785357953580535815358253583535845358553586535875358853589535905359153592535935359453595535965359753598535995360053601536025360353604536055360653607536085360953610536115361253613536145361553616536175361853619536205362153622536235362453625536265362753628536295363053631536325363353634536355363653637536385363953640536415364253643536445364553646536475364853649536505365153652536535365453655536565365753658536595366053661536625366353664536655366653667536685366953670536715367253673536745367553676536775367853679536805368153682536835368453685536865368753688536895369053691536925369353694536955369653697536985369953700537015370253703537045370553706537075370853709537105371153712537135371453715537165371753718537195372053721537225372353724537255372653727537285372953730537315373253733537345373553736537375373853739537405374153742537435374453745537465374753748537495375053751537525375353754537555375653757537585375953760537615376253763537645376553766537675376853769537705377153772537735377453775537765377753778537795378053781537825378353784537855378653787537885378953790537915379253793537945379553796537975379853799538005380153802538035380453805538065380753808538095381053811538125381353814538155381653817538185381953820538215382253823538245382553826538275382853829538305383153832538335383453835538365383753838538395384053841538425384353844538455384653847538485384953850538515385253853538545385553856538575385853859538605386153862538635386453865538665386753868538695387053871538725387353874538755387653877538785387953880538815388253883538845388553886538875388853889538905389153892538935389453895538965389753898538995390053901539025390353904539055390653907539085390953910539115391253913539145391553916539175391853919539205392153922539235392453925539265392753928539295393053931539325393353934539355393653937539385393953940539415394253943539445394553946539475394853949539505395153952539535395453955539565395753958539595396053961539625396353964539655396653967539685396953970539715397253973539745397553976539775397853979539805398153982539835398453985539865398753988539895399053991539925399353994539955399653997539985399954000540015400254003540045400554006540075400854009540105401154012540135401454015540165401754018540195402054021540225402354024540255402654027540285402954030540315403254033540345403554036540375403854039540405404154042540435404454045540465404754048540495405054051540525405354054540555405654057540585405954060540615406254063540645406554066540675406854069540705407154072540735407454075540765407754078540795408054081540825408354084540855408654087540885408954090540915409254093540945409554096540975409854099541005410154102541035410454105541065410754108541095411054111541125411354114541155411654117541185411954120541215412254123541245412554126541275412854129541305413154132541335413454135541365413754138541395414054141541425414354144541455414654147541485414954150541515415254153541545415554156541575415854159541605416154162541635416454165541665416754168541695417054171541725417354174541755417654177541785417954180541815418254183541845418554186541875418854189541905419154192541935419454195541965419754198541995420054201542025420354204542055420654207542085420954210542115421254213542145421554216542175421854219542205422154222542235422454225542265422754228542295423054231542325423354234542355423654237542385423954240542415424254243542445424554246542475424854249542505425154252542535425454255542565425754258542595426054261542625426354264542655426654267542685426954270542715427254273542745427554276542775427854279542805428154282542835428454285542865428754288542895429054291542925429354294542955429654297542985429954300543015430254303543045430554306543075430854309543105431154312543135431454315543165431754318543195432054321543225432354324543255432654327543285432954330543315433254333543345433554336543375433854339543405434154342543435434454345543465434754348543495435054351543525435354354543555435654357543585435954360543615436254363543645436554366543675436854369543705437154372543735437454375543765437754378543795438054381543825438354384543855438654387543885438954390543915439254393543945439554396543975439854399544005440154402544035440454405544065440754408544095441054411544125441354414544155441654417544185441954420544215442254423544245442554426544275442854429544305443154432544335443454435544365443754438544395444054441544425444354444544455444654447544485444954450544515445254453544545445554456544575445854459544605446154462544635446454465544665446754468544695447054471544725447354474544755447654477544785447954480544815448254483544845448554486544875448854489544905449154492544935449454495544965449754498544995450054501545025450354504545055450654507545085450954510545115451254513545145451554516545175451854519545205452154522545235452454525545265452754528545295453054531545325453354534545355453654537545385453954540545415454254543545445454554546545475454854549545505455154552545535455454555545565455754558545595456054561545625456354564545655456654567545685456954570545715457254573545745457554576545775457854579545805458154582545835458454585545865458754588545895459054591545925459354594545955459654597545985459954600546015460254603546045460554606546075460854609546105461154612546135461454615546165461754618546195462054621546225462354624546255462654627546285462954630546315463254633546345463554636546375463854639546405464154642546435464454645546465464754648546495465054651546525465354654546555465654657546585465954660546615466254663546645466554666546675466854669546705467154672546735467454675546765467754678546795468054681546825468354684546855468654687546885468954690546915469254693546945469554696546975469854699547005470154702547035470454705547065470754708547095471054711547125471354714547155471654717547185471954720547215472254723547245472554726547275472854729547305473154732547335473454735547365473754738547395474054741547425474354744547455474654747547485474954750547515475254753547545475554756547575475854759547605476154762547635476454765547665476754768547695477054771547725477354774547755477654777547785477954780547815478254783547845478554786547875478854789547905479154792547935479454795547965479754798547995480054801548025480354804548055480654807548085480954810548115481254813548145481554816548175481854819548205482154822548235482454825548265482754828548295483054831548325483354834548355483654837548385483954840548415484254843548445484554846548475484854849548505485154852548535485454855548565485754858548595486054861548625486354864548655486654867548685486954870548715487254873548745487554876548775487854879548805488154882548835488454885548865488754888548895489054891548925489354894548955489654897548985489954900549015490254903549045490554906549075490854909549105491154912549135491454915549165491754918549195492054921549225492354924549255492654927549285492954930549315493254933549345493554936549375493854939549405494154942549435494454945549465494754948549495495054951549525495354954549555495654957549585495954960549615496254963549645496554966549675496854969549705497154972549735497454975549765497754978549795498054981549825498354984549855498654987549885498954990549915499254993549945499554996549975499854999550005500155002550035500455005550065500755008550095501055011550125501355014550155501655017550185501955020550215502255023550245502555026550275502855029550305503155032550335503455035550365503755038550395504055041550425504355044550455504655047550485504955050550515505255053550545505555056550575505855059550605506155062550635506455065550665506755068550695507055071550725507355074550755507655077550785507955080550815508255083550845508555086550875508855089550905509155092550935509455095550965509755098550995510055101551025510355104551055510655107551085510955110551115511255113551145511555116551175511855119551205512155122551235512455125551265512755128551295513055131551325513355134551355513655137551385513955140551415514255143551445514555146551475514855149551505515155152551535515455155551565515755158551595516055161551625516355164551655516655167551685516955170551715517255173551745517555176551775517855179551805518155182551835518455185551865518755188551895519055191551925519355194551955519655197551985519955200552015520255203552045520555206552075520855209552105521155212552135521455215552165521755218552195522055221552225522355224552255522655227552285522955230552315523255233552345523555236552375523855239552405524155242552435524455245552465524755248552495525055251552525525355254552555525655257552585525955260552615526255263552645526555266552675526855269552705527155272552735527455275552765527755278552795528055281552825528355284552855528655287552885528955290552915529255293552945529555296552975529855299553005530155302553035530455305553065530755308553095531055311553125531355314553155531655317553185531955320553215532255323553245532555326553275532855329553305533155332553335533455335553365533755338553395534055341553425534355344553455534655347553485534955350553515535255353553545535555356553575535855359553605536155362553635536455365553665536755368553695537055371553725537355374553755537655377553785537955380553815538255383553845538555386553875538855389553905539155392553935539455395553965539755398553995540055401554025540355404554055540655407554085540955410554115541255413554145541555416554175541855419554205542155422554235542455425554265542755428554295543055431554325543355434554355543655437554385543955440554415544255443554445544555446554475544855449554505545155452554535545455455554565545755458554595546055461554625546355464554655546655467554685546955470554715547255473554745547555476554775547855479554805548155482554835548455485554865548755488554895549055491554925549355494554955549655497554985549955500555015550255503555045550555506555075550855509555105551155512555135551455515555165551755518555195552055521555225552355524555255552655527555285552955530555315553255533555345553555536555375553855539555405554155542555435554455545555465554755548555495555055551555525555355554555555555655557555585555955560555615556255563555645556555566555675556855569555705557155572555735557455575555765557755578555795558055581555825558355584555855558655587555885558955590555915559255593555945559555596555975559855599556005560155602556035560455605556065560755608556095561055611556125561355614556155561655617556185561955620556215562255623556245562555626556275562855629556305563155632556335563455635556365563755638556395564055641556425564355644556455564655647556485564955650556515565255653556545565555656556575565855659556605566155662556635566455665556665566755668556695567055671556725567355674556755567655677556785567955680556815568255683556845568555686556875568855689556905569155692556935569455695556965569755698556995570055701557025570355704557055570655707557085570955710557115571255713557145571555716557175571855719557205572155722557235572455725557265572755728557295573055731557325573355734557355573655737557385573955740557415574255743557445574555746557475574855749557505575155752557535575455755557565575755758557595576055761557625576355764557655576655767557685576955770557715577255773557745577555776557775577855779557805578155782557835578455785557865578755788557895579055791557925579355794557955579655797557985579955800558015580255803558045580555806558075580855809558105581155812558135581455815558165581755818558195582055821558225582355824558255582655827558285582955830558315583255833558345583555836558375583855839558405584155842558435584455845558465584755848558495585055851558525585355854558555585655857558585585955860558615586255863558645586555866558675586855869558705587155872558735587455875558765587755878558795588055881558825588355884558855588655887558885588955890558915589255893558945589555896558975589855899559005590155902559035590455905559065590755908559095591055911559125591355914559155591655917559185591955920559215592255923559245592555926559275592855929559305593155932559335593455935559365593755938559395594055941559425594355944559455594655947559485594955950559515595255953559545595555956559575595855959559605596155962559635596455965559665596755968559695597055971559725597355974559755597655977559785597955980559815598255983559845598555986559875598855989559905599155992559935599455995559965599755998559995600056001560025600356004560055600656007560085600956010560115601256013560145601556016560175601856019560205602156022560235602456025560265602756028560295603056031560325603356034560355603656037560385603956040560415604256043560445604556046560475604856049560505605156052560535605456055560565605756058560595606056061560625606356064560655606656067560685606956070560715607256073560745607556076560775607856079560805608156082560835608456085560865608756088560895609056091560925609356094560955609656097560985609956100561015610256103561045610556106561075610856109561105611156112561135611456115561165611756118561195612056121561225612356124561255612656127561285612956130561315613256133561345613556136561375613856139561405614156142561435614456145561465614756148561495615056151561525615356154561555615656157561585615956160561615616256163561645616556166561675616856169561705617156172561735617456175561765617756178561795618056181561825618356184561855618656187561885618956190561915619256193561945619556196561975619856199562005620156202562035620456205562065620756208562095621056211562125621356214562155621656217562185621956220562215622256223562245622556226562275622856229562305623156232562335623456235562365623756238562395624056241562425624356244562455624656247562485624956250562515625256253562545625556256562575625856259562605626156262562635626456265562665626756268562695627056271562725627356274562755627656277562785627956280562815628256283562845628556286562875628856289562905629156292562935629456295562965629756298562995630056301563025630356304563055630656307563085630956310563115631256313563145631556316563175631856319563205632156322563235632456325563265632756328563295633056331563325633356334563355633656337563385633956340563415634256343563445634556346563475634856349563505635156352563535635456355563565635756358563595636056361563625636356364563655636656367563685636956370563715637256373563745637556376563775637856379563805638156382563835638456385563865638756388563895639056391563925639356394563955639656397563985639956400564015640256403564045640556406564075640856409564105641156412564135641456415564165641756418564195642056421564225642356424564255642656427564285642956430564315643256433564345643556436564375643856439564405644156442564435644456445564465644756448564495645056451564525645356454564555645656457564585645956460564615646256463564645646556466564675646856469564705647156472564735647456475564765647756478564795648056481564825648356484564855648656487564885648956490564915649256493564945649556496564975649856499565005650156502565035650456505565065650756508565095651056511565125651356514565155651656517565185651956520565215652256523565245652556526565275652856529565305653156532565335653456535565365653756538565395654056541565425654356544565455654656547565485654956550565515655256553565545655556556565575655856559565605656156562565635656456565565665656756568565695657056571565725657356574565755657656577565785657956580565815658256583565845658556586565875658856589565905659156592565935659456595565965659756598565995660056601566025660356604566055660656607566085660956610566115661256613566145661556616566175661856619566205662156622566235662456625566265662756628566295663056631566325663356634566355663656637566385663956640566415664256643566445664556646566475664856649566505665156652566535665456655566565665756658566595666056661566625666356664566655666656667566685666956670566715667256673566745667556676566775667856679566805668156682566835668456685566865668756688566895669056691566925669356694566955669656697566985669956700567015670256703567045670556706567075670856709567105671156712567135671456715567165671756718567195672056721567225672356724567255672656727567285672956730567315673256733567345673556736567375673856739567405674156742567435674456745567465674756748567495675056751567525675356754567555675656757567585675956760567615676256763567645676556766567675676856769567705677156772567735677456775567765677756778567795678056781567825678356784567855678656787567885678956790567915679256793567945679556796567975679856799568005680156802568035680456805568065680756808568095681056811568125681356814568155681656817568185681956820568215682256823568245682556826568275682856829568305683156832568335683456835568365683756838568395684056841568425684356844568455684656847568485684956850568515685256853568545685556856568575685856859568605686156862568635686456865568665686756868568695687056871568725687356874568755687656877568785687956880568815688256883568845688556886568875688856889568905689156892568935689456895568965689756898568995690056901569025690356904569055690656907569085690956910569115691256913569145691556916569175691856919569205692156922569235692456925569265692756928569295693056931569325693356934569355693656937569385693956940569415694256943569445694556946569475694856949569505695156952569535695456955569565695756958569595696056961569625696356964569655696656967569685696956970569715697256973569745697556976569775697856979569805698156982569835698456985569865698756988569895699056991569925699356994569955699656997569985699957000570015700257003570045700557006570075700857009570105701157012570135701457015570165701757018570195702057021570225702357024570255702657027570285702957030570315703257033570345703557036570375703857039570405704157042570435704457045570465704757048570495705057051570525705357054570555705657057570585705957060570615706257063570645706557066570675706857069570705707157072570735707457075570765707757078570795708057081570825708357084570855708657087570885708957090570915709257093570945709557096570975709857099571005710157102571035710457105571065710757108571095711057111571125711357114571155711657117571185711957120571215712257123571245712557126571275712857129571305713157132571335713457135571365713757138571395714057141571425714357144571455714657147571485714957150571515715257153571545715557156571575715857159571605716157162571635716457165571665716757168571695717057171571725717357174571755717657177571785717957180571815718257183571845718557186571875718857189571905719157192571935719457195571965719757198571995720057201572025720357204572055720657207572085720957210572115721257213572145721557216572175721857219572205722157222572235722457225572265722757228572295723057231572325723357234572355723657237572385723957240572415724257243572445724557246572475724857249572505725157252572535725457255572565725757258572595726057261572625726357264572655726657267572685726957270572715727257273572745727557276572775727857279572805728157282572835728457285572865728757288572895729057291572925729357294572955729657297572985729957300573015730257303573045730557306573075730857309573105731157312573135731457315573165731757318573195732057321573225732357324573255732657327573285732957330573315733257333573345733557336573375733857339573405734157342573435734457345573465734757348573495735057351573525735357354573555735657357573585735957360573615736257363573645736557366573675736857369573705737157372573735737457375573765737757378573795738057381573825738357384573855738657387573885738957390573915739257393573945739557396573975739857399574005740157402574035740457405574065740757408574095741057411574125741357414574155741657417574185741957420574215742257423574245742557426574275742857429574305743157432574335743457435574365743757438574395744057441574425744357444574455744657447574485744957450574515745257453574545745557456574575745857459574605746157462574635746457465574665746757468574695747057471574725747357474574755747657477574785747957480574815748257483574845748557486574875748857489574905749157492574935749457495574965749757498574995750057501575025750357504575055750657507575085750957510575115751257513575145751557516575175751857519575205752157522575235752457525575265752757528575295753057531575325753357534575355753657537575385753957540575415754257543575445754557546575475754857549575505755157552575535755457555575565755757558575595756057561575625756357564575655756657567575685756957570575715757257573575745757557576575775757857579575805758157582575835758457585575865758757588575895759057591575925759357594575955759657597575985759957600576015760257603576045760557606576075760857609576105761157612576135761457615576165761757618576195762057621576225762357624576255762657627576285762957630576315763257633576345763557636576375763857639576405764157642576435764457645576465764757648576495765057651576525765357654576555765657657576585765957660576615766257663576645766557666576675766857669576705767157672576735767457675576765767757678576795768057681576825768357684576855768657687576885768957690576915769257693576945769557696576975769857699577005770157702577035770457705577065770757708577095771057711577125771357714577155771657717577185771957720577215772257723577245772557726577275772857729577305773157732577335773457735577365773757738577395774057741577425774357744577455774657747577485774957750577515775257753577545775557756577575775857759577605776157762577635776457765577665776757768577695777057771577725777357774577755777657777577785777957780577815778257783577845778557786577875778857789577905779157792577935779457795577965779757798577995780057801578025780357804578055780657807578085780957810578115781257813578145781557816578175781857819578205782157822578235782457825578265782757828578295783057831578325783357834578355783657837578385783957840578415784257843578445784557846578475784857849578505785157852578535785457855578565785757858578595786057861578625786357864578655786657867578685786957870578715787257873578745787557876578775787857879578805788157882578835788457885578865788757888578895789057891578925789357894578955789657897578985789957900579015790257903579045790557906579075790857909579105791157912579135791457915579165791757918579195792057921579225792357924579255792657927579285792957930579315793257933579345793557936579375793857939579405794157942579435794457945579465794757948579495795057951579525795357954579555795657957579585795957960579615796257963579645796557966579675796857969579705797157972579735797457975579765797757978579795798057981579825798357984579855798657987579885798957990579915799257993579945799557996579975799857999580005800158002580035800458005580065800758008580095801058011580125801358014580155801658017580185801958020580215802258023580245802558026580275802858029580305803158032580335803458035580365803758038580395804058041580425804358044580455804658047580485804958050580515805258053580545805558056580575805858059580605806158062580635806458065580665806758068580695807058071580725807358074580755807658077580785807958080580815808258083580845808558086580875808858089580905809158092580935809458095580965809758098580995810058101581025810358104581055810658107581085810958110581115811258113581145811558116581175811858119581205812158122581235812458125581265812758128581295813058131581325813358134581355813658137581385813958140581415814258143581445814558146581475814858149581505815158152581535815458155581565815758158581595816058161581625816358164581655816658167581685816958170581715817258173581745817558176581775817858179581805818158182581835818458185581865818758188581895819058191581925819358194581955819658197581985819958200582015820258203582045820558206582075820858209582105821158212582135821458215582165821758218582195822058221582225822358224582255822658227582285822958230582315823258233582345823558236582375823858239582405824158242582435824458245582465824758248582495825058251582525825358254582555825658257582585825958260582615826258263582645826558266582675826858269582705827158272582735827458275582765827758278582795828058281582825828358284582855828658287582885828958290582915829258293582945829558296582975829858299583005830158302583035830458305583065830758308583095831058311583125831358314583155831658317583185831958320583215832258323583245832558326583275832858329583305833158332583335833458335583365833758338583395834058341583425834358344583455834658347583485834958350583515835258353583545835558356583575835858359583605836158362583635836458365583665836758368583695837058371583725837358374583755837658377583785837958380583815838258383583845838558386583875838858389583905839158392583935839458395583965839758398583995840058401584025840358404584055840658407584085840958410584115841258413584145841558416584175841858419584205842158422584235842458425584265842758428584295843058431584325843358434584355843658437584385843958440584415844258443584445844558446584475844858449584505845158452584535845458455584565845758458584595846058461584625846358464584655846658467584685846958470584715847258473584745847558476584775847858479584805848158482584835848458485584865848758488584895849058491584925849358494584955849658497584985849958500585015850258503585045850558506585075850858509585105851158512585135851458515585165851758518585195852058521585225852358524585255852658527585285852958530585315853258533585345853558536585375853858539585405854158542585435854458545585465854758548585495855058551585525855358554585555855658557585585855958560585615856258563585645856558566585675856858569585705857158572585735857458575585765857758578585795858058581585825858358584585855858658587585885858958590585915859258593585945859558596585975859858599586005860158602586035860458605586065860758608586095861058611586125861358614586155861658617586185861958620586215862258623586245862558626586275862858629586305863158632586335863458635586365863758638586395864058641586425864358644586455864658647586485864958650586515865258653586545865558656586575865858659586605866158662586635866458665586665866758668586695867058671586725867358674586755867658677586785867958680586815868258683586845868558686586875868858689586905869158692586935869458695586965869758698586995870058701587025870358704587055870658707587085870958710587115871258713587145871558716587175871858719587205872158722587235872458725587265872758728587295873058731587325873358734587355873658737587385873958740587415874258743587445874558746587475874858749587505875158752587535875458755587565875758758587595876058761587625876358764587655876658767587685876958770587715877258773587745877558776587775877858779587805878158782587835878458785587865878758788587895879058791587925879358794587955879658797587985879958800588015880258803588045880558806588075880858809588105881158812588135881458815588165881758818588195882058821588225882358824588255882658827588285882958830588315883258833588345883558836588375883858839588405884158842588435884458845588465884758848588495885058851588525885358854588555885658857588585885958860588615886258863588645886558866588675886858869588705887158872588735887458875588765887758878588795888058881588825888358884588855888658887588885888958890588915889258893588945889558896588975889858899589005890158902589035890458905589065890758908589095891058911589125891358914589155891658917589185891958920589215892258923589245892558926589275892858929589305893158932589335893458935589365893758938589395894058941589425894358944589455894658947589485894958950589515895258953589545895558956589575895858959589605896158962589635896458965589665896758968589695897058971589725897358974589755897658977589785897958980589815898258983589845898558986589875898858989589905899158992589935899458995589965899758998589995900059001590025900359004590055900659007590085900959010590115901259013590145901559016590175901859019590205902159022590235902459025590265902759028590295903059031590325903359034590355903659037590385903959040590415904259043590445904559046590475904859049590505905159052590535905459055590565905759058590595906059061590625906359064590655906659067590685906959070590715907259073590745907559076590775907859079590805908159082590835908459085590865908759088590895909059091590925909359094590955909659097590985909959100591015910259103591045910559106591075910859109591105911159112591135911459115591165911759118591195912059121591225912359124591255912659127591285912959130591315913259133591345913559136591375913859139591405914159142591435914459145591465914759148591495915059151591525915359154591555915659157591585915959160591615916259163591645916559166591675916859169591705917159172591735917459175591765917759178591795918059181591825918359184591855918659187591885918959190591915919259193591945919559196591975919859199592005920159202592035920459205592065920759208592095921059211592125921359214592155921659217592185921959220592215922259223592245922559226592275922859229592305923159232592335923459235592365923759238592395924059241592425924359244592455924659247592485924959250592515925259253592545925559256592575925859259592605926159262592635926459265592665926759268592695927059271592725927359274592755927659277592785927959280592815928259283592845928559286592875928859289592905929159292592935929459295592965929759298592995930059301593025930359304593055930659307593085930959310593115931259313593145931559316593175931859319593205932159322593235932459325593265932759328593295933059331593325933359334593355933659337593385933959340593415934259343593445934559346593475934859349593505935159352593535935459355593565935759358593595936059361593625936359364593655936659367593685936959370593715937259373593745937559376593775937859379593805938159382593835938459385593865938759388593895939059391593925939359394593955939659397593985939959400594015940259403594045940559406594075940859409594105941159412594135941459415594165941759418594195942059421594225942359424594255942659427594285942959430594315943259433594345943559436594375943859439594405944159442594435944459445594465944759448594495945059451594525945359454594555945659457594585945959460594615946259463594645946559466594675946859469594705947159472594735947459475594765947759478594795948059481594825948359484594855948659487594885948959490594915949259493594945949559496594975949859499595005950159502595035950459505595065950759508595095951059511595125951359514595155951659517595185951959520595215952259523595245952559526595275952859529595305953159532595335953459535595365953759538595395954059541595425954359544595455954659547595485954959550595515955259553595545955559556595575955859559595605956159562595635956459565595665956759568595695957059571595725957359574595755957659577595785957959580595815958259583595845958559586595875958859589595905959159592595935959459595595965959759598595995960059601596025960359604596055960659607596085960959610596115961259613596145961559616596175961859619596205962159622596235962459625596265962759628596295963059631596325963359634596355963659637596385963959640596415964259643596445964559646596475964859649596505965159652596535965459655596565965759658596595966059661596625966359664596655966659667596685966959670596715967259673596745967559676596775967859679596805968159682596835968459685596865968759688596895969059691596925969359694596955969659697596985969959700597015970259703597045970559706597075970859709597105971159712597135971459715597165971759718597195972059721597225972359724597255972659727597285972959730597315973259733597345973559736597375973859739597405974159742597435974459745597465974759748597495975059751597525975359754597555975659757597585975959760597615976259763597645976559766597675976859769597705977159772597735977459775597765977759778597795978059781597825978359784597855978659787597885978959790597915979259793597945979559796597975979859799598005980159802598035980459805598065980759808598095981059811598125981359814598155981659817598185981959820598215982259823598245982559826598275982859829598305983159832598335983459835598365983759838598395984059841598425984359844598455984659847598485984959850598515985259853598545985559856598575985859859598605986159862598635986459865598665986759868598695987059871598725987359874598755987659877598785987959880598815988259883598845988559886598875988859889598905989159892598935989459895598965989759898598995990059901599025990359904599055990659907599085990959910599115991259913599145991559916599175991859919599205992159922599235992459925599265992759928599295993059931599325993359934599355993659937599385993959940599415994259943599445994559946599475994859949599505995159952599535995459955599565995759958599595996059961599625996359964599655996659967599685996959970599715997259973599745997559976599775997859979599805998159982599835998459985599865998759988599895999059991599925999359994599955999659997599985999960000600016000260003600046000560006600076000860009600106001160012600136001460015600166001760018600196002060021600226002360024600256002660027600286002960030600316003260033600346003560036600376003860039600406004160042600436004460045600466004760048600496005060051600526005360054600556005660057600586005960060600616006260063600646006560066600676006860069600706007160072600736007460075600766007760078600796008060081600826008360084600856008660087600886008960090600916009260093600946009560096600976009860099601006010160102601036010460105601066010760108601096011060111601126011360114601156011660117601186011960120601216012260123601246012560126601276012860129601306013160132601336013460135601366013760138601396014060141601426014360144601456014660147601486014960150601516015260153601546015560156601576015860159601606016160162601636016460165601666016760168601696017060171601726017360174601756017660177601786017960180601816018260183601846018560186601876018860189601906019160192601936019460195601966019760198601996020060201602026020360204602056020660207602086020960210602116021260213602146021560216602176021860219602206022160222602236022460225602266022760228602296023060231602326023360234602356023660237602386023960240602416024260243602446024560246602476024860249602506025160252602536025460255602566025760258602596026060261602626026360264602656026660267602686026960270602716027260273602746027560276602776027860279602806028160282602836028460285602866028760288602896029060291602926029360294602956029660297602986029960300603016030260303603046030560306603076030860309603106031160312603136031460315603166031760318603196032060321603226032360324603256032660327603286032960330603316033260333603346033560336603376033860339603406034160342603436034460345603466034760348603496035060351603526035360354603556035660357603586035960360603616036260363603646036560366603676036860369603706037160372603736037460375603766037760378603796038060381603826038360384603856038660387603886038960390603916039260393603946039560396603976039860399604006040160402604036040460405604066040760408604096041060411604126041360414604156041660417604186041960420604216042260423604246042560426604276042860429604306043160432604336043460435604366043760438604396044060441604426044360444604456044660447604486044960450604516045260453604546045560456604576045860459604606046160462604636046460465604666046760468604696047060471604726047360474604756047660477604786047960480604816048260483604846048560486604876048860489604906049160492604936049460495604966049760498604996050060501605026050360504605056050660507605086050960510605116051260513605146051560516605176051860519605206052160522605236052460525605266052760528605296053060531605326053360534605356053660537605386053960540605416054260543605446054560546605476054860549605506055160552605536055460555605566055760558605596056060561605626056360564605656056660567605686056960570605716057260573605746057560576605776057860579605806058160582605836058460585605866058760588605896059060591605926059360594605956059660597605986059960600606016060260603606046060560606606076060860609606106061160612606136061460615606166061760618606196062060621606226062360624606256062660627606286062960630606316063260633606346063560636606376063860639606406064160642606436064460645606466064760648606496065060651606526065360654606556065660657606586065960660606616066260663606646066560666606676066860669606706067160672606736067460675606766067760678606796068060681606826068360684606856068660687606886068960690606916069260693606946069560696606976069860699607006070160702607036070460705607066070760708607096071060711607126071360714607156071660717607186071960720607216072260723607246072560726607276072860729607306073160732607336073460735607366073760738607396074060741607426074360744607456074660747607486074960750607516075260753607546075560756607576075860759607606076160762607636076460765607666076760768607696077060771607726077360774607756077660777607786077960780607816078260783607846078560786607876078860789607906079160792607936079460795607966079760798607996080060801608026080360804608056080660807608086080960810608116081260813608146081560816608176081860819608206082160822608236082460825608266082760828608296083060831608326083360834608356083660837608386083960840608416084260843608446084560846608476084860849608506085160852608536085460855608566085760858608596086060861608626086360864608656086660867608686086960870608716087260873608746087560876608776087860879608806088160882608836088460885608866088760888608896089060891608926089360894608956089660897608986089960900609016090260903609046090560906609076090860909609106091160912609136091460915609166091760918609196092060921609226092360924609256092660927609286092960930609316093260933609346093560936609376093860939609406094160942609436094460945609466094760948609496095060951609526095360954609556095660957609586095960960609616096260963609646096560966609676096860969609706097160972609736097460975609766097760978609796098060981609826098360984609856098660987609886098960990609916099260993609946099560996609976099860999610006100161002610036100461005610066100761008610096101061011610126101361014610156101661017610186101961020610216102261023610246102561026610276102861029610306103161032610336103461035610366103761038610396104061041610426104361044610456104661047610486104961050610516105261053610546105561056610576105861059610606106161062610636106461065610666106761068610696107061071610726107361074610756107661077610786107961080610816108261083610846108561086610876108861089610906109161092610936109461095610966109761098610996110061101611026110361104611056110661107611086110961110611116111261113611146111561116611176111861119611206112161122611236112461125611266112761128611296113061131611326113361134611356113661137611386113961140611416114261143611446114561146611476114861149611506115161152611536115461155611566115761158611596116061161611626116361164611656116661167611686116961170611716117261173611746117561176611776117861179611806118161182611836118461185611866118761188611896119061191611926119361194611956119661197611986119961200612016120261203612046120561206612076120861209612106121161212612136121461215612166121761218612196122061221612226122361224612256122661227612286122961230612316123261233612346123561236612376123861239612406124161242612436124461245612466124761248612496125061251612526125361254612556125661257612586125961260612616126261263612646126561266612676126861269612706127161272612736127461275612766127761278612796128061281612826128361284612856128661287612886128961290612916129261293612946129561296612976129861299613006130161302613036130461305613066130761308613096131061311613126131361314613156131661317613186131961320613216132261323613246132561326613276132861329613306133161332613336133461335613366133761338613396134061341613426134361344613456134661347613486134961350613516135261353613546135561356613576135861359613606136161362613636136461365613666136761368613696137061371613726137361374613756137661377613786137961380613816138261383613846138561386613876138861389613906139161392613936139461395613966139761398613996140061401614026140361404614056140661407614086140961410614116141261413614146141561416614176141861419614206142161422614236142461425614266142761428614296143061431614326143361434614356143661437614386143961440614416144261443614446144561446614476144861449614506145161452614536145461455614566145761458614596146061461614626146361464614656146661467614686146961470614716147261473614746147561476614776147861479614806148161482614836148461485614866148761488614896149061491614926149361494614956149661497614986149961500615016150261503615046150561506615076150861509615106151161512615136151461515615166151761518615196152061521615226152361524615256152661527615286152961530615316153261533615346153561536615376153861539615406154161542615436154461545615466154761548615496155061551615526155361554615556155661557615586155961560615616156261563615646156561566615676156861569615706157161572615736157461575615766157761578615796158061581615826158361584615856158661587615886158961590615916159261593615946159561596615976159861599616006160161602616036160461605616066160761608616096161061611616126161361614616156161661617616186161961620616216162261623616246162561626616276162861629616306163161632616336163461635616366163761638616396164061641616426164361644616456164661647616486164961650616516165261653616546165561656616576165861659616606166161662616636166461665616666166761668616696167061671616726167361674616756167661677616786167961680616816168261683616846168561686616876168861689616906169161692616936169461695616966169761698616996170061701617026170361704617056170661707617086170961710617116171261713617146171561716617176171861719617206172161722617236172461725617266172761728617296173061731617326173361734617356173661737617386173961740617416174261743617446174561746617476174861749617506175161752617536175461755617566175761758617596176061761617626176361764617656176661767617686176961770617716177261773617746177561776617776177861779617806178161782617836178461785617866178761788617896179061791617926179361794617956179661797617986179961800618016180261803618046180561806618076180861809618106181161812618136181461815618166181761818618196182061821618226182361824618256182661827618286182961830618316183261833618346183561836618376183861839618406184161842618436184461845618466184761848618496185061851618526185361854618556185661857618586185961860618616186261863618646186561866618676186861869618706187161872618736187461875618766187761878618796188061881618826188361884618856188661887618886188961890618916189261893618946189561896618976189861899619006190161902619036190461905619066190761908619096191061911619126191361914619156191661917619186191961920619216192261923619246192561926619276192861929619306193161932619336193461935619366193761938619396194061941619426194361944619456194661947619486194961950619516195261953619546195561956619576195861959619606196161962619636196461965619666196761968619696197061971619726197361974619756197661977619786197961980619816198261983619846198561986619876198861989619906199161992619936199461995619966199761998619996200062001620026200362004620056200662007620086200962010620116201262013620146201562016620176201862019620206202162022620236202462025620266202762028620296203062031620326203362034620356203662037620386203962040620416204262043620446204562046620476204862049620506205162052620536205462055620566205762058620596206062061620626206362064620656206662067620686206962070620716207262073620746207562076620776207862079620806208162082620836208462085620866208762088620896209062091620926209362094620956209662097620986209962100621016210262103621046210562106621076210862109621106211162112621136211462115621166211762118621196212062121621226212362124621256212662127621286212962130621316213262133621346213562136621376213862139621406214162142621436214462145621466214762148621496215062151621526215362154621556215662157621586215962160621616216262163621646216562166621676216862169621706217162172621736217462175621766217762178621796218062181621826218362184621856218662187621886218962190621916219262193621946219562196621976219862199622006220162202622036220462205622066220762208622096221062211622126221362214622156221662217622186221962220622216222262223622246222562226622276222862229622306223162232622336223462235622366223762238622396224062241622426224362244622456224662247622486224962250622516225262253622546225562256622576225862259622606226162262622636226462265622666226762268622696227062271622726227362274622756227662277622786227962280622816228262283622846228562286622876228862289622906229162292622936229462295622966229762298622996230062301623026230362304623056230662307623086230962310623116231262313623146231562316623176231862319623206232162322623236232462325623266232762328623296233062331623326233362334623356233662337623386233962340623416234262343623446234562346623476234862349623506235162352623536235462355623566235762358623596236062361623626236362364623656236662367623686236962370623716237262373623746237562376623776237862379623806238162382623836238462385623866238762388623896239062391623926239362394623956239662397623986239962400624016240262403624046240562406624076240862409624106241162412624136241462415624166241762418624196242062421624226242362424624256242662427624286242962430624316243262433624346243562436624376243862439624406244162442624436244462445624466244762448624496245062451624526245362454624556245662457624586245962460624616246262463624646246562466624676246862469624706247162472624736247462475624766247762478624796248062481624826248362484624856248662487624886248962490624916249262493624946249562496624976249862499625006250162502625036250462505625066250762508625096251062511625126251362514625156251662517625186251962520625216252262523625246252562526625276252862529625306253162532625336253462535625366253762538625396254062541625426254362544625456254662547625486254962550625516255262553625546255562556625576255862559625606256162562625636256462565625666256762568625696257062571625726257362574625756257662577625786257962580625816258262583625846258562586625876258862589625906259162592625936259462595625966259762598625996260062601626026260362604626056260662607626086260962610626116261262613626146261562616626176261862619626206262162622626236262462625626266262762628626296263062631626326263362634626356263662637626386263962640626416264262643626446264562646626476264862649626506265162652626536265462655626566265762658626596266062661626626266362664626656266662667626686266962670626716267262673626746267562676626776267862679626806268162682626836268462685626866268762688626896269062691626926269362694626956269662697626986269962700627016270262703627046270562706627076270862709627106271162712627136271462715627166271762718627196272062721627226272362724627256272662727627286272962730627316273262733627346273562736627376273862739627406274162742627436274462745627466274762748627496275062751627526275362754627556275662757627586275962760627616276262763627646276562766627676276862769627706277162772627736277462775627766277762778627796278062781627826278362784627856278662787627886278962790627916279262793627946279562796627976279862799628006280162802628036280462805628066280762808628096281062811628126281362814628156281662817628186281962820628216282262823628246282562826628276282862829628306283162832628336283462835628366283762838628396284062841628426284362844628456284662847628486284962850628516285262853628546285562856628576285862859628606286162862628636286462865628666286762868628696287062871628726287362874628756287662877628786287962880628816288262883628846288562886628876288862889628906289162892628936289462895628966289762898628996290062901629026290362904629056290662907629086290962910629116291262913629146291562916629176291862919629206292162922629236292462925629266292762928629296293062931629326293362934629356293662937629386293962940629416294262943629446294562946629476294862949629506295162952629536295462955629566295762958629596296062961629626296362964629656296662967629686296962970629716297262973629746297562976629776297862979629806298162982629836298462985629866298762988629896299062991629926299362994629956299662997629986299963000630016300263003630046300563006630076300863009630106301163012630136301463015630166301763018630196302063021630226302363024630256302663027630286302963030630316303263033630346303563036630376303863039630406304163042630436304463045630466304763048630496305063051630526305363054630556305663057630586305963060630616306263063630646306563066630676306863069630706307163072630736307463075630766307763078630796308063081630826308363084630856308663087630886308963090630916309263093630946309563096630976309863099631006310163102631036310463105631066310763108631096311063111631126311363114631156311663117631186311963120631216312263123631246312563126631276312863129631306313163132631336313463135631366313763138631396314063141631426314363144631456314663147631486314963150631516315263153631546315563156631576315863159631606316163162631636316463165631666316763168631696317063171631726317363174631756317663177631786317963180631816318263183631846318563186631876318863189631906319163192631936319463195631966319763198631996320063201632026320363204632056320663207632086320963210632116321263213632146321563216632176321863219632206322163222632236322463225632266322763228632296323063231632326323363234632356323663237632386323963240632416324263243632446324563246632476324863249632506325163252632536325463255632566325763258632596326063261632626326363264632656326663267632686326963270632716327263273632746327563276632776327863279632806328163282632836328463285632866328763288632896329063291632926329363294632956329663297632986329963300633016330263303633046330563306633076330863309633106331163312633136331463315633166331763318633196332063321633226332363324633256332663327633286332963330633316333263333633346333563336633376333863339633406334163342633436334463345633466334763348633496335063351633526335363354633556335663357633586335963360633616336263363633646336563366633676336863369633706337163372633736337463375633766337763378633796338063381633826338363384633856338663387633886338963390633916339263393633946339563396633976339863399634006340163402634036340463405634066340763408634096341063411634126341363414634156341663417634186341963420634216342263423634246342563426634276342863429634306343163432634336343463435634366343763438634396344063441634426344363444634456344663447634486344963450634516345263453634546345563456634576345863459634606346163462634636346463465634666346763468634696347063471634726347363474634756347663477634786347963480634816348263483634846348563486634876348863489634906349163492634936349463495634966349763498634996350063501635026350363504635056350663507635086350963510635116351263513635146351563516635176351863519635206352163522635236352463525635266352763528635296353063531635326353363534635356353663537635386353963540635416354263543635446354563546635476354863549635506355163552635536355463555635566355763558635596356063561635626356363564635656356663567635686356963570635716357263573635746357563576635776357863579635806358163582635836358463585635866358763588635896359063591635926359363594635956359663597635986359963600636016360263603636046360563606636076360863609636106361163612636136361463615636166361763618636196362063621636226362363624636256362663627636286362963630636316363263633636346363563636636376363863639636406364163642636436364463645636466364763648636496365063651636526365363654636556365663657636586365963660636616366263663636646366563666636676366863669636706367163672636736367463675636766367763678636796368063681636826368363684636856368663687636886368963690636916369263693636946369563696636976369863699637006370163702637036370463705637066370763708637096371063711637126371363714637156371663717637186371963720637216372263723637246372563726637276372863729637306373163732637336373463735637366373763738637396374063741637426374363744637456374663747637486374963750637516375263753637546375563756637576375863759637606376163762637636376463765637666376763768637696377063771637726377363774637756377663777637786377963780637816378263783637846378563786637876378863789637906379163792637936379463795637966379763798637996380063801638026380363804638056380663807638086380963810638116381263813638146381563816638176381863819638206382163822638236382463825638266382763828638296383063831638326383363834638356383663837638386383963840638416384263843638446384563846638476384863849638506385163852638536385463855638566385763858638596386063861638626386363864638656386663867638686386963870638716387263873638746387563876638776387863879638806388163882638836388463885638866388763888638896389063891638926389363894638956389663897638986389963900639016390263903639046390563906639076390863909639106391163912639136391463915639166391763918639196392063921639226392363924639256392663927639286392963930639316393263933639346393563936639376393863939639406394163942639436394463945639466394763948639496395063951639526395363954639556395663957639586395963960639616396263963639646396563966639676396863969639706397163972639736397463975639766397763978639796398063981639826398363984639856398663987639886398963990639916399263993639946399563996639976399863999640006400164002640036400464005640066400764008640096401064011640126401364014640156401664017640186401964020640216402264023640246402564026640276402864029640306403164032640336403464035640366403764038640396404064041640426404364044640456404664047640486404964050640516405264053640546405564056640576405864059640606406164062640636406464065640666406764068640696407064071640726407364074640756407664077640786407964080640816408264083640846408564086640876408864089640906409164092640936409464095640966409764098640996410064101641026410364104641056410664107641086410964110641116411264113641146411564116641176411864119641206412164122641236412464125641266412764128641296413064131641326413364134641356413664137641386413964140641416414264143641446414564146641476414864149641506415164152641536415464155641566415764158641596416064161641626416364164641656416664167641686416964170641716417264173641746417564176641776417864179641806418164182641836418464185641866418764188641896419064191641926419364194641956419664197641986419964200642016420264203642046420564206642076420864209642106421164212642136421464215642166421764218642196422064221642226422364224642256422664227642286422964230642316423264233642346423564236642376423864239642406424164242642436424464245642466424764248642496425064251642526425364254642556425664257642586425964260642616426264263642646426564266642676426864269642706427164272642736427464275642766427764278642796428064281642826428364284642856428664287642886428964290642916429264293642946429564296642976429864299643006430164302643036430464305643066430764308643096431064311643126431364314643156431664317643186431964320643216432264323643246432564326643276432864329643306433164332643336433464335643366433764338643396434064341643426434364344643456434664347643486434964350643516435264353643546435564356643576435864359643606436164362643636436464365643666436764368643696437064371643726437364374643756437664377643786437964380643816438264383643846438564386643876438864389643906439164392643936439464395643966439764398643996440064401644026440364404644056440664407644086440964410644116441264413644146441564416644176441864419644206442164422644236442464425644266442764428644296443064431644326443364434644356443664437644386443964440644416444264443644446444564446644476444864449644506445164452644536445464455644566445764458644596446064461644626446364464644656446664467644686446964470644716447264473644746447564476644776447864479644806448164482644836448464485644866448764488644896449064491644926449364494644956449664497644986449964500645016450264503645046450564506645076450864509645106451164512645136451464515645166451764518645196452064521645226452364524645256452664527645286452964530645316453264533645346453564536645376453864539645406454164542645436454464545645466454764548645496455064551645526455364554645556455664557645586455964560645616456264563645646456564566645676456864569645706457164572645736457464575645766457764578645796458064581645826458364584645856458664587645886458964590645916459264593645946459564596645976459864599646006460164602646036460464605646066460764608646096461064611646126461364614646156461664617646186461964620646216462264623646246462564626646276462864629646306463164632646336463464635646366463764638646396464064641646426464364644646456464664647646486464964650646516465264653646546465564656646576465864659646606466164662646636466464665646666466764668646696467064671646726467364674646756467664677646786467964680646816468264683646846468564686646876468864689646906469164692646936469464695646966469764698646996470064701647026470364704647056470664707647086470964710647116471264713647146471564716647176471864719647206472164722647236472464725647266472764728647296473064731647326473364734647356473664737647386473964740647416474264743647446474564746647476474864749647506475164752647536475464755647566475764758647596476064761647626476364764647656476664767647686476964770647716477264773647746477564776647776477864779647806478164782647836478464785647866478764788647896479064791647926479364794647956479664797647986479964800648016480264803648046480564806648076480864809648106481164812648136481464815648166481764818648196482064821648226482364824648256482664827648286482964830648316483264833648346483564836648376483864839648406484164842648436484464845648466484764848648496485064851648526485364854648556485664857648586485964860648616486264863648646486564866648676486864869648706487164872648736487464875648766487764878648796488064881648826488364884648856488664887648886488964890648916489264893648946489564896648976489864899649006490164902649036490464905649066490764908649096491064911649126491364914649156491664917649186491964920649216492264923649246492564926649276492864929649306493164932649336493464935649366493764938649396494064941649426494364944649456494664947649486494964950649516495264953649546495564956649576495864959649606496164962649636496464965649666496764968649696497064971649726497364974649756497664977649786497964980649816498264983649846498564986649876498864989649906499164992649936499464995649966499764998649996500065001650026500365004650056500665007650086500965010650116501265013650146501565016650176501865019650206502165022650236502465025650266502765028650296503065031650326503365034650356503665037650386503965040650416504265043650446504565046650476504865049650506505165052650536505465055650566505765058650596506065061650626506365064650656506665067650686506965070650716507265073650746507565076650776507865079650806508165082650836508465085650866508765088650896509065091650926509365094650956509665097650986509965100651016510265103651046510565106651076510865109651106511165112651136511465115651166511765118651196512065121651226512365124651256512665127651286512965130651316513265133651346513565136651376513865139651406514165142651436514465145651466514765148651496515065151651526515365154651556515665157651586515965160651616516265163651646516565166651676516865169651706517165172651736517465175651766517765178651796518065181651826518365184651856518665187651886518965190651916519265193651946519565196651976519865199652006520165202652036520465205652066520765208652096521065211652126521365214652156521665217652186521965220652216522265223652246522565226652276522865229652306523165232652336523465235652366523765238652396524065241652426524365244652456524665247652486524965250652516525265253652546525565256652576525865259652606526165262652636526465265652666526765268652696527065271652726527365274652756527665277652786527965280652816528265283652846528565286652876528865289652906529165292652936529465295652966529765298652996530065301653026530365304653056530665307653086530965310653116531265313653146531565316653176531865319653206532165322653236532465325653266532765328653296533065331653326533365334653356533665337653386533965340653416534265343653446534565346653476534865349653506535165352653536535465355653566535765358653596536065361653626536365364653656536665367653686536965370653716537265373653746537565376653776537865379653806538165382653836538465385653866538765388653896539065391653926539365394653956539665397653986539965400654016540265403654046540565406654076540865409654106541165412654136541465415654166541765418654196542065421654226542365424654256542665427654286542965430654316543265433654346543565436654376543865439654406544165442654436544465445654466544765448654496545065451654526545365454654556545665457654586545965460654616546265463654646546565466654676546865469654706547165472654736547465475654766547765478654796548065481654826548365484654856548665487654886548965490654916549265493654946549565496654976549865499655006550165502655036550465505655066550765508655096551065511655126551365514655156551665517655186551965520655216552265523655246552565526655276552865529655306553165532655336553465535655366553765538655396554065541655426554365544655456554665547655486554965550655516555265553655546555565556655576555865559655606556165562655636556465565655666556765568655696557065571655726557365574655756557665577655786557965580655816558265583655846558565586655876558865589655906559165592655936559465595655966559765598655996560065601656026560365604656056560665607656086560965610656116561265613656146561565616656176561865619656206562165622656236562465625656266562765628656296563065631656326563365634656356563665637656386563965640656416564265643656446564565646656476564865649656506565165652656536565465655656566565765658656596566065661656626566365664656656566665667656686566965670656716567265673656746567565676656776567865679656806568165682656836568465685656866568765688656896569065691656926569365694656956569665697656986569965700657016570265703657046570565706657076570865709657106571165712657136571465715657166571765718657196572065721657226572365724657256572665727657286572965730657316573265733657346573565736657376573865739657406574165742657436574465745657466574765748657496575065751657526575365754657556575665757657586575965760657616576265763657646576565766657676576865769657706577165772657736577465775657766577765778657796578065781657826578365784657856578665787657886578965790657916579265793657946579565796657976579865799658006580165802658036580465805658066580765808658096581065811658126581365814658156581665817658186581965820658216582265823658246582565826658276582865829658306583165832658336583465835658366583765838658396584065841658426584365844658456584665847658486584965850658516585265853658546585565856658576585865859658606586165862658636586465865658666586765868658696587065871658726587365874658756587665877658786587965880658816588265883658846588565886658876588865889658906589165892658936589465895658966589765898658996590065901659026590365904659056590665907659086590965910659116591265913659146591565916659176591865919659206592165922659236592465925659266592765928659296593065931659326593365934659356593665937659386593965940659416594265943659446594565946659476594865949659506595165952659536595465955659566595765958659596596065961659626596365964659656596665967659686596965970659716597265973659746597565976659776597865979659806598165982659836598465985659866598765988659896599065991659926599365994659956599665997659986599966000660016600266003660046600566006660076600866009660106601166012660136601466015660166601766018660196602066021660226602366024660256602666027660286602966030660316603266033660346603566036660376603866039660406604166042660436604466045660466604766048660496605066051660526605366054660556605666057660586605966060660616606266063660646606566066660676606866069660706607166072660736607466075660766607766078660796608066081660826608366084660856608666087660886608966090660916609266093660946609566096660976609866099661006610166102661036610466105661066610766108661096611066111661126611366114661156611666117661186611966120661216612266123661246612566126661276612866129661306613166132661336613466135661366613766138661396614066141661426614366144661456614666147661486614966150661516615266153661546615566156661576615866159661606616166162661636616466165661666616766168661696617066171661726617366174661756617666177661786617966180661816618266183661846618566186661876618866189661906619166192661936619466195661966619766198661996620066201662026620366204662056620666207662086620966210662116621266213662146621566216662176621866219662206622166222662236622466225662266622766228662296623066231662326623366234662356623666237662386623966240662416624266243662446624566246662476624866249662506625166252662536625466255662566625766258662596626066261662626626366264662656626666267662686626966270662716627266273662746627566276662776627866279662806628166282662836628466285662866628766288662896629066291662926629366294662956629666297662986629966300663016630266303663046630566306663076630866309663106631166312663136631466315663166631766318663196632066321663226632366324663256632666327663286632966330663316633266333663346633566336663376633866339663406634166342663436634466345663466634766348663496635066351663526635366354663556635666357663586635966360663616636266363663646636566366663676636866369663706637166372663736637466375663766637766378663796638066381663826638366384663856638666387663886638966390663916639266393663946639566396663976639866399664006640166402664036640466405664066640766408664096641066411664126641366414664156641666417664186641966420664216642266423664246642566426664276642866429664306643166432664336643466435664366643766438664396644066441664426644366444664456644666447664486644966450664516645266453664546645566456664576645866459664606646166462664636646466465664666646766468664696647066471664726647366474664756647666477664786647966480664816648266483664846648566486664876648866489664906649166492664936649466495664966649766498664996650066501665026650366504665056650666507665086650966510665116651266513665146651566516665176651866519665206652166522665236652466525665266652766528665296653066531665326653366534665356653666537665386653966540665416654266543665446654566546665476654866549665506655166552665536655466555665566655766558665596656066561665626656366564665656656666567665686656966570665716657266573665746657566576665776657866579665806658166582665836658466585665866658766588665896659066591665926659366594665956659666597665986659966600666016660266603666046660566606666076660866609666106661166612666136661466615666166661766618666196662066621666226662366624666256662666627666286662966630666316663266633666346663566636666376663866639666406664166642666436664466645666466664766648666496665066651666526665366654666556665666657666586665966660666616666266663666646666566666666676666866669666706667166672666736667466675666766667766678666796668066681666826668366684666856668666687666886668966690666916669266693666946669566696666976669866699667006670166702667036670466705667066670766708667096671066711667126671366714667156671666717667186671966720667216672266723667246672566726667276672866729667306673166732667336673466735667366673766738667396674066741667426674366744667456674666747667486674966750667516675266753667546675566756667576675866759667606676166762667636676466765667666676766768667696677066771667726677366774667756677666777667786677966780667816678266783667846678566786667876678866789667906679166792667936679466795667966679766798667996680066801668026680366804668056680666807668086680966810668116681266813668146681566816668176681866819668206682166822668236682466825668266682766828668296683066831668326683366834668356683666837668386683966840668416684266843668446684566846668476684866849668506685166852668536685466855668566685766858668596686066861668626686366864668656686666867668686686966870668716687266873668746687566876668776687866879668806688166882668836688466885668866688766888668896689066891668926689366894668956689666897668986689966900669016690266903669046690566906669076690866909669106691166912669136691466915669166691766918669196692066921669226692366924669256692666927669286692966930669316693266933669346693566936669376693866939669406694166942669436694466945669466694766948669496695066951669526695366954669556695666957669586695966960669616696266963669646696566966669676696866969669706697166972669736697466975669766697766978669796698066981669826698366984669856698666987669886698966990669916699266993669946699566996669976699866999670006700167002670036700467005670066700767008670096701067011670126701367014670156701667017670186701967020670216702267023670246702567026670276702867029670306703167032670336703467035670366703767038670396704067041670426704367044670456704667047670486704967050670516705267053670546705567056670576705867059670606706167062670636706467065670666706767068670696707067071670726707367074670756707667077670786707967080670816708267083670846708567086670876708867089670906709167092670936709467095670966709767098670996710067101671026710367104671056710667107671086710967110671116711267113671146711567116671176711867119671206712167122671236712467125671266712767128671296713067131671326713367134671356713667137671386713967140671416714267143671446714567146671476714867149671506715167152671536715467155671566715767158671596716067161671626716367164671656716667167671686716967170671716717267173671746717567176671776717867179671806718167182671836718467185671866718767188671896719067191671926719367194671956719667197671986719967200672016720267203672046720567206672076720867209672106721167212672136721467215672166721767218672196722067221672226722367224672256722667227672286722967230672316723267233672346723567236672376723867239672406724167242672436724467245672466724767248672496725067251672526725367254672556725667257672586725967260672616726267263672646726567266672676726867269672706727167272672736727467275672766727767278672796728067281672826728367284672856728667287672886728967290672916729267293672946729567296672976729867299673006730167302673036730467305673066730767308673096731067311673126731367314673156731667317673186731967320673216732267323673246732567326673276732867329673306733167332673336733467335673366733767338673396734067341673426734367344673456734667347673486734967350673516735267353673546735567356673576735867359673606736167362673636736467365673666736767368673696737067371673726737367374673756737667377673786737967380673816738267383673846738567386673876738867389673906739167392673936739467395673966739767398673996740067401674026740367404674056740667407674086740967410674116741267413674146741567416674176741867419674206742167422674236742467425674266742767428674296743067431674326743367434674356743667437674386743967440674416744267443674446744567446674476744867449674506745167452674536745467455674566745767458674596746067461674626746367464674656746667467674686746967470674716747267473674746747567476674776747867479674806748167482674836748467485674866748767488674896749067491674926749367494674956749667497674986749967500675016750267503675046750567506675076750867509675106751167512675136751467515675166751767518675196752067521675226752367524675256752667527675286752967530675316753267533675346753567536675376753867539675406754167542675436754467545675466754767548675496755067551675526755367554675556755667557675586755967560675616756267563675646756567566675676756867569675706757167572675736757467575675766757767578675796758067581675826758367584675856758667587675886758967590675916759267593675946759567596675976759867599676006760167602676036760467605676066760767608676096761067611676126761367614676156761667617676186761967620676216762267623676246762567626676276762867629676306763167632676336763467635676366763767638676396764067641676426764367644676456764667647676486764967650676516765267653676546765567656676576765867659676606766167662676636766467665676666766767668676696767067671676726767367674676756767667677676786767967680676816768267683676846768567686676876768867689676906769167692676936769467695676966769767698676996770067701677026770367704677056770667707677086770967710677116771267713677146771567716677176771867719677206772167722677236772467725677266772767728677296773067731677326773367734677356773667737677386773967740677416774267743677446774567746677476774867749677506775167752677536775467755677566775767758677596776067761677626776367764677656776667767677686776967770677716777267773677746777567776677776777867779677806778167782677836778467785677866778767788677896779067791677926779367794677956779667797677986779967800678016780267803678046780567806678076780867809678106781167812678136781467815678166781767818678196782067821678226782367824678256782667827678286782967830678316783267833678346783567836678376783867839678406784167842678436784467845678466784767848678496785067851678526785367854678556785667857678586785967860678616786267863678646786567866678676786867869678706787167872678736787467875678766787767878678796788067881678826788367884678856788667887678886788967890678916789267893678946789567896678976789867899679006790167902679036790467905679066790767908679096791067911679126791367914679156791667917679186791967920679216792267923679246792567926679276792867929679306793167932679336793467935679366793767938679396794067941679426794367944679456794667947679486794967950679516795267953679546795567956679576795867959679606796167962679636796467965679666796767968679696797067971679726797367974679756797667977679786797967980679816798267983679846798567986679876798867989679906799167992679936799467995679966799767998679996800068001680026800368004680056800668007680086800968010680116801268013680146801568016680176801868019680206802168022680236802468025680266802768028680296803068031680326803368034680356803668037680386803968040680416804268043680446804568046680476804868049680506805168052680536805468055680566805768058680596806068061680626806368064680656806668067680686806968070680716807268073680746807568076680776807868079680806808168082680836808468085680866808768088680896809068091680926809368094680956809668097680986809968100681016810268103681046810568106681076810868109681106811168112681136811468115681166811768118681196812068121681226812368124681256812668127681286812968130681316813268133681346813568136681376813868139681406814168142681436814468145681466814768148681496815068151681526815368154681556815668157681586815968160681616816268163681646816568166681676816868169681706817168172681736817468175681766817768178681796818068181681826818368184681856818668187681886818968190681916819268193681946819568196681976819868199682006820168202682036820468205682066820768208682096821068211682126821368214682156821668217682186821968220682216822268223682246822568226682276822868229682306823168232682336823468235682366823768238682396824068241682426824368244682456824668247682486824968250682516825268253682546825568256682576825868259682606826168262682636826468265682666826768268682696827068271682726827368274682756827668277682786827968280682816828268283682846828568286682876828868289682906829168292682936829468295682966829768298682996830068301683026830368304683056830668307683086830968310683116831268313683146831568316683176831868319683206832168322683236832468325683266832768328683296833068331683326833368334683356833668337683386833968340683416834268343683446834568346683476834868349683506835168352683536835468355683566835768358683596836068361683626836368364683656836668367683686836968370683716837268373683746837568376683776837868379683806838168382683836838468385683866838768388683896839068391683926839368394683956839668397683986839968400684016840268403684046840568406684076840868409684106841168412684136841468415684166841768418684196842068421684226842368424684256842668427684286842968430684316843268433684346843568436684376843868439684406844168442684436844468445684466844768448684496845068451684526845368454684556845668457684586845968460684616846268463684646846568466684676846868469684706847168472684736847468475684766847768478684796848068481684826848368484684856848668487684886848968490684916849268493684946849568496684976849868499685006850168502685036850468505685066850768508685096851068511685126851368514685156851668517685186851968520685216852268523685246852568526685276852868529685306853168532685336853468535685366853768538685396854068541685426854368544685456854668547685486854968550685516855268553685546855568556685576855868559685606856168562685636856468565685666856768568685696857068571685726857368574685756857668577685786857968580685816858268583685846858568586685876858868589685906859168592685936859468595685966859768598685996860068601686026860368604686056860668607686086860968610686116861268613686146861568616686176861868619686206862168622686236862468625686266862768628686296863068631686326863368634686356863668637686386863968640686416864268643686446864568646686476864868649686506865168652686536865468655686566865768658686596866068661686626866368664686656866668667686686866968670686716867268673686746867568676686776867868679686806868168682686836868468685686866868768688686896869068691686926869368694686956869668697686986869968700687016870268703687046870568706687076870868709687106871168712687136871468715687166871768718687196872068721687226872368724687256872668727687286872968730687316873268733687346873568736687376873868739687406874168742687436874468745687466874768748687496875068751687526875368754687556875668757687586875968760687616876268763687646876568766687676876868769687706877168772687736877468775687766877768778687796878068781687826878368784687856878668787687886878968790687916879268793687946879568796687976879868799688006880168802688036880468805688066880768808688096881068811688126881368814688156881668817688186881968820688216882268823688246882568826688276882868829688306883168832688336883468835688366883768838688396884068841688426884368844688456884668847688486884968850688516885268853688546885568856688576885868859688606886168862688636886468865688666886768868688696887068871688726887368874688756887668877688786887968880688816888268883688846888568886688876888868889688906889168892688936889468895688966889768898688996890068901689026890368904689056890668907689086890968910689116891268913689146891568916689176891868919689206892168922689236892468925689266892768928689296893068931689326893368934689356893668937689386893968940689416894268943689446894568946689476894868949689506895168952689536895468955689566895768958689596896068961689626896368964689656896668967689686896968970689716897268973689746897568976689776897868979689806898168982689836898468985689866898768988689896899068991689926899368994689956899668997689986899969000690016900269003690046900569006690076900869009690106901169012690136901469015690166901769018690196902069021690226902369024690256902669027690286902969030690316903269033690346903569036690376903869039690406904169042690436904469045690466904769048690496905069051690526905369054690556905669057690586905969060690616906269063690646906569066690676906869069690706907169072690736907469075690766907769078690796908069081690826908369084690856908669087690886908969090690916909269093690946909569096690976909869099691006910169102691036910469105691066910769108691096911069111691126911369114691156911669117691186911969120691216912269123691246912569126691276912869129691306913169132691336913469135691366913769138691396914069141691426914369144691456914669147691486914969150691516915269153691546915569156691576915869159691606916169162691636916469165691666916769168691696917069171691726917369174691756917669177691786917969180691816918269183691846918569186691876918869189691906919169192691936919469195691966919769198691996920069201692026920369204692056920669207692086920969210692116921269213692146921569216692176921869219692206922169222692236922469225692266922769228692296923069231692326923369234692356923669237692386923969240692416924269243692446924569246692476924869249692506925169252692536925469255692566925769258692596926069261692626926369264692656926669267692686926969270692716927269273692746927569276692776927869279692806928169282692836928469285692866928769288692896929069291692926929369294692956929669297692986929969300693016930269303693046930569306693076930869309693106931169312693136931469315693166931769318693196932069321693226932369324693256932669327693286932969330693316933269333693346933569336693376933869339693406934169342693436934469345693466934769348693496935069351693526935369354693556935669357693586935969360693616936269363693646936569366693676936869369693706937169372693736937469375693766937769378693796938069381693826938369384693856938669387693886938969390693916939269393693946939569396693976939869399694006940169402694036940469405694066940769408694096941069411694126941369414694156941669417694186941969420694216942269423694246942569426694276942869429694306943169432694336943469435694366943769438694396944069441694426944369444694456944669447694486944969450694516945269453694546945569456694576945869459694606946169462694636946469465694666946769468694696947069471694726947369474694756947669477694786947969480694816948269483694846948569486694876948869489694906949169492694936949469495694966949769498694996950069501695026950369504695056950669507695086950969510695116951269513695146951569516695176951869519695206952169522695236952469525695266952769528695296953069531695326953369534695356953669537695386953969540695416954269543695446954569546695476954869549695506955169552695536955469555695566955769558695596956069561695626956369564695656956669567695686956969570695716957269573695746957569576695776957869579695806958169582695836958469585695866958769588695896959069591695926959369594695956959669597695986959969600696016960269603696046960569606696076960869609696106961169612696136961469615696166961769618696196962069621696226962369624696256962669627696286962969630696316963269633696346963569636696376963869639696406964169642696436964469645696466964769648696496965069651696526965369654696556965669657696586965969660696616966269663696646966569666696676966869669696706967169672696736967469675696766967769678696796968069681696826968369684696856968669687696886968969690696916969269693696946969569696696976969869699697006970169702697036970469705697066970769708697096971069711697126971369714697156971669717697186971969720697216972269723697246972569726697276972869729697306973169732697336973469735697366973769738697396974069741697426974369744697456974669747697486974969750697516975269753697546975569756697576975869759697606976169762697636976469765697666976769768697696977069771697726977369774697756977669777697786977969780697816978269783697846978569786697876978869789697906979169792697936979469795697966979769798697996980069801698026980369804698056980669807698086980969810698116981269813698146981569816698176981869819698206982169822698236982469825698266982769828698296983069831698326983369834698356983669837698386983969840698416984269843698446984569846698476984869849698506985169852698536985469855698566985769858698596986069861698626986369864698656986669867698686986969870698716987269873698746987569876698776987869879698806988169882698836988469885698866988769888698896989069891698926989369894698956989669897698986989969900699016990269903699046990569906699076990869909699106991169912699136991469915699166991769918699196992069921699226992369924699256992669927699286992969930699316993269933699346993569936699376993869939699406994169942699436994469945699466994769948699496995069951699526995369954699556995669957699586995969960699616996269963699646996569966699676996869969699706997169972699736997469975699766997769978699796998069981699826998369984699856998669987699886998969990699916999269993699946999569996699976999869999700007000170002700037000470005700067000770008700097001070011700127001370014700157001670017700187001970020700217002270023700247002570026700277002870029700307003170032700337003470035700367003770038700397004070041700427004370044700457004670047700487004970050700517005270053700547005570056700577005870059700607006170062700637006470065700667006770068700697007070071700727007370074700757007670077700787007970080700817008270083700847008570086700877008870089700907009170092700937009470095700967009770098700997010070101701027010370104701057010670107701087010970110701117011270113701147011570116701177011870119701207012170122701237012470125701267012770128701297013070131701327013370134701357013670137701387013970140701417014270143701447014570146701477014870149701507015170152701537015470155701567015770158701597016070161701627016370164701657016670167701687016970170701717017270173701747017570176701777017870179701807018170182701837018470185701867018770188701897019070191701927019370194701957019670197701987019970200702017020270203702047020570206702077020870209702107021170212702137021470215702167021770218702197022070221702227022370224702257022670227702287022970230702317023270233702347023570236702377023870239702407024170242702437024470245702467024770248702497025070251702527025370254702557025670257702587025970260702617026270263702647026570266702677026870269702707027170272702737027470275702767027770278702797028070281702827028370284702857028670287702887028970290702917029270293702947029570296702977029870299703007030170302703037030470305703067030770308703097031070311703127031370314703157031670317703187031970320703217032270323703247032570326703277032870329703307033170332703337033470335703367033770338703397034070341703427034370344703457034670347703487034970350703517035270353703547035570356703577035870359703607036170362703637036470365703667036770368703697037070371703727037370374703757037670377703787037970380703817038270383703847038570386703877038870389703907039170392703937039470395703967039770398703997040070401704027040370404704057040670407704087040970410704117041270413704147041570416704177041870419704207042170422704237042470425704267042770428704297043070431704327043370434704357043670437704387043970440704417044270443704447044570446704477044870449704507045170452704537045470455704567045770458704597046070461704627046370464704657046670467704687046970470704717047270473704747047570476704777047870479704807048170482704837048470485704867048770488704897049070491704927049370494704957049670497704987049970500705017050270503705047050570506705077050870509705107051170512705137051470515705167051770518705197052070521705227052370524705257052670527705287052970530705317053270533705347053570536705377053870539705407054170542705437054470545705467054770548705497055070551705527055370554705557055670557705587055970560705617056270563705647056570566705677056870569705707057170572705737057470575705767057770578705797058070581705827058370584705857058670587705887058970590705917059270593705947059570596705977059870599706007060170602706037060470605706067060770608706097061070611706127061370614706157061670617706187061970620706217062270623706247062570626706277062870629706307063170632706337063470635706367063770638706397064070641706427064370644706457064670647706487064970650706517065270653706547065570656706577065870659706607066170662706637066470665706667066770668706697067070671706727067370674706757067670677706787067970680706817068270683706847068570686706877068870689706907069170692706937069470695706967069770698706997070070701707027070370704707057070670707707087070970710707117071270713707147071570716707177071870719707207072170722707237072470725707267072770728707297073070731707327073370734707357073670737707387073970740707417074270743707447074570746707477074870749707507075170752707537075470755707567075770758707597076070761707627076370764707657076670767707687076970770707717077270773707747077570776707777077870779707807078170782707837078470785707867078770788707897079070791707927079370794707957079670797707987079970800708017080270803708047080570806708077080870809708107081170812708137081470815708167081770818708197082070821708227082370824708257082670827708287082970830708317083270833708347083570836708377083870839708407084170842708437084470845708467084770848708497085070851708527085370854708557085670857708587085970860708617086270863708647086570866708677086870869708707087170872708737087470875708767087770878708797088070881708827088370884708857088670887708887088970890708917089270893708947089570896708977089870899709007090170902709037090470905709067090770908709097091070911709127091370914709157091670917709187091970920709217092270923709247092570926709277092870929709307093170932709337093470935709367093770938709397094070941709427094370944709457094670947709487094970950709517095270953709547095570956709577095870959709607096170962709637096470965709667096770968709697097070971709727097370974709757097670977709787097970980709817098270983709847098570986709877098870989709907099170992709937099470995709967099770998709997100071001710027100371004710057100671007710087100971010710117101271013710147101571016710177101871019710207102171022710237102471025710267102771028710297103071031710327103371034710357103671037710387103971040710417104271043710447104571046710477104871049710507105171052710537105471055710567105771058710597106071061710627106371064710657106671067710687106971070710717107271073710747107571076710777107871079710807108171082710837108471085710867108771088710897109071091710927109371094710957109671097710987109971100711017110271103711047110571106711077110871109711107111171112711137111471115711167111771118711197112071121711227112371124711257112671127711287112971130711317113271133711347113571136711377113871139711407114171142711437114471145711467114771148711497115071151711527115371154711557115671157711587115971160711617116271163711647116571166711677116871169711707117171172711737117471175711767117771178711797118071181711827118371184711857118671187711887118971190711917119271193711947119571196711977119871199712007120171202712037120471205712067120771208712097121071211712127121371214712157121671217712187121971220712217122271223712247122571226712277122871229712307123171232712337123471235712367123771238712397124071241712427124371244712457124671247712487124971250712517125271253712547125571256712577125871259712607126171262712637126471265712667126771268712697127071271712727127371274712757127671277712787127971280712817128271283712847128571286712877128871289712907129171292712937129471295712967129771298712997130071301713027130371304713057130671307713087130971310713117131271313713147131571316713177131871319713207132171322713237132471325713267132771328713297133071331713327133371334713357133671337713387133971340713417134271343713447134571346713477134871349713507135171352713537135471355713567135771358713597136071361713627136371364713657136671367713687136971370713717137271373713747137571376713777137871379713807138171382713837138471385713867138771388713897139071391713927139371394713957139671397713987139971400714017140271403714047140571406714077140871409714107141171412714137141471415714167141771418714197142071421714227142371424714257142671427714287142971430714317143271433714347143571436714377143871439714407144171442714437144471445714467144771448714497145071451714527145371454714557145671457714587145971460714617146271463714647146571466714677146871469714707147171472714737147471475714767147771478714797148071481714827148371484714857148671487714887148971490714917149271493714947149571496714977149871499715007150171502715037150471505715067150771508715097151071511715127151371514715157151671517715187151971520715217152271523715247152571526715277152871529715307153171532715337153471535715367153771538715397154071541715427154371544715457154671547715487154971550715517155271553715547155571556715577155871559715607156171562715637156471565715667156771568715697157071571715727157371574715757157671577715787157971580715817158271583715847158571586715877158871589715907159171592715937159471595715967159771598715997160071601716027160371604716057160671607716087160971610716117161271613716147161571616716177161871619716207162171622716237162471625716267162771628716297163071631716327163371634716357163671637716387163971640716417164271643716447164571646716477164871649716507165171652716537165471655716567165771658716597166071661716627166371664716657166671667716687166971670716717167271673716747167571676716777167871679716807168171682716837168471685716867168771688716897169071691716927169371694716957169671697716987169971700717017170271703717047170571706717077170871709717107171171712717137171471715717167171771718717197172071721717227172371724717257172671727717287172971730717317173271733717347173571736717377173871739717407174171742717437174471745717467174771748717497175071751717527175371754717557175671757717587175971760717617176271763717647176571766717677176871769717707177171772717737177471775717767177771778717797178071781717827178371784717857178671787717887178971790717917179271793717947179571796717977179871799718007180171802718037180471805718067180771808718097181071811718127181371814718157181671817718187181971820718217182271823718247182571826718277182871829718307183171832718337183471835718367183771838718397184071841718427184371844718457184671847718487184971850718517185271853718547185571856718577185871859718607186171862718637186471865718667186771868718697187071871718727187371874718757187671877718787187971880718817188271883718847188571886718877188871889718907189171892718937189471895718967189771898718997190071901719027190371904719057190671907719087190971910719117191271913719147191571916719177191871919719207192171922719237192471925719267192771928719297193071931719327193371934719357193671937719387193971940719417194271943719447194571946719477194871949719507195171952719537195471955719567195771958719597196071961719627196371964719657196671967719687196971970719717197271973719747197571976719777197871979719807198171982719837198471985719867198771988719897199071991719927199371994719957199671997719987199972000720017200272003720047200572006720077200872009720107201172012720137201472015720167201772018720197202072021720227202372024720257202672027720287202972030720317203272033720347203572036720377203872039720407204172042720437204472045720467204772048720497205072051720527205372054720557205672057720587205972060720617206272063720647206572066720677206872069720707207172072720737207472075720767207772078720797208072081720827208372084720857208672087720887208972090720917209272093720947209572096720977209872099721007210172102721037210472105721067210772108721097211072111721127211372114721157211672117721187211972120721217212272123721247212572126721277212872129721307213172132721337213472135721367213772138721397214072141721427214372144721457214672147721487214972150721517215272153721547215572156721577215872159721607216172162721637216472165721667216772168721697217072171721727217372174721757217672177721787217972180721817218272183721847218572186721877218872189721907219172192721937219472195721967219772198721997220072201722027220372204722057220672207722087220972210722117221272213722147221572216722177221872219722207222172222722237222472225722267222772228722297223072231722327223372234722357223672237722387223972240722417224272243722447224572246722477224872249722507225172252722537225472255722567225772258722597226072261722627226372264722657226672267722687226972270722717227272273722747227572276722777227872279722807228172282722837228472285722867228772288722897229072291722927229372294722957229672297722987229972300723017230272303723047230572306723077230872309723107231172312723137231472315723167231772318723197232072321723227232372324723257232672327723287232972330723317233272333723347233572336723377233872339723407234172342723437234472345723467234772348723497235072351723527235372354723557235672357723587235972360723617236272363723647236572366723677236872369723707237172372723737237472375723767237772378723797238072381723827238372384723857238672387723887238972390723917239272393723947239572396723977239872399724007240172402724037240472405724067240772408724097241072411724127241372414724157241672417724187241972420724217242272423724247242572426724277242872429724307243172432724337243472435724367243772438724397244072441724427244372444724457244672447724487244972450724517245272453724547245572456724577245872459724607246172462724637246472465724667246772468724697247072471724727247372474724757247672477724787247972480724817248272483724847248572486724877248872489724907249172492724937249472495724967249772498724997250072501725027250372504725057250672507725087250972510725117251272513725147251572516725177251872519725207252172522725237252472525725267252772528725297253072531725327253372534725357253672537725387253972540725417254272543725447254572546725477254872549725507255172552725537255472555725567255772558725597256072561725627256372564725657256672567725687256972570725717257272573725747257572576725777257872579725807258172582725837258472585725867258772588725897259072591725927259372594725957259672597725987259972600726017260272603726047260572606726077260872609726107261172612726137261472615726167261772618726197262072621726227262372624726257262672627726287262972630726317263272633726347263572636726377263872639726407264172642726437264472645726467264772648726497265072651726527265372654726557265672657726587265972660726617266272663726647266572666726677266872669726707267172672726737267472675726767267772678726797268072681726827268372684726857268672687726887268972690726917269272693726947269572696726977269872699727007270172702727037270472705727067270772708727097271072711727127271372714727157271672717727187271972720727217272272723727247272572726727277272872729727307273172732727337273472735727367273772738727397274072741727427274372744727457274672747727487274972750727517275272753727547275572756727577275872759727607276172762727637276472765727667276772768727697277072771727727277372774727757277672777727787277972780727817278272783727847278572786727877278872789727907279172792727937279472795727967279772798727997280072801728027280372804728057280672807728087280972810728117281272813728147281572816728177281872819728207282172822728237282472825728267282772828728297283072831728327283372834728357283672837728387283972840728417284272843728447284572846728477284872849728507285172852728537285472855728567285772858728597286072861728627286372864728657286672867728687286972870728717287272873728747287572876728777287872879728807288172882728837288472885728867288772888728897289072891728927289372894728957289672897728987289972900729017290272903729047290572906729077290872909729107291172912729137291472915729167291772918729197292072921729227292372924729257292672927729287292972930729317293272933729347293572936729377293872939729407294172942729437294472945729467294772948729497295072951729527295372954729557295672957729587295972960729617296272963729647296572966729677296872969729707297172972729737297472975729767297772978729797298072981729827298372984729857298672987729887298972990729917299272993729947299572996729977299872999730007300173002730037300473005730067300773008730097301073011730127301373014730157301673017730187301973020730217302273023730247302573026730277302873029730307303173032730337303473035730367303773038730397304073041730427304373044730457304673047730487304973050730517305273053730547305573056730577305873059730607306173062730637306473065730667306773068730697307073071730727307373074730757307673077730787307973080730817308273083730847308573086730877308873089730907309173092730937309473095730967309773098730997310073101731027310373104731057310673107731087310973110731117311273113731147311573116731177311873119731207312173122731237312473125731267312773128731297313073131731327313373134731357313673137731387313973140731417314273143731447314573146731477314873149731507315173152731537315473155731567315773158731597316073161731627316373164731657316673167731687316973170731717317273173731747317573176731777317873179731807318173182731837318473185731867318773188731897319073191731927319373194731957319673197731987319973200732017320273203732047320573206732077320873209732107321173212732137321473215732167321773218732197322073221732227322373224732257322673227732287322973230732317323273233732347323573236732377323873239732407324173242732437324473245732467324773248732497325073251732527325373254732557325673257732587325973260732617326273263732647326573266732677326873269732707327173272732737327473275732767327773278732797328073281732827328373284732857328673287732887328973290732917329273293732947329573296732977329873299733007330173302733037330473305733067330773308733097331073311733127331373314733157331673317733187331973320733217332273323733247332573326733277332873329733307333173332733337333473335733367333773338733397334073341733427334373344733457334673347733487334973350733517335273353733547335573356733577335873359733607336173362733637336473365733667336773368733697337073371733727337373374733757337673377733787337973380733817338273383733847338573386733877338873389733907339173392733937339473395733967339773398733997340073401734027340373404734057340673407734087340973410734117341273413734147341573416734177341873419734207342173422734237342473425734267342773428734297343073431734327343373434734357343673437734387343973440734417344273443734447344573446734477344873449734507345173452734537345473455734567345773458734597346073461734627346373464734657346673467734687346973470734717347273473734747347573476734777347873479734807348173482734837348473485734867348773488734897349073491734927349373494734957349673497734987349973500735017350273503735047350573506735077350873509735107351173512735137351473515735167351773518735197352073521735227352373524735257352673527735287352973530735317353273533735347353573536735377353873539735407354173542735437354473545735467354773548735497355073551735527355373554735557355673557735587355973560735617356273563735647356573566735677356873569735707357173572735737357473575735767357773578735797358073581735827358373584735857358673587735887358973590735917359273593735947359573596735977359873599736007360173602736037360473605736067360773608736097361073611736127361373614736157361673617736187361973620736217362273623736247362573626736277362873629736307363173632736337363473635736367363773638736397364073641736427364373644736457364673647736487364973650736517365273653736547365573656736577365873659736607366173662736637366473665736667366773668736697367073671736727367373674736757367673677736787367973680736817368273683736847368573686736877368873689736907369173692736937369473695736967369773698736997370073701737027370373704737057370673707737087370973710737117371273713737147371573716737177371873719737207372173722737237372473725737267372773728737297373073731737327373373734737357373673737737387373973740737417374273743737447374573746737477374873749737507375173752737537375473755737567375773758737597376073761737627376373764737657376673767737687376973770737717377273773737747377573776737777377873779737807378173782737837378473785737867378773788737897379073791737927379373794737957379673797737987379973800738017380273803738047380573806738077380873809738107381173812738137381473815738167381773818738197382073821738227382373824738257382673827738287382973830738317383273833738347383573836738377383873839738407384173842738437384473845738467384773848738497385073851738527385373854738557385673857738587385973860738617386273863738647386573866738677386873869738707387173872738737387473875738767387773878738797388073881738827388373884738857388673887738887388973890738917389273893738947389573896738977389873899739007390173902739037390473905739067390773908739097391073911739127391373914739157391673917739187391973920739217392273923739247392573926739277392873929739307393173932739337393473935739367393773938739397394073941739427394373944739457394673947739487394973950739517395273953739547395573956739577395873959739607396173962739637396473965739667396773968739697397073971739727397373974739757397673977739787397973980739817398273983739847398573986739877398873989739907399173992739937399473995739967399773998739997400074001740027400374004740057400674007740087400974010740117401274013740147401574016740177401874019740207402174022740237402474025740267402774028740297403074031740327403374034740357403674037740387403974040740417404274043740447404574046740477404874049740507405174052740537405474055740567405774058740597406074061740627406374064740657406674067740687406974070740717407274073740747407574076740777407874079740807408174082740837408474085740867408774088740897409074091740927409374094740957409674097740987409974100741017410274103741047410574106741077410874109741107411174112741137411474115741167411774118741197412074121741227412374124741257412674127741287412974130741317413274133741347413574136741377413874139741407414174142741437414474145741467414774148741497415074151741527415374154741557415674157741587415974160741617416274163741647416574166741677416874169741707417174172741737417474175741767417774178741797418074181741827418374184741857418674187741887418974190741917419274193741947419574196741977419874199742007420174202742037420474205742067420774208742097421074211742127421374214742157421674217742187421974220742217422274223742247422574226742277422874229742307423174232742337423474235742367423774238742397424074241742427424374244742457424674247742487424974250742517425274253742547425574256742577425874259742607426174262742637426474265742667426774268742697427074271742727427374274742757427674277742787427974280742817428274283742847428574286742877428874289742907429174292742937429474295742967429774298742997430074301743027430374304743057430674307743087430974310743117431274313743147431574316743177431874319743207432174322743237432474325743267432774328743297433074331743327433374334743357433674337743387433974340743417434274343743447434574346743477434874349743507435174352743537435474355743567435774358743597436074361743627436374364743657436674367743687436974370743717437274373743747437574376743777437874379743807438174382743837438474385743867438774388743897439074391743927439374394743957439674397743987439974400744017440274403744047440574406744077440874409744107441174412744137441474415744167441774418744197442074421744227442374424744257442674427744287442974430744317443274433744347443574436744377443874439744407444174442744437444474445744467444774448744497445074451744527445374454744557445674457744587445974460744617446274463744647446574466744677446874469744707447174472744737447474475744767447774478744797448074481744827448374484744857448674487744887448974490744917449274493744947449574496744977449874499745007450174502745037450474505745067450774508745097451074511745127451374514745157451674517745187451974520745217452274523745247452574526745277452874529745307453174532745337453474535745367453774538745397454074541745427454374544745457454674547745487454974550745517455274553745547455574556745577455874559745607456174562745637456474565745667456774568745697457074571745727457374574745757457674577745787457974580745817458274583745847458574586745877458874589745907459174592745937459474595745967459774598745997460074601746027460374604746057460674607746087460974610746117461274613746147461574616746177461874619746207462174622746237462474625746267462774628746297463074631746327463374634746357463674637746387463974640746417464274643746447464574646746477464874649746507465174652746537465474655746567465774658746597466074661746627466374664746657466674667746687466974670746717467274673746747467574676746777467874679746807468174682746837468474685746867468774688746897469074691746927469374694746957469674697746987469974700747017470274703747047470574706747077470874709747107471174712747137471474715747167471774718747197472074721747227472374724747257472674727747287472974730747317473274733747347473574736747377473874739747407474174742747437474474745747467474774748747497475074751747527475374754747557475674757747587475974760747617476274763747647476574766747677476874769747707477174772747737477474775747767477774778747797478074781747827478374784747857478674787747887478974790747917479274793747947479574796747977479874799748007480174802748037480474805748067480774808748097481074811748127481374814748157481674817748187481974820748217482274823748247482574826748277482874829748307483174832748337483474835748367483774838748397484074841748427484374844748457484674847748487484974850748517485274853748547485574856748577485874859748607486174862748637486474865748667486774868748697487074871748727487374874748757487674877748787487974880748817488274883748847488574886748877488874889748907489174892748937489474895748967489774898748997490074901749027490374904749057490674907749087490974910749117491274913749147491574916749177491874919749207492174922749237492474925749267492774928749297493074931749327493374934749357493674937749387493974940749417494274943749447494574946749477494874949749507495174952749537495474955749567495774958749597496074961749627496374964749657496674967749687496974970749717497274973749747497574976749777497874979749807498174982749837498474985749867498774988749897499074991749927499374994749957499674997749987499975000750017500275003750047500575006750077500875009750107501175012750137501475015750167501775018750197502075021750227502375024750257502675027750287502975030750317503275033750347503575036750377503875039750407504175042750437504475045750467504775048750497505075051750527505375054750557505675057750587505975060750617506275063750647506575066750677506875069750707507175072750737507475075750767507775078750797508075081750827508375084750857508675087750887508975090750917509275093750947509575096750977509875099751007510175102751037510475105751067510775108751097511075111751127511375114751157511675117751187511975120751217512275123751247512575126751277512875129751307513175132751337513475135751367513775138751397514075141751427514375144751457514675147751487514975150751517515275153751547515575156751577515875159751607516175162751637516475165751667516775168751697517075171751727517375174751757517675177751787517975180751817518275183751847518575186751877518875189751907519175192751937519475195751967519775198751997520075201752027520375204752057520675207752087520975210752117521275213752147521575216752177521875219752207522175222752237522475225752267522775228752297523075231752327523375234752357523675237752387523975240752417524275243752447524575246752477524875249752507525175252752537525475255752567525775258752597526075261752627526375264752657526675267752687526975270752717527275273752747527575276752777527875279752807528175282752837528475285752867528775288752897529075291752927529375294752957529675297752987529975300753017530275303753047530575306753077530875309753107531175312753137531475315753167531775318753197532075321753227532375324753257532675327753287532975330753317533275333753347533575336753377533875339753407534175342753437534475345753467534775348753497535075351753527535375354753557535675357753587535975360753617536275363753647536575366753677536875369753707537175372753737537475375753767537775378753797538075381753827538375384753857538675387753887538975390753917539275393753947539575396753977539875399754007540175402754037540475405754067540775408754097541075411754127541375414754157541675417754187541975420754217542275423754247542575426754277542875429754307543175432754337543475435754367543775438754397544075441754427544375444754457544675447754487544975450754517545275453754547545575456754577545875459754607546175462754637546475465754667546775468754697547075471754727547375474754757547675477754787547975480754817548275483754847548575486754877548875489754907549175492754937549475495754967549775498754997550075501755027550375504755057550675507755087550975510755117551275513755147551575516755177551875519755207552175522755237552475525755267552775528755297553075531755327553375534755357553675537755387553975540755417554275543755447554575546755477554875549755507555175552755537555475555755567555775558755597556075561755627556375564755657556675567755687556975570755717557275573755747557575576755777557875579755807558175582755837558475585755867558775588755897559075591755927559375594755957559675597755987559975600756017560275603756047560575606756077560875609756107561175612756137561475615756167561775618756197562075621756227562375624756257562675627756287562975630756317563275633756347563575636756377563875639756407564175642756437564475645756467564775648756497565075651756527565375654756557565675657756587565975660756617566275663756647566575666756677566875669756707567175672756737567475675756767567775678756797568075681756827568375684756857568675687756887568975690756917569275693756947569575696756977569875699757007570175702757037570475705757067570775708757097571075711757127571375714757157571675717757187571975720757217572275723757247572575726757277572875729757307573175732757337573475735757367573775738757397574075741757427574375744757457574675747757487574975750757517575275753757547575575756757577575875759757607576175762757637576475765757667576775768757697577075771757727577375774757757577675777757787577975780757817578275783757847578575786757877578875789757907579175792757937579475795757967579775798757997580075801758027580375804758057580675807758087580975810758117581275813758147581575816758177581875819758207582175822758237582475825758267582775828758297583075831758327583375834758357583675837758387583975840758417584275843758447584575846758477584875849758507585175852758537585475855758567585775858758597586075861758627586375864758657586675867758687586975870758717587275873758747587575876758777587875879758807588175882758837588475885758867588775888758897589075891758927589375894758957589675897758987589975900759017590275903759047590575906759077590875909759107591175912759137591475915759167591775918759197592075921759227592375924759257592675927759287592975930759317593275933759347593575936759377593875939759407594175942759437594475945759467594775948759497595075951759527595375954759557595675957759587595975960759617596275963759647596575966759677596875969759707597175972759737597475975759767597775978759797598075981759827598375984759857598675987759887598975990759917599275993759947599575996759977599875999760007600176002760037600476005760067600776008760097601076011760127601376014760157601676017760187601976020760217602276023760247602576026760277602876029760307603176032760337603476035760367603776038760397604076041760427604376044760457604676047760487604976050760517605276053760547605576056760577605876059760607606176062760637606476065760667606776068760697607076071760727607376074760757607676077760787607976080760817608276083760847608576086760877608876089760907609176092760937609476095760967609776098760997610076101761027610376104761057610676107761087610976110761117611276113761147611576116761177611876119761207612176122761237612476125761267612776128761297613076131761327613376134761357613676137761387613976140761417614276143761447614576146761477614876149761507615176152761537615476155761567615776158761597616076161761627616376164761657616676167761687616976170761717617276173761747617576176761777617876179761807618176182761837618476185761867618776188761897619076191761927619376194761957619676197761987619976200762017620276203762047620576206762077620876209762107621176212762137621476215762167621776218762197622076221762227622376224762257622676227762287622976230762317623276233762347623576236762377623876239762407624176242762437624476245762467624776248762497625076251762527625376254762557625676257762587625976260762617626276263762647626576266762677626876269762707627176272762737627476275762767627776278762797628076281762827628376284762857628676287762887628976290762917629276293762947629576296762977629876299763007630176302763037630476305763067630776308763097631076311763127631376314763157631676317763187631976320763217632276323763247632576326763277632876329763307633176332763337633476335763367633776338763397634076341763427634376344763457634676347763487634976350763517635276353763547635576356763577635876359763607636176362763637636476365763667636776368763697637076371763727637376374763757637676377763787637976380763817638276383763847638576386763877638876389763907639176392763937639476395763967639776398763997640076401764027640376404764057640676407764087640976410764117641276413764147641576416764177641876419764207642176422764237642476425764267642776428764297643076431764327643376434764357643676437764387643976440764417644276443764447644576446764477644876449764507645176452764537645476455764567645776458764597646076461764627646376464764657646676467764687646976470764717647276473764747647576476764777647876479764807648176482764837648476485764867648776488764897649076491764927649376494764957649676497764987649976500765017650276503765047650576506765077650876509765107651176512765137651476515765167651776518765197652076521765227652376524765257652676527765287652976530765317653276533765347653576536765377653876539765407654176542765437654476545765467654776548765497655076551765527655376554765557655676557765587655976560765617656276563765647656576566765677656876569765707657176572765737657476575765767657776578765797658076581765827658376584765857658676587765887658976590765917659276593765947659576596765977659876599766007660176602766037660476605766067660776608766097661076611766127661376614766157661676617766187661976620766217662276623766247662576626766277662876629766307663176632766337663476635766367663776638766397664076641766427664376644766457664676647766487664976650766517665276653766547665576656766577665876659766607666176662766637666476665766667666776668766697667076671766727667376674766757667676677766787667976680766817668276683766847668576686766877668876689766907669176692766937669476695766967669776698766997670076701767027670376704767057670676707767087670976710767117671276713767147671576716767177671876719767207672176722767237672476725767267672776728767297673076731767327673376734767357673676737767387673976740767417674276743767447674576746767477674876749767507675176752767537675476755767567675776758767597676076761767627676376764767657676676767767687676976770767717677276773767747677576776767777677876779767807678176782767837678476785767867678776788767897679076791767927679376794767957679676797767987679976800768017680276803768047680576806768077680876809768107681176812768137681476815768167681776818768197682076821768227682376824768257682676827768287682976830768317683276833768347683576836768377683876839768407684176842768437684476845768467684776848768497685076851768527685376854768557685676857768587685976860768617686276863768647686576866768677686876869768707687176872768737687476875768767687776878768797688076881768827688376884768857688676887768887688976890768917689276893768947689576896768977689876899769007690176902769037690476905769067690776908769097691076911769127691376914769157691676917769187691976920769217692276923769247692576926769277692876929769307693176932769337693476935769367693776938769397694076941769427694376944769457694676947769487694976950769517695276953769547695576956769577695876959769607696176962769637696476965769667696776968769697697076971769727697376974769757697676977769787697976980769817698276983769847698576986769877698876989769907699176992769937699476995769967699776998769997700077001770027700377004770057700677007770087700977010770117701277013770147701577016770177701877019770207702177022770237702477025770267702777028770297703077031770327703377034770357703677037770387703977040770417704277043770447704577046770477704877049770507705177052770537705477055770567705777058770597706077061770627706377064770657706677067770687706977070770717707277073770747707577076770777707877079770807708177082770837708477085770867708777088770897709077091770927709377094770957709677097770987709977100771017710277103771047710577106771077710877109771107711177112771137711477115771167711777118771197712077121771227712377124771257712677127771287712977130771317713277133771347713577136771377713877139771407714177142771437714477145771467714777148771497715077151771527715377154771557715677157771587715977160771617716277163771647716577166771677716877169771707717177172771737717477175771767717777178771797718077181771827718377184771857718677187771887718977190771917719277193771947719577196771977719877199772007720177202772037720477205772067720777208772097721077211772127721377214772157721677217772187721977220772217722277223772247722577226772277722877229772307723177232772337723477235772367723777238772397724077241772427724377244772457724677247772487724977250772517725277253772547725577256772577725877259772607726177262772637726477265772667726777268772697727077271772727727377274772757727677277772787727977280772817728277283772847728577286772877728877289772907729177292772937729477295772967729777298772997730077301773027730377304773057730677307773087730977310773117731277313773147731577316773177731877319773207732177322773237732477325773267732777328773297733077331773327733377334773357733677337773387733977340773417734277343773447734577346773477734877349773507735177352773537735477355773567735777358773597736077361773627736377364773657736677367773687736977370773717737277373773747737577376773777737877379773807738177382773837738477385773867738777388773897739077391773927739377394773957739677397773987739977400774017740277403774047740577406774077740877409774107741177412774137741477415774167741777418774197742077421774227742377424774257742677427774287742977430774317743277433774347743577436774377743877439774407744177442774437744477445774467744777448774497745077451774527745377454774557745677457774587745977460774617746277463774647746577466774677746877469774707747177472774737747477475774767747777478774797748077481774827748377484774857748677487774887748977490774917749277493774947749577496774977749877499775007750177502775037750477505775067750777508775097751077511775127751377514775157751677517775187751977520775217752277523775247752577526775277752877529775307753177532775337753477535775367753777538775397754077541775427754377544775457754677547775487754977550775517755277553775547755577556775577755877559775607756177562775637756477565775667756777568775697757077571775727757377574775757757677577775787757977580775817758277583775847758577586775877758877589775907759177592775937759477595775967759777598775997760077601776027760377604776057760677607776087760977610776117761277613776147761577616776177761877619776207762177622776237762477625776267762777628776297763077631776327763377634776357763677637776387763977640776417764277643776447764577646776477764877649776507765177652776537765477655776567765777658776597766077661776627766377664776657766677667776687766977670776717767277673776747767577676776777767877679776807768177682776837768477685776867768777688776897769077691776927769377694776957769677697776987769977700777017770277703777047770577706777077770877709777107771177712777137771477715777167771777718777197772077721777227772377724777257772677727777287772977730777317773277733777347773577736777377773877739777407774177742777437774477745777467774777748777497775077751777527775377754777557775677757777587775977760777617776277763777647776577766777677776877769777707777177772777737777477775777767777777778777797778077781777827778377784777857778677787777887778977790777917779277793777947779577796777977779877799778007780177802778037780477805778067780777808778097781077811778127781377814778157781677817778187781977820778217782277823778247782577826778277782877829778307783177832778337783477835778367783777838778397784077841778427784377844778457784677847778487784977850778517785277853778547785577856778577785877859778607786177862778637786477865778667786777868778697787077871778727787377874778757787677877778787787977880778817788277883778847788577886778877788877889778907789177892778937789477895778967789777898778997790077901779027790377904779057790677907779087790977910779117791277913779147791577916779177791877919779207792177922779237792477925779267792777928779297793077931779327793377934779357793677937779387793977940779417794277943779447794577946779477794877949779507795177952779537795477955779567795777958779597796077961779627796377964779657796677967779687796977970779717797277973779747797577976779777797877979779807798177982779837798477985779867798777988779897799077991779927799377994779957799677997779987799978000780017800278003780047800578006780077800878009780107801178012780137801478015780167801778018780197802078021780227802378024780257802678027780287802978030780317803278033780347803578036780377803878039780407804178042780437804478045780467804778048780497805078051780527805378054780557805678057780587805978060780617806278063780647806578066780677806878069780707807178072780737807478075780767807778078780797808078081780827808378084780857808678087780887808978090780917809278093780947809578096780977809878099781007810178102781037810478105781067810778108781097811078111781127811378114781157811678117781187811978120781217812278123781247812578126781277812878129781307813178132781337813478135781367813778138781397814078141781427814378144781457814678147781487814978150781517815278153781547815578156781577815878159781607816178162781637816478165781667816778168781697817078171781727817378174781757817678177781787817978180781817818278183781847818578186781877818878189781907819178192781937819478195781967819778198781997820078201782027820378204782057820678207782087820978210782117821278213782147821578216782177821878219782207822178222782237822478225782267822778228782297823078231782327823378234782357823678237782387823978240782417824278243782447824578246782477824878249782507825178252782537825478255782567825778258782597826078261782627826378264782657826678267782687826978270782717827278273782747827578276782777827878279782807828178282782837828478285782867828778288782897829078291782927829378294782957829678297782987829978300783017830278303783047830578306783077830878309783107831178312783137831478315783167831778318783197832078321783227832378324783257832678327783287832978330783317833278333783347833578336783377833878339783407834178342783437834478345783467834778348783497835078351783527835378354783557835678357783587835978360783617836278363783647836578366783677836878369783707837178372783737837478375783767837778378783797838078381783827838378384783857838678387783887838978390783917839278393783947839578396783977839878399784007840178402784037840478405784067840778408784097841078411784127841378414784157841678417784187841978420784217842278423784247842578426784277842878429784307843178432784337843478435784367843778438784397844078441784427844378444784457844678447784487844978450784517845278453784547845578456784577845878459784607846178462784637846478465784667846778468784697847078471784727847378474784757847678477784787847978480784817848278483784847848578486784877848878489784907849178492784937849478495784967849778498784997850078501785027850378504785057850678507785087850978510785117851278513785147851578516785177851878519785207852178522785237852478525785267852778528785297853078531785327853378534785357853678537785387853978540785417854278543785447854578546785477854878549785507855178552785537855478555785567855778558785597856078561785627856378564785657856678567785687856978570785717857278573785747857578576785777857878579785807858178582785837858478585785867858778588785897859078591785927859378594785957859678597785987859978600786017860278603786047860578606786077860878609786107861178612786137861478615786167861778618786197862078621786227862378624786257862678627786287862978630786317863278633786347863578636786377863878639786407864178642786437864478645786467864778648786497865078651786527865378654786557865678657786587865978660786617866278663786647866578666786677866878669786707867178672786737867478675786767867778678786797868078681786827868378684786857868678687786887868978690786917869278693786947869578696786977869878699787007870178702787037870478705787067870778708787097871078711787127871378714787157871678717787187871978720787217872278723787247872578726787277872878729787307873178732787337873478735787367873778738787397874078741787427874378744787457874678747787487874978750787517875278753787547875578756787577875878759787607876178762787637876478765787667876778768787697877078771787727877378774787757877678777787787877978780787817878278783787847878578786787877878878789787907879178792787937879478795787967879778798787997880078801788027880378804788057880678807788087880978810788117881278813788147881578816788177881878819788207882178822788237882478825788267882778828788297883078831788327883378834788357883678837788387883978840788417884278843788447884578846788477884878849788507885178852788537885478855788567885778858788597886078861788627886378864788657886678867788687886978870788717887278873788747887578876788777887878879788807888178882788837888478885788867888778888788897889078891788927889378894788957889678897788987889978900789017890278903789047890578906789077890878909789107891178912789137891478915789167891778918789197892078921789227892378924789257892678927789287892978930789317893278933789347893578936789377893878939789407894178942789437894478945789467894778948789497895078951789527895378954789557895678957789587895978960789617896278963789647896578966789677896878969789707897178972789737897478975789767897778978789797898078981789827898378984789857898678987789887898978990789917899278993789947899578996789977899878999790007900179002790037900479005790067900779008790097901079011790127901379014790157901679017790187901979020790217902279023790247902579026790277902879029790307903179032790337903479035790367903779038790397904079041790427904379044790457904679047790487904979050790517905279053790547905579056790577905879059790607906179062790637906479065790667906779068790697907079071790727907379074790757907679077790787907979080790817908279083790847908579086790877908879089790907909179092790937909479095790967909779098790997910079101791027910379104791057910679107791087910979110791117911279113791147911579116791177911879119791207912179122791237912479125791267912779128791297913079131791327913379134791357913679137791387913979140791417914279143791447914579146791477914879149791507915179152791537915479155791567915779158791597916079161791627916379164791657916679167791687916979170791717917279173791747917579176791777917879179791807918179182791837918479185791867918779188791897919079191791927919379194791957919679197791987919979200792017920279203792047920579206792077920879209792107921179212792137921479215792167921779218792197922079221792227922379224792257922679227792287922979230792317923279233792347923579236792377923879239792407924179242792437924479245792467924779248792497925079251792527925379254792557925679257792587925979260792617926279263792647926579266792677926879269792707927179272792737927479275792767927779278792797928079281792827928379284792857928679287792887928979290792917929279293792947929579296792977929879299793007930179302793037930479305793067930779308793097931079311793127931379314793157931679317793187931979320793217932279323793247932579326793277932879329793307933179332793337933479335793367933779338793397934079341793427934379344793457934679347793487934979350793517935279353793547935579356793577935879359793607936179362793637936479365793667936779368793697937079371793727937379374793757937679377793787937979380793817938279383793847938579386793877938879389793907939179392793937939479395793967939779398793997940079401794027940379404794057940679407794087940979410794117941279413794147941579416794177941879419794207942179422794237942479425794267942779428794297943079431794327943379434794357943679437794387943979440794417944279443794447944579446794477944879449794507945179452794537945479455794567945779458794597946079461794627946379464794657946679467794687946979470794717947279473794747947579476794777947879479794807948179482794837948479485794867948779488794897949079491794927949379494794957949679497794987949979500795017950279503795047950579506795077950879509795107951179512795137951479515795167951779518795197952079521795227952379524795257952679527795287952979530795317953279533795347953579536795377953879539795407954179542795437954479545795467954779548795497955079551795527955379554795557955679557795587955979560795617956279563795647956579566795677956879569795707957179572795737957479575795767957779578795797958079581795827958379584795857958679587795887958979590795917959279593795947959579596795977959879599796007960179602796037960479605796067960779608796097961079611796127961379614796157961679617796187961979620796217962279623796247962579626796277962879629796307963179632796337963479635796367963779638796397964079641796427964379644796457964679647796487964979650796517965279653796547965579656796577965879659796607966179662796637966479665796667966779668796697967079671796727967379674796757967679677796787967979680796817968279683796847968579686796877968879689796907969179692796937969479695796967969779698796997970079701797027970379704797057970679707797087970979710797117971279713797147971579716797177971879719797207972179722797237972479725797267972779728797297973079731797327973379734797357973679737797387973979740797417974279743797447974579746797477974879749797507975179752797537975479755797567975779758797597976079761797627976379764797657976679767797687976979770797717977279773797747977579776797777977879779797807978179782797837978479785797867978779788797897979079791797927979379794797957979679797797987979979800798017980279803798047980579806798077980879809798107981179812798137981479815798167981779818798197982079821798227982379824798257982679827798287982979830798317983279833798347983579836798377983879839798407984179842798437984479845798467984779848798497985079851798527985379854798557985679857798587985979860798617986279863798647986579866798677986879869798707987179872798737987479875798767987779878798797988079881798827988379884798857988679887798887988979890798917989279893798947989579896798977989879899799007990179902799037990479905799067990779908799097991079911799127991379914799157991679917799187991979920799217992279923799247992579926799277992879929799307993179932799337993479935799367993779938799397994079941799427994379944799457994679947799487994979950799517995279953799547995579956799577995879959799607996179962799637996479965799667996779968799697997079971799727997379974799757997679977799787997979980799817998279983799847998579986799877998879989799907999179992799937999479995799967999779998799998000080001800028000380004800058000680007800088000980010800118001280013800148001580016800178001880019800208002180022800238002480025800268002780028800298003080031800328003380034800358003680037800388003980040800418004280043800448004580046800478004880049800508005180052800538005480055800568005780058800598006080061800628006380064800658006680067800688006980070800718007280073800748007580076800778007880079800808008180082800838008480085800868008780088800898009080091800928009380094800958009680097800988009980100801018010280103801048010580106801078010880109801108011180112801138011480115801168011780118801198012080121801228012380124801258012680127801288012980130801318013280133801348013580136801378013880139801408014180142801438014480145801468014780148801498015080151801528015380154801558015680157801588015980160801618016280163801648016580166801678016880169801708017180172801738017480175801768017780178801798018080181801828018380184801858018680187801888018980190801918019280193801948019580196801978019880199802008020180202802038020480205802068020780208802098021080211802128021380214802158021680217802188021980220802218022280223802248022580226802278022880229802308023180232802338023480235802368023780238802398024080241802428024380244802458024680247802488024980250802518025280253802548025580256802578025880259802608026180262802638026480265802668026780268802698027080271802728027380274802758027680277802788027980280802818028280283802848028580286802878028880289802908029180292802938029480295802968029780298802998030080301803028030380304803058030680307803088030980310803118031280313803148031580316803178031880319803208032180322803238032480325803268032780328803298033080331803328033380334803358033680337803388033980340803418034280343803448034580346803478034880349803508035180352803538035480355803568035780358803598036080361803628036380364803658036680367803688036980370803718037280373803748037580376803778037880379803808038180382803838038480385803868038780388803898039080391803928039380394803958039680397803988039980400804018040280403804048040580406804078040880409804108041180412804138041480415804168041780418804198042080421804228042380424804258042680427804288042980430804318043280433804348043580436804378043880439804408044180442804438044480445804468044780448804498045080451804528045380454804558045680457804588045980460804618046280463804648046580466804678046880469804708047180472804738047480475804768047780478804798048080481804828048380484804858048680487804888048980490804918049280493804948049580496804978049880499805008050180502805038050480505805068050780508805098051080511805128051380514805158051680517805188051980520805218052280523805248052580526805278052880529805308053180532805338053480535805368053780538805398054080541805428054380544805458054680547805488054980550805518055280553805548055580556805578055880559805608056180562805638056480565805668056780568805698057080571805728057380574805758057680577805788057980580805818058280583805848058580586805878058880589805908059180592805938059480595805968059780598805998060080601806028060380604806058060680607806088060980610806118061280613806148061580616806178061880619806208062180622806238062480625806268062780628806298063080631806328063380634806358063680637806388063980640806418064280643806448064580646806478064880649806508065180652806538065480655806568065780658806598066080661806628066380664806658066680667806688066980670806718067280673806748067580676806778067880679806808068180682806838068480685806868068780688806898069080691806928069380694806958069680697806988069980700807018070280703807048070580706807078070880709807108071180712807138071480715807168071780718807198072080721807228072380724807258072680727807288072980730807318073280733807348073580736807378073880739807408074180742807438074480745807468074780748807498075080751807528075380754807558075680757807588075980760807618076280763807648076580766807678076880769807708077180772807738077480775807768077780778807798078080781807828078380784807858078680787807888078980790807918079280793807948079580796807978079880799808008080180802808038080480805808068080780808808098081080811808128081380814808158081680817808188081980820808218082280823808248082580826808278082880829808308083180832808338083480835808368083780838808398084080841808428084380844808458084680847808488084980850808518085280853808548085580856808578085880859808608086180862808638086480865808668086780868808698087080871808728087380874808758087680877808788087980880808818088280883808848088580886808878088880889808908089180892808938089480895808968089780898808998090080901809028090380904809058090680907809088090980910809118091280913809148091580916809178091880919809208092180922809238092480925809268092780928809298093080931809328093380934809358093680937809388093980940809418094280943809448094580946809478094880949809508095180952809538095480955809568095780958809598096080961809628096380964809658096680967809688096980970809718097280973809748097580976809778097880979809808098180982809838098480985809868098780988809898099080991809928099380994809958099680997809988099981000810018100281003810048100581006810078100881009810108101181012810138101481015810168101781018810198102081021810228102381024810258102681027810288102981030810318103281033810348103581036810378103881039810408104181042810438104481045810468104781048810498105081051810528105381054810558105681057810588105981060810618106281063810648106581066810678106881069810708107181072810738107481075810768107781078810798108081081810828108381084810858108681087810888108981090810918109281093810948109581096810978109881099811008110181102811038110481105811068110781108811098111081111811128111381114811158111681117811188111981120811218112281123811248112581126811278112881129811308113181132811338113481135811368113781138811398114081141811428114381144811458114681147811488114981150811518115281153811548115581156811578115881159811608116181162811638116481165811668116781168811698117081171811728117381174811758117681177811788117981180811818118281183811848118581186811878118881189811908119181192811938119481195811968119781198811998120081201812028120381204812058120681207812088120981210812118121281213812148121581216812178121881219812208122181222812238122481225812268122781228812298123081231812328123381234812358123681237812388123981240812418124281243812448124581246812478124881249812508125181252812538125481255812568125781258812598126081261812628126381264812658126681267812688126981270812718127281273812748127581276812778127881279812808128181282812838128481285812868128781288812898129081291812928129381294812958129681297812988129981300813018130281303813048130581306813078130881309813108131181312813138131481315813168131781318813198132081321813228132381324813258132681327813288132981330813318133281333813348133581336813378133881339813408134181342813438134481345813468134781348813498135081351813528135381354813558135681357813588135981360813618136281363813648136581366813678136881369813708137181372813738137481375813768137781378813798138081381813828138381384813858138681387813888138981390813918139281393813948139581396813978139881399814008140181402814038140481405814068140781408814098141081411814128141381414814158141681417814188141981420814218142281423814248142581426814278142881429814308143181432814338143481435814368143781438814398144081441814428144381444814458144681447814488144981450814518145281453814548145581456814578145881459814608146181462814638146481465814668146781468814698147081471814728147381474814758147681477814788147981480814818148281483814848148581486814878148881489814908149181492814938149481495814968149781498814998150081501815028150381504815058150681507815088150981510815118151281513815148151581516815178151881519815208152181522815238152481525815268152781528815298153081531815328153381534815358153681537815388153981540815418154281543815448154581546815478154881549815508155181552815538155481555815568155781558815598156081561815628156381564815658156681567815688156981570815718157281573815748157581576815778157881579815808158181582815838158481585815868158781588815898159081591815928159381594815958159681597815988159981600816018160281603816048160581606816078160881609816108161181612816138161481615816168161781618816198162081621816228162381624816258162681627816288162981630816318163281633816348163581636816378163881639816408164181642816438164481645816468164781648816498165081651816528165381654816558165681657816588165981660816618166281663816648166581666816678166881669816708167181672816738167481675816768167781678816798168081681816828168381684816858168681687816888168981690816918169281693816948169581696816978169881699817008170181702817038170481705817068170781708817098171081711817128171381714817158171681717817188171981720817218172281723817248172581726817278172881729817308173181732817338173481735817368173781738817398174081741817428174381744817458174681747817488174981750817518175281753817548175581756817578175881759817608176181762817638176481765817668176781768817698177081771817728177381774817758177681777817788177981780817818178281783817848178581786817878178881789817908179181792817938179481795817968179781798817998180081801818028180381804818058180681807818088180981810818118181281813818148181581816818178181881819818208182181822818238182481825818268182781828818298183081831818328183381834818358183681837818388183981840818418184281843818448184581846818478184881849818508185181852818538185481855818568185781858818598186081861818628186381864818658186681867818688186981870818718187281873818748187581876818778187881879818808188181882818838188481885818868188781888818898189081891818928189381894818958189681897818988189981900819018190281903819048190581906819078190881909819108191181912819138191481915819168191781918819198192081921819228192381924819258192681927819288192981930819318193281933819348193581936819378193881939819408194181942819438194481945819468194781948819498195081951819528195381954819558195681957819588195981960819618196281963819648196581966819678196881969819708197181972819738197481975819768197781978819798198081981819828198381984819858198681987819888198981990819918199281993819948199581996819978199881999820008200182002820038200482005820068200782008820098201082011820128201382014820158201682017820188201982020820218202282023820248202582026820278202882029820308203182032820338203482035820368203782038820398204082041820428204382044820458204682047820488204982050820518205282053820548205582056820578205882059820608206182062820638206482065820668206782068820698207082071820728207382074820758207682077820788207982080820818208282083820848208582086820878208882089820908209182092820938209482095820968209782098820998210082101821028210382104821058210682107821088210982110821118211282113821148211582116821178211882119821208212182122821238212482125821268212782128821298213082131821328213382134821358213682137821388213982140821418214282143821448214582146821478214882149821508215182152821538215482155821568215782158821598216082161821628216382164821658216682167821688216982170821718217282173821748217582176821778217882179821808218182182821838218482185821868218782188821898219082191821928219382194821958219682197821988219982200822018220282203822048220582206822078220882209822108221182212822138221482215822168221782218822198222082221822228222382224822258222682227822288222982230822318223282233822348223582236822378223882239822408224182242822438224482245822468224782248822498225082251822528225382254822558225682257822588225982260822618226282263822648226582266822678226882269822708227182272822738227482275822768227782278822798228082281822828228382284822858228682287822888228982290822918229282293822948229582296822978229882299823008230182302823038230482305823068230782308823098231082311823128231382314823158231682317823188231982320823218232282323823248232582326823278232882329823308233182332823338233482335823368233782338823398234082341823428234382344823458234682347823488234982350823518235282353823548235582356823578235882359823608236182362823638236482365823668236782368823698237082371823728237382374823758237682377823788237982380823818238282383823848238582386823878238882389823908239182392823938239482395823968239782398823998240082401824028240382404824058240682407824088240982410824118241282413824148241582416824178241882419824208242182422824238242482425824268242782428824298243082431824328243382434824358243682437824388243982440824418244282443824448244582446824478244882449824508245182452824538245482455824568245782458824598246082461824628246382464824658246682467824688246982470824718247282473824748247582476824778247882479824808248182482824838248482485824868248782488824898249082491824928249382494824958249682497824988249982500825018250282503825048250582506825078250882509825108251182512825138251482515825168251782518825198252082521825228252382524825258252682527825288252982530825318253282533825348253582536825378253882539825408254182542825438254482545825468254782548825498255082551825528255382554825558255682557825588255982560825618256282563825648256582566825678256882569825708257182572825738257482575825768257782578825798258082581825828258382584825858258682587825888258982590825918259282593825948259582596825978259882599826008260182602826038260482605826068260782608826098261082611826128261382614826158261682617826188261982620826218262282623826248262582626826278262882629826308263182632826338263482635826368263782638826398264082641826428264382644826458264682647826488264982650826518265282653826548265582656826578265882659826608266182662826638266482665826668266782668826698267082671826728267382674826758267682677826788267982680826818268282683826848268582686826878268882689826908269182692826938269482695826968269782698826998270082701827028270382704827058270682707827088270982710827118271282713827148271582716827178271882719827208272182722827238272482725827268272782728827298273082731827328273382734827358273682737827388273982740827418274282743827448274582746827478274882749827508275182752827538275482755827568275782758827598276082761827628276382764827658276682767827688276982770827718277282773827748277582776827778277882779827808278182782827838278482785827868278782788827898279082791827928279382794827958279682797827988279982800828018280282803828048280582806828078280882809828108281182812828138281482815828168281782818828198282082821828228282382824828258282682827828288282982830828318283282833828348283582836828378283882839828408284182842828438284482845828468284782848828498285082851828528285382854828558285682857828588285982860828618286282863828648286582866828678286882869828708287182872828738287482875828768287782878828798288082881828828288382884828858288682887828888288982890828918289282893828948289582896828978289882899829008290182902829038290482905829068290782908829098291082911829128291382914829158291682917829188291982920829218292282923829248292582926829278292882929829308293182932829338293482935829368293782938829398294082941829428294382944829458294682947829488294982950829518295282953829548295582956829578295882959829608296182962829638296482965829668296782968829698297082971829728297382974829758297682977829788297982980829818298282983829848298582986829878298882989829908299182992829938299482995829968299782998829998300083001830028300383004830058300683007830088300983010830118301283013830148301583016830178301883019830208302183022830238302483025830268302783028830298303083031830328303383034830358303683037830388303983040830418304283043830448304583046830478304883049830508305183052830538305483055830568305783058830598306083061830628306383064830658306683067830688306983070830718307283073830748307583076830778307883079830808308183082830838308483085830868308783088830898309083091830928309383094830958309683097830988309983100831018310283103831048310583106831078310883109831108311183112831138311483115831168311783118831198312083121831228312383124831258312683127831288312983130831318313283133831348313583136831378313883139831408314183142831438314483145831468314783148831498315083151831528315383154831558315683157831588315983160831618316283163831648316583166831678316883169831708317183172831738317483175831768317783178831798318083181831828318383184831858318683187831888318983190831918319283193831948319583196831978319883199832008320183202832038320483205832068320783208832098321083211832128321383214832158321683217832188321983220832218322283223832248322583226832278322883229832308323183232832338323483235832368323783238832398324083241832428324383244832458324683247832488324983250832518325283253832548325583256832578325883259832608326183262832638326483265832668326783268832698327083271832728327383274832758327683277832788327983280832818328283283832848328583286832878328883289832908329183292832938329483295832968329783298832998330083301833028330383304833058330683307833088330983310833118331283313833148331583316833178331883319833208332183322833238332483325833268332783328833298333083331833328333383334833358333683337833388333983340833418334283343833448334583346833478334883349833508335183352833538335483355833568335783358833598336083361833628336383364833658336683367833688336983370833718337283373833748337583376833778337883379833808338183382833838338483385833868338783388833898339083391833928339383394833958339683397833988339983400834018340283403834048340583406834078340883409834108341183412834138341483415834168341783418834198342083421834228342383424834258342683427834288342983430834318343283433834348343583436834378343883439834408344183442834438344483445834468344783448834498345083451834528345383454834558345683457834588345983460834618346283463834648346583466834678346883469834708347183472834738347483475834768347783478834798348083481834828348383484834858348683487834888348983490834918349283493834948349583496834978349883499835008350183502835038350483505835068350783508835098351083511835128351383514835158351683517835188351983520835218352283523835248352583526835278352883529835308353183532835338353483535835368353783538835398354083541835428354383544835458354683547835488354983550835518355283553835548355583556835578355883559835608356183562835638356483565835668356783568835698357083571835728357383574835758357683577835788357983580835818358283583835848358583586835878358883589835908359183592835938359483595835968359783598835998360083601836028360383604836058360683607836088360983610836118361283613836148361583616836178361883619836208362183622836238362483625836268362783628836298363083631836328363383634836358363683637836388363983640836418364283643836448364583646836478364883649836508365183652836538365483655836568365783658836598366083661836628366383664836658366683667836688366983670836718367283673836748367583676836778367883679836808368183682836838368483685836868368783688836898369083691836928369383694836958369683697836988369983700837018370283703837048370583706837078370883709837108371183712837138371483715837168371783718837198372083721837228372383724837258372683727837288372983730837318373283733837348373583736837378373883739837408374183742837438374483745837468374783748837498375083751837528375383754837558375683757837588375983760837618376283763837648376583766837678376883769837708377183772837738377483775837768377783778837798378083781837828378383784837858378683787837888378983790837918379283793837948379583796837978379883799838008380183802838038380483805838068380783808838098381083811838128381383814838158381683817838188381983820838218382283823838248382583826838278382883829838308383183832838338383483835838368383783838838398384083841838428384383844838458384683847838488384983850838518385283853838548385583856838578385883859838608386183862838638386483865838668386783868838698387083871838728387383874838758387683877838788387983880838818388283883838848388583886838878388883889838908389183892838938389483895838968389783898838998390083901839028390383904839058390683907839088390983910839118391283913839148391583916839178391883919839208392183922839238392483925839268392783928839298393083931839328393383934839358393683937839388393983940839418394283943839448394583946839478394883949839508395183952839538395483955839568395783958839598396083961839628396383964839658396683967839688396983970839718397283973839748397583976839778397883979839808398183982839838398483985839868398783988839898399083991839928399383994839958399683997839988399984000840018400284003840048400584006840078400884009840108401184012840138401484015840168401784018840198402084021840228402384024840258402684027840288402984030840318403284033840348403584036840378403884039840408404184042840438404484045840468404784048840498405084051840528405384054840558405684057840588405984060840618406284063840648406584066840678406884069840708407184072840738407484075840768407784078840798408084081840828408384084840858408684087840888408984090840918409284093840948409584096840978409884099841008410184102841038410484105841068410784108841098411084111841128411384114841158411684117841188411984120841218412284123841248412584126841278412884129841308413184132841338413484135841368413784138841398414084141841428414384144841458414684147841488414984150841518415284153841548415584156841578415884159841608416184162841638416484165841668416784168841698417084171841728417384174841758417684177841788417984180841818418284183841848418584186841878418884189841908419184192841938419484195841968419784198841998420084201842028420384204842058420684207842088420984210842118421284213842148421584216842178421884219842208422184222842238422484225842268422784228842298423084231842328423384234842358423684237842388423984240842418424284243842448424584246842478424884249842508425184252842538425484255842568425784258842598426084261842628426384264842658426684267842688426984270842718427284273842748427584276842778427884279842808428184282842838428484285842868428784288842898429084291842928429384294842958429684297842988429984300843018430284303843048430584306843078430884309843108431184312843138431484315843168431784318843198432084321843228432384324843258432684327843288432984330843318433284333843348433584336843378433884339843408434184342843438434484345843468434784348843498435084351843528435384354843558435684357843588435984360843618436284363843648436584366843678436884369843708437184372843738437484375843768437784378843798438084381843828438384384843858438684387843888438984390843918439284393843948439584396843978439884399844008440184402844038440484405844068440784408844098441084411844128441384414844158441684417844188441984420844218442284423844248442584426844278442884429844308443184432844338443484435844368443784438844398444084441844428444384444844458444684447844488444984450844518445284453844548445584456844578445884459844608446184462844638446484465844668446784468844698447084471844728447384474844758447684477844788447984480844818448284483844848448584486844878448884489844908449184492844938449484495844968449784498844998450084501845028450384504845058450684507845088450984510845118451284513845148451584516845178451884519845208452184522845238452484525845268452784528845298453084531845328453384534845358453684537845388453984540845418454284543845448454584546845478454884549845508455184552845538455484555845568455784558845598456084561845628456384564845658456684567845688456984570845718457284573845748457584576845778457884579845808458184582845838458484585845868458784588845898459084591845928459384594845958459684597845988459984600846018460284603846048460584606846078460884609846108461184612846138461484615846168461784618846198462084621846228462384624846258462684627846288462984630846318463284633846348463584636846378463884639846408464184642846438464484645846468464784648846498465084651846528465384654846558465684657846588465984660846618466284663846648466584666846678466884669846708467184672846738467484675846768467784678846798468084681846828468384684846858468684687846888468984690846918469284693846948469584696846978469884699847008470184702847038470484705847068470784708847098471084711847128471384714847158471684717847188471984720847218472284723847248472584726847278472884729847308473184732847338473484735847368473784738847398474084741847428474384744847458474684747847488474984750847518475284753847548475584756847578475884759847608476184762847638476484765847668476784768847698477084771847728477384774847758477684777847788477984780847818478284783847848478584786847878478884789847908479184792847938479484795847968479784798847998480084801848028480384804848058480684807848088480984810848118481284813848148481584816848178481884819848208482184822848238482484825848268482784828848298483084831848328483384834848358483684837848388483984840848418484284843848448484584846848478484884849848508485184852848538485484855848568485784858848598486084861848628486384864848658486684867848688486984870848718487284873848748487584876848778487884879848808488184882848838488484885848868488784888848898489084891848928489384894848958489684897848988489984900849018490284903849048490584906849078490884909849108491184912849138491484915849168491784918849198492084921849228492384924849258492684927849288492984930849318493284933849348493584936849378493884939849408494184942849438494484945849468494784948849498495084951849528495384954849558495684957849588495984960849618496284963849648496584966849678496884969849708497184972849738497484975849768497784978849798498084981849828498384984849858498684987849888498984990849918499284993849948499584996849978499884999850008500185002850038500485005850068500785008850098501085011850128501385014850158501685017850188501985020850218502285023850248502585026850278502885029850308503185032850338503485035850368503785038850398504085041850428504385044850458504685047850488504985050850518505285053850548505585056850578505885059850608506185062850638506485065850668506785068850698507085071850728507385074850758507685077850788507985080850818508285083850848508585086850878508885089850908509185092850938509485095850968509785098850998510085101851028510385104851058510685107851088510985110851118511285113851148511585116851178511885119851208512185122851238512485125851268512785128851298513085131851328513385134851358513685137851388513985140851418514285143851448514585146851478514885149851508515185152851538515485155851568515785158851598516085161851628516385164851658516685167851688516985170851718517285173851748517585176851778517885179851808518185182851838518485185851868518785188851898519085191851928519385194851958519685197851988519985200852018520285203852048520585206852078520885209852108521185212852138521485215852168521785218852198522085221852228522385224852258522685227852288522985230852318523285233852348523585236852378523885239852408524185242852438524485245852468524785248852498525085251852528525385254852558525685257852588525985260852618526285263852648526585266852678526885269852708527185272852738527485275852768527785278852798528085281852828528385284852858528685287852888528985290852918529285293852948529585296852978529885299853008530185302853038530485305853068530785308853098531085311853128531385314853158531685317853188531985320853218532285323853248532585326853278532885329853308533185332853338533485335853368533785338853398534085341853428534385344853458534685347853488534985350853518535285353853548535585356853578535885359853608536185362853638536485365853668536785368853698537085371853728537385374853758537685377853788537985380853818538285383853848538585386853878538885389853908539185392853938539485395853968539785398853998540085401854028540385404854058540685407854088540985410854118541285413854148541585416854178541885419854208542185422854238542485425854268542785428854298543085431854328543385434854358543685437854388543985440854418544285443854448544585446854478544885449854508545185452854538545485455854568545785458854598546085461854628546385464854658546685467854688546985470854718547285473854748547585476854778547885479854808548185482854838548485485854868548785488854898549085491854928549385494854958549685497854988549985500855018550285503855048550585506855078550885509855108551185512855138551485515855168551785518855198552085521855228552385524855258552685527855288552985530855318553285533855348553585536855378553885539855408554185542855438554485545855468554785548855498555085551855528555385554855558555685557855588555985560855618556285563855648556585566855678556885569855708557185572855738557485575855768557785578855798558085581855828558385584855858558685587855888558985590855918559285593855948559585596855978559885599856008560185602856038560485605856068560785608856098561085611856128561385614856158561685617856188561985620856218562285623856248562585626856278562885629856308563185632856338563485635856368563785638856398564085641856428564385644856458564685647856488564985650856518565285653856548565585656856578565885659856608566185662856638566485665856668566785668856698567085671856728567385674856758567685677856788567985680856818568285683856848568585686856878568885689856908569185692856938569485695856968569785698856998570085701857028570385704857058570685707857088570985710857118571285713857148571585716857178571885719857208572185722857238572485725857268572785728857298573085731857328573385734857358573685737857388573985740857418574285743857448574585746857478574885749857508575185752857538575485755857568575785758857598576085761857628576385764857658576685767857688576985770857718577285773857748577585776857778577885779857808578185782857838578485785857868578785788857898579085791857928579385794857958579685797857988579985800858018580285803858048580585806858078580885809858108581185812858138581485815858168581785818858198582085821858228582385824858258582685827858288582985830858318583285833858348583585836858378583885839858408584185842858438584485845858468584785848858498585085851858528585385854858558585685857858588585985860858618586285863858648586585866858678586885869858708587185872858738587485875858768587785878858798588085881858828588385884858858588685887858888588985890858918589285893858948589585896858978589885899859008590185902859038590485905859068590785908859098591085911859128591385914859158591685917859188591985920859218592285923859248592585926859278592885929859308593185932859338593485935859368593785938859398594085941859428594385944859458594685947859488594985950859518595285953859548595585956859578595885959859608596185962859638596485965859668596785968859698597085971859728597385974859758597685977859788597985980859818598285983859848598585986859878598885989859908599185992859938599485995859968599785998859998600086001860028600386004860058600686007860088600986010860118601286013860148601586016860178601886019860208602186022860238602486025860268602786028860298603086031860328603386034860358603686037860388603986040860418604286043860448604586046860478604886049860508605186052860538605486055860568605786058860598606086061860628606386064860658606686067860688606986070860718607286073860748607586076860778607886079860808608186082860838608486085860868608786088860898609086091860928609386094860958609686097860988609986100861018610286103861048610586106861078610886109861108611186112861138611486115861168611786118861198612086121861228612386124861258612686127861288612986130861318613286133861348613586136861378613886139861408614186142861438614486145861468614786148861498615086151861528615386154861558615686157861588615986160861618616286163861648616586166861678616886169861708617186172861738617486175861768617786178861798618086181861828618386184861858618686187861888618986190861918619286193861948619586196861978619886199862008620186202862038620486205862068620786208862098621086211862128621386214862158621686217862188621986220862218622286223862248622586226862278622886229862308623186232862338623486235862368623786238862398624086241862428624386244862458624686247862488624986250862518625286253862548625586256862578625886259862608626186262862638626486265862668626786268862698627086271862728627386274862758627686277862788627986280862818628286283862848628586286862878628886289862908629186292862938629486295862968629786298862998630086301863028630386304863058630686307863088630986310863118631286313863148631586316863178631886319863208632186322863238632486325863268632786328863298633086331863328633386334863358633686337863388633986340863418634286343863448634586346863478634886349863508635186352863538635486355863568635786358863598636086361863628636386364863658636686367863688636986370863718637286373863748637586376863778637886379863808638186382863838638486385863868638786388863898639086391863928639386394863958639686397863988639986400864018640286403864048640586406864078640886409864108641186412864138641486415864168641786418864198642086421864228642386424864258642686427864288642986430864318643286433864348643586436864378643886439864408644186442864438644486445864468644786448864498645086451864528645386454864558645686457864588645986460864618646286463864648646586466864678646886469864708647186472864738647486475864768647786478864798648086481864828648386484864858648686487864888648986490864918649286493864948649586496864978649886499865008650186502865038650486505865068650786508865098651086511865128651386514865158651686517865188651986520865218652286523865248652586526865278652886529865308653186532865338653486535865368653786538865398654086541865428654386544865458654686547865488654986550865518655286553865548655586556865578655886559865608656186562865638656486565865668656786568865698657086571865728657386574865758657686577865788657986580865818658286583865848658586586865878658886589865908659186592865938659486595865968659786598865998660086601866028660386604866058660686607866088660986610866118661286613866148661586616866178661886619866208662186622866238662486625866268662786628866298663086631866328663386634866358663686637866388663986640866418664286643866448664586646866478664886649866508665186652866538665486655866568665786658866598666086661866628666386664866658666686667866688666986670866718667286673866748667586676866778667886679866808668186682866838668486685866868668786688866898669086691866928669386694866958669686697866988669986700867018670286703867048670586706867078670886709867108671186712867138671486715867168671786718867198672086721867228672386724867258672686727867288672986730867318673286733867348673586736867378673886739867408674186742867438674486745867468674786748867498675086751867528675386754867558675686757867588675986760867618676286763867648676586766867678676886769867708677186772867738677486775867768677786778867798678086781867828678386784867858678686787867888678986790867918679286793867948679586796867978679886799868008680186802868038680486805868068680786808868098681086811868128681386814868158681686817868188681986820868218682286823868248682586826868278682886829868308683186832868338683486835868368683786838868398684086841868428684386844868458684686847868488684986850868518685286853868548685586856868578685886859868608686186862868638686486865868668686786868868698687086871868728687386874868758687686877868788687986880868818688286883868848688586886868878688886889868908689186892868938689486895868968689786898868998690086901869028690386904869058690686907869088690986910869118691286913869148691586916869178691886919869208692186922869238692486925869268692786928869298693086931869328693386934869358693686937869388693986940869418694286943869448694586946869478694886949869508695186952869538695486955869568695786958869598696086961869628696386964869658696686967869688696986970869718697286973869748697586976869778697886979869808698186982869838698486985869868698786988869898699086991869928699386994869958699686997869988699987000870018700287003870048700587006870078700887009870108701187012870138701487015870168701787018870198702087021870228702387024870258702687027870288702987030870318703287033870348703587036870378703887039870408704187042870438704487045870468704787048870498705087051870528705387054870558705687057870588705987060870618706287063870648706587066870678706887069870708707187072870738707487075870768707787078870798708087081870828708387084870858708687087870888708987090870918709287093870948709587096870978709887099871008710187102871038710487105871068710787108871098711087111871128711387114871158711687117871188711987120871218712287123871248712587126871278712887129871308713187132871338713487135871368713787138871398714087141871428714387144871458714687147871488714987150871518715287153871548715587156871578715887159871608716187162871638716487165871668716787168871698717087171871728717387174871758717687177871788717987180871818718287183871848718587186871878718887189871908719187192871938719487195871968719787198871998720087201872028720387204872058720687207872088720987210872118721287213872148721587216872178721887219872208722187222872238722487225872268722787228872298723087231872328723387234872358723687237872388723987240872418724287243872448724587246872478724887249872508725187252872538725487255872568725787258872598726087261872628726387264872658726687267872688726987270872718727287273872748727587276872778727887279872808728187282872838728487285872868728787288872898729087291872928729387294872958729687297872988729987300873018730287303873048730587306873078730887309873108731187312873138731487315873168731787318873198732087321873228732387324873258732687327873288732987330873318733287333873348733587336873378733887339873408734187342873438734487345873468734787348873498735087351873528735387354873558735687357873588735987360873618736287363873648736587366873678736887369873708737187372873738737487375873768737787378873798738087381873828738387384873858738687387873888738987390873918739287393873948739587396873978739887399874008740187402874038740487405874068740787408874098741087411874128741387414874158741687417874188741987420874218742287423874248742587426874278742887429874308743187432874338743487435874368743787438874398744087441874428744387444874458744687447874488744987450874518745287453874548745587456874578745887459874608746187462874638746487465874668746787468874698747087471874728747387474874758747687477874788747987480874818748287483874848748587486874878748887489874908749187492874938749487495874968749787498874998750087501875028750387504875058750687507875088750987510875118751287513875148751587516875178751887519875208752187522875238752487525875268752787528875298753087531875328753387534875358753687537875388753987540875418754287543875448754587546875478754887549875508755187552875538755487555875568755787558875598756087561875628756387564875658756687567875688756987570875718757287573875748757587576875778757887579875808758187582875838758487585875868758787588875898759087591875928759387594875958759687597875988759987600876018760287603876048760587606876078760887609876108761187612876138761487615876168761787618876198762087621876228762387624876258762687627876288762987630876318763287633876348763587636876378763887639876408764187642876438764487645876468764787648876498765087651876528765387654876558765687657876588765987660876618766287663876648766587666876678766887669876708767187672876738767487675876768767787678876798768087681876828768387684876858768687687876888768987690876918769287693876948769587696876978769887699877008770187702877038770487705877068770787708877098771087711877128771387714877158771687717877188771987720877218772287723877248772587726877278772887729877308773187732877338773487735877368773787738877398774087741877428774387744877458774687747877488774987750877518775287753877548775587756877578775887759877608776187762877638776487765877668776787768877698777087771877728777387774877758777687777877788777987780877818778287783877848778587786877878778887789877908779187792877938779487795877968779787798877998780087801878028780387804878058780687807878088780987810878118781287813878148781587816878178781887819878208782187822878238782487825878268782787828878298783087831878328783387834878358783687837878388783987840878418784287843878448784587846878478784887849878508785187852878538785487855878568785787858878598786087861878628786387864878658786687867878688786987870878718787287873878748787587876878778787887879878808788187882878838788487885878868788787888878898789087891878928789387894878958789687897878988789987900879018790287903879048790587906879078790887909879108791187912879138791487915879168791787918879198792087921879228792387924879258792687927879288792987930879318793287933879348793587936879378793887939879408794187942879438794487945879468794787948879498795087951879528795387954879558795687957879588795987960879618796287963879648796587966879678796887969879708797187972879738797487975879768797787978879798798087981879828798387984879858798687987879888798987990879918799287993879948799587996879978799887999880008800188002880038800488005880068800788008880098801088011880128801388014880158801688017880188801988020880218802288023880248802588026880278802888029880308803188032880338803488035880368803788038880398804088041880428804388044880458804688047880488804988050880518805288053880548805588056880578805888059880608806188062880638806488065880668806788068880698807088071880728807388074880758807688077880788807988080880818808288083880848808588086880878808888089880908809188092880938809488095880968809788098880998810088101881028810388104881058810688107881088810988110881118811288113881148811588116881178811888119881208812188122881238812488125881268812788128881298813088131881328813388134881358813688137881388813988140881418814288143881448814588146881478814888149881508815188152881538815488155881568815788158881598816088161881628816388164881658816688167881688816988170881718817288173881748817588176881778817888179881808818188182881838818488185881868818788188881898819088191881928819388194881958819688197881988819988200882018820288203882048820588206882078820888209882108821188212882138821488215882168821788218882198822088221882228822388224882258822688227882288822988230882318823288233882348823588236882378823888239882408824188242882438824488245882468824788248882498825088251882528825388254882558825688257882588825988260882618826288263882648826588266882678826888269882708827188272882738827488275882768827788278882798828088281882828828388284882858828688287882888828988290882918829288293882948829588296882978829888299883008830188302883038830488305883068830788308883098831088311883128831388314883158831688317883188831988320883218832288323883248832588326883278832888329883308833188332883338833488335883368833788338883398834088341883428834388344883458834688347883488834988350883518835288353883548835588356883578835888359883608836188362883638836488365883668836788368883698837088371883728837388374883758837688377883788837988380883818838288383883848838588386883878838888389883908839188392883938839488395883968839788398883998840088401884028840388404884058840688407884088840988410884118841288413884148841588416884178841888419884208842188422884238842488425884268842788428884298843088431884328843388434884358843688437884388843988440884418844288443884448844588446884478844888449884508845188452884538845488455884568845788458884598846088461884628846388464884658846688467884688846988470884718847288473884748847588476884778847888479884808848188482884838848488485884868848788488884898849088491884928849388494884958849688497884988849988500885018850288503885048850588506885078850888509885108851188512885138851488515885168851788518885198852088521885228852388524885258852688527885288852988530885318853288533885348853588536885378853888539885408854188542885438854488545885468854788548885498855088551885528855388554885558855688557885588855988560885618856288563885648856588566885678856888569885708857188572885738857488575885768857788578885798858088581885828858388584885858858688587885888858988590885918859288593885948859588596885978859888599886008860188602886038860488605886068860788608886098861088611886128861388614886158861688617886188861988620886218862288623886248862588626886278862888629886308863188632886338863488635886368863788638886398864088641886428864388644886458864688647886488864988650886518865288653886548865588656886578865888659886608866188662886638866488665886668866788668886698867088671886728867388674886758867688677886788867988680886818868288683886848868588686886878868888689886908869188692886938869488695886968869788698886998870088701887028870388704887058870688707887088870988710887118871288713887148871588716887178871888719887208872188722887238872488725887268872788728887298873088731887328873388734887358873688737887388873988740887418874288743887448874588746887478874888749887508875188752887538875488755887568875788758887598876088761887628876388764887658876688767887688876988770887718877288773887748877588776887778877888779887808878188782887838878488785887868878788788887898879088791887928879388794887958879688797887988879988800888018880288803888048880588806888078880888809888108881188812888138881488815888168881788818888198882088821888228882388824888258882688827888288882988830888318883288833888348883588836888378883888839888408884188842888438884488845888468884788848888498885088851888528885388854888558885688857888588885988860888618886288863888648886588866888678886888869888708887188872888738887488875888768887788878888798888088881888828888388884888858888688887888888888988890888918889288893888948889588896888978889888899889008890188902889038890488905889068890788908889098891088911889128891388914889158891688917889188891988920889218892288923889248892588926889278892888929889308893188932889338893488935889368893788938889398894088941889428894388944889458894688947889488894988950889518895288953889548895588956889578895888959889608896188962889638896488965889668896788968889698897088971889728897388974889758897688977889788897988980889818898288983889848898588986889878898888989889908899188992889938899488995889968899788998889998900089001890028900389004890058900689007890088900989010890118901289013890148901589016890178901889019890208902189022890238902489025890268902789028890298903089031890328903389034890358903689037890388903989040890418904289043890448904589046890478904889049890508905189052890538905489055890568905789058890598906089061890628906389064890658906689067890688906989070890718907289073890748907589076890778907889079890808908189082890838908489085890868908789088890898909089091890928909389094890958909689097890988909989100891018910289103891048910589106891078910889109891108911189112891138911489115891168911789118891198912089121891228912389124891258912689127891288912989130891318913289133891348913589136891378913889139891408914189142891438914489145891468914789148891498915089151891528915389154891558915689157891588915989160891618916289163891648916589166891678916889169891708917189172891738917489175891768917789178891798918089181891828918389184891858918689187891888918989190891918919289193891948919589196891978919889199892008920189202892038920489205892068920789208892098921089211892128921389214892158921689217892188921989220892218922289223892248922589226892278922889229892308923189232892338923489235892368923789238892398924089241892428924389244892458924689247892488924989250892518925289253892548925589256892578925889259892608926189262892638926489265892668926789268892698927089271892728927389274892758927689277892788927989280892818928289283892848928589286892878928889289892908929189292892938929489295892968929789298892998930089301893028930389304893058930689307893088930989310893118931289313893148931589316893178931889319893208932189322893238932489325893268932789328893298933089331893328933389334893358933689337893388933989340893418934289343893448934589346893478934889349893508935189352893538935489355893568935789358893598936089361893628936389364893658936689367893688936989370893718937289373893748937589376893778937889379893808938189382893838938489385893868938789388893898939089391893928939389394893958939689397893988939989400894018940289403894048940589406894078940889409894108941189412894138941489415894168941789418894198942089421894228942389424894258942689427894288942989430894318943289433894348943589436894378943889439894408944189442894438944489445894468944789448894498945089451894528945389454894558945689457894588945989460894618946289463894648946589466894678946889469894708947189472894738947489475894768947789478894798948089481894828948389484894858948689487894888948989490894918949289493894948949589496894978949889499895008950189502895038950489505895068950789508895098951089511895128951389514895158951689517895188951989520895218952289523895248952589526895278952889529895308953189532895338953489535895368953789538895398954089541895428954389544895458954689547895488954989550895518955289553895548955589556895578955889559895608956189562895638956489565895668956789568895698957089571895728957389574895758957689577895788957989580895818958289583895848958589586895878958889589895908959189592895938959489595895968959789598895998960089601896028960389604896058960689607896088960989610896118961289613896148961589616896178961889619896208962189622896238962489625896268962789628896298963089631896328963389634896358963689637896388963989640896418964289643896448964589646896478964889649896508965189652896538965489655896568965789658896598966089661896628966389664896658966689667896688966989670896718967289673896748967589676896778967889679896808968189682896838968489685896868968789688896898969089691896928969389694896958969689697896988969989700897018970289703897048970589706897078970889709897108971189712897138971489715897168971789718897198972089721897228972389724897258972689727897288972989730897318973289733897348973589736897378973889739897408974189742897438974489745897468974789748897498975089751897528975389754897558975689757897588975989760897618976289763897648976589766897678976889769897708977189772897738977489775897768977789778897798978089781897828978389784897858978689787897888978989790897918979289793897948979589796897978979889799898008980189802898038980489805898068980789808898098981089811898128981389814898158981689817898188981989820898218982289823898248982589826898278982889829898308983189832898338983489835898368983789838898398984089841898428984389844898458984689847898488984989850898518985289853898548985589856898578985889859898608986189862898638986489865898668986789868898698987089871898728987389874898758987689877898788987989880898818988289883898848988589886898878988889889898908989189892898938989489895898968989789898898998990089901899028990389904899058990689907899088990989910899118991289913899148991589916899178991889919899208992189922899238992489925899268992789928899298993089931899328993389934899358993689937899388993989940899418994289943899448994589946899478994889949899508995189952899538995489955899568995789958899598996089961899628996389964899658996689967899688996989970899718997289973899748997589976899778997889979899808998189982899838998489985899868998789988899898999089991899928999389994899958999689997899988999990000900019000290003900049000590006900079000890009900109001190012900139001490015900169001790018900199002090021900229002390024900259002690027900289002990030900319003290033900349003590036900379003890039900409004190042900439004490045900469004790048900499005090051900529005390054900559005690057900589005990060900619006290063900649006590066900679006890069900709007190072900739007490075900769007790078900799008090081900829008390084900859008690087900889008990090900919009290093900949009590096900979009890099901009010190102901039010490105901069010790108901099011090111901129011390114901159011690117901189011990120901219012290123901249012590126901279012890129901309013190132901339013490135901369013790138901399014090141901429014390144901459014690147901489014990150901519015290153901549015590156901579015890159901609016190162901639016490165901669016790168901699017090171901729017390174901759017690177901789017990180901819018290183901849018590186901879018890189901909019190192901939019490195901969019790198901999020090201902029020390204902059020690207902089020990210902119021290213902149021590216902179021890219902209022190222902239022490225902269022790228902299023090231902329023390234902359023690237902389023990240902419024290243902449024590246902479024890249902509025190252902539025490255902569025790258902599026090261902629026390264902659026690267902689026990270902719027290273902749027590276902779027890279902809028190282902839028490285902869028790288902899029090291902929029390294902959029690297902989029990300903019030290303903049030590306903079030890309903109031190312903139031490315903169031790318903199032090321903229032390324903259032690327903289032990330903319033290333903349033590336903379033890339903409034190342903439034490345903469034790348903499035090351903529035390354903559035690357903589035990360903619036290363903649036590366903679036890369903709037190372903739037490375903769037790378903799038090381903829038390384903859038690387903889038990390903919039290393903949039590396903979039890399904009040190402904039040490405904069040790408904099041090411904129041390414904159041690417904189041990420904219042290423904249042590426904279042890429904309043190432904339043490435904369043790438904399044090441904429044390444904459044690447904489044990450904519045290453904549045590456904579045890459904609046190462904639046490465904669046790468904699047090471904729047390474904759047690477904789047990480904819048290483904849048590486904879048890489904909049190492904939049490495904969049790498904999050090501905029050390504905059050690507905089050990510905119051290513905149051590516905179051890519905209052190522905239052490525905269052790528905299053090531905329053390534905359053690537905389053990540905419054290543905449054590546905479054890549905509055190552905539055490555905569055790558905599056090561905629056390564905659056690567905689056990570905719057290573905749057590576905779057890579905809058190582905839058490585905869058790588905899059090591905929059390594905959059690597905989059990600906019060290603906049060590606906079060890609906109061190612906139061490615906169061790618906199062090621906229062390624906259062690627906289062990630906319063290633906349063590636906379063890639906409064190642906439064490645906469064790648906499065090651906529065390654906559065690657906589065990660906619066290663906649066590666906679066890669906709067190672906739067490675906769067790678906799068090681906829068390684906859068690687906889068990690906919069290693906949069590696906979069890699907009070190702907039070490705907069070790708907099071090711907129071390714907159071690717907189071990720907219072290723907249072590726907279072890729907309073190732907339073490735907369073790738907399074090741907429074390744907459074690747907489074990750907519075290753907549075590756907579075890759907609076190762907639076490765907669076790768907699077090771907729077390774907759077690777907789077990780907819078290783907849078590786907879078890789907909079190792907939079490795907969079790798907999080090801908029080390804908059080690807908089080990810908119081290813908149081590816908179081890819908209082190822908239082490825908269082790828908299083090831908329083390834908359083690837908389083990840908419084290843908449084590846908479084890849908509085190852908539085490855908569085790858908599086090861908629086390864908659086690867908689086990870908719087290873908749087590876908779087890879908809088190882908839088490885908869088790888908899089090891908929089390894908959089690897908989089990900909019090290903909049090590906909079090890909909109091190912909139091490915909169091790918909199092090921909229092390924909259092690927909289092990930909319093290933909349093590936909379093890939909409094190942909439094490945909469094790948909499095090951909529095390954909559095690957909589095990960909619096290963909649096590966909679096890969909709097190972909739097490975909769097790978909799098090981909829098390984909859098690987909889098990990909919099290993909949099590996909979099890999910009100191002910039100491005910069100791008910099101091011910129101391014910159101691017910189101991020910219102291023910249102591026910279102891029910309103191032910339103491035910369103791038910399104091041910429104391044910459104691047910489104991050910519105291053910549105591056910579105891059910609106191062910639106491065910669106791068910699107091071910729107391074910759107691077910789107991080910819108291083910849108591086910879108891089910909109191092910939109491095910969109791098910999110091101911029110391104911059110691107911089110991110911119111291113911149111591116911179111891119911209112191122911239112491125911269112791128911299113091131911329113391134911359113691137911389113991140911419114291143911449114591146911479114891149911509115191152911539115491155911569115791158911599116091161911629116391164911659116691167911689116991170911719117291173911749117591176911779117891179911809118191182911839118491185911869118791188911899119091191911929119391194911959119691197911989119991200912019120291203912049120591206912079120891209912109121191212912139121491215912169121791218912199122091221912229122391224912259122691227912289122991230912319123291233912349123591236912379123891239912409124191242912439124491245912469124791248912499125091251912529125391254912559125691257912589125991260912619126291263912649126591266912679126891269912709127191272912739127491275912769127791278912799128091281912829128391284912859128691287912889128991290912919129291293912949129591296912979129891299913009130191302913039130491305913069130791308913099131091311913129131391314913159131691317913189131991320913219132291323913249132591326913279132891329913309133191332913339133491335913369133791338913399134091341913429134391344913459134691347913489134991350913519135291353913549135591356913579135891359913609136191362913639136491365913669136791368913699137091371913729137391374913759137691377913789137991380913819138291383913849138591386913879138891389913909139191392913939139491395913969139791398913999140091401914029140391404914059140691407914089140991410914119141291413914149141591416914179141891419914209142191422914239142491425914269142791428914299143091431914329143391434914359143691437914389143991440914419144291443914449144591446914479144891449914509145191452914539145491455914569145791458914599146091461914629146391464914659146691467914689146991470914719147291473914749147591476914779147891479914809148191482914839148491485914869148791488914899149091491914929149391494914959149691497914989149991500915019150291503915049150591506915079150891509915109151191512915139151491515915169151791518915199152091521915229152391524915259152691527915289152991530915319153291533915349153591536915379153891539915409154191542915439154491545915469154791548915499155091551915529155391554915559155691557915589155991560915619156291563915649156591566915679156891569915709157191572915739157491575915769157791578915799158091581915829158391584915859158691587915889158991590915919159291593915949159591596915979159891599916009160191602916039160491605916069160791608916099161091611916129161391614916159161691617916189161991620916219162291623916249162591626916279162891629916309163191632916339163491635916369163791638916399164091641916429164391644916459164691647916489164991650916519165291653916549165591656916579165891659916609166191662916639166491665916669166791668916699167091671916729167391674916759167691677916789167991680916819168291683916849168591686916879168891689916909169191692916939169491695916969169791698916999170091701917029170391704917059170691707917089170991710917119171291713917149171591716917179171891719917209172191722917239172491725917269172791728917299173091731917329173391734917359173691737917389173991740917419174291743917449174591746917479174891749917509175191752917539175491755917569175791758917599176091761917629176391764917659176691767917689176991770917719177291773917749177591776917779177891779917809178191782917839178491785917869178791788917899179091791917929179391794917959179691797917989179991800918019180291803918049180591806918079180891809918109181191812918139181491815918169181791818918199182091821918229182391824918259182691827918289182991830918319183291833918349183591836918379183891839918409184191842918439184491845918469184791848918499185091851918529185391854918559185691857918589185991860918619186291863918649186591866918679186891869918709187191872918739187491875918769187791878918799188091881918829188391884918859188691887918889188991890918919189291893918949189591896918979189891899919009190191902919039190491905919069190791908919099191091911919129191391914919159191691917919189191991920919219192291923919249192591926919279192891929919309193191932919339193491935919369193791938919399194091941919429194391944919459194691947919489194991950919519195291953919549195591956919579195891959919609196191962919639196491965919669196791968919699197091971919729197391974919759197691977919789197991980919819198291983919849198591986919879198891989919909199191992919939199491995919969199791998919999200092001920029200392004920059200692007920089200992010920119201292013920149201592016920179201892019920209202192022920239202492025920269202792028920299203092031920329203392034920359203692037920389203992040920419204292043920449204592046920479204892049920509205192052920539205492055920569205792058920599206092061920629206392064920659206692067920689206992070920719207292073920749207592076920779207892079920809208192082920839208492085920869208792088920899209092091920929209392094920959209692097920989209992100921019210292103921049210592106921079210892109921109211192112921139211492115921169211792118921199212092121921229212392124921259212692127921289212992130921319213292133921349213592136921379213892139921409214192142921439214492145921469214792148921499215092151921529215392154921559215692157921589215992160921619216292163921649216592166921679216892169921709217192172921739217492175921769217792178921799218092181921829218392184921859218692187921889218992190921919219292193921949219592196921979219892199922009220192202922039220492205922069220792208922099221092211922129221392214922159221692217922189221992220922219222292223922249222592226922279222892229922309223192232922339223492235922369223792238922399224092241922429224392244922459224692247922489224992250922519225292253922549225592256922579225892259922609226192262922639226492265922669226792268922699227092271922729227392274922759227692277922789227992280922819228292283922849228592286922879228892289922909229192292922939229492295922969229792298922999230092301923029230392304923059230692307923089230992310923119231292313923149231592316923179231892319923209232192322923239232492325923269232792328923299233092331923329233392334923359233692337923389233992340923419234292343923449234592346923479234892349923509235192352923539235492355923569235792358923599236092361923629236392364923659236692367923689236992370923719237292373923749237592376923779237892379923809238192382923839238492385923869238792388923899239092391923929239392394923959239692397923989239992400924019240292403924049240592406924079240892409924109241192412924139241492415924169241792418924199242092421924229242392424924259242692427924289242992430924319243292433924349243592436924379243892439924409244192442924439244492445924469244792448924499245092451924529245392454924559245692457924589245992460924619246292463924649246592466924679246892469924709247192472924739247492475924769247792478924799248092481924829248392484924859248692487924889248992490924919249292493924949249592496924979249892499925009250192502925039250492505925069250792508925099251092511925129251392514925159251692517925189251992520925219252292523925249252592526925279252892529925309253192532925339253492535925369253792538925399254092541925429254392544925459254692547925489254992550925519255292553925549255592556925579255892559925609256192562925639256492565925669256792568925699257092571925729257392574925759257692577925789257992580925819258292583925849258592586925879258892589925909259192592925939259492595925969259792598925999260092601926029260392604926059260692607926089260992610926119261292613926149261592616926179261892619926209262192622926239262492625926269262792628926299263092631926329263392634926359263692637926389263992640926419264292643926449264592646926479264892649926509265192652926539265492655926569265792658926599266092661926629266392664926659266692667926689266992670926719267292673926749267592676926779267892679926809268192682926839268492685926869268792688926899269092691926929269392694926959269692697926989269992700927019270292703927049270592706927079270892709927109271192712927139271492715927169271792718927199272092721927229272392724927259272692727927289272992730927319273292733927349273592736927379273892739927409274192742927439274492745927469274792748927499275092751927529275392754927559275692757927589275992760927619276292763927649276592766927679276892769927709277192772927739277492775927769277792778927799278092781927829278392784927859278692787927889278992790927919279292793927949279592796927979279892799928009280192802928039280492805928069280792808928099281092811928129281392814928159281692817928189281992820928219282292823928249282592826928279282892829928309283192832928339283492835928369283792838928399284092841928429284392844928459284692847928489284992850928519285292853928549285592856928579285892859928609286192862928639286492865928669286792868928699287092871928729287392874928759287692877928789287992880928819288292883928849288592886928879288892889928909289192892928939289492895928969289792898928999290092901929029290392904929059290692907929089290992910929119291292913929149291592916929179291892919929209292192922929239292492925929269292792928929299293092931929329293392934929359293692937929389293992940929419294292943929449294592946929479294892949929509295192952929539295492955929569295792958929599296092961929629296392964929659296692967929689296992970929719297292973929749297592976929779297892979929809298192982929839298492985929869298792988929899299092991929929299392994929959299692997929989299993000930019300293003930049300593006930079300893009930109301193012930139301493015930169301793018930199302093021930229302393024930259302693027930289302993030930319303293033930349303593036930379303893039930409304193042930439304493045930469304793048930499305093051930529305393054930559305693057930589305993060930619306293063930649306593066930679306893069930709307193072930739307493075930769307793078930799308093081930829308393084930859308693087930889308993090930919309293093930949309593096930979309893099931009310193102931039310493105931069310793108931099311093111931129311393114931159311693117931189311993120931219312293123931249312593126931279312893129931309313193132931339313493135931369313793138931399314093141931429314393144931459314693147931489314993150931519315293153931549315593156931579315893159931609316193162931639316493165931669316793168931699317093171931729317393174931759317693177931789317993180931819318293183931849318593186931879318893189931909319193192931939319493195931969319793198931999320093201932029320393204932059320693207932089320993210932119321293213932149321593216932179321893219932209322193222932239322493225932269322793228932299323093231932329323393234932359323693237932389323993240932419324293243932449324593246932479324893249932509325193252932539325493255932569325793258932599326093261932629326393264932659326693267932689326993270932719327293273932749327593276932779327893279932809328193282932839328493285932869328793288932899329093291932929329393294932959329693297932989329993300933019330293303933049330593306933079330893309933109331193312933139331493315933169331793318933199332093321933229332393324933259332693327933289332993330933319333293333933349333593336933379333893339933409334193342933439334493345933469334793348933499335093351933529335393354933559335693357933589335993360933619336293363933649336593366933679336893369933709337193372933739337493375933769337793378933799338093381933829338393384933859338693387933889338993390933919339293393933949339593396933979339893399934009340193402934039340493405934069340793408934099341093411934129341393414934159341693417934189341993420934219342293423934249342593426934279342893429934309343193432934339343493435934369343793438934399344093441934429344393444934459344693447934489344993450934519345293453934549345593456934579345893459934609346193462934639346493465934669346793468934699347093471934729347393474934759347693477934789347993480934819348293483934849348593486934879348893489934909349193492934939349493495934969349793498934999350093501935029350393504935059350693507935089350993510935119351293513935149351593516935179351893519935209352193522935239352493525935269352793528935299353093531935329353393534935359353693537935389353993540935419354293543935449354593546935479354893549935509355193552935539355493555935569355793558935599356093561935629356393564935659356693567935689356993570935719357293573935749357593576935779357893579935809358193582935839358493585935869358793588935899359093591935929359393594935959359693597935989359993600936019360293603936049360593606936079360893609936109361193612936139361493615936169361793618936199362093621936229362393624936259362693627936289362993630936319363293633936349363593636936379363893639936409364193642936439364493645936469364793648936499365093651936529365393654936559365693657936589365993660936619366293663936649366593666936679366893669936709367193672936739367493675936769367793678936799368093681936829368393684936859368693687936889368993690936919369293693936949369593696936979369893699937009370193702937039370493705937069370793708937099371093711937129371393714937159371693717937189371993720937219372293723937249372593726937279372893729937309373193732937339373493735937369373793738937399374093741937429374393744937459374693747937489374993750937519375293753937549375593756937579375893759937609376193762937639376493765937669376793768937699377093771937729377393774937759377693777937789377993780937819378293783937849378593786937879378893789937909379193792937939379493795937969379793798937999380093801938029380393804938059380693807
  1. declare module BABYLON {
  2. /** Alias type for value that can be null */
  3. export type Nullable<T> = T | null;
  4. /**
  5. * Alias type for number that are floats
  6. * @ignorenaming
  7. */
  8. export type float = number;
  9. /**
  10. * Alias type for number that are doubles.
  11. * @ignorenaming
  12. */
  13. export type double = number;
  14. /**
  15. * Alias type for number that are integer
  16. * @ignorenaming
  17. */
  18. export type int = number;
  19. /** Alias type for number array or Float32Array */
  20. export type FloatArray = number[] | Float32Array;
  21. /** Alias type for number array or Float32Array or Int32Array or Uint32Array or Uint16Array */
  22. export type IndicesArray = number[] | Int32Array | Uint32Array | Uint16Array;
  23. /**
  24. * Alias for types that can be used by a Buffer or VertexBuffer.
  25. */
  26. export type DataArray = number[] | ArrayBuffer | ArrayBufferView;
  27. /**
  28. * Alias type for primitive types
  29. * @ignorenaming
  30. */
  31. type Primitive = undefined | null | boolean | string | number | Function;
  32. /**
  33. * Type modifier to make all the properties of an object Readonly
  34. */
  35. export type Immutable<T> = T extends Primitive ? T : T extends Array<infer U> ? ReadonlyArray<U> : DeepImmutable<T>;
  36. /**
  37. * Type modifier to make all the properties of an object Readonly recursively
  38. */
  39. export type DeepImmutable<T> = T extends Primitive ? T : T extends Array<infer U> ? DeepImmutableArray<U> : DeepImmutableObject<T>;
  40. /**
  41. * Type modifier to make object properties readonly.
  42. */
  43. export type DeepImmutableObject<T> = {
  44. readonly [K in keyof T]: DeepImmutable<T[K]>;
  45. };
  46. /** @hidden */
  47. interface DeepImmutableArray<T> extends ReadonlyArray<DeepImmutable<T>> {
  48. }
  49. }
  50. declare module BABYLON {
  51. /**
  52. * A class serves as a medium between the observable and its observers
  53. */
  54. export class EventState {
  55. /**
  56. * Create a new EventState
  57. * @param mask defines the mask associated with this state
  58. * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true
  59. * @param target defines the original target of the state
  60. * @param currentTarget defines the current target of the state
  61. */
  62. constructor(mask: number, skipNextObservers?: boolean, target?: any, currentTarget?: any);
  63. /**
  64. * Initialize the current event state
  65. * @param mask defines the mask associated with this state
  66. * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true
  67. * @param target defines the original target of the state
  68. * @param currentTarget defines the current target of the state
  69. * @returns the current event state
  70. */
  71. initalize(mask: number, skipNextObservers?: boolean, target?: any, currentTarget?: any): EventState;
  72. /**
  73. * An Observer can set this property to true to prevent subsequent observers of being notified
  74. */
  75. skipNextObservers: boolean;
  76. /**
  77. * Get the mask value that were used to trigger the event corresponding to this EventState object
  78. */
  79. mask: number;
  80. /**
  81. * The object that originally notified the event
  82. */
  83. target?: any;
  84. /**
  85. * The current object in the bubbling phase
  86. */
  87. currentTarget?: any;
  88. /**
  89. * This will be populated with the return value of the last function that was executed.
  90. * If it is the first function in the callback chain it will be the event data.
  91. */
  92. lastReturnValue?: any;
  93. /**
  94. * User defined information that will be sent to observers
  95. */
  96. userInfo?: any;
  97. }
  98. /**
  99. * Represent an Observer registered to a given Observable object.
  100. */
  101. export class Observer<T> {
  102. /**
  103. * Defines the callback to call when the observer is notified
  104. */
  105. callback: (eventData: T, eventState: EventState) => void;
  106. /**
  107. * Defines the mask of the observer (used to filter notifications)
  108. */
  109. mask: number;
  110. /**
  111. * Defines the current scope used to restore the JS context
  112. */
  113. scope: any;
  114. /** @hidden */
  115. _willBeUnregistered: boolean;
  116. /**
  117. * Gets or sets a property defining that the observer as to be unregistered after the next notification
  118. */
  119. unregisterOnNextCall: boolean;
  120. /**
  121. * Creates a new observer
  122. * @param callback defines the callback to call when the observer is notified
  123. * @param mask defines the mask of the observer (used to filter notifications)
  124. * @param scope defines the current scope used to restore the JS context
  125. */
  126. constructor(
  127. /**
  128. * Defines the callback to call when the observer is notified
  129. */
  130. callback: (eventData: T, eventState: EventState) => void,
  131. /**
  132. * Defines the mask of the observer (used to filter notifications)
  133. */
  134. mask: number,
  135. /**
  136. * Defines the current scope used to restore the JS context
  137. */
  138. scope?: any);
  139. }
  140. /**
  141. * Represent a list of observers registered to multiple Observables object.
  142. */
  143. export class MultiObserver<T> {
  144. private _observers;
  145. private _observables;
  146. /**
  147. * Release associated resources
  148. */
  149. dispose(): void;
  150. /**
  151. * Raise a callback when one of the observable will notify
  152. * @param observables defines a list of observables to watch
  153. * @param callback defines the callback to call on notification
  154. * @param mask defines the mask used to filter notifications
  155. * @param scope defines the current scope used to restore the JS context
  156. * @returns the new MultiObserver
  157. */
  158. static Watch<T>(observables: Observable<T>[], callback: (eventData: T, eventState: EventState) => void, mask?: number, scope?: any): MultiObserver<T>;
  159. }
  160. /**
  161. * The Observable class is a simple implementation of the Observable pattern.
  162. *
  163. * There's one slight particularity though: a given Observable can notify its observer using a particular mask value, only the Observers registered with this mask value will be notified.
  164. * This enable a more fine grained execution without having to rely on multiple different Observable objects.
  165. * For instance you may have a given Observable that have four different types of notifications: Move (mask = 0x01), Stop (mask = 0x02), Turn Right (mask = 0X04), Turn Left (mask = 0X08).
  166. * A given observer can register itself with only Move and Stop (mask = 0x03), then it will only be notified when one of these two occurs and will never be for Turn Left/Right.
  167. */
  168. export class Observable<T> {
  169. private _observers;
  170. private _eventState;
  171. private _onObserverAdded;
  172. /**
  173. * Gets the list of observers
  174. */
  175. get observers(): Array<Observer<T>>;
  176. /**
  177. * Creates a new observable
  178. * @param onObserverAdded defines a callback to call when a new observer is added
  179. */
  180. constructor(onObserverAdded?: (observer: Observer<T>) => void);
  181. /**
  182. * Create a new Observer with the specified callback
  183. * @param callback the callback that will be executed for that Observer
  184. * @param mask the mask used to filter observers
  185. * @param insertFirst if true the callback will be inserted at the first position, hence executed before the others ones. If false (default behavior) the callback will be inserted at the last position, executed after all the others already present.
  186. * @param scope optional scope for the callback to be called from
  187. * @param unregisterOnFirstCall defines if the observer as to be unregistered after the next notification
  188. * @returns the new observer created for the callback
  189. */
  190. add(callback: (eventData: T, eventState: EventState) => void, mask?: number, insertFirst?: boolean, scope?: any, unregisterOnFirstCall?: boolean): Nullable<Observer<T>>;
  191. /**
  192. * Create a new Observer with the specified callback and unregisters after the next notification
  193. * @param callback the callback that will be executed for that Observer
  194. * @returns the new observer created for the callback
  195. */
  196. addOnce(callback: (eventData: T, eventState: EventState) => void): Nullable<Observer<T>>;
  197. /**
  198. * Remove an Observer from the Observable object
  199. * @param observer the instance of the Observer to remove
  200. * @returns false if it doesn't belong to this Observable
  201. */
  202. remove(observer: Nullable<Observer<T>>): boolean;
  203. /**
  204. * Remove a callback from the Observable object
  205. * @param callback the callback to remove
  206. * @param scope optional scope. If used only the callbacks with this scope will be removed
  207. * @returns false if it doesn't belong to this Observable
  208. */
  209. removeCallback(callback: (eventData: T, eventState: EventState) => void, scope?: any): boolean;
  210. private _deferUnregister;
  211. private _remove;
  212. /**
  213. * Moves the observable to the top of the observer list making it get called first when notified
  214. * @param observer the observer to move
  215. */
  216. makeObserverTopPriority(observer: Observer<T>): void;
  217. /**
  218. * Moves the observable to the bottom of the observer list making it get called last when notified
  219. * @param observer the observer to move
  220. */
  221. makeObserverBottomPriority(observer: Observer<T>): void;
  222. /**
  223. * Notify all Observers by calling their respective callback with the given data
  224. * Will return true if all observers were executed, false if an observer set skipNextObservers to true, then prevent the subsequent ones to execute
  225. * @param eventData defines the data to send to all observers
  226. * @param mask defines the mask of the current notification (observers with incompatible mask (ie mask & observer.mask === 0) will not be notified)
  227. * @param target defines the original target of the state
  228. * @param currentTarget defines the current target of the state
  229. * @param userInfo defines any user info to send to observers
  230. * @returns false if the complete observer chain was not processed (because one observer set the skipNextObservers to true)
  231. */
  232. notifyObservers(eventData: T, mask?: number, target?: any, currentTarget?: any, userInfo?: any): boolean;
  233. /**
  234. * Calling this will execute each callback, expecting it to be a promise or return a value.
  235. * If at any point in the chain one function fails, the promise will fail and the execution will not continue.
  236. * This is useful when a chain of events (sometimes async events) is needed to initialize a certain object
  237. * and it is crucial that all callbacks will be executed.
  238. * The order of the callbacks is kept, callbacks are not executed parallel.
  239. *
  240. * @param eventData The data to be sent to each callback
  241. * @param mask is used to filter observers defaults to -1
  242. * @param target defines the callback target (see EventState)
  243. * @param currentTarget defines he current object in the bubbling phase
  244. * @param userInfo defines any user info to send to observers
  245. * @returns {Promise<T>} will return a Promise than resolves when all callbacks executed successfully.
  246. */
  247. notifyObserversWithPromise(eventData: T, mask?: number, target?: any, currentTarget?: any, userInfo?: any): Promise<T>;
  248. /**
  249. * Notify a specific observer
  250. * @param observer defines the observer to notify
  251. * @param eventData defines the data to be sent to each callback
  252. * @param mask is used to filter observers defaults to -1
  253. */
  254. notifyObserver(observer: Observer<T>, eventData: T, mask?: number): void;
  255. /**
  256. * Gets a boolean indicating if the observable has at least one observer
  257. * @returns true is the Observable has at least one Observer registered
  258. */
  259. hasObservers(): boolean;
  260. /**
  261. * Clear the list of observers
  262. */
  263. clear(): void;
  264. /**
  265. * Clone the current observable
  266. * @returns a new observable
  267. */
  268. clone(): Observable<T>;
  269. /**
  270. * Does this observable handles observer registered with a given mask
  271. * @param mask defines the mask to be tested
  272. * @return whether or not one observer registered with the given mask is handled
  273. **/
  274. hasSpecificMask(mask?: number): boolean;
  275. }
  276. }
  277. declare module BABYLON {
  278. /**
  279. * Sets of helpers dealing with the DOM and some of the recurrent functions needed in
  280. * Babylon.js
  281. */
  282. export class DomManagement {
  283. /**
  284. * Checks if the window object exists
  285. * @returns true if the window object exists
  286. */
  287. static IsWindowObjectExist(): boolean;
  288. /**
  289. * Checks if the navigator object exists
  290. * @returns true if the navigator object exists
  291. */
  292. static IsNavigatorAvailable(): boolean;
  293. /**
  294. * Check if the document object exists
  295. * @returns true if the document object exists
  296. */
  297. static IsDocumentAvailable(): boolean;
  298. /**
  299. * Extracts text content from a DOM element hierarchy
  300. * @param element defines the root element
  301. * @returns a string
  302. */
  303. static GetDOMTextContent(element: HTMLElement): string;
  304. }
  305. }
  306. declare module BABYLON {
  307. /**
  308. * Logger used throughout the application to allow configuration of
  309. * the log level required for the messages.
  310. */
  311. export class Logger {
  312. /**
  313. * No log
  314. */
  315. static readonly NoneLogLevel: number;
  316. /**
  317. * Only message logs
  318. */
  319. static readonly MessageLogLevel: number;
  320. /**
  321. * Only warning logs
  322. */
  323. static readonly WarningLogLevel: number;
  324. /**
  325. * Only error logs
  326. */
  327. static readonly ErrorLogLevel: number;
  328. /**
  329. * All logs
  330. */
  331. static readonly AllLogLevel: number;
  332. /**
  333. * Message to display when a message has been logged too many times
  334. */
  335. static MessageLimitReached: string;
  336. private static _LogCache;
  337. private static _LogLimitOutputs;
  338. /**
  339. * Gets a value indicating the number of loading errors
  340. * @ignorenaming
  341. */
  342. static errorsCount: number;
  343. /**
  344. * Callback called when a new log is added
  345. */
  346. static OnNewCacheEntry: (entry: string) => void;
  347. private static _CheckLimit;
  348. private static _GenerateLimitMessage;
  349. private static _AddLogEntry;
  350. private static _FormatMessage;
  351. private static _LogDisabled;
  352. private static _LogEnabled;
  353. private static _WarnDisabled;
  354. private static _WarnEnabled;
  355. private static _ErrorDisabled;
  356. private static _ErrorEnabled;
  357. /**
  358. * Log a message to the console
  359. */
  360. static Log: (message: string, limit?: number) => void;
  361. /**
  362. * Write a warning message to the console
  363. */
  364. static Warn: (message: string, limit?: number) => void;
  365. /**
  366. * Write an error message to the console
  367. */
  368. static Error: (message: string, limit?: number) => void;
  369. /**
  370. * Gets current log cache (list of logs)
  371. */
  372. static get LogCache(): string;
  373. /**
  374. * Clears the log cache
  375. */
  376. static ClearLogCache(): void;
  377. /**
  378. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  379. */
  380. static set LogLevels(level: number);
  381. }
  382. }
  383. declare module BABYLON {
  384. /** @hidden */
  385. export class _TypeStore {
  386. /** @hidden */
  387. static RegisteredTypes: {
  388. [key: string]: Object;
  389. };
  390. /** @hidden */
  391. static GetClass(fqdn: string): any;
  392. }
  393. }
  394. declare module BABYLON {
  395. /**
  396. * Helper to manipulate strings
  397. */
  398. export class StringTools {
  399. /**
  400. * Checks for a matching suffix at the end of a string (for ES5 and lower)
  401. * @param str Source string
  402. * @param suffix Suffix to search for in the source string
  403. * @returns Boolean indicating whether the suffix was found (true) or not (false)
  404. */
  405. static EndsWith(str: string, suffix: string): boolean;
  406. /**
  407. * Checks for a matching suffix at the beginning of a string (for ES5 and lower)
  408. * @param str Source string
  409. * @param suffix Suffix to search for in the source string
  410. * @returns Boolean indicating whether the suffix was found (true) or not (false)
  411. */
  412. static StartsWith(str: string, suffix: string): boolean;
  413. /**
  414. * Decodes a buffer into a string
  415. * @param buffer The buffer to decode
  416. * @returns The decoded string
  417. */
  418. static Decode(buffer: Uint8Array | Uint16Array): string;
  419. /**
  420. * Encode a buffer to a base64 string
  421. * @param buffer defines the buffer to encode
  422. * @returns the encoded string
  423. */
  424. static EncodeArrayBufferToBase64(buffer: ArrayBuffer | ArrayBufferView): string;
  425. /**
  426. * Converts a number to string and pads with preceding zeroes until it is of specified length.
  427. * @param num the number to convert and pad
  428. * @param length the expected length of the string
  429. * @returns the padded string
  430. */
  431. static PadNumber(num: number, length: number): string;
  432. }
  433. }
  434. declare module BABYLON {
  435. /**
  436. * Class containing a set of static utilities functions for deep copy.
  437. */
  438. export class DeepCopier {
  439. /**
  440. * Tries to copy an object by duplicating every property
  441. * @param source defines the source object
  442. * @param destination defines the target object
  443. * @param doNotCopyList defines a list of properties to avoid
  444. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  445. */
  446. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  447. }
  448. }
  449. declare module BABYLON {
  450. /**
  451. * Class containing a set of static utilities functions for precision date
  452. */
  453. export class PrecisionDate {
  454. /**
  455. * Gets either window.performance.now() if supported or Date.now() else
  456. */
  457. static get Now(): number;
  458. }
  459. }
  460. declare module BABYLON {
  461. /** @hidden */
  462. export class _DevTools {
  463. static WarnImport(name: string): string;
  464. }
  465. }
  466. declare module BABYLON {
  467. /**
  468. * Interface used to define the mechanism to get data from the network
  469. */
  470. export interface IWebRequest {
  471. /**
  472. * Returns client's response url
  473. */
  474. responseURL: string;
  475. /**
  476. * Returns client's status
  477. */
  478. status: number;
  479. /**
  480. * Returns client's status as a text
  481. */
  482. statusText: string;
  483. }
  484. }
  485. declare module BABYLON {
  486. /**
  487. * Extended version of XMLHttpRequest with support for customizations (headers, ...)
  488. */
  489. export class WebRequest implements IWebRequest {
  490. private readonly _xhr;
  491. /**
  492. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  493. * i.e. when loading files, where the server/service expects an Authorization header
  494. */
  495. static CustomRequestHeaders: {
  496. [key: string]: string;
  497. };
  498. /**
  499. * Add callback functions in this array to update all the requests before they get sent to the network
  500. */
  501. static CustomRequestModifiers: ((request: XMLHttpRequest, url: string) => void)[];
  502. private _injectCustomRequestHeaders;
  503. /**
  504. * Gets or sets a function to be called when loading progress changes
  505. */
  506. get onprogress(): ((this: XMLHttpRequest, ev: ProgressEvent) => any) | null;
  507. set onprogress(value: ((this: XMLHttpRequest, ev: ProgressEvent) => any) | null);
  508. /**
  509. * Returns client's state
  510. */
  511. get readyState(): number;
  512. /**
  513. * Returns client's status
  514. */
  515. get status(): number;
  516. /**
  517. * Returns client's status as a text
  518. */
  519. get statusText(): string;
  520. /**
  521. * Returns client's response
  522. */
  523. get response(): any;
  524. /**
  525. * Returns client's response url
  526. */
  527. get responseURL(): string;
  528. /**
  529. * Returns client's response as text
  530. */
  531. get responseText(): string;
  532. /**
  533. * Gets or sets the expected response type
  534. */
  535. get responseType(): XMLHttpRequestResponseType;
  536. set responseType(value: XMLHttpRequestResponseType);
  537. /** @hidden */
  538. addEventListener<K extends keyof XMLHttpRequestEventMap>(type: K, listener: (this: XMLHttpRequest, ev: XMLHttpRequestEventMap[K]) => any, options?: boolean | AddEventListenerOptions): void;
  539. /** @hidden */
  540. removeEventListener<K extends keyof XMLHttpRequestEventMap>(type: K, listener: (this: XMLHttpRequest, ev: XMLHttpRequestEventMap[K]) => any, options?: boolean | EventListenerOptions): void;
  541. /**
  542. * Cancels any network activity
  543. */
  544. abort(): void;
  545. /**
  546. * Initiates the request. The optional argument provides the request body. The argument is ignored if request method is GET or HEAD
  547. * @param body defines an optional request body
  548. */
  549. send(body?: Document | BodyInit | null): void;
  550. /**
  551. * Sets the request method, request URL
  552. * @param method defines the method to use (GET, POST, etc..)
  553. * @param url defines the url to connect with
  554. */
  555. open(method: string, url: string): void;
  556. /**
  557. * Sets the value of a request header.
  558. * @param name The name of the header whose value is to be set
  559. * @param value The value to set as the body of the header
  560. */
  561. setRequestHeader(name: string, value: string): void;
  562. /**
  563. * Get the string containing the text of a particular header's value.
  564. * @param name The name of the header
  565. * @returns The string containing the text of the given header name
  566. */
  567. getResponseHeader(name: string): Nullable<string>;
  568. }
  569. }
  570. declare module BABYLON {
  571. /**
  572. * File request interface
  573. */
  574. export interface IFileRequest {
  575. /**
  576. * Raised when the request is complete (success or error).
  577. */
  578. onCompleteObservable: Observable<IFileRequest>;
  579. /**
  580. * Aborts the request for a file.
  581. */
  582. abort: () => void;
  583. }
  584. }
  585. declare module BABYLON {
  586. /**
  587. * Define options used to create a render target texture
  588. */
  589. export class RenderTargetCreationOptions {
  590. /**
  591. * Specifies if mipmaps must be created. If undefined, the value from generateMipMaps is taken instead
  592. */
  593. createMipMaps?: boolean;
  594. /**
  595. * Specifies if mipmaps must be generated
  596. */
  597. generateMipMaps?: boolean;
  598. /** Specifies whether or not a depth should be allocated in the texture (true by default) */
  599. generateDepthBuffer?: boolean;
  600. /** Specifies whether or not a stencil should be allocated in the texture (false by default)*/
  601. generateStencilBuffer?: boolean;
  602. /** Defines texture type (int by default) */
  603. type?: number;
  604. /** Defines sampling mode (trilinear by default) */
  605. samplingMode?: number;
  606. /** Defines format (RGBA by default) */
  607. format?: number;
  608. /** Defines sample count (1 by default) */
  609. samples?: number;
  610. }
  611. }
  612. declare module BABYLON {
  613. /** Defines the cross module used constants to avoid circular dependencies */
  614. export class Constants {
  615. /** Defines that alpha blending is disabled */
  616. static readonly ALPHA_DISABLE: number;
  617. /** Defines that alpha blending is SRC ALPHA * SRC + DEST */
  618. static readonly ALPHA_ADD: number;
  619. /** Defines that alpha blending is SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  620. static readonly ALPHA_COMBINE: number;
  621. /** Defines that alpha blending is DEST - SRC * DEST */
  622. static readonly ALPHA_SUBTRACT: number;
  623. /** Defines that alpha blending is SRC * DEST */
  624. static readonly ALPHA_MULTIPLY: number;
  625. /** Defines that alpha blending is SRC ALPHA * SRC + (1 - SRC) * DEST */
  626. static readonly ALPHA_MAXIMIZED: number;
  627. /** Defines that alpha blending is SRC + DEST */
  628. static readonly ALPHA_ONEONE: number;
  629. /** Defines that alpha blending is SRC + (1 - SRC ALPHA) * DEST */
  630. static readonly ALPHA_PREMULTIPLIED: number;
  631. /**
  632. * Defines that alpha blending is SRC + (1 - SRC ALPHA) * DEST
  633. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  634. */
  635. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  636. /** Defines that alpha blending is CST * SRC + (1 - CST) * DEST */
  637. static readonly ALPHA_INTERPOLATE: number;
  638. /**
  639. * Defines that alpha blending is SRC + (1 - SRC) * DEST
  640. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  641. */
  642. static readonly ALPHA_SCREENMODE: number;
  643. /**
  644. * Defines that alpha blending is SRC + DST
  645. * Alpha will be set to SRC ALPHA + DST ALPHA
  646. */
  647. static readonly ALPHA_ONEONE_ONEONE: number;
  648. /**
  649. * Defines that alpha blending is SRC * DST ALPHA + DST
  650. * Alpha will be set to 0
  651. */
  652. static readonly ALPHA_ALPHATOCOLOR: number;
  653. /**
  654. * Defines that alpha blending is SRC * (1 - DST) + DST * (1 - SRC)
  655. */
  656. static readonly ALPHA_REVERSEONEMINUS: number;
  657. /**
  658. * Defines that alpha blending is SRC + DST * (1 - SRC ALPHA)
  659. * Alpha will be set to SRC ALPHA + DST ALPHA * (1 - SRC ALPHA)
  660. */
  661. static readonly ALPHA_SRC_DSTONEMINUSSRCALPHA: number;
  662. /**
  663. * Defines that alpha blending is SRC + DST
  664. * Alpha will be set to SRC ALPHA
  665. */
  666. static readonly ALPHA_ONEONE_ONEZERO: number;
  667. /**
  668. * Defines that alpha blending is SRC * (1 - DST) + DST * (1 - SRC)
  669. * Alpha will be set to DST ALPHA
  670. */
  671. static readonly ALPHA_EXCLUSION: number;
  672. /** Defines that alpha blending equation a SUM */
  673. static readonly ALPHA_EQUATION_ADD: number;
  674. /** Defines that alpha blending equation a SUBSTRACTION */
  675. static readonly ALPHA_EQUATION_SUBSTRACT: number;
  676. /** Defines that alpha blending equation a REVERSE SUBSTRACTION */
  677. static readonly ALPHA_EQUATION_REVERSE_SUBTRACT: number;
  678. /** Defines that alpha blending equation a MAX operation */
  679. static readonly ALPHA_EQUATION_MAX: number;
  680. /** Defines that alpha blending equation a MIN operation */
  681. static readonly ALPHA_EQUATION_MIN: number;
  682. /**
  683. * Defines that alpha blending equation a DARKEN operation:
  684. * It takes the min of the src and sums the alpha channels.
  685. */
  686. static readonly ALPHA_EQUATION_DARKEN: number;
  687. /** Defines that the resource is not delayed*/
  688. static readonly DELAYLOADSTATE_NONE: number;
  689. /** Defines that the resource was successfully delay loaded */
  690. static readonly DELAYLOADSTATE_LOADED: number;
  691. /** Defines that the resource is currently delay loading */
  692. static readonly DELAYLOADSTATE_LOADING: number;
  693. /** Defines that the resource is delayed and has not started loading */
  694. static readonly DELAYLOADSTATE_NOTLOADED: number;
  695. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  696. static readonly NEVER: number;
  697. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will always pass. i.e. Pixels will be drawn in the order they are drawn */
  698. static readonly ALWAYS: number;
  699. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  700. static readonly LESS: number;
  701. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  702. static readonly EQUAL: number;
  703. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than or equal to the stored value */
  704. static readonly LEQUAL: number;
  705. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  706. static readonly GREATER: number;
  707. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than or equal to the stored value */
  708. static readonly GEQUAL: number;
  709. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is not equal to the stored value */
  710. static readonly NOTEQUAL: number;
  711. /** Passed to stencilOperation to specify that stencil value must be kept */
  712. static readonly KEEP: number;
  713. /** Passed to stencilOperation to specify that stencil value must be zero */
  714. static readonly ZERO: number;
  715. /** Passed to stencilOperation to specify that stencil value must be replaced */
  716. static readonly REPLACE: number;
  717. /** Passed to stencilOperation to specify that stencil value must be incremented */
  718. static readonly INCR: number;
  719. /** Passed to stencilOperation to specify that stencil value must be decremented */
  720. static readonly DECR: number;
  721. /** Passed to stencilOperation to specify that stencil value must be inverted */
  722. static readonly INVERT: number;
  723. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  724. static readonly INCR_WRAP: number;
  725. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  726. static readonly DECR_WRAP: number;
  727. /** Texture is not repeating outside of 0..1 UVs */
  728. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  729. /** Texture is repeating outside of 0..1 UVs */
  730. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  731. /** Texture is repeating and mirrored */
  732. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  733. /** ALPHA */
  734. static readonly TEXTUREFORMAT_ALPHA: number;
  735. /** LUMINANCE */
  736. static readonly TEXTUREFORMAT_LUMINANCE: number;
  737. /** LUMINANCE_ALPHA */
  738. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  739. /** RGB */
  740. static readonly TEXTUREFORMAT_RGB: number;
  741. /** RGBA */
  742. static readonly TEXTUREFORMAT_RGBA: number;
  743. /** RED */
  744. static readonly TEXTUREFORMAT_RED: number;
  745. /** RED (2nd reference) */
  746. static readonly TEXTUREFORMAT_R: number;
  747. /** RG */
  748. static readonly TEXTUREFORMAT_RG: number;
  749. /** RED_INTEGER */
  750. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  751. /** RED_INTEGER (2nd reference) */
  752. static readonly TEXTUREFORMAT_R_INTEGER: number;
  753. /** RG_INTEGER */
  754. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  755. /** RGB_INTEGER */
  756. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  757. /** RGBA_INTEGER */
  758. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  759. /** BGRA */
  760. static readonly TEXTUREFORMAT_BGRA: number;
  761. /** Depth 24 bits + Stencil 8 bits */
  762. static readonly TEXTUREFORMAT_DEPTH24_STENCIL8: number;
  763. /** Depth 32 bits float */
  764. static readonly TEXTUREFORMAT_DEPTH32_FLOAT: number;
  765. /** Compressed BC7 */
  766. static readonly TEXTUREFORMAT_COMPRESSED_RGBA_BPTC_UNORM: number;
  767. /** Compressed BC6 unsigned float */
  768. static readonly TEXTUREFORMAT_COMPRESSED_RGB_BPTC_UNSIGNED_FLOAT: number;
  769. /** Compressed BC6 signed float */
  770. static readonly TEXTUREFORMAT_COMPRESSED_RGB_BPTC_SIGNED_FLOAT: number;
  771. /** Compressed BC3 */
  772. static readonly TEXTUREFORMAT_COMPRESSED_RGBA_S3TC_DXT5: number;
  773. /** Compressed BC2 */
  774. static readonly TEXTUREFORMAT_COMPRESSED_RGBA_S3TC_DXT3: number;
  775. /** Compressed BC1 */
  776. static readonly TEXTUREFORMAT_COMPRESSED_RGBA_S3TC_DXT1: number;
  777. /** UNSIGNED_BYTE */
  778. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  779. /** UNSIGNED_BYTE (2nd reference) */
  780. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  781. /** FLOAT */
  782. static readonly TEXTURETYPE_FLOAT: number;
  783. /** HALF_FLOAT */
  784. static readonly TEXTURETYPE_HALF_FLOAT: number;
  785. /** BYTE */
  786. static readonly TEXTURETYPE_BYTE: number;
  787. /** SHORT */
  788. static readonly TEXTURETYPE_SHORT: number;
  789. /** UNSIGNED_SHORT */
  790. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  791. /** INT */
  792. static readonly TEXTURETYPE_INT: number;
  793. /** UNSIGNED_INT */
  794. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  795. /** UNSIGNED_SHORT_4_4_4_4 */
  796. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  797. /** UNSIGNED_SHORT_5_5_5_1 */
  798. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  799. /** UNSIGNED_SHORT_5_6_5 */
  800. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  801. /** UNSIGNED_INT_2_10_10_10_REV */
  802. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  803. /** UNSIGNED_INT_24_8 */
  804. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  805. /** UNSIGNED_INT_10F_11F_11F_REV */
  806. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  807. /** UNSIGNED_INT_5_9_9_9_REV */
  808. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  809. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  810. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  811. /** nearest is mag = nearest and min = nearest and no mip */
  812. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  813. /** mag = nearest and min = nearest and mip = none */
  814. static readonly TEXTURE_NEAREST_NEAREST: number;
  815. /** Bilinear is mag = linear and min = linear and no mip */
  816. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  817. /** mag = linear and min = linear and mip = none */
  818. static readonly TEXTURE_LINEAR_LINEAR: number;
  819. /** Trilinear is mag = linear and min = linear and mip = linear */
  820. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  821. /** Trilinear is mag = linear and min = linear and mip = linear */
  822. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  823. /** mag = nearest and min = nearest and mip = nearest */
  824. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  825. /** mag = nearest and min = linear and mip = nearest */
  826. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  827. /** mag = nearest and min = linear and mip = linear */
  828. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  829. /** mag = nearest and min = linear and mip = none */
  830. static readonly TEXTURE_NEAREST_LINEAR: number;
  831. /** nearest is mag = nearest and min = nearest and mip = linear */
  832. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  833. /** mag = linear and min = nearest and mip = nearest */
  834. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  835. /** mag = linear and min = nearest and mip = linear */
  836. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  837. /** Bilinear is mag = linear and min = linear and mip = nearest */
  838. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  839. /** mag = linear and min = nearest and mip = none */
  840. static readonly TEXTURE_LINEAR_NEAREST: number;
  841. /** Explicit coordinates mode */
  842. static readonly TEXTURE_EXPLICIT_MODE: number;
  843. /** Spherical coordinates mode */
  844. static readonly TEXTURE_SPHERICAL_MODE: number;
  845. /** Planar coordinates mode */
  846. static readonly TEXTURE_PLANAR_MODE: number;
  847. /** Cubic coordinates mode */
  848. static readonly TEXTURE_CUBIC_MODE: number;
  849. /** Projection coordinates mode */
  850. static readonly TEXTURE_PROJECTION_MODE: number;
  851. /** Skybox coordinates mode */
  852. static readonly TEXTURE_SKYBOX_MODE: number;
  853. /** Inverse Cubic coordinates mode */
  854. static readonly TEXTURE_INVCUBIC_MODE: number;
  855. /** Equirectangular coordinates mode */
  856. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  857. /** Equirectangular Fixed coordinates mode */
  858. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  859. /** Equirectangular Fixed Mirrored coordinates mode */
  860. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  861. /** Offline (baking) quality for texture filtering */
  862. static readonly TEXTURE_FILTERING_QUALITY_OFFLINE: number;
  863. /** High quality for texture filtering */
  864. static readonly TEXTURE_FILTERING_QUALITY_HIGH: number;
  865. /** Medium quality for texture filtering */
  866. static readonly TEXTURE_FILTERING_QUALITY_MEDIUM: number;
  867. /** Low quality for texture filtering */
  868. static readonly TEXTURE_FILTERING_QUALITY_LOW: number;
  869. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  870. static readonly SCALEMODE_FLOOR: number;
  871. /** Defines that texture rescaling will look for the nearest power of 2 size */
  872. static readonly SCALEMODE_NEAREST: number;
  873. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  874. static readonly SCALEMODE_CEILING: number;
  875. /**
  876. * The dirty texture flag value
  877. */
  878. static readonly MATERIAL_TextureDirtyFlag: number;
  879. /**
  880. * The dirty light flag value
  881. */
  882. static readonly MATERIAL_LightDirtyFlag: number;
  883. /**
  884. * The dirty fresnel flag value
  885. */
  886. static readonly MATERIAL_FresnelDirtyFlag: number;
  887. /**
  888. * The dirty attribute flag value
  889. */
  890. static readonly MATERIAL_AttributesDirtyFlag: number;
  891. /**
  892. * The dirty misc flag value
  893. */
  894. static readonly MATERIAL_MiscDirtyFlag: number;
  895. /**
  896. * The dirty prepass flag value
  897. */
  898. static readonly MATERIAL_PrePassDirtyFlag: number;
  899. /**
  900. * The all dirty flag value
  901. */
  902. static readonly MATERIAL_AllDirtyFlag: number;
  903. /**
  904. * Returns the triangle fill mode
  905. */
  906. static readonly MATERIAL_TriangleFillMode: number;
  907. /**
  908. * Returns the wireframe mode
  909. */
  910. static readonly MATERIAL_WireFrameFillMode: number;
  911. /**
  912. * Returns the point fill mode
  913. */
  914. static readonly MATERIAL_PointFillMode: number;
  915. /**
  916. * Returns the point list draw mode
  917. */
  918. static readonly MATERIAL_PointListDrawMode: number;
  919. /**
  920. * Returns the line list draw mode
  921. */
  922. static readonly MATERIAL_LineListDrawMode: number;
  923. /**
  924. * Returns the line loop draw mode
  925. */
  926. static readonly MATERIAL_LineLoopDrawMode: number;
  927. /**
  928. * Returns the line strip draw mode
  929. */
  930. static readonly MATERIAL_LineStripDrawMode: number;
  931. /**
  932. * Returns the triangle strip draw mode
  933. */
  934. static readonly MATERIAL_TriangleStripDrawMode: number;
  935. /**
  936. * Returns the triangle fan draw mode
  937. */
  938. static readonly MATERIAL_TriangleFanDrawMode: number;
  939. /**
  940. * Stores the clock-wise side orientation
  941. */
  942. static readonly MATERIAL_ClockWiseSideOrientation: number;
  943. /**
  944. * Stores the counter clock-wise side orientation
  945. */
  946. static readonly MATERIAL_CounterClockWiseSideOrientation: number;
  947. /**
  948. * Nothing
  949. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  950. */
  951. static readonly ACTION_NothingTrigger: number;
  952. /**
  953. * On pick
  954. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  955. */
  956. static readonly ACTION_OnPickTrigger: number;
  957. /**
  958. * On left pick
  959. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  960. */
  961. static readonly ACTION_OnLeftPickTrigger: number;
  962. /**
  963. * On right pick
  964. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  965. */
  966. static readonly ACTION_OnRightPickTrigger: number;
  967. /**
  968. * On center pick
  969. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  970. */
  971. static readonly ACTION_OnCenterPickTrigger: number;
  972. /**
  973. * On pick down
  974. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  975. */
  976. static readonly ACTION_OnPickDownTrigger: number;
  977. /**
  978. * On double pick
  979. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  980. */
  981. static readonly ACTION_OnDoublePickTrigger: number;
  982. /**
  983. * On pick up
  984. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  985. */
  986. static readonly ACTION_OnPickUpTrigger: number;
  987. /**
  988. * On pick out.
  989. * This trigger will only be raised if you also declared a OnPickDown
  990. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  991. */
  992. static readonly ACTION_OnPickOutTrigger: number;
  993. /**
  994. * On long press
  995. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  996. */
  997. static readonly ACTION_OnLongPressTrigger: number;
  998. /**
  999. * On pointer over
  1000. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  1001. */
  1002. static readonly ACTION_OnPointerOverTrigger: number;
  1003. /**
  1004. * On pointer out
  1005. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  1006. */
  1007. static readonly ACTION_OnPointerOutTrigger: number;
  1008. /**
  1009. * On every frame
  1010. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  1011. */
  1012. static readonly ACTION_OnEveryFrameTrigger: number;
  1013. /**
  1014. * On intersection enter
  1015. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  1016. */
  1017. static readonly ACTION_OnIntersectionEnterTrigger: number;
  1018. /**
  1019. * On intersection exit
  1020. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  1021. */
  1022. static readonly ACTION_OnIntersectionExitTrigger: number;
  1023. /**
  1024. * On key down
  1025. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  1026. */
  1027. static readonly ACTION_OnKeyDownTrigger: number;
  1028. /**
  1029. * On key up
  1030. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  1031. */
  1032. static readonly ACTION_OnKeyUpTrigger: number;
  1033. /**
  1034. * Billboard mode will only apply to Y axis
  1035. */
  1036. static readonly PARTICLES_BILLBOARDMODE_Y: number;
  1037. /**
  1038. * Billboard mode will apply to all axes
  1039. */
  1040. static readonly PARTICLES_BILLBOARDMODE_ALL: number;
  1041. /**
  1042. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  1043. */
  1044. static readonly PARTICLES_BILLBOARDMODE_STRETCHED: number;
  1045. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  1046. * Test order :
  1047. * Is the bounding sphere outside the frustum ?
  1048. * If not, are the bounding box vertices outside the frustum ?
  1049. * It not, then the cullable object is in the frustum.
  1050. */
  1051. static readonly MESHES_CULLINGSTRATEGY_STANDARD: number;
  1052. /** Culling strategy : Bounding Sphere Only.
  1053. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  1054. * It's also less accurate than the standard because some not visible objects can still be selected.
  1055. * Test : is the bounding sphere outside the frustum ?
  1056. * If not, then the cullable object is in the frustum.
  1057. */
  1058. static readonly MESHES_CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  1059. /** Culling strategy : Optimistic Inclusion.
  1060. * This in an inclusion test first, then the standard exclusion test.
  1061. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  1062. * This could also be a little slower than the standard test when the tested object center is not the frustum but one of its bounding box vertex is still inside.
  1063. * Anyway, it's as accurate as the standard strategy.
  1064. * Test :
  1065. * Is the cullable object bounding sphere center in the frustum ?
  1066. * If not, apply the default culling strategy.
  1067. */
  1068. static readonly MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  1069. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  1070. * This in an inclusion test first, then the bounding sphere only exclusion test.
  1071. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  1072. * This could also be a little slower than the BoundingSphereOnly strategy when the tested object center is not in the frustum but its bounding sphere still intersects it.
  1073. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  1074. * Test :
  1075. * Is the cullable object bounding sphere center in the frustum ?
  1076. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  1077. */
  1078. static readonly MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  1079. /**
  1080. * No logging while loading
  1081. */
  1082. static readonly SCENELOADER_NO_LOGGING: number;
  1083. /**
  1084. * Minimal logging while loading
  1085. */
  1086. static readonly SCENELOADER_MINIMAL_LOGGING: number;
  1087. /**
  1088. * Summary logging while loading
  1089. */
  1090. static readonly SCENELOADER_SUMMARY_LOGGING: number;
  1091. /**
  1092. * Detailed logging while loading
  1093. */
  1094. static readonly SCENELOADER_DETAILED_LOGGING: number;
  1095. /**
  1096. * Constant used to retrieve the irradiance texture index in the textures array in the prepass
  1097. * using getIndex(Constants.PREPASS_IRRADIANCE_TEXTURE_TYPE)
  1098. */
  1099. static readonly PREPASS_IRRADIANCE_TEXTURE_TYPE: number;
  1100. /**
  1101. * Constant used to retrieve the position texture index in the textures array in the prepass
  1102. * using getIndex(Constants.PREPASS_POSITION_TEXTURE_INDEX)
  1103. */
  1104. static readonly PREPASS_POSITION_TEXTURE_TYPE: number;
  1105. /**
  1106. * Constant used to retrieve the velocity texture index in the textures array in the prepass
  1107. * using getIndex(Constants.PREPASS_VELOCITY_TEXTURE_INDEX)
  1108. */
  1109. static readonly PREPASS_VELOCITY_TEXTURE_TYPE: number;
  1110. /**
  1111. * Constant used to retrieve the reflectivity texture index in the textures array in the prepass
  1112. * using the getIndex(Constants.PREPASS_REFLECTIVITY_TEXTURE_TYPE)
  1113. */
  1114. static readonly PREPASS_REFLECTIVITY_TEXTURE_TYPE: number;
  1115. /**
  1116. * Constant used to retrieve the lit color texture index in the textures array in the prepass
  1117. * using the getIndex(Constants.PREPASS_COLOR_TEXTURE_TYPE)
  1118. */
  1119. static readonly PREPASS_COLOR_TEXTURE_TYPE: number;
  1120. /**
  1121. * Constant used to retrieve depth index in the textures array in the prepass
  1122. * using the getIndex(Constants.PREPASS_DEPTH_TEXTURE_TYPE)
  1123. */
  1124. static readonly PREPASS_DEPTH_TEXTURE_TYPE: number;
  1125. /**
  1126. * Constant used to retrieve normal index in the textures array in the prepass
  1127. * using the getIndex(Constants.PREPASS_NORMAL_TEXTURE_TYPE)
  1128. */
  1129. static readonly PREPASS_NORMAL_TEXTURE_TYPE: number;
  1130. /**
  1131. * Constant used to retrieve albedo index in the textures array in the prepass
  1132. * using the getIndex(Constants.PREPASS_ALBEDO_TEXTURE_TYPE)
  1133. */
  1134. static readonly PREPASS_ALBEDO_TEXTURE_TYPE: number;
  1135. /**
  1136. * Prefixes used by the engine for custom effects
  1137. */
  1138. static readonly CUSTOMEFFECT_PREFIX_SHADOWGENERATOR: string;
  1139. }
  1140. }
  1141. declare module BABYLON {
  1142. /** @hidden */
  1143. export interface HardwareTextureWrapper {
  1144. underlyingResource: any;
  1145. set(hardwareTexture: any): void;
  1146. setUsage(textureSource: number, generateMipMaps: boolean, isCube: boolean, width: number, height: number): void;
  1147. reset(): void;
  1148. release(): void;
  1149. }
  1150. }
  1151. declare module BABYLON {
  1152. /**
  1153. * This represents the required contract to create a new type of texture loader.
  1154. */
  1155. export interface IInternalTextureLoader {
  1156. /**
  1157. * Defines whether the loader supports cascade loading the different faces.
  1158. */
  1159. supportCascades: boolean;
  1160. /**
  1161. * This returns if the loader support the current file information.
  1162. * @param extension defines the file extension of the file being loaded
  1163. * @param mimeType defines the optional mime type of the file being loaded
  1164. * @returns true if the loader can load the specified file
  1165. */
  1166. canLoad(extension: string, mimeType?: string): boolean;
  1167. /**
  1168. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  1169. * @param data contains the texture data
  1170. * @param texture defines the BabylonJS internal texture
  1171. * @param createPolynomials will be true if polynomials have been requested
  1172. * @param onLoad defines the callback to trigger once the texture is ready
  1173. * @param onError defines the callback to trigger in case of error
  1174. * @param options options to be passed to the loader
  1175. */
  1176. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>, options?: any): void;
  1177. /**
  1178. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  1179. * @param data contains the texture data
  1180. * @param texture defines the BabylonJS internal texture
  1181. * @param callback defines the method to call once ready to upload
  1182. * @param options options to be passed to the loader
  1183. */
  1184. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed?: boolean) => void, options?: any): void;
  1185. }
  1186. }
  1187. declare module BABYLON {
  1188. /**
  1189. * @hidden
  1190. */
  1191. export interface IColor4Like {
  1192. r: float;
  1193. g: float;
  1194. b: float;
  1195. a: float;
  1196. }
  1197. /**
  1198. * @hidden
  1199. */
  1200. export interface IColor3Like {
  1201. r: float;
  1202. g: float;
  1203. b: float;
  1204. }
  1205. /**
  1206. * @hidden
  1207. */
  1208. export interface IVector4Like {
  1209. x: float;
  1210. y: float;
  1211. z: float;
  1212. w: float;
  1213. }
  1214. /**
  1215. * @hidden
  1216. */
  1217. export interface IVector3Like {
  1218. x: float;
  1219. y: float;
  1220. z: float;
  1221. }
  1222. /**
  1223. * @hidden
  1224. */
  1225. export interface IVector2Like {
  1226. x: float;
  1227. y: float;
  1228. }
  1229. /**
  1230. * @hidden
  1231. */
  1232. export interface IMatrixLike {
  1233. toArray(): DeepImmutable<Float32Array | Array<number>>;
  1234. updateFlag: int;
  1235. }
  1236. /**
  1237. * @hidden
  1238. */
  1239. export interface IViewportLike {
  1240. x: float;
  1241. y: float;
  1242. width: float;
  1243. height: float;
  1244. }
  1245. /**
  1246. * @hidden
  1247. */
  1248. export interface IPlaneLike {
  1249. normal: IVector3Like;
  1250. d: float;
  1251. normalize(): void;
  1252. }
  1253. }
  1254. declare module BABYLON {
  1255. /**
  1256. * Class used to store and describe the pipeline context associated with an effect
  1257. */
  1258. export interface IPipelineContext {
  1259. /**
  1260. * Gets a boolean indicating that this pipeline context is supporting asynchronous creating
  1261. */
  1262. isAsync: boolean;
  1263. /**
  1264. * Gets a boolean indicating that the context is ready to be used (like shaders / pipelines are compiled and ready for instance)
  1265. */
  1266. isReady: boolean;
  1267. /** @hidden */
  1268. _name?: string;
  1269. /** @hidden */
  1270. _getVertexShaderCode(): string | null;
  1271. /** @hidden */
  1272. _getFragmentShaderCode(): string | null;
  1273. /** @hidden */
  1274. _handlesSpectorRebuildCallback(onCompiled: (compiledObject: any) => void): void;
  1275. /** @hidden */
  1276. _fillEffectInformation(effect: Effect, uniformBuffersNames: {
  1277. [key: string]: number;
  1278. }, uniformsNames: string[], uniforms: {
  1279. [key: string]: Nullable<WebGLUniformLocation>;
  1280. }, samplerList: string[], samplers: {
  1281. [key: string]: number;
  1282. }, attributesNames: string[], attributes: number[]): void;
  1283. /** Releases the resources associated with the pipeline. */
  1284. dispose(): void;
  1285. /**
  1286. * Sets an integer value on a uniform variable.
  1287. * @param uniformName Name of the variable.
  1288. * @param value Value to be set.
  1289. */
  1290. setInt(uniformName: string, value: number): void;
  1291. /**
  1292. * Sets an int2 value on a uniform variable.
  1293. * @param uniformName Name of the variable.
  1294. * @param x First int in int2.
  1295. * @param y Second int in int2.
  1296. */
  1297. setInt2(uniformName: string, x: number, y: number): void;
  1298. /**
  1299. * Sets an int3 value on a uniform variable.
  1300. * @param uniformName Name of the variable.
  1301. * @param x First int in int3.
  1302. * @param y Second int in int3.
  1303. * @param z Third int in int3.
  1304. */
  1305. setInt3(uniformName: string, x: number, y: number, z: number): void;
  1306. /**
  1307. * Sets an int4 value on a uniform variable.
  1308. * @param uniformName Name of the variable.
  1309. * @param x First int in int4.
  1310. * @param y Second int in int4.
  1311. * @param z Third int in int4.
  1312. * @param w Fourth int in int4.
  1313. */
  1314. setInt4(uniformName: string, x: number, y: number, z: number, w: number): void;
  1315. /**
  1316. * Sets an int array on a uniform variable.
  1317. * @param uniformName Name of the variable.
  1318. * @param array array to be set.
  1319. */
  1320. setIntArray(uniformName: string, array: Int32Array): void;
  1321. /**
  1322. * Sets an int array 2 on a uniform variable. (Array is specified as single array eg. [1,2,3,4] will result in [[1,2],[3,4]] in the shader)
  1323. * @param uniformName Name of the variable.
  1324. * @param array array to be set.
  1325. */
  1326. setIntArray2(uniformName: string, array: Int32Array): void;
  1327. /**
  1328. * Sets an int array 3 on a uniform variable. (Array is specified as single array eg. [1,2,3,4,5,6] will result in [[1,2,3],[4,5,6]] in the shader)
  1329. * @param uniformName Name of the variable.
  1330. * @param array array to be set.
  1331. */
  1332. setIntArray3(uniformName: string, array: Int32Array): void;
  1333. /**
  1334. * Sets an int array 4 on a uniform variable. (Array is specified as single array eg. [1,2,3,4,5,6,7,8] will result in [[1,2,3,4],[5,6,7,8]] in the shader)
  1335. * @param uniformName Name of the variable.
  1336. * @param array array to be set.
  1337. */
  1338. setIntArray4(uniformName: string, array: Int32Array): void;
  1339. /**
  1340. * Sets an array on a uniform variable.
  1341. * @param uniformName Name of the variable.
  1342. * @param array array to be set.
  1343. */
  1344. setArray(uniformName: string, array: number[] | Float32Array): void;
  1345. /**
  1346. * Sets an array 2 on a uniform variable. (Array is specified as single array eg. [1,2,3,4] will result in [[1,2],[3,4]] in the shader)
  1347. * @param uniformName Name of the variable.
  1348. * @param array array to be set.
  1349. */
  1350. setArray2(uniformName: string, array: number[] | Float32Array): void;
  1351. /**
  1352. * Sets an array 3 on a uniform variable. (Array is specified as single array eg. [1,2,3,4,5,6] will result in [[1,2,3],[4,5,6]] in the shader)
  1353. * @param uniformName Name of the variable.
  1354. * @param array array to be set.
  1355. */
  1356. setArray3(uniformName: string, array: number[] | Float32Array): void;
  1357. /**
  1358. * Sets an array 4 on a uniform variable. (Array is specified as single array eg. [1,2,3,4,5,6,7,8] will result in [[1,2,3,4],[5,6,7,8]] in the shader)
  1359. * @param uniformName Name of the variable.
  1360. * @param array array to be set.
  1361. */
  1362. setArray4(uniformName: string, array: number[] | Float32Array): void;
  1363. /**
  1364. * Sets matrices on a uniform variable.
  1365. * @param uniformName Name of the variable.
  1366. * @param matrices matrices to be set.
  1367. */
  1368. setMatrices(uniformName: string, matrices: Float32Array): void;
  1369. /**
  1370. * Sets matrix on a uniform variable.
  1371. * @param uniformName Name of the variable.
  1372. * @param matrix matrix to be set.
  1373. */
  1374. setMatrix(uniformName: string, matrix: IMatrixLike): void;
  1375. /**
  1376. * Sets a 3x3 matrix on a uniform variable. (Specified as [1,2,3,4,5,6,7,8,9] will result in [1,2,3][4,5,6][7,8,9] matrix)
  1377. * @param uniformName Name of the variable.
  1378. * @param matrix matrix to be set.
  1379. */
  1380. setMatrix3x3(uniformName: string, matrix: Float32Array): void;
  1381. /**
  1382. * Sets a 2x2 matrix on a uniform variable. (Specified as [1,2,3,4] will result in [1,2][3,4] matrix)
  1383. * @param uniformName Name of the variable.
  1384. * @param matrix matrix to be set.
  1385. */
  1386. setMatrix2x2(uniformName: string, matrix: Float32Array): void;
  1387. /**
  1388. * Sets a float on a uniform variable.
  1389. * @param uniformName Name of the variable.
  1390. * @param value value to be set.
  1391. */
  1392. setFloat(uniformName: string, value: number): void;
  1393. /**
  1394. * Sets a Vector2 on a uniform variable.
  1395. * @param uniformName Name of the variable.
  1396. * @param vector2 vector2 to be set.
  1397. */
  1398. setVector2(uniformName: string, vector2: IVector2Like): void;
  1399. /**
  1400. * Sets a float2 on a uniform variable.
  1401. * @param uniformName Name of the variable.
  1402. * @param x First float in float2.
  1403. * @param y Second float in float2.
  1404. */
  1405. setFloat2(uniformName: string, x: number, y: number): void;
  1406. /**
  1407. * Sets a Vector3 on a uniform variable.
  1408. * @param uniformName Name of the variable.
  1409. * @param vector3 Value to be set.
  1410. */
  1411. setVector3(uniformName: string, vector3: IVector3Like): void;
  1412. /**
  1413. * Sets a float3 on a uniform variable.
  1414. * @param uniformName Name of the variable.
  1415. * @param x First float in float3.
  1416. * @param y Second float in float3.
  1417. * @param z Third float in float3.
  1418. */
  1419. setFloat3(uniformName: string, x: number, y: number, z: number): void;
  1420. /**
  1421. * Sets a Vector4 on a uniform variable.
  1422. * @param uniformName Name of the variable.
  1423. * @param vector4 Value to be set.
  1424. */
  1425. setVector4(uniformName: string, vector4: IVector4Like): void;
  1426. /**
  1427. * Sets a float4 on a uniform variable.
  1428. * @param uniformName Name of the variable.
  1429. * @param x First float in float4.
  1430. * @param y Second float in float4.
  1431. * @param z Third float in float4.
  1432. * @param w Fourth float in float4.
  1433. */
  1434. setFloat4(uniformName: string, x: number, y: number, z: number, w: number): void;
  1435. /**
  1436. * Sets a Color3 on a uniform variable.
  1437. * @param uniformName Name of the variable.
  1438. * @param color3 Value to be set.
  1439. */
  1440. setColor3(uniformName: string, color3: IColor3Like): void;
  1441. /**
  1442. * Sets a Color4 on a uniform variable.
  1443. * @param uniformName Name of the variable.
  1444. * @param color3 Value to be set.
  1445. * @param alpha Alpha value to be set.
  1446. */
  1447. setColor4(uniformName: string, color3: IColor3Like, alpha: number): void;
  1448. /**
  1449. * Sets a Color4 on a uniform variable
  1450. * @param uniformName defines the name of the variable
  1451. * @param color4 defines the value to be set
  1452. */
  1453. setDirectColor4(uniformName: string, color4: IColor4Like): void;
  1454. }
  1455. }
  1456. declare module BABYLON {
  1457. /**
  1458. * Class used to store gfx data (like WebGLBuffer)
  1459. */
  1460. export class DataBuffer {
  1461. private static _Counter;
  1462. /**
  1463. * Gets or sets the number of objects referencing this buffer
  1464. */
  1465. references: number;
  1466. /** Gets or sets the size of the underlying buffer */
  1467. capacity: number;
  1468. /**
  1469. * Gets or sets a boolean indicating if the buffer contains 32bits indices
  1470. */
  1471. is32Bits: boolean;
  1472. /**
  1473. * Gets the underlying buffer
  1474. */
  1475. get underlyingResource(): any;
  1476. /**
  1477. * Gets the unique id of this buffer
  1478. */
  1479. readonly uniqueId: number;
  1480. /**
  1481. * Constructs the buffer
  1482. */
  1483. constructor();
  1484. }
  1485. }
  1486. declare module BABYLON {
  1487. /** @hidden */
  1488. export interface IShaderProcessor {
  1489. attributeProcessor?: (attribute: string, preProcessors: {
  1490. [key: string]: string;
  1491. }, processingContext: Nullable<ShaderProcessingContext>) => string;
  1492. varyingProcessor?: (varying: string, isFragment: boolean, preProcessors: {
  1493. [key: string]: string;
  1494. }, processingContext: Nullable<ShaderProcessingContext>) => string;
  1495. uniformProcessor?: (uniform: string, isFragment: boolean, preProcessors: {
  1496. [key: string]: string;
  1497. }, processingContext: Nullable<ShaderProcessingContext>) => string;
  1498. uniformBufferProcessor?: (uniformBuffer: string, isFragment: boolean, processingContext: Nullable<ShaderProcessingContext>) => string;
  1499. endOfUniformBufferProcessor?: (closingBracketLine: string, isFragment: boolean, processingContext: Nullable<ShaderProcessingContext>) => string;
  1500. lineProcessor?: (line: string, isFragment: boolean, processingContext: Nullable<ShaderProcessingContext>) => string;
  1501. preProcessor?: (code: string, defines: string[], isFragment: boolean, processingContext: Nullable<ShaderProcessingContext>) => string;
  1502. postProcessor?: (code: string, defines: string[], isFragment: boolean, processingContext: Nullable<ShaderProcessingContext>, engine: ThinEngine) => string;
  1503. initializeShaders?: (processingContext: Nullable<ShaderProcessingContext>) => void;
  1504. finalizeShaders?: (vertexCode: string, fragmentCode: string, processingContext: Nullable<ShaderProcessingContext>) => {
  1505. vertexCode: string;
  1506. fragmentCode: string;
  1507. };
  1508. }
  1509. }
  1510. declare module BABYLON {
  1511. /** @hidden */
  1512. export interface ShaderProcessingContext {
  1513. }
  1514. /** @hidden */
  1515. export interface ProcessingOptions {
  1516. defines: string[];
  1517. indexParameters: any;
  1518. isFragment: boolean;
  1519. shouldUseHighPrecisionShader: boolean;
  1520. supportsUniformBuffers: boolean;
  1521. shadersRepository: string;
  1522. includesShadersStore: {
  1523. [key: string]: string;
  1524. };
  1525. processor: Nullable<IShaderProcessor>;
  1526. version: string;
  1527. platformName: string;
  1528. lookForClosingBracketForUniformBuffer?: boolean;
  1529. processingContext: Nullable<ShaderProcessingContext>;
  1530. }
  1531. }
  1532. declare module BABYLON {
  1533. /** @hidden */
  1534. export class ShaderCodeNode {
  1535. line: string;
  1536. children: ShaderCodeNode[];
  1537. additionalDefineKey?: string;
  1538. additionalDefineValue?: string;
  1539. isValid(preprocessors: {
  1540. [key: string]: string;
  1541. }): boolean;
  1542. process(preprocessors: {
  1543. [key: string]: string;
  1544. }, options: ProcessingOptions): string;
  1545. }
  1546. }
  1547. declare module BABYLON {
  1548. /** @hidden */
  1549. export class ShaderCodeCursor {
  1550. private _lines;
  1551. lineIndex: number;
  1552. get currentLine(): string;
  1553. get canRead(): boolean;
  1554. set lines(value: string[]);
  1555. }
  1556. }
  1557. declare module BABYLON {
  1558. /** @hidden */
  1559. export class ShaderCodeConditionNode extends ShaderCodeNode {
  1560. process(preprocessors: {
  1561. [key: string]: string;
  1562. }, options: ProcessingOptions): string;
  1563. }
  1564. }
  1565. declare module BABYLON {
  1566. /** @hidden */
  1567. export class ShaderDefineExpression {
  1568. isTrue(preprocessors: {
  1569. [key: string]: string;
  1570. }): boolean;
  1571. private static _OperatorPriority;
  1572. private static _Stack;
  1573. static postfixToInfix(postfix: string[]): string;
  1574. static infixToPostfix(infix: string): string[];
  1575. }
  1576. }
  1577. declare module BABYLON {
  1578. /** @hidden */
  1579. export class ShaderCodeTestNode extends ShaderCodeNode {
  1580. testExpression: ShaderDefineExpression;
  1581. isValid(preprocessors: {
  1582. [key: string]: string;
  1583. }): boolean;
  1584. }
  1585. }
  1586. declare module BABYLON {
  1587. /** @hidden */
  1588. export class ShaderDefineIsDefinedOperator extends ShaderDefineExpression {
  1589. define: string;
  1590. not: boolean;
  1591. constructor(define: string, not?: boolean);
  1592. isTrue(preprocessors: {
  1593. [key: string]: string;
  1594. }): boolean;
  1595. }
  1596. }
  1597. declare module BABYLON {
  1598. /** @hidden */
  1599. export class ShaderDefineOrOperator extends ShaderDefineExpression {
  1600. leftOperand: ShaderDefineExpression;
  1601. rightOperand: ShaderDefineExpression;
  1602. isTrue(preprocessors: {
  1603. [key: string]: string;
  1604. }): boolean;
  1605. }
  1606. }
  1607. declare module BABYLON {
  1608. /** @hidden */
  1609. export class ShaderDefineAndOperator extends ShaderDefineExpression {
  1610. leftOperand: ShaderDefineExpression;
  1611. rightOperand: ShaderDefineExpression;
  1612. isTrue(preprocessors: {
  1613. [key: string]: string;
  1614. }): boolean;
  1615. }
  1616. }
  1617. declare module BABYLON {
  1618. /** @hidden */
  1619. export class ShaderDefineArithmeticOperator extends ShaderDefineExpression {
  1620. define: string;
  1621. operand: string;
  1622. testValue: string;
  1623. constructor(define: string, operand: string, testValue: string);
  1624. isTrue(preprocessors: {
  1625. [key: string]: string;
  1626. }): boolean;
  1627. }
  1628. }
  1629. declare module BABYLON {
  1630. /**
  1631. * Class used to enable access to offline support
  1632. * @see https://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  1633. */
  1634. export interface IOfflineProvider {
  1635. /**
  1636. * Gets a boolean indicating if scene must be saved in the database
  1637. */
  1638. enableSceneOffline: boolean;
  1639. /**
  1640. * Gets a boolean indicating if textures must be saved in the database
  1641. */
  1642. enableTexturesOffline: boolean;
  1643. /**
  1644. * Open the offline support and make it available
  1645. * @param successCallback defines the callback to call on success
  1646. * @param errorCallback defines the callback to call on error
  1647. */
  1648. open(successCallback: () => void, errorCallback: () => void): void;
  1649. /**
  1650. * Loads an image from the offline support
  1651. * @param url defines the url to load from
  1652. * @param image defines the target DOM image
  1653. */
  1654. loadImage(url: string, image: HTMLImageElement): void;
  1655. /**
  1656. * Loads a file from offline support
  1657. * @param url defines the URL to load from
  1658. * @param sceneLoaded defines a callback to call on success
  1659. * @param progressCallBack defines a callback to call when progress changed
  1660. * @param errorCallback defines a callback to call on error
  1661. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  1662. */
  1663. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  1664. }
  1665. }
  1666. declare module BABYLON {
  1667. /**
  1668. * Class used to help managing file picking and drag'n'drop
  1669. * File Storage
  1670. */
  1671. export class FilesInputStore {
  1672. /**
  1673. * List of files ready to be loaded
  1674. */
  1675. static FilesToLoad: {
  1676. [key: string]: File;
  1677. };
  1678. }
  1679. }
  1680. declare module BABYLON {
  1681. /**
  1682. * Class used to define a retry strategy when error happens while loading assets
  1683. */
  1684. export class RetryStrategy {
  1685. /**
  1686. * Function used to defines an exponential back off strategy
  1687. * @param maxRetries defines the maximum number of retries (3 by default)
  1688. * @param baseInterval defines the interval between retries
  1689. * @returns the strategy function to use
  1690. */
  1691. static ExponentialBackoff(maxRetries?: number, baseInterval?: number): (url: string, request: WebRequest, retryIndex: number) => number;
  1692. }
  1693. }
  1694. declare module BABYLON {
  1695. /**
  1696. * @ignore
  1697. * Application error to support additional information when loading a file
  1698. */
  1699. export abstract class BaseError extends Error {
  1700. protected static _setPrototypeOf: (o: any, proto: object | null) => any;
  1701. }
  1702. }
  1703. declare module BABYLON {
  1704. /** @ignore */
  1705. export class LoadFileError extends BaseError {
  1706. request?: WebRequest;
  1707. file?: File;
  1708. /**
  1709. * Creates a new LoadFileError
  1710. * @param message defines the message of the error
  1711. * @param request defines the optional web request
  1712. * @param file defines the optional file
  1713. */
  1714. constructor(message: string, object?: WebRequest | File);
  1715. }
  1716. /** @ignore */
  1717. export class RequestFileError extends BaseError {
  1718. request: WebRequest;
  1719. /**
  1720. * Creates a new LoadFileError
  1721. * @param message defines the message of the error
  1722. * @param request defines the optional web request
  1723. */
  1724. constructor(message: string, request: WebRequest);
  1725. }
  1726. /** @ignore */
  1727. export class ReadFileError extends BaseError {
  1728. file: File;
  1729. /**
  1730. * Creates a new ReadFileError
  1731. * @param message defines the message of the error
  1732. * @param file defines the optional file
  1733. */
  1734. constructor(message: string, file: File);
  1735. }
  1736. /**
  1737. * @hidden
  1738. */
  1739. export class FileTools {
  1740. /**
  1741. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  1742. */
  1743. static DefaultRetryStrategy: (url: string, request: WebRequest, retryIndex: number) => number;
  1744. /**
  1745. * Gets or sets the base URL to use to load assets
  1746. */
  1747. static BaseUrl: string;
  1748. /**
  1749. * Default behaviour for cors in the application.
  1750. * It can be a string if the expected behavior is identical in the entire app.
  1751. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  1752. */
  1753. static CorsBehavior: string | ((url: string | string[]) => string);
  1754. /**
  1755. * Gets or sets a function used to pre-process url before using them to load assets
  1756. */
  1757. static PreprocessUrl: (url: string) => string;
  1758. /**
  1759. * Removes unwanted characters from an url
  1760. * @param url defines the url to clean
  1761. * @returns the cleaned url
  1762. */
  1763. private static _CleanUrl;
  1764. /**
  1765. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  1766. * @param url define the url we are trying
  1767. * @param element define the dom element where to configure the cors policy
  1768. */
  1769. static SetCorsBehavior(url: string | string[], element: {
  1770. crossOrigin: string | null;
  1771. }): void;
  1772. /**
  1773. * Loads an image as an HTMLImageElement.
  1774. * @param input url string, ArrayBuffer, or Blob to load
  1775. * @param onLoad callback called when the image successfully loads
  1776. * @param onError callback called when the image fails to load
  1777. * @param offlineProvider offline provider for caching
  1778. * @param mimeType optional mime type
  1779. * @returns the HTMLImageElement of the loaded image
  1780. */
  1781. static LoadImage(input: string | ArrayBuffer | ArrayBufferView | Blob, onLoad: (img: HTMLImageElement | ImageBitmap) => void, onError: (message?: string, exception?: any) => void, offlineProvider: Nullable<IOfflineProvider>, mimeType?: string): Nullable<HTMLImageElement>;
  1782. /**
  1783. * Reads a file from a File object
  1784. * @param file defines the file to load
  1785. * @param onSuccess defines the callback to call when data is loaded
  1786. * @param onProgress defines the callback to call during loading process
  1787. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  1788. * @param onError defines the callback to call when an error occurs
  1789. * @returns a file request object
  1790. */
  1791. static ReadFile(file: File, onSuccess: (data: any) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: ReadFileError) => void): IFileRequest;
  1792. /**
  1793. * Loads a file from a url
  1794. * @param url url to load
  1795. * @param onSuccess callback called when the file successfully loads
  1796. * @param onProgress callback called while file is loading (if the server supports this mode)
  1797. * @param offlineProvider defines the offline provider for caching
  1798. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  1799. * @param onError callback called when the file fails to load
  1800. * @returns a file request object
  1801. */
  1802. static LoadFile(url: string, onSuccess: (data: string | ArrayBuffer, responseURL?: string) => void, onProgress?: (ev: ProgressEvent) => void, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean, onError?: (request?: WebRequest, exception?: LoadFileError) => void): IFileRequest;
  1803. /**
  1804. * Loads a file
  1805. * @param url url to load
  1806. * @param onSuccess callback called when the file successfully loads
  1807. * @param onProgress callback called while file is loading (if the server supports this mode)
  1808. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  1809. * @param onError callback called when the file fails to load
  1810. * @param onOpened callback called when the web request is opened
  1811. * @returns a file request object
  1812. */
  1813. static RequestFile(url: string, onSuccess: (data: string | ArrayBuffer, request?: WebRequest) => void, onProgress?: (event: ProgressEvent) => void, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean, onError?: (error: RequestFileError) => void, onOpened?: (request: WebRequest) => void): IFileRequest;
  1814. /**
  1815. * Checks if the loaded document was accessed via `file:`-Protocol.
  1816. * @returns boolean
  1817. */
  1818. static IsFileURL(): boolean;
  1819. }
  1820. }
  1821. declare module BABYLON {
  1822. /** @hidden */
  1823. export class ShaderProcessor {
  1824. static Initialize(options: ProcessingOptions): void;
  1825. static Process(sourceCode: string, options: ProcessingOptions, callback: (migratedCode: string) => void, engine: ThinEngine): void;
  1826. static Finalize(vertexCode: string, fragmentCode: string, options: ProcessingOptions): {
  1827. vertexCode: string;
  1828. fragmentCode: string;
  1829. };
  1830. private static _ProcessPrecision;
  1831. private static _ExtractOperation;
  1832. private static _BuildSubExpression;
  1833. private static _BuildExpression;
  1834. private static _MoveCursorWithinIf;
  1835. private static _MoveCursor;
  1836. private static _EvaluatePreProcessors;
  1837. private static _PreparePreProcessors;
  1838. private static _ProcessShaderConversion;
  1839. private static _ProcessIncludes;
  1840. /**
  1841. * Loads a file from a url
  1842. * @param url url to load
  1843. * @param onSuccess callback called when the file successfully loads
  1844. * @param onProgress callback called while file is loading (if the server supports this mode)
  1845. * @param offlineProvider defines the offline provider for caching
  1846. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  1847. * @param onError callback called when the file fails to load
  1848. * @returns a file request object
  1849. * @hidden
  1850. */
  1851. static _FileToolsLoadFile(url: string, onSuccess: (data: string | ArrayBuffer, responseURL?: string) => void, onProgress?: (ev: ProgressEvent) => void, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean, onError?: (request?: WebRequest, exception?: LoadFileError) => void): IFileRequest;
  1852. }
  1853. }
  1854. declare module BABYLON {
  1855. /**
  1856. * Interface used to define common properties for effect fallbacks
  1857. */
  1858. export interface IEffectFallbacks {
  1859. /**
  1860. * Removes the defines that should be removed when falling back.
  1861. * @param currentDefines defines the current define statements for the shader.
  1862. * @param effect defines the current effect we try to compile
  1863. * @returns The resulting defines with defines of the current rank removed.
  1864. */
  1865. reduce(currentDefines: string, effect: Effect): string;
  1866. /**
  1867. * Removes the fallback from the bound mesh.
  1868. */
  1869. unBindMesh(): void;
  1870. /**
  1871. * Checks to see if more fallbacks are still available.
  1872. */
  1873. hasMoreFallbacks: boolean;
  1874. }
  1875. }
  1876. declare module BABYLON {
  1877. /**
  1878. * Interface for the size containing width and height
  1879. */
  1880. export interface ISize {
  1881. /**
  1882. * Width
  1883. */
  1884. width: number;
  1885. /**
  1886. * Heighht
  1887. */
  1888. height: number;
  1889. }
  1890. /**
  1891. * Size containing widht and height
  1892. */
  1893. export class Size implements ISize {
  1894. /**
  1895. * Width
  1896. */
  1897. width: number;
  1898. /**
  1899. * Height
  1900. */
  1901. height: number;
  1902. /**
  1903. * Creates a Size object from the given width and height (floats).
  1904. * @param width width of the new size
  1905. * @param height height of the new size
  1906. */
  1907. constructor(width: number, height: number);
  1908. /**
  1909. * Returns a string with the Size width and height
  1910. * @returns a string with the Size width and height
  1911. */
  1912. toString(): string;
  1913. /**
  1914. * "Size"
  1915. * @returns the string "Size"
  1916. */
  1917. getClassName(): string;
  1918. /**
  1919. * Returns the Size hash code.
  1920. * @returns a hash code for a unique width and height
  1921. */
  1922. getHashCode(): number;
  1923. /**
  1924. * Updates the current size from the given one.
  1925. * @param src the given size
  1926. */
  1927. copyFrom(src: Size): void;
  1928. /**
  1929. * Updates in place the current Size from the given floats.
  1930. * @param width width of the new size
  1931. * @param height height of the new size
  1932. * @returns the updated Size.
  1933. */
  1934. copyFromFloats(width: number, height: number): Size;
  1935. /**
  1936. * Updates in place the current Size from the given floats.
  1937. * @param width width to set
  1938. * @param height height to set
  1939. * @returns the updated Size.
  1940. */
  1941. set(width: number, height: number): Size;
  1942. /**
  1943. * Multiplies the width and height by numbers
  1944. * @param w factor to multiple the width by
  1945. * @param h factor to multiple the height by
  1946. * @returns a new Size set with the multiplication result of the current Size and the given floats.
  1947. */
  1948. multiplyByFloats(w: number, h: number): Size;
  1949. /**
  1950. * Clones the size
  1951. * @returns a new Size copied from the given one.
  1952. */
  1953. clone(): Size;
  1954. /**
  1955. * True if the current Size and the given one width and height are strictly equal.
  1956. * @param other the other size to compare against
  1957. * @returns True if the current Size and the given one width and height are strictly equal.
  1958. */
  1959. equals(other: Size): boolean;
  1960. /**
  1961. * The surface of the Size : width * height (float).
  1962. */
  1963. get surface(): number;
  1964. /**
  1965. * Create a new size of zero
  1966. * @returns a new Size set to (0.0, 0.0)
  1967. */
  1968. static Zero(): Size;
  1969. /**
  1970. * Sums the width and height of two sizes
  1971. * @param otherSize size to add to this size
  1972. * @returns a new Size set as the addition result of the current Size and the given one.
  1973. */
  1974. add(otherSize: Size): Size;
  1975. /**
  1976. * Subtracts the width and height of two
  1977. * @param otherSize size to subtract to this size
  1978. * @returns a new Size set as the subtraction result of the given one from the current Size.
  1979. */
  1980. subtract(otherSize: Size): Size;
  1981. /**
  1982. * Creates a new Size set at the linear interpolation "amount" between "start" and "end"
  1983. * @param start starting size to lerp between
  1984. * @param end end size to lerp between
  1985. * @param amount amount to lerp between the start and end values
  1986. * @returns a new Size set at the linear interpolation "amount" between "start" and "end"
  1987. */
  1988. static Lerp(start: Size, end: Size, amount: number): Size;
  1989. }
  1990. }
  1991. declare module BABYLON {
  1992. /**
  1993. * Base class of all the textures in babylon.
  1994. * It groups all the common properties required to work with Thin Engine.
  1995. */
  1996. export class ThinTexture {
  1997. protected _wrapU: number;
  1998. /**
  1999. * | Value | Type | Description |
  2000. * | ----- | ------------------ | ----------- |
  2001. * | 0 | CLAMP_ADDRESSMODE | |
  2002. * | 1 | WRAP_ADDRESSMODE | |
  2003. * | 2 | MIRROR_ADDRESSMODE | |
  2004. */
  2005. get wrapU(): number;
  2006. set wrapU(value: number);
  2007. protected _wrapV: number;
  2008. /**
  2009. * | Value | Type | Description |
  2010. * | ----- | ------------------ | ----------- |
  2011. * | 0 | CLAMP_ADDRESSMODE | |
  2012. * | 1 | WRAP_ADDRESSMODE | |
  2013. * | 2 | MIRROR_ADDRESSMODE | |
  2014. */
  2015. get wrapV(): number;
  2016. set wrapV(value: number);
  2017. /**
  2018. * | Value | Type | Description |
  2019. * | ----- | ------------------ | ----------- |
  2020. * | 0 | CLAMP_ADDRESSMODE | |
  2021. * | 1 | WRAP_ADDRESSMODE | |
  2022. * | 2 | MIRROR_ADDRESSMODE | |
  2023. */
  2024. wrapR: number;
  2025. /**
  2026. * With compliant hardware and browser (supporting anisotropic filtering)
  2027. * this defines the level of anisotropic filtering in the texture.
  2028. * The higher the better but the slower. This defaults to 4 as it seems to be the best tradeoff.
  2029. */
  2030. anisotropicFilteringLevel: number;
  2031. /**
  2032. * Define the current state of the loading sequence when in delayed load mode.
  2033. */
  2034. delayLoadState: number;
  2035. /**
  2036. * How a texture is mapped.
  2037. * Unused in thin texture mode.
  2038. */
  2039. get coordinatesMode(): number;
  2040. /**
  2041. * Define if the texture is a cube texture or if false a 2d texture.
  2042. */
  2043. get isCube(): boolean;
  2044. set isCube(value: boolean);
  2045. /**
  2046. * Define if the texture is a 3d texture (webgl 2) or if false a 2d texture.
  2047. */
  2048. get is3D(): boolean;
  2049. set is3D(value: boolean);
  2050. /**
  2051. * Define if the texture is a 2d array texture (webgl 2) or if false a 2d texture.
  2052. */
  2053. get is2DArray(): boolean;
  2054. set is2DArray(value: boolean);
  2055. /**
  2056. * Get the class name of the texture.
  2057. * @returns "ThinTexture"
  2058. */
  2059. getClassName(): string;
  2060. /** @hidden */
  2061. _texture: Nullable<InternalTexture>;
  2062. protected _engine: Nullable<ThinEngine>;
  2063. private _cachedSize;
  2064. private _cachedBaseSize;
  2065. /**
  2066. * Instantiates a new ThinTexture.
  2067. * Base class of all the textures in babylon.
  2068. * This can be used as an internal texture wrapper in ThinEngine to benefit from the cache
  2069. * @param internalTexture Define the internalTexture to wrap
  2070. */
  2071. constructor(internalTexture: Nullable<InternalTexture>);
  2072. /**
  2073. * Get if the texture is ready to be used (downloaded, converted, mip mapped...).
  2074. * @returns true if fully ready
  2075. */
  2076. isReady(): boolean;
  2077. /**
  2078. * Triggers the load sequence in delayed load mode.
  2079. */
  2080. delayLoad(): void;
  2081. /**
  2082. * Get the underlying lower level texture from Babylon.
  2083. * @returns the internal texture
  2084. */
  2085. getInternalTexture(): Nullable<InternalTexture>;
  2086. /**
  2087. * Get the size of the texture.
  2088. * @returns the texture size.
  2089. */
  2090. getSize(): ISize;
  2091. /**
  2092. * Get the base size of the texture.
  2093. * It can be different from the size if the texture has been resized for POT for instance
  2094. * @returns the base size
  2095. */
  2096. getBaseSize(): ISize;
  2097. /**
  2098. * Update the sampling mode of the texture.
  2099. * Default is Trilinear mode.
  2100. *
  2101. * | Value | Type | Description |
  2102. * | ----- | ------------------ | ----------- |
  2103. * | 1 | NEAREST_SAMPLINGMODE or NEAREST_NEAREST_MIPLINEAR | Nearest is: mag = nearest, min = nearest, mip = linear |
  2104. * | 2 | BILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPNEAREST | Bilinear is: mag = linear, min = linear, mip = nearest |
  2105. * | 3 | TRILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPLINEAR | Trilinear is: mag = linear, min = linear, mip = linear |
  2106. * | 4 | NEAREST_NEAREST_MIPNEAREST | |
  2107. * | 5 | NEAREST_LINEAR_MIPNEAREST | |
  2108. * | 6 | NEAREST_LINEAR_MIPLINEAR | |
  2109. * | 7 | NEAREST_LINEAR | |
  2110. * | 8 | NEAREST_NEAREST | |
  2111. * | 9 | LINEAR_NEAREST_MIPNEAREST | |
  2112. * | 10 | LINEAR_NEAREST_MIPLINEAR | |
  2113. * | 11 | LINEAR_LINEAR | |
  2114. * | 12 | LINEAR_NEAREST | |
  2115. *
  2116. * > _mag_: magnification filter (close to the viewer)
  2117. * > _min_: minification filter (far from the viewer)
  2118. * > _mip_: filter used between mip map levels
  2119. *@param samplingMode Define the new sampling mode of the texture
  2120. */
  2121. updateSamplingMode(samplingMode: number): void;
  2122. /**
  2123. * Release and destroy the underlying lower level texture aka internalTexture.
  2124. */
  2125. releaseInternalTexture(): void;
  2126. /**
  2127. * Dispose the texture and release its associated resources.
  2128. */
  2129. dispose(): void;
  2130. }
  2131. }
  2132. declare module BABYLON {
  2133. /**
  2134. * Defines an array and its length.
  2135. * It can be helpful to group result from both Arrays and smart arrays in one structure.
  2136. */
  2137. export interface ISmartArrayLike<T> {
  2138. /**
  2139. * The data of the array.
  2140. */
  2141. data: Array<T>;
  2142. /**
  2143. * The active length of the array.
  2144. */
  2145. length: number;
  2146. }
  2147. /**
  2148. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  2149. */
  2150. export class SmartArray<T> implements ISmartArrayLike<T> {
  2151. /**
  2152. * The full set of data from the array.
  2153. */
  2154. data: Array<T>;
  2155. /**
  2156. * The active length of the array.
  2157. */
  2158. length: number;
  2159. protected _id: number;
  2160. /**
  2161. * Instantiates a Smart Array.
  2162. * @param capacity defines the default capacity of the array.
  2163. */
  2164. constructor(capacity: number);
  2165. /**
  2166. * Pushes a value at the end of the active data.
  2167. * @param value defines the object to push in the array.
  2168. */
  2169. push(value: T): void;
  2170. /**
  2171. * Iterates over the active data and apply the lambda to them.
  2172. * @param func defines the action to apply on each value.
  2173. */
  2174. forEach(func: (content: T) => void): void;
  2175. /**
  2176. * Sorts the full sets of data.
  2177. * @param compareFn defines the comparison function to apply.
  2178. */
  2179. sort(compareFn: (a: T, b: T) => number): void;
  2180. /**
  2181. * Resets the active data to an empty array.
  2182. */
  2183. reset(): void;
  2184. /**
  2185. * Releases all the data from the array as well as the array.
  2186. */
  2187. dispose(): void;
  2188. /**
  2189. * Concats the active data with a given array.
  2190. * @param array defines the data to concatenate with.
  2191. */
  2192. concat(array: any): void;
  2193. /**
  2194. * Returns the position of a value in the active data.
  2195. * @param value defines the value to find the index for
  2196. * @returns the index if found in the active data otherwise -1
  2197. */
  2198. indexOf(value: T): number;
  2199. /**
  2200. * Returns whether an element is part of the active data.
  2201. * @param value defines the value to look for
  2202. * @returns true if found in the active data otherwise false
  2203. */
  2204. contains(value: T): boolean;
  2205. private static _GlobalId;
  2206. }
  2207. /**
  2208. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  2209. * The data in this array can only be present once
  2210. */
  2211. export class SmartArrayNoDuplicate<T> extends SmartArray<T> {
  2212. private _duplicateId;
  2213. /**
  2214. * Pushes a value at the end of the active data.
  2215. * THIS DOES NOT PREVENT DUPPLICATE DATA
  2216. * @param value defines the object to push in the array.
  2217. */
  2218. push(value: T): void;
  2219. /**
  2220. * Pushes a value at the end of the active data.
  2221. * If the data is already present, it won t be added again
  2222. * @param value defines the object to push in the array.
  2223. * @returns true if added false if it was already present
  2224. */
  2225. pushNoDuplicate(value: T): boolean;
  2226. /**
  2227. * Resets the active data to an empty array.
  2228. */
  2229. reset(): void;
  2230. /**
  2231. * Concats the active data with a given array.
  2232. * This ensures no duplicate will be present in the result.
  2233. * @param array defines the data to concatenate with.
  2234. */
  2235. concatWithNoDuplicate(array: any): void;
  2236. }
  2237. }
  2238. declare module BABYLON {
  2239. /**
  2240. * Class used to evaluate queries containing `and` and `or` operators
  2241. */
  2242. export class AndOrNotEvaluator {
  2243. /**
  2244. * Evaluate a query
  2245. * @param query defines the query to evaluate
  2246. * @param evaluateCallback defines the callback used to filter result
  2247. * @returns true if the query matches
  2248. */
  2249. static Eval(query: string, evaluateCallback: (val: any) => boolean): boolean;
  2250. private static _HandleParenthesisContent;
  2251. private static _SimplifyNegation;
  2252. }
  2253. }
  2254. declare module BABYLON {
  2255. /**
  2256. * Class used to store custom tags
  2257. */
  2258. export class Tags {
  2259. /**
  2260. * Adds support for tags on the given object
  2261. * @param obj defines the object to use
  2262. */
  2263. static EnableFor(obj: any): void;
  2264. /**
  2265. * Removes tags support
  2266. * @param obj defines the object to use
  2267. */
  2268. static DisableFor(obj: any): void;
  2269. /**
  2270. * Gets a boolean indicating if the given object has tags
  2271. * @param obj defines the object to use
  2272. * @returns a boolean
  2273. */
  2274. static HasTags(obj: any): boolean;
  2275. /**
  2276. * Gets the tags available on a given object
  2277. * @param obj defines the object to use
  2278. * @param asString defines if the tags must be returned as a string instead of an array of strings
  2279. * @returns the tags
  2280. */
  2281. static GetTags(obj: any, asString?: boolean): any;
  2282. /**
  2283. * Adds tags to an object
  2284. * @param obj defines the object to use
  2285. * @param tagsString defines the tag string. The tags 'true' and 'false' are reserved and cannot be used as tags.
  2286. * A tag cannot start with '||', '&&', and '!'. It cannot contain whitespaces
  2287. */
  2288. static AddTagsTo(obj: any, tagsString: string): void;
  2289. /**
  2290. * @hidden
  2291. */
  2292. static _AddTagTo(obj: any, tag: string): void;
  2293. /**
  2294. * Removes specific tags from a specific object
  2295. * @param obj defines the object to use
  2296. * @param tagsString defines the tags to remove
  2297. */
  2298. static RemoveTagsFrom(obj: any, tagsString: string): void;
  2299. /**
  2300. * @hidden
  2301. */
  2302. static _RemoveTagFrom(obj: any, tag: string): void;
  2303. /**
  2304. * Defines if tags hosted on an object match a given query
  2305. * @param obj defines the object to use
  2306. * @param tagsQuery defines the tag query
  2307. * @returns a boolean
  2308. */
  2309. static MatchesQuery(obj: any, tagsQuery: string): boolean;
  2310. }
  2311. }
  2312. declare module BABYLON {
  2313. /**
  2314. * Scalar computation library
  2315. */
  2316. export class Scalar {
  2317. /**
  2318. * Two pi constants convenient for computation.
  2319. */
  2320. static TwoPi: number;
  2321. /**
  2322. * Boolean : true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  2323. * @param a number
  2324. * @param b number
  2325. * @param epsilon (default = 1.401298E-45)
  2326. * @returns true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  2327. */
  2328. static WithinEpsilon(a: number, b: number, epsilon?: number): boolean;
  2329. /**
  2330. * Returns a string : the upper case translation of the number i to hexadecimal.
  2331. * @param i number
  2332. * @returns the upper case translation of the number i to hexadecimal.
  2333. */
  2334. static ToHex(i: number): string;
  2335. /**
  2336. * Returns -1 if value is negative and +1 is value is positive.
  2337. * @param value the value
  2338. * @returns the value itself if it's equal to zero.
  2339. */
  2340. static Sign(value: number): number;
  2341. /**
  2342. * Returns the value itself if it's between min and max.
  2343. * Returns min if the value is lower than min.
  2344. * Returns max if the value is greater than max.
  2345. * @param value the value to clmap
  2346. * @param min the min value to clamp to (default: 0)
  2347. * @param max the max value to clamp to (default: 1)
  2348. * @returns the clamped value
  2349. */
  2350. static Clamp(value: number, min?: number, max?: number): number;
  2351. /**
  2352. * the log2 of value.
  2353. * @param value the value to compute log2 of
  2354. * @returns the log2 of value.
  2355. */
  2356. static Log2(value: number): number;
  2357. /**
  2358. * the floor part of a log2 value.
  2359. * @param value the value to compute log2 of
  2360. * @returns the log2 of value.
  2361. */
  2362. static ILog2(value: number): number;
  2363. /**
  2364. * Loops the value, so that it is never larger than length and never smaller than 0.
  2365. *
  2366. * This is similar to the modulo operator but it works with floating point numbers.
  2367. * For example, using 3.0 for t and 2.5 for length, the result would be 0.5.
  2368. * With t = 5 and length = 2.5, the result would be 0.0.
  2369. * Note, however, that the behaviour is not defined for negative numbers as it is for the modulo operator
  2370. * @param value the value
  2371. * @param length the length
  2372. * @returns the looped value
  2373. */
  2374. static Repeat(value: number, length: number): number;
  2375. /**
  2376. * Normalize the value between 0.0 and 1.0 using min and max values
  2377. * @param value value to normalize
  2378. * @param min max to normalize between
  2379. * @param max min to normalize between
  2380. * @returns the normalized value
  2381. */
  2382. static Normalize(value: number, min: number, max: number): number;
  2383. /**
  2384. * Denormalize the value from 0.0 and 1.0 using min and max values
  2385. * @param normalized value to denormalize
  2386. * @param min max to denormalize between
  2387. * @param max min to denormalize between
  2388. * @returns the denormalized value
  2389. */
  2390. static Denormalize(normalized: number, min: number, max: number): number;
  2391. /**
  2392. * Calculates the shortest difference between two given angles given in degrees.
  2393. * @param current current angle in degrees
  2394. * @param target target angle in degrees
  2395. * @returns the delta
  2396. */
  2397. static DeltaAngle(current: number, target: number): number;
  2398. /**
  2399. * PingPongs the value t, so that it is never larger than length and never smaller than 0.
  2400. * @param tx value
  2401. * @param length length
  2402. * @returns The returned value will move back and forth between 0 and length
  2403. */
  2404. static PingPong(tx: number, length: number): number;
  2405. /**
  2406. * Interpolates between min and max with smoothing at the limits.
  2407. *
  2408. * This function interpolates between min and max in a similar way to Lerp. However, the interpolation will gradually speed up
  2409. * from the start and slow down toward the end. This is useful for creating natural-looking animation, fading and other transitions.
  2410. * @param from from
  2411. * @param to to
  2412. * @param tx value
  2413. * @returns the smooth stepped value
  2414. */
  2415. static SmoothStep(from: number, to: number, tx: number): number;
  2416. /**
  2417. * Moves a value current towards target.
  2418. *
  2419. * This is essentially the same as Mathf.Lerp but instead the function will ensure that the speed never exceeds maxDelta.
  2420. * Negative values of maxDelta pushes the value away from target.
  2421. * @param current current value
  2422. * @param target target value
  2423. * @param maxDelta max distance to move
  2424. * @returns resulting value
  2425. */
  2426. static MoveTowards(current: number, target: number, maxDelta: number): number;
  2427. /**
  2428. * Same as MoveTowards but makes sure the values interpolate correctly when they wrap around 360 degrees.
  2429. *
  2430. * Variables current and target are assumed to be in degrees. For optimization reasons, negative values of maxDelta
  2431. * are not supported and may cause oscillation. To push current away from a target angle, add 180 to that angle instead.
  2432. * @param current current value
  2433. * @param target target value
  2434. * @param maxDelta max distance to move
  2435. * @returns resulting angle
  2436. */
  2437. static MoveTowardsAngle(current: number, target: number, maxDelta: number): number;
  2438. /**
  2439. * Creates a new scalar with values linearly interpolated of "amount" between the start scalar and the end scalar.
  2440. * @param start start value
  2441. * @param end target value
  2442. * @param amount amount to lerp between
  2443. * @returns the lerped value
  2444. */
  2445. static Lerp(start: number, end: number, amount: number): number;
  2446. /**
  2447. * Same as Lerp but makes sure the values interpolate correctly when they wrap around 360 degrees.
  2448. * The parameter t is clamped to the range [0, 1]. Variables a and b are assumed to be in degrees.
  2449. * @param start start value
  2450. * @param end target value
  2451. * @param amount amount to lerp between
  2452. * @returns the lerped value
  2453. */
  2454. static LerpAngle(start: number, end: number, amount: number): number;
  2455. /**
  2456. * Calculates the linear parameter t that produces the interpolant value within the range [a, b].
  2457. * @param a start value
  2458. * @param b target value
  2459. * @param value value between a and b
  2460. * @returns the inverseLerp value
  2461. */
  2462. static InverseLerp(a: number, b: number, value: number): number;
  2463. /**
  2464. * Returns a new scalar located for "amount" (float) on the Hermite spline defined by the scalars "value1", "value3", "tangent1", "tangent2".
  2465. * @see http://mathworld.wolfram.com/HermitePolynomial.html
  2466. * @param value1 spline value
  2467. * @param tangent1 spline value
  2468. * @param value2 spline value
  2469. * @param tangent2 spline value
  2470. * @param amount input value
  2471. * @returns hermite result
  2472. */
  2473. static Hermite(value1: number, tangent1: number, value2: number, tangent2: number, amount: number): number;
  2474. /**
  2475. * Returns a random float number between and min and max values
  2476. * @param min min value of random
  2477. * @param max max value of random
  2478. * @returns random value
  2479. */
  2480. static RandomRange(min: number, max: number): number;
  2481. /**
  2482. * This function returns percentage of a number in a given range.
  2483. *
  2484. * RangeToPercent(40,20,60) will return 0.5 (50%)
  2485. * RangeToPercent(34,0,100) will return 0.34 (34%)
  2486. * @param number to convert to percentage
  2487. * @param min min range
  2488. * @param max max range
  2489. * @returns the percentage
  2490. */
  2491. static RangeToPercent(number: number, min: number, max: number): number;
  2492. /**
  2493. * This function returns number that corresponds to the percentage in a given range.
  2494. *
  2495. * PercentToRange(0.34,0,100) will return 34.
  2496. * @param percent to convert to number
  2497. * @param min min range
  2498. * @param max max range
  2499. * @returns the number
  2500. */
  2501. static PercentToRange(percent: number, min: number, max: number): number;
  2502. /**
  2503. * Returns the angle converted to equivalent value between -Math.PI and Math.PI radians.
  2504. * @param angle The angle to normalize in radian.
  2505. * @return The converted angle.
  2506. */
  2507. static NormalizeRadians(angle: number): number;
  2508. }
  2509. }
  2510. declare module BABYLON {
  2511. /**
  2512. * Constant used to convert a value to gamma space
  2513. * @ignorenaming
  2514. */
  2515. export const ToGammaSpace: number;
  2516. /**
  2517. * Constant used to convert a value to linear space
  2518. * @ignorenaming
  2519. */
  2520. export const ToLinearSpace = 2.2;
  2521. /**
  2522. * Constant used to define the minimal number value in Babylon.js
  2523. * @ignorenaming
  2524. */
  2525. let Epsilon: number;
  2526. }
  2527. declare module BABYLON {
  2528. /**
  2529. * Class used to represent a viewport on screen
  2530. */
  2531. export class Viewport {
  2532. /** viewport left coordinate */
  2533. x: number;
  2534. /** viewport top coordinate */
  2535. y: number;
  2536. /**viewport width */
  2537. width: number;
  2538. /** viewport height */
  2539. height: number;
  2540. /**
  2541. * Creates a Viewport object located at (x, y) and sized (width, height)
  2542. * @param x defines viewport left coordinate
  2543. * @param y defines viewport top coordinate
  2544. * @param width defines the viewport width
  2545. * @param height defines the viewport height
  2546. */
  2547. constructor(
  2548. /** viewport left coordinate */
  2549. x: number,
  2550. /** viewport top coordinate */
  2551. y: number,
  2552. /**viewport width */
  2553. width: number,
  2554. /** viewport height */
  2555. height: number);
  2556. /**
  2557. * Creates a new viewport using absolute sizing (from 0-> width, 0-> height instead of 0->1)
  2558. * @param renderWidth defines the rendering width
  2559. * @param renderHeight defines the rendering height
  2560. * @returns a new Viewport
  2561. */
  2562. toGlobal(renderWidth: number, renderHeight: number): Viewport;
  2563. /**
  2564. * Stores absolute viewport value into a target viewport (from 0-> width, 0-> height instead of 0->1)
  2565. * @param renderWidth defines the rendering width
  2566. * @param renderHeight defines the rendering height
  2567. * @param ref defines the target viewport
  2568. * @returns the current viewport
  2569. */
  2570. toGlobalToRef(renderWidth: number, renderHeight: number, ref: Viewport): Viewport;
  2571. /**
  2572. * Returns a new Viewport copied from the current one
  2573. * @returns a new Viewport
  2574. */
  2575. clone(): Viewport;
  2576. }
  2577. }
  2578. declare module BABYLON {
  2579. /**
  2580. * Class containing a set of static utilities functions for arrays.
  2581. */
  2582. export class ArrayTools {
  2583. /**
  2584. * Returns an array of the given size filled with element built from the given constructor and the parameters
  2585. * @param size the number of element to construct and put in the array
  2586. * @param itemBuilder a callback responsible for creating new instance of item. Called once per array entry.
  2587. * @returns a new array filled with new objects
  2588. */
  2589. static BuildArray<T>(size: number, itemBuilder: () => T): Array<T>;
  2590. }
  2591. }
  2592. declare module BABYLON {
  2593. /**
  2594. * Represents a plane by the equation ax + by + cz + d = 0
  2595. */
  2596. export class Plane {
  2597. private static _TmpMatrix;
  2598. /**
  2599. * Normal of the plane (a,b,c)
  2600. */
  2601. normal: Vector3;
  2602. /**
  2603. * d component of the plane
  2604. */
  2605. d: number;
  2606. /**
  2607. * Creates a Plane object according to the given floats a, b, c, d and the plane equation : ax + by + cz + d = 0
  2608. * @param a a component of the plane
  2609. * @param b b component of the plane
  2610. * @param c c component of the plane
  2611. * @param d d component of the plane
  2612. */
  2613. constructor(a: number, b: number, c: number, d: number);
  2614. /**
  2615. * @returns the plane coordinates as a new array of 4 elements [a, b, c, d].
  2616. */
  2617. asArray(): number[];
  2618. /**
  2619. * @returns a new plane copied from the current Plane.
  2620. */
  2621. clone(): Plane;
  2622. /**
  2623. * @returns the string "Plane".
  2624. */
  2625. getClassName(): string;
  2626. /**
  2627. * @returns the Plane hash code.
  2628. */
  2629. getHashCode(): number;
  2630. /**
  2631. * Normalize the current Plane in place.
  2632. * @returns the updated Plane.
  2633. */
  2634. normalize(): Plane;
  2635. /**
  2636. * Applies a transformation the plane and returns the result
  2637. * @param transformation the transformation matrix to be applied to the plane
  2638. * @returns a new Plane as the result of the transformation of the current Plane by the given matrix.
  2639. */
  2640. transform(transformation: DeepImmutable<Matrix>): Plane;
  2641. /**
  2642. * Compute the dot product between the point and the plane normal
  2643. * @param point point to calculate the dot product with
  2644. * @returns the dot product (float) of the point coordinates and the plane normal.
  2645. */
  2646. dotCoordinate(point: DeepImmutable<Vector3>): number;
  2647. /**
  2648. * Updates the current Plane from the plane defined by the three given points.
  2649. * @param point1 one of the points used to contruct the plane
  2650. * @param point2 one of the points used to contruct the plane
  2651. * @param point3 one of the points used to contruct the plane
  2652. * @returns the updated Plane.
  2653. */
  2654. copyFromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  2655. /**
  2656. * Checks if the plane is facing a given direction (meaning if the plane's normal is pointing in the opposite direction of the given vector).
  2657. * Note that for this function to work as expected you should make sure that:
  2658. * - direction and the plane normal are normalized
  2659. * - epsilon is a number just bigger than -1, something like -0.99 for eg
  2660. * @param direction the direction to check if the plane is facing
  2661. * @param epsilon value the dot product is compared against (returns true if dot <= epsilon)
  2662. * @returns True if the plane is facing the given direction
  2663. */
  2664. isFrontFacingTo(direction: DeepImmutable<Vector3>, epsilon: number): boolean;
  2665. /**
  2666. * Calculates the distance to a point
  2667. * @param point point to calculate distance to
  2668. * @returns the signed distance (float) from the given point to the Plane.
  2669. */
  2670. signedDistanceTo(point: DeepImmutable<Vector3>): number;
  2671. /**
  2672. * Creates a plane from an array
  2673. * @param array the array to create a plane from
  2674. * @returns a new Plane from the given array.
  2675. */
  2676. static FromArray(array: DeepImmutable<ArrayLike<number>>): Plane;
  2677. /**
  2678. * Creates a plane from three points
  2679. * @param point1 point used to create the plane
  2680. * @param point2 point used to create the plane
  2681. * @param point3 point used to create the plane
  2682. * @returns a new Plane defined by the three given points.
  2683. */
  2684. static FromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  2685. /**
  2686. * Creates a plane from an origin point and a normal
  2687. * @param origin origin of the plane to be constructed
  2688. * @param normal normal of the plane to be constructed
  2689. * @returns a new Plane the normal vector to this plane at the given origin point.
  2690. * Note : the vector "normal" is updated because normalized.
  2691. */
  2692. static FromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: Vector3): Plane;
  2693. /**
  2694. * Calculates the distance from a plane and a point
  2695. * @param origin origin of the plane to be constructed
  2696. * @param normal normal of the plane to be constructed
  2697. * @param point point to calculate distance to
  2698. * @returns the signed distance between the plane defined by the normal vector at the "origin"" point and the given other point.
  2699. */
  2700. static SignedDistanceToPlaneFromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>, point: DeepImmutable<Vector3>): number;
  2701. }
  2702. }
  2703. declare module BABYLON {
  2704. /** @hidden */
  2705. export class PerformanceConfigurator {
  2706. /** @hidden */
  2707. static MatrixUse64Bits: boolean;
  2708. /** @hidden */
  2709. static MatrixTrackPrecisionChange: boolean;
  2710. /** @hidden */
  2711. static MatrixCurrentType: any;
  2712. /** @hidden */
  2713. static MatrixTrackedMatrices: Array<any> | null;
  2714. /** @hidden */
  2715. static SetMatrixPrecision(use64bits: boolean): void;
  2716. }
  2717. }
  2718. declare module BABYLON {
  2719. /**
  2720. * Class representing a vector containing 2 coordinates
  2721. */
  2722. export class Vector2 {
  2723. /** defines the first coordinate */
  2724. x: number;
  2725. /** defines the second coordinate */
  2726. y: number;
  2727. /**
  2728. * Creates a new Vector2 from the given x and y coordinates
  2729. * @param x defines the first coordinate
  2730. * @param y defines the second coordinate
  2731. */
  2732. constructor(
  2733. /** defines the first coordinate */
  2734. x?: number,
  2735. /** defines the second coordinate */
  2736. y?: number);
  2737. /**
  2738. * Gets a string with the Vector2 coordinates
  2739. * @returns a string with the Vector2 coordinates
  2740. */
  2741. toString(): string;
  2742. /**
  2743. * Gets class name
  2744. * @returns the string "Vector2"
  2745. */
  2746. getClassName(): string;
  2747. /**
  2748. * Gets current vector hash code
  2749. * @returns the Vector2 hash code as a number
  2750. */
  2751. getHashCode(): number;
  2752. /**
  2753. * Sets the Vector2 coordinates in the given array or Float32Array from the given index.
  2754. * @param array defines the source array
  2755. * @param index defines the offset in source array
  2756. * @returns the current Vector2
  2757. */
  2758. toArray(array: FloatArray, index?: number): Vector2;
  2759. /**
  2760. * Update the current vector from an array
  2761. * @param array defines the destination array
  2762. * @param index defines the offset in the destination array
  2763. * @returns the current Vector3
  2764. */
  2765. fromArray(array: FloatArray, index?: number): Vector2;
  2766. /**
  2767. * Copy the current vector to an array
  2768. * @returns a new array with 2 elements: the Vector2 coordinates.
  2769. */
  2770. asArray(): number[];
  2771. /**
  2772. * Sets the Vector2 coordinates with the given Vector2 coordinates
  2773. * @param source defines the source Vector2
  2774. * @returns the current updated Vector2
  2775. */
  2776. copyFrom(source: DeepImmutable<Vector2>): Vector2;
  2777. /**
  2778. * Sets the Vector2 coordinates with the given floats
  2779. * @param x defines the first coordinate
  2780. * @param y defines the second coordinate
  2781. * @returns the current updated Vector2
  2782. */
  2783. copyFromFloats(x: number, y: number): Vector2;
  2784. /**
  2785. * Sets the Vector2 coordinates with the given floats
  2786. * @param x defines the first coordinate
  2787. * @param y defines the second coordinate
  2788. * @returns the current updated Vector2
  2789. */
  2790. set(x: number, y: number): Vector2;
  2791. /**
  2792. * Add another vector with the current one
  2793. * @param otherVector defines the other vector
  2794. * @returns a new Vector2 set with the addition of the current Vector2 and the given one coordinates
  2795. */
  2796. add(otherVector: DeepImmutable<Vector2>): Vector2;
  2797. /**
  2798. * Sets the "result" coordinates with the addition of the current Vector2 and the given one coordinates
  2799. * @param otherVector defines the other vector
  2800. * @param result defines the target vector
  2801. * @returns the unmodified current Vector2
  2802. */
  2803. addToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  2804. /**
  2805. * Set the Vector2 coordinates by adding the given Vector2 coordinates
  2806. * @param otherVector defines the other vector
  2807. * @returns the current updated Vector2
  2808. */
  2809. addInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  2810. /**
  2811. * Gets a new Vector2 by adding the current Vector2 coordinates to the given Vector3 x, y coordinates
  2812. * @param otherVector defines the other vector
  2813. * @returns a new Vector2
  2814. */
  2815. addVector3(otherVector: Vector3): Vector2;
  2816. /**
  2817. * Gets a new Vector2 set with the subtracted coordinates of the given one from the current Vector2
  2818. * @param otherVector defines the other vector
  2819. * @returns a new Vector2
  2820. */
  2821. subtract(otherVector: Vector2): Vector2;
  2822. /**
  2823. * Sets the "result" coordinates with the subtraction of the given one from the current Vector2 coordinates.
  2824. * @param otherVector defines the other vector
  2825. * @param result defines the target vector
  2826. * @returns the unmodified current Vector2
  2827. */
  2828. subtractToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  2829. /**
  2830. * Sets the current Vector2 coordinates by subtracting from it the given one coordinates
  2831. * @param otherVector defines the other vector
  2832. * @returns the current updated Vector2
  2833. */
  2834. subtractInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  2835. /**
  2836. * Multiplies in place the current Vector2 coordinates by the given ones
  2837. * @param otherVector defines the other vector
  2838. * @returns the current updated Vector2
  2839. */
  2840. multiplyInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  2841. /**
  2842. * Returns a new Vector2 set with the multiplication of the current Vector2 and the given one coordinates
  2843. * @param otherVector defines the other vector
  2844. * @returns a new Vector2
  2845. */
  2846. multiply(otherVector: DeepImmutable<Vector2>): Vector2;
  2847. /**
  2848. * Sets "result" coordinates with the multiplication of the current Vector2 and the given one coordinates
  2849. * @param otherVector defines the other vector
  2850. * @param result defines the target vector
  2851. * @returns the unmodified current Vector2
  2852. */
  2853. multiplyToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  2854. /**
  2855. * Gets a new Vector2 set with the Vector2 coordinates multiplied by the given floats
  2856. * @param x defines the first coordinate
  2857. * @param y defines the second coordinate
  2858. * @returns a new Vector2
  2859. */
  2860. multiplyByFloats(x: number, y: number): Vector2;
  2861. /**
  2862. * Returns a new Vector2 set with the Vector2 coordinates divided by the given one coordinates
  2863. * @param otherVector defines the other vector
  2864. * @returns a new Vector2
  2865. */
  2866. divide(otherVector: Vector2): Vector2;
  2867. /**
  2868. * Sets the "result" coordinates with the Vector2 divided by the given one coordinates
  2869. * @param otherVector defines the other vector
  2870. * @param result defines the target vector
  2871. * @returns the unmodified current Vector2
  2872. */
  2873. divideToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  2874. /**
  2875. * Divides the current Vector2 coordinates by the given ones
  2876. * @param otherVector defines the other vector
  2877. * @returns the current updated Vector2
  2878. */
  2879. divideInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  2880. /**
  2881. * Gets a new Vector2 with current Vector2 negated coordinates
  2882. * @returns a new Vector2
  2883. */
  2884. negate(): Vector2;
  2885. /**
  2886. * Negate this vector in place
  2887. * @returns this
  2888. */
  2889. negateInPlace(): Vector2;
  2890. /**
  2891. * Negate the current Vector2 and stores the result in the given vector "result" coordinates
  2892. * @param result defines the Vector3 object where to store the result
  2893. * @returns the current Vector2
  2894. */
  2895. negateToRef(result: Vector2): Vector2;
  2896. /**
  2897. * Multiply the Vector2 coordinates by scale
  2898. * @param scale defines the scaling factor
  2899. * @returns the current updated Vector2
  2900. */
  2901. scaleInPlace(scale: number): Vector2;
  2902. /**
  2903. * Returns a new Vector2 scaled by "scale" from the current Vector2
  2904. * @param scale defines the scaling factor
  2905. * @returns a new Vector2
  2906. */
  2907. scale(scale: number): Vector2;
  2908. /**
  2909. * Scale the current Vector2 values by a factor to a given Vector2
  2910. * @param scale defines the scale factor
  2911. * @param result defines the Vector2 object where to store the result
  2912. * @returns the unmodified current Vector2
  2913. */
  2914. scaleToRef(scale: number, result: Vector2): Vector2;
  2915. /**
  2916. * Scale the current Vector2 values by a factor and add the result to a given Vector2
  2917. * @param scale defines the scale factor
  2918. * @param result defines the Vector2 object where to store the result
  2919. * @returns the unmodified current Vector2
  2920. */
  2921. scaleAndAddToRef(scale: number, result: Vector2): Vector2;
  2922. /**
  2923. * Gets a boolean if two vectors are equals
  2924. * @param otherVector defines the other vector
  2925. * @returns true if the given vector coordinates strictly equal the current Vector2 ones
  2926. */
  2927. equals(otherVector: DeepImmutable<Vector2>): boolean;
  2928. /**
  2929. * Gets a boolean if two vectors are equals (using an epsilon value)
  2930. * @param otherVector defines the other vector
  2931. * @param epsilon defines the minimal distance to consider equality
  2932. * @returns true if the given vector coordinates are close to the current ones by a distance of epsilon.
  2933. */
  2934. equalsWithEpsilon(otherVector: DeepImmutable<Vector2>, epsilon?: number): boolean;
  2935. /**
  2936. * Gets a new Vector2 from current Vector2 floored values
  2937. * @returns a new Vector2
  2938. */
  2939. floor(): Vector2;
  2940. /**
  2941. * Gets a new Vector2 from current Vector2 floored values
  2942. * @returns a new Vector2
  2943. */
  2944. fract(): Vector2;
  2945. /**
  2946. * Gets the length of the vector
  2947. * @returns the vector length (float)
  2948. */
  2949. length(): number;
  2950. /**
  2951. * Gets the vector squared length
  2952. * @returns the vector squared length (float)
  2953. */
  2954. lengthSquared(): number;
  2955. /**
  2956. * Normalize the vector
  2957. * @returns the current updated Vector2
  2958. */
  2959. normalize(): Vector2;
  2960. /**
  2961. * Gets a new Vector2 copied from the Vector2
  2962. * @returns a new Vector2
  2963. */
  2964. clone(): Vector2;
  2965. /**
  2966. * Gets a new Vector2(0, 0)
  2967. * @returns a new Vector2
  2968. */
  2969. static Zero(): Vector2;
  2970. /**
  2971. * Gets a new Vector2(1, 1)
  2972. * @returns a new Vector2
  2973. */
  2974. static One(): Vector2;
  2975. /**
  2976. * Gets a new Vector2 set from the given index element of the given array
  2977. * @param array defines the data source
  2978. * @param offset defines the offset in the data source
  2979. * @returns a new Vector2
  2980. */
  2981. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector2;
  2982. /**
  2983. * Sets "result" from the given index element of the given array
  2984. * @param array defines the data source
  2985. * @param offset defines the offset in the data source
  2986. * @param result defines the target vector
  2987. */
  2988. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector2): void;
  2989. /**
  2990. * Gets a new Vector2 located for "amount" (float) on the CatmullRom spline defined by the given four Vector2
  2991. * @param value1 defines 1st point of control
  2992. * @param value2 defines 2nd point of control
  2993. * @param value3 defines 3rd point of control
  2994. * @param value4 defines 4th point of control
  2995. * @param amount defines the interpolation factor
  2996. * @returns a new Vector2
  2997. */
  2998. static CatmullRom(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, value3: DeepImmutable<Vector2>, value4: DeepImmutable<Vector2>, amount: number): Vector2;
  2999. /**
  3000. * Returns a new Vector2 set with same the coordinates than "value" ones if the vector "value" is in the square defined by "min" and "max".
  3001. * If a coordinate of "value" is lower than "min" coordinates, the returned Vector2 is given this "min" coordinate.
  3002. * If a coordinate of "value" is greater than "max" coordinates, the returned Vector2 is given this "max" coordinate
  3003. * @param value defines the value to clamp
  3004. * @param min defines the lower limit
  3005. * @param max defines the upper limit
  3006. * @returns a new Vector2
  3007. */
  3008. static Clamp(value: DeepImmutable<Vector2>, min: DeepImmutable<Vector2>, max: DeepImmutable<Vector2>): Vector2;
  3009. /**
  3010. * Returns a new Vector2 located for "amount" (float) on the Hermite spline defined by the vectors "value1", "value3", "tangent1", "tangent2"
  3011. * @param value1 defines the 1st control point
  3012. * @param tangent1 defines the outgoing tangent
  3013. * @param value2 defines the 2nd control point
  3014. * @param tangent2 defines the incoming tangent
  3015. * @param amount defines the interpolation factor
  3016. * @returns a new Vector2
  3017. */
  3018. static Hermite(value1: DeepImmutable<Vector2>, tangent1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, tangent2: DeepImmutable<Vector2>, amount: number): Vector2;
  3019. /**
  3020. * Returns a new Vector2 located for "amount" (float) on the linear interpolation between the vector "start" adn the vector "end".
  3021. * @param start defines the start vector
  3022. * @param end defines the end vector
  3023. * @param amount defines the interpolation factor
  3024. * @returns a new Vector2
  3025. */
  3026. static Lerp(start: DeepImmutable<Vector2>, end: DeepImmutable<Vector2>, amount: number): Vector2;
  3027. /**
  3028. * Gets the dot product of the vector "left" and the vector "right"
  3029. * @param left defines first vector
  3030. * @param right defines second vector
  3031. * @returns the dot product (float)
  3032. */
  3033. static Dot(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): number;
  3034. /**
  3035. * Returns a new Vector2 equal to the normalized given vector
  3036. * @param vector defines the vector to normalize
  3037. * @returns a new Vector2
  3038. */
  3039. static Normalize(vector: DeepImmutable<Vector2>): Vector2;
  3040. /**
  3041. * Gets a new Vector2 set with the minimal coordinate values from the "left" and "right" vectors
  3042. * @param left defines 1st vector
  3043. * @param right defines 2nd vector
  3044. * @returns a new Vector2
  3045. */
  3046. static Minimize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  3047. /**
  3048. * Gets a new Vecto2 set with the maximal coordinate values from the "left" and "right" vectors
  3049. * @param left defines 1st vector
  3050. * @param right defines 2nd vector
  3051. * @returns a new Vector2
  3052. */
  3053. static Maximize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  3054. /**
  3055. * Gets a new Vector2 set with the transformed coordinates of the given vector by the given transformation matrix
  3056. * @param vector defines the vector to transform
  3057. * @param transformation defines the matrix to apply
  3058. * @returns a new Vector2
  3059. */
  3060. static Transform(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>): Vector2;
  3061. /**
  3062. * Transforms the given vector coordinates by the given transformation matrix and stores the result in the vector "result" coordinates
  3063. * @param vector defines the vector to transform
  3064. * @param transformation defines the matrix to apply
  3065. * @param result defines the target vector
  3066. */
  3067. static TransformToRef(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>, result: Vector2): void;
  3068. /**
  3069. * Determines if a given vector is included in a triangle
  3070. * @param p defines the vector to test
  3071. * @param p0 defines 1st triangle point
  3072. * @param p1 defines 2nd triangle point
  3073. * @param p2 defines 3rd triangle point
  3074. * @returns true if the point "p" is in the triangle defined by the vertors "p0", "p1", "p2"
  3075. */
  3076. static PointInTriangle(p: DeepImmutable<Vector2>, p0: DeepImmutable<Vector2>, p1: DeepImmutable<Vector2>, p2: DeepImmutable<Vector2>): boolean;
  3077. /**
  3078. * Gets the distance between the vectors "value1" and "value2"
  3079. * @param value1 defines first vector
  3080. * @param value2 defines second vector
  3081. * @returns the distance between vectors
  3082. */
  3083. static Distance(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  3084. /**
  3085. * Returns the squared distance between the vectors "value1" and "value2"
  3086. * @param value1 defines first vector
  3087. * @param value2 defines second vector
  3088. * @returns the squared distance between vectors
  3089. */
  3090. static DistanceSquared(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  3091. /**
  3092. * Gets a new Vector2 located at the center of the vectors "value1" and "value2"
  3093. * @param value1 defines first vector
  3094. * @param value2 defines second vector
  3095. * @returns a new Vector2
  3096. */
  3097. static Center(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): Vector2;
  3098. /**
  3099. * Gets the center of the vectors "value1" and "value2" and stores the result in the vector "ref"
  3100. * @param value1 defines first vector
  3101. * @param value2 defines second vector
  3102. * @param ref defines third vector
  3103. * @returns ref
  3104. */
  3105. static CenterToRef(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, ref: DeepImmutable<Vector2>): Vector2;
  3106. /**
  3107. * Gets the shortest distance (float) between the point "p" and the segment defined by the two points "segA" and "segB".
  3108. * @param p defines the middle point
  3109. * @param segA defines one point of the segment
  3110. * @param segB defines the other point of the segment
  3111. * @returns the shortest distance
  3112. */
  3113. static DistanceOfPointFromSegment(p: DeepImmutable<Vector2>, segA: DeepImmutable<Vector2>, segB: DeepImmutable<Vector2>): number;
  3114. }
  3115. /**
  3116. * Class used to store (x,y,z) vector representation
  3117. * A Vector3 is the main object used in 3D geometry
  3118. * It can represent etiher the coordinates of a point the space, either a direction
  3119. * Reminder: js uses a left handed forward facing system
  3120. */
  3121. export class Vector3 {
  3122. private static _UpReadOnly;
  3123. private static _ZeroReadOnly;
  3124. /** @hidden */
  3125. _x: number;
  3126. /** @hidden */
  3127. _y: number;
  3128. /** @hidden */
  3129. _z: number;
  3130. /** @hidden */
  3131. _isDirty: boolean;
  3132. /** Gets or sets the x coordinate */
  3133. get x(): number;
  3134. set x(value: number);
  3135. /** Gets or sets the y coordinate */
  3136. get y(): number;
  3137. set y(value: number);
  3138. /** Gets or sets the z coordinate */
  3139. get z(): number;
  3140. set z(value: number);
  3141. /**
  3142. * Creates a new Vector3 object from the given x, y, z (floats) coordinates.
  3143. * @param x defines the first coordinates (on X axis)
  3144. * @param y defines the second coordinates (on Y axis)
  3145. * @param z defines the third coordinates (on Z axis)
  3146. */
  3147. constructor(x?: number, y?: number, z?: number);
  3148. /**
  3149. * Creates a string representation of the Vector3
  3150. * @returns a string with the Vector3 coordinates.
  3151. */
  3152. toString(): string;
  3153. /**
  3154. * Gets the class name
  3155. * @returns the string "Vector3"
  3156. */
  3157. getClassName(): string;
  3158. /**
  3159. * Creates the Vector3 hash code
  3160. * @returns a number which tends to be unique between Vector3 instances
  3161. */
  3162. getHashCode(): number;
  3163. /**
  3164. * Creates an array containing three elements : the coordinates of the Vector3
  3165. * @returns a new array of numbers
  3166. */
  3167. asArray(): number[];
  3168. /**
  3169. * Populates the given array or Float32Array from the given index with the successive coordinates of the Vector3
  3170. * @param array defines the destination array
  3171. * @param index defines the offset in the destination array
  3172. * @returns the current Vector3
  3173. */
  3174. toArray(array: FloatArray, index?: number): Vector3;
  3175. /**
  3176. * Update the current vector from an array
  3177. * @param array defines the destination array
  3178. * @param index defines the offset in the destination array
  3179. * @returns the current Vector3
  3180. */
  3181. fromArray(array: FloatArray, index?: number): Vector3;
  3182. /**
  3183. * Converts the current Vector3 into a quaternion (considering that the Vector3 contains Euler angles representation of a rotation)
  3184. * @returns a new Quaternion object, computed from the Vector3 coordinates
  3185. */
  3186. toQuaternion(): Quaternion;
  3187. /**
  3188. * Adds the given vector to the current Vector3
  3189. * @param otherVector defines the second operand
  3190. * @returns the current updated Vector3
  3191. */
  3192. addInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  3193. /**
  3194. * Adds the given coordinates to the current Vector3
  3195. * @param x defines the x coordinate of the operand
  3196. * @param y defines the y coordinate of the operand
  3197. * @param z defines the z coordinate of the operand
  3198. * @returns the current updated Vector3
  3199. */
  3200. addInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  3201. /**
  3202. * Gets a new Vector3, result of the addition the current Vector3 and the given vector
  3203. * @param otherVector defines the second operand
  3204. * @returns the resulting Vector3
  3205. */
  3206. add(otherVector: DeepImmutable<Vector3>): Vector3;
  3207. /**
  3208. * Adds the current Vector3 to the given one and stores the result in the vector "result"
  3209. * @param otherVector defines the second operand
  3210. * @param result defines the Vector3 object where to store the result
  3211. * @returns the current Vector3
  3212. */
  3213. addToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  3214. /**
  3215. * Subtract the given vector from the current Vector3
  3216. * @param otherVector defines the second operand
  3217. * @returns the current updated Vector3
  3218. */
  3219. subtractInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  3220. /**
  3221. * Returns a new Vector3, result of the subtraction of the given vector from the current Vector3
  3222. * @param otherVector defines the second operand
  3223. * @returns the resulting Vector3
  3224. */
  3225. subtract(otherVector: DeepImmutable<Vector3>): Vector3;
  3226. /**
  3227. * Subtracts the given vector from the current Vector3 and stores the result in the vector "result".
  3228. * @param otherVector defines the second operand
  3229. * @param result defines the Vector3 object where to store the result
  3230. * @returns the current Vector3
  3231. */
  3232. subtractToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  3233. /**
  3234. * Returns a new Vector3 set with the subtraction of the given floats from the current Vector3 coordinates
  3235. * @param x defines the x coordinate of the operand
  3236. * @param y defines the y coordinate of the operand
  3237. * @param z defines the z coordinate of the operand
  3238. * @returns the resulting Vector3
  3239. */
  3240. subtractFromFloats(x: number, y: number, z: number): Vector3;
  3241. /**
  3242. * Subtracts the given floats from the current Vector3 coordinates and set the given vector "result" with this result
  3243. * @param x defines the x coordinate of the operand
  3244. * @param y defines the y coordinate of the operand
  3245. * @param z defines the z coordinate of the operand
  3246. * @param result defines the Vector3 object where to store the result
  3247. * @returns the current Vector3
  3248. */
  3249. subtractFromFloatsToRef(x: number, y: number, z: number, result: Vector3): Vector3;
  3250. /**
  3251. * Gets a new Vector3 set with the current Vector3 negated coordinates
  3252. * @returns a new Vector3
  3253. */
  3254. negate(): Vector3;
  3255. /**
  3256. * Negate this vector in place
  3257. * @returns this
  3258. */
  3259. negateInPlace(): Vector3;
  3260. /**
  3261. * Negate the current Vector3 and stores the result in the given vector "result" coordinates
  3262. * @param result defines the Vector3 object where to store the result
  3263. * @returns the current Vector3
  3264. */
  3265. negateToRef(result: Vector3): Vector3;
  3266. /**
  3267. * Multiplies the Vector3 coordinates by the float "scale"
  3268. * @param scale defines the multiplier factor
  3269. * @returns the current updated Vector3
  3270. */
  3271. scaleInPlace(scale: number): Vector3;
  3272. /**
  3273. * Returns a new Vector3 set with the current Vector3 coordinates multiplied by the float "scale"
  3274. * @param scale defines the multiplier factor
  3275. * @returns a new Vector3
  3276. */
  3277. scale(scale: number): Vector3;
  3278. /**
  3279. * Multiplies the current Vector3 coordinates by the float "scale" and stores the result in the given vector "result" coordinates
  3280. * @param scale defines the multiplier factor
  3281. * @param result defines the Vector3 object where to store the result
  3282. * @returns the current Vector3
  3283. */
  3284. scaleToRef(scale: number, result: Vector3): Vector3;
  3285. /**
  3286. * Scale the current Vector3 values by a factor and add the result to a given Vector3
  3287. * @param scale defines the scale factor
  3288. * @param result defines the Vector3 object where to store the result
  3289. * @returns the unmodified current Vector3
  3290. */
  3291. scaleAndAddToRef(scale: number, result: Vector3): Vector3;
  3292. /**
  3293. * Projects the current vector3 to a plane along a ray starting from a specified origin and directed towards the point.
  3294. * @param origin defines the origin of the projection ray
  3295. * @param plane defines the plane to project to
  3296. * @returns the projected vector3
  3297. */
  3298. projectOnPlane(plane: Plane, origin: Vector3): Vector3;
  3299. /**
  3300. * Projects the current vector3 to a plane along a ray starting from a specified origin and directed towards the point.
  3301. * @param origin defines the origin of the projection ray
  3302. * @param plane defines the plane to project to
  3303. * @param result defines the Vector3 where to store the result
  3304. */
  3305. projectOnPlaneToRef(plane: Plane, origin: Vector3, result: Vector3): void;
  3306. /**
  3307. * Returns true if the current Vector3 and the given vector coordinates are strictly equal
  3308. * @param otherVector defines the second operand
  3309. * @returns true if both vectors are equals
  3310. */
  3311. equals(otherVector: DeepImmutable<Vector3>): boolean;
  3312. /**
  3313. * Returns true if the current Vector3 and the given vector coordinates are distant less than epsilon
  3314. * @param otherVector defines the second operand
  3315. * @param epsilon defines the minimal distance to define values as equals
  3316. * @returns true if both vectors are distant less than epsilon
  3317. */
  3318. equalsWithEpsilon(otherVector: DeepImmutable<Vector3>, epsilon?: number): boolean;
  3319. /**
  3320. * Returns true if the current Vector3 coordinates equals the given floats
  3321. * @param x defines the x coordinate of the operand
  3322. * @param y defines the y coordinate of the operand
  3323. * @param z defines the z coordinate of the operand
  3324. * @returns true if both vectors are equals
  3325. */
  3326. equalsToFloats(x: number, y: number, z: number): boolean;
  3327. /**
  3328. * Multiplies the current Vector3 coordinates by the given ones
  3329. * @param otherVector defines the second operand
  3330. * @returns the current updated Vector3
  3331. */
  3332. multiplyInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  3333. /**
  3334. * Returns a new Vector3, result of the multiplication of the current Vector3 by the given vector
  3335. * @param otherVector defines the second operand
  3336. * @returns the new Vector3
  3337. */
  3338. multiply(otherVector: DeepImmutable<Vector3>): Vector3;
  3339. /**
  3340. * Multiplies the current Vector3 by the given one and stores the result in the given vector "result"
  3341. * @param otherVector defines the second operand
  3342. * @param result defines the Vector3 object where to store the result
  3343. * @returns the current Vector3
  3344. */
  3345. multiplyToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  3346. /**
  3347. * Returns a new Vector3 set with the result of the mulliplication of the current Vector3 coordinates by the given floats
  3348. * @param x defines the x coordinate of the operand
  3349. * @param y defines the y coordinate of the operand
  3350. * @param z defines the z coordinate of the operand
  3351. * @returns the new Vector3
  3352. */
  3353. multiplyByFloats(x: number, y: number, z: number): Vector3;
  3354. /**
  3355. * Returns a new Vector3 set with the result of the division of the current Vector3 coordinates by the given ones
  3356. * @param otherVector defines the second operand
  3357. * @returns the new Vector3
  3358. */
  3359. divide(otherVector: DeepImmutable<Vector3>): Vector3;
  3360. /**
  3361. * Divides the current Vector3 coordinates by the given ones and stores the result in the given vector "result"
  3362. * @param otherVector defines the second operand
  3363. * @param result defines the Vector3 object where to store the result
  3364. * @returns the current Vector3
  3365. */
  3366. divideToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  3367. /**
  3368. * Divides the current Vector3 coordinates by the given ones.
  3369. * @param otherVector defines the second operand
  3370. * @returns the current updated Vector3
  3371. */
  3372. divideInPlace(otherVector: Vector3): Vector3;
  3373. /**
  3374. * Updates the current Vector3 with the minimal coordinate values between its and the given vector ones
  3375. * @param other defines the second operand
  3376. * @returns the current updated Vector3
  3377. */
  3378. minimizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  3379. /**
  3380. * Updates the current Vector3 with the maximal coordinate values between its and the given vector ones.
  3381. * @param other defines the second operand
  3382. * @returns the current updated Vector3
  3383. */
  3384. maximizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  3385. /**
  3386. * Updates the current Vector3 with the minimal coordinate values between its and the given coordinates
  3387. * @param x defines the x coordinate of the operand
  3388. * @param y defines the y coordinate of the operand
  3389. * @param z defines the z coordinate of the operand
  3390. * @returns the current updated Vector3
  3391. */
  3392. minimizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  3393. /**
  3394. * Updates the current Vector3 with the maximal coordinate values between its and the given coordinates.
  3395. * @param x defines the x coordinate of the operand
  3396. * @param y defines the y coordinate of the operand
  3397. * @param z defines the z coordinate of the operand
  3398. * @returns the current updated Vector3
  3399. */
  3400. maximizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  3401. /**
  3402. * Due to float precision, scale of a mesh could be uniform but float values are off by a small fraction
  3403. * Check if is non uniform within a certain amount of decimal places to account for this
  3404. * @param epsilon the amount the values can differ
  3405. * @returns if the the vector is non uniform to a certain number of decimal places
  3406. */
  3407. isNonUniformWithinEpsilon(epsilon: number): boolean;
  3408. /**
  3409. * Gets a boolean indicating that the vector is non uniform meaning x, y or z are not all the same
  3410. */
  3411. get isNonUniform(): boolean;
  3412. /**
  3413. * Gets a new Vector3 from current Vector3 floored values
  3414. * @returns a new Vector3
  3415. */
  3416. floor(): Vector3;
  3417. /**
  3418. * Gets a new Vector3 from current Vector3 floored values
  3419. * @returns a new Vector3
  3420. */
  3421. fract(): Vector3;
  3422. /**
  3423. * Gets the length of the Vector3
  3424. * @returns the length of the Vector3
  3425. */
  3426. length(): number;
  3427. /**
  3428. * Gets the squared length of the Vector3
  3429. * @returns squared length of the Vector3
  3430. */
  3431. lengthSquared(): number;
  3432. /**
  3433. * Normalize the current Vector3.
  3434. * Please note that this is an in place operation.
  3435. * @returns the current updated Vector3
  3436. */
  3437. normalize(): Vector3;
  3438. /**
  3439. * Reorders the x y z properties of the vector in place
  3440. * @param order new ordering of the properties (eg. for vector 1,2,3 with "ZYX" will produce 3,2,1)
  3441. * @returns the current updated vector
  3442. */
  3443. reorderInPlace(order: string): this;
  3444. /**
  3445. * Rotates the vector around 0,0,0 by a quaternion
  3446. * @param quaternion the rotation quaternion
  3447. * @param result vector to store the result
  3448. * @returns the resulting vector
  3449. */
  3450. rotateByQuaternionToRef(quaternion: Quaternion, result: Vector3): Vector3;
  3451. /**
  3452. * Rotates a vector around a given point
  3453. * @param quaternion the rotation quaternion
  3454. * @param point the point to rotate around
  3455. * @param result vector to store the result
  3456. * @returns the resulting vector
  3457. */
  3458. rotateByQuaternionAroundPointToRef(quaternion: Quaternion, point: Vector3, result: Vector3): Vector3;
  3459. /**
  3460. * Returns a new Vector3 as the cross product of the current vector and the "other" one
  3461. * The cross product is then orthogonal to both current and "other"
  3462. * @param other defines the right operand
  3463. * @returns the cross product
  3464. */
  3465. cross(other: Vector3): Vector3;
  3466. /**
  3467. * Normalize the current Vector3 with the given input length.
  3468. * Please note that this is an in place operation.
  3469. * @param len the length of the vector
  3470. * @returns the current updated Vector3
  3471. */
  3472. normalizeFromLength(len: number): Vector3;
  3473. /**
  3474. * Normalize the current Vector3 to a new vector
  3475. * @returns the new Vector3
  3476. */
  3477. normalizeToNew(): Vector3;
  3478. /**
  3479. * Normalize the current Vector3 to the reference
  3480. * @param reference define the Vector3 to update
  3481. * @returns the updated Vector3
  3482. */
  3483. normalizeToRef(reference: Vector3): Vector3;
  3484. /**
  3485. * Creates a new Vector3 copied from the current Vector3
  3486. * @returns the new Vector3
  3487. */
  3488. clone(): Vector3;
  3489. /**
  3490. * Copies the given vector coordinates to the current Vector3 ones
  3491. * @param source defines the source Vector3
  3492. * @returns the current updated Vector3
  3493. */
  3494. copyFrom(source: DeepImmutable<Vector3>): Vector3;
  3495. /**
  3496. * Copies the given floats to the current Vector3 coordinates
  3497. * @param x defines the x coordinate of the operand
  3498. * @param y defines the y coordinate of the operand
  3499. * @param z defines the z coordinate of the operand
  3500. * @returns the current updated Vector3
  3501. */
  3502. copyFromFloats(x: number, y: number, z: number): Vector3;
  3503. /**
  3504. * Copies the given floats to the current Vector3 coordinates
  3505. * @param x defines the x coordinate of the operand
  3506. * @param y defines the y coordinate of the operand
  3507. * @param z defines the z coordinate of the operand
  3508. * @returns the current updated Vector3
  3509. */
  3510. set(x: number, y: number, z: number): Vector3;
  3511. /**
  3512. * Copies the given float to the current Vector3 coordinates
  3513. * @param v defines the x, y and z coordinates of the operand
  3514. * @returns the current updated Vector3
  3515. */
  3516. setAll(v: number): Vector3;
  3517. /**
  3518. * Get the clip factor between two vectors
  3519. * @param vector0 defines the first operand
  3520. * @param vector1 defines the second operand
  3521. * @param axis defines the axis to use
  3522. * @param size defines the size along the axis
  3523. * @returns the clip factor
  3524. */
  3525. static GetClipFactor(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, axis: DeepImmutable<Vector3>, size: number): number;
  3526. /**
  3527. * Get angle between two vectors
  3528. * @param vector0 angle between vector0 and vector1
  3529. * @param vector1 angle between vector0 and vector1
  3530. * @param normal direction of the normal
  3531. * @return the angle between vector0 and vector1
  3532. */
  3533. static GetAngleBetweenVectors(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>): number;
  3534. /**
  3535. * Returns a new Vector3 set from the index "offset" of the given array
  3536. * @param array defines the source array
  3537. * @param offset defines the offset in the source array
  3538. * @returns the new Vector3
  3539. */
  3540. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector3;
  3541. /**
  3542. * Returns a new Vector3 set from the index "offset" of the given Float32Array
  3543. * @param array defines the source array
  3544. * @param offset defines the offset in the source array
  3545. * @returns the new Vector3
  3546. * @deprecated Please use FromArray instead.
  3547. */
  3548. static FromFloatArray(array: DeepImmutable<Float32Array>, offset?: number): Vector3;
  3549. /**
  3550. * Sets the given vector "result" with the element values from the index "offset" of the given array
  3551. * @param array defines the source array
  3552. * @param offset defines the offset in the source array
  3553. * @param result defines the Vector3 where to store the result
  3554. */
  3555. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector3): void;
  3556. /**
  3557. * Sets the given vector "result" with the element values from the index "offset" of the given Float32Array
  3558. * @param array defines the source array
  3559. * @param offset defines the offset in the source array
  3560. * @param result defines the Vector3 where to store the result
  3561. * @deprecated Please use FromArrayToRef instead.
  3562. */
  3563. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector3): void;
  3564. /**
  3565. * Sets the given vector "result" with the given floats.
  3566. * @param x defines the x coordinate of the source
  3567. * @param y defines the y coordinate of the source
  3568. * @param z defines the z coordinate of the source
  3569. * @param result defines the Vector3 where to store the result
  3570. */
  3571. static FromFloatsToRef(x: number, y: number, z: number, result: Vector3): void;
  3572. /**
  3573. * Returns a new Vector3 set to (0.0, 0.0, 0.0)
  3574. * @returns a new empty Vector3
  3575. */
  3576. static Zero(): Vector3;
  3577. /**
  3578. * Returns a new Vector3 set to (1.0, 1.0, 1.0)
  3579. * @returns a new unit Vector3
  3580. */
  3581. static One(): Vector3;
  3582. /**
  3583. * Returns a new Vector3 set to (0.0, 1.0, 0.0)
  3584. * @returns a new up Vector3
  3585. */
  3586. static Up(): Vector3;
  3587. /**
  3588. * Gets a up Vector3 that must not be updated
  3589. */
  3590. static get UpReadOnly(): DeepImmutable<Vector3>;
  3591. /**
  3592. * Gets a zero Vector3 that must not be updated
  3593. */
  3594. static get ZeroReadOnly(): DeepImmutable<Vector3>;
  3595. /**
  3596. * Returns a new Vector3 set to (0.0, -1.0, 0.0)
  3597. * @returns a new down Vector3
  3598. */
  3599. static Down(): Vector3;
  3600. /**
  3601. * Returns a new Vector3 set to (0.0, 0.0, 1.0)
  3602. * @param rightHandedSystem is the scene right-handed (negative z)
  3603. * @returns a new forward Vector3
  3604. */
  3605. static Forward(rightHandedSystem?: boolean): Vector3;
  3606. /**
  3607. * Returns a new Vector3 set to (0.0, 0.0, -1.0)
  3608. * @param rightHandedSystem is the scene right-handed (negative-z)
  3609. * @returns a new forward Vector3
  3610. */
  3611. static Backward(rightHandedSystem?: boolean): Vector3;
  3612. /**
  3613. * Returns a new Vector3 set to (1.0, 0.0, 0.0)
  3614. * @returns a new right Vector3
  3615. */
  3616. static Right(): Vector3;
  3617. /**
  3618. * Returns a new Vector3 set to (-1.0, 0.0, 0.0)
  3619. * @returns a new left Vector3
  3620. */
  3621. static Left(): Vector3;
  3622. /**
  3623. * Returns a new Vector3 set with the result of the transformation by the given matrix of the given vector.
  3624. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  3625. * @param vector defines the Vector3 to transform
  3626. * @param transformation defines the transformation matrix
  3627. * @returns the transformed Vector3
  3628. */
  3629. static TransformCoordinates(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  3630. /**
  3631. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given vector
  3632. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  3633. * @param vector defines the Vector3 to transform
  3634. * @param transformation defines the transformation matrix
  3635. * @param result defines the Vector3 where to store the result
  3636. */
  3637. static TransformCoordinatesToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  3638. /**
  3639. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given floats (x, y, z)
  3640. * This method computes tranformed coordinates only, not transformed direction vectors
  3641. * @param x define the x coordinate of the source vector
  3642. * @param y define the y coordinate of the source vector
  3643. * @param z define the z coordinate of the source vector
  3644. * @param transformation defines the transformation matrix
  3645. * @param result defines the Vector3 where to store the result
  3646. */
  3647. static TransformCoordinatesFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  3648. /**
  3649. * Returns a new Vector3 set with the result of the normal transformation by the given matrix of the given vector
  3650. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  3651. * @param vector defines the Vector3 to transform
  3652. * @param transformation defines the transformation matrix
  3653. * @returns the new Vector3
  3654. */
  3655. static TransformNormal(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  3656. /**
  3657. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector
  3658. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  3659. * @param vector defines the Vector3 to transform
  3660. * @param transformation defines the transformation matrix
  3661. * @param result defines the Vector3 where to store the result
  3662. */
  3663. static TransformNormalToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  3664. /**
  3665. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z)
  3666. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  3667. * @param x define the x coordinate of the source vector
  3668. * @param y define the y coordinate of the source vector
  3669. * @param z define the z coordinate of the source vector
  3670. * @param transformation defines the transformation matrix
  3671. * @param result defines the Vector3 where to store the result
  3672. */
  3673. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  3674. /**
  3675. * Returns a new Vector3 located for "amount" on the CatmullRom interpolation spline defined by the vectors "value1", "value2", "value3", "value4"
  3676. * @param value1 defines the first control point
  3677. * @param value2 defines the second control point
  3678. * @param value3 defines the third control point
  3679. * @param value4 defines the fourth control point
  3680. * @param amount defines the amount on the spline to use
  3681. * @returns the new Vector3
  3682. */
  3683. static CatmullRom(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, value3: DeepImmutable<Vector3>, value4: DeepImmutable<Vector3>, amount: number): Vector3;
  3684. /**
  3685. * Returns a new Vector3 set with the coordinates of "value", if the vector "value" is in the cube defined by the vectors "min" and "max"
  3686. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  3687. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  3688. * @param value defines the current value
  3689. * @param min defines the lower range value
  3690. * @param max defines the upper range value
  3691. * @returns the new Vector3
  3692. */
  3693. static Clamp(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): Vector3;
  3694. /**
  3695. * Sets the given vector "result" with the coordinates of "value", if the vector "value" is in the cube defined by the vectors "min" and "max"
  3696. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  3697. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  3698. * @param value defines the current value
  3699. * @param min defines the lower range value
  3700. * @param max defines the upper range value
  3701. * @param result defines the Vector3 where to store the result
  3702. */
  3703. static ClampToRef(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, result: Vector3): void;
  3704. /**
  3705. * Checks if a given vector is inside a specific range
  3706. * @param v defines the vector to test
  3707. * @param min defines the minimum range
  3708. * @param max defines the maximum range
  3709. */
  3710. static CheckExtends(v: Vector3, min: Vector3, max: Vector3): void;
  3711. /**
  3712. * Returns a new Vector3 located for "amount" (float) on the Hermite interpolation spline defined by the vectors "value1", "tangent1", "value2", "tangent2"
  3713. * @param value1 defines the first control point
  3714. * @param tangent1 defines the first tangent vector
  3715. * @param value2 defines the second control point
  3716. * @param tangent2 defines the second tangent vector
  3717. * @param amount defines the amount on the interpolation spline (between 0 and 1)
  3718. * @returns the new Vector3
  3719. */
  3720. static Hermite(value1: DeepImmutable<Vector3>, tangent1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, tangent2: DeepImmutable<Vector3>, amount: number): Vector3;
  3721. /**
  3722. * Returns a new Vector3 located for "amount" (float) on the linear interpolation between the vectors "start" and "end"
  3723. * @param start defines the start value
  3724. * @param end defines the end value
  3725. * @param amount max defines amount between both (between 0 and 1)
  3726. * @returns the new Vector3
  3727. */
  3728. static Lerp(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number): Vector3;
  3729. /**
  3730. * Sets the given vector "result" with the result of the linear interpolation from the vector "start" for "amount" to the vector "end"
  3731. * @param start defines the start value
  3732. * @param end defines the end value
  3733. * @param amount max defines amount between both (between 0 and 1)
  3734. * @param result defines the Vector3 where to store the result
  3735. */
  3736. static LerpToRef(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number, result: Vector3): void;
  3737. /**
  3738. * Returns the dot product (float) between the vectors "left" and "right"
  3739. * @param left defines the left operand
  3740. * @param right defines the right operand
  3741. * @returns the dot product
  3742. */
  3743. static Dot(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): number;
  3744. /**
  3745. * Returns a new Vector3 as the cross product of the vectors "left" and "right"
  3746. * The cross product is then orthogonal to both "left" and "right"
  3747. * @param left defines the left operand
  3748. * @param right defines the right operand
  3749. * @returns the cross product
  3750. */
  3751. static Cross(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  3752. /**
  3753. * Sets the given vector "result" with the cross product of "left" and "right"
  3754. * The cross product is then orthogonal to both "left" and "right"
  3755. * @param left defines the left operand
  3756. * @param right defines the right operand
  3757. * @param result defines the Vector3 where to store the result
  3758. */
  3759. static CrossToRef(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>, result: Vector3): void;
  3760. /**
  3761. * Returns a new Vector3 as the normalization of the given vector
  3762. * @param vector defines the Vector3 to normalize
  3763. * @returns the new Vector3
  3764. */
  3765. static Normalize(vector: DeepImmutable<Vector3>): Vector3;
  3766. /**
  3767. * Sets the given vector "result" with the normalization of the given first vector
  3768. * @param vector defines the Vector3 to normalize
  3769. * @param result defines the Vector3 where to store the result
  3770. */
  3771. static NormalizeToRef(vector: DeepImmutable<Vector3>, result: Vector3): void;
  3772. /**
  3773. * Project a Vector3 onto screen space
  3774. * @param vector defines the Vector3 to project
  3775. * @param world defines the world matrix to use
  3776. * @param transform defines the transform (view x projection) matrix to use
  3777. * @param viewport defines the screen viewport to use
  3778. * @returns the new Vector3
  3779. */
  3780. static Project(vector: DeepImmutable<Vector3>, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>, viewport: DeepImmutable<Viewport>): Vector3;
  3781. /**
  3782. * Project a Vector3 onto screen space to reference
  3783. * @param vector defines the Vector3 to project
  3784. * @param world defines the world matrix to use
  3785. * @param transform defines the transform (view x projection) matrix to use
  3786. * @param viewport defines the screen viewport to use
  3787. * @param result the vector in which the screen space will be stored
  3788. * @returns the new Vector3
  3789. */
  3790. static ProjectToRef(vector: DeepImmutable<Vector3>, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>, viewport: DeepImmutable<Viewport>, result: DeepImmutable<Vector3>): Vector3;
  3791. /** @hidden */
  3792. static _UnprojectFromInvertedMatrixToRef(source: DeepImmutable<Vector3>, matrix: DeepImmutable<Matrix>, result: Vector3): void;
  3793. /**
  3794. * Unproject from screen space to object space
  3795. * @param source defines the screen space Vector3 to use
  3796. * @param viewportWidth defines the current width of the viewport
  3797. * @param viewportHeight defines the current height of the viewport
  3798. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  3799. * @param transform defines the transform (view x projection) matrix to use
  3800. * @returns the new Vector3
  3801. */
  3802. static UnprojectFromTransform(source: Vector3, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>): Vector3;
  3803. /**
  3804. * Unproject from screen space to object space
  3805. * @param source defines the screen space Vector3 to use
  3806. * @param viewportWidth defines the current width of the viewport
  3807. * @param viewportHeight defines the current height of the viewport
  3808. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  3809. * @param view defines the view matrix to use
  3810. * @param projection defines the projection matrix to use
  3811. * @returns the new Vector3
  3812. */
  3813. static Unproject(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Vector3;
  3814. /**
  3815. * Unproject from screen space to object space
  3816. * @param source defines the screen space Vector3 to use
  3817. * @param viewportWidth defines the current width of the viewport
  3818. * @param viewportHeight defines the current height of the viewport
  3819. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  3820. * @param view defines the view matrix to use
  3821. * @param projection defines the projection matrix to use
  3822. * @param result defines the Vector3 where to store the result
  3823. */
  3824. static UnprojectToRef(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  3825. /**
  3826. * Unproject from screen space to object space
  3827. * @param sourceX defines the screen space x coordinate to use
  3828. * @param sourceY defines the screen space y coordinate to use
  3829. * @param sourceZ defines the screen space z coordinate to use
  3830. * @param viewportWidth defines the current width of the viewport
  3831. * @param viewportHeight defines the current height of the viewport
  3832. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  3833. * @param view defines the view matrix to use
  3834. * @param projection defines the projection matrix to use
  3835. * @param result defines the Vector3 where to store the result
  3836. */
  3837. static UnprojectFloatsToRef(sourceX: float, sourceY: float, sourceZ: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  3838. /**
  3839. * Gets the minimal coordinate values between two Vector3
  3840. * @param left defines the first operand
  3841. * @param right defines the second operand
  3842. * @returns the new Vector3
  3843. */
  3844. static Minimize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  3845. /**
  3846. * Gets the maximal coordinate values between two Vector3
  3847. * @param left defines the first operand
  3848. * @param right defines the second operand
  3849. * @returns the new Vector3
  3850. */
  3851. static Maximize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  3852. /**
  3853. * Returns the distance between the vectors "value1" and "value2"
  3854. * @param value1 defines the first operand
  3855. * @param value2 defines the second operand
  3856. * @returns the distance
  3857. */
  3858. static Distance(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  3859. /**
  3860. * Returns the squared distance between the vectors "value1" and "value2"
  3861. * @param value1 defines the first operand
  3862. * @param value2 defines the second operand
  3863. * @returns the squared distance
  3864. */
  3865. static DistanceSquared(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  3866. /**
  3867. * Returns a new Vector3 located at the center between "value1" and "value2"
  3868. * @param value1 defines the first operand
  3869. * @param value2 defines the second operand
  3870. * @returns the new Vector3
  3871. */
  3872. static Center(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): Vector3;
  3873. /**
  3874. * Gets the center of the vectors "value1" and "value2" and stores the result in the vector "ref"
  3875. * @param value1 defines first vector
  3876. * @param value2 defines second vector
  3877. * @param ref defines third vector
  3878. * @returns ref
  3879. */
  3880. static CenterToRef(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, ref: DeepImmutable<Vector3>): Vector3;
  3881. /**
  3882. * Given three orthogonal normalized left-handed oriented Vector3 axis in space (target system),
  3883. * RotationFromAxis() returns the rotation Euler angles (ex : rotation.x, rotation.y, rotation.z) to apply
  3884. * to something in order to rotate it from its local system to the given target system
  3885. * Note: axis1, axis2 and axis3 are normalized during this operation
  3886. * @param axis1 defines the first axis
  3887. * @param axis2 defines the second axis
  3888. * @param axis3 defines the third axis
  3889. * @returns a new Vector3
  3890. */
  3891. static RotationFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Vector3;
  3892. /**
  3893. * The same than RotationFromAxis but updates the given ref Vector3 parameter instead of returning a new Vector3
  3894. * @param axis1 defines the first axis
  3895. * @param axis2 defines the second axis
  3896. * @param axis3 defines the third axis
  3897. * @param ref defines the Vector3 where to store the result
  3898. */
  3899. static RotationFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Vector3): void;
  3900. }
  3901. /**
  3902. * Vector4 class created for EulerAngle class conversion to Quaternion
  3903. */
  3904. export class Vector4 {
  3905. /** x value of the vector */
  3906. x: number;
  3907. /** y value of the vector */
  3908. y: number;
  3909. /** z value of the vector */
  3910. z: number;
  3911. /** w value of the vector */
  3912. w: number;
  3913. /**
  3914. * Creates a Vector4 object from the given floats.
  3915. * @param x x value of the vector
  3916. * @param y y value of the vector
  3917. * @param z z value of the vector
  3918. * @param w w value of the vector
  3919. */
  3920. constructor(
  3921. /** x value of the vector */
  3922. x: number,
  3923. /** y value of the vector */
  3924. y: number,
  3925. /** z value of the vector */
  3926. z: number,
  3927. /** w value of the vector */
  3928. w: number);
  3929. /**
  3930. * Returns the string with the Vector4 coordinates.
  3931. * @returns a string containing all the vector values
  3932. */
  3933. toString(): string;
  3934. /**
  3935. * Returns the string "Vector4".
  3936. * @returns "Vector4"
  3937. */
  3938. getClassName(): string;
  3939. /**
  3940. * Returns the Vector4 hash code.
  3941. * @returns a unique hash code
  3942. */
  3943. getHashCode(): number;
  3944. /**
  3945. * Returns a new array populated with 4 elements : the Vector4 coordinates.
  3946. * @returns the resulting array
  3947. */
  3948. asArray(): number[];
  3949. /**
  3950. * Populates the given array from the given index with the Vector4 coordinates.
  3951. * @param array array to populate
  3952. * @param index index of the array to start at (default: 0)
  3953. * @returns the Vector4.
  3954. */
  3955. toArray(array: FloatArray, index?: number): Vector4;
  3956. /**
  3957. * Update the current vector from an array
  3958. * @param array defines the destination array
  3959. * @param index defines the offset in the destination array
  3960. * @returns the current Vector3
  3961. */
  3962. fromArray(array: FloatArray, index?: number): Vector4;
  3963. /**
  3964. * Adds the given vector to the current Vector4.
  3965. * @param otherVector the vector to add
  3966. * @returns the updated Vector4.
  3967. */
  3968. addInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  3969. /**
  3970. * Returns a new Vector4 as the result of the addition of the current Vector4 and the given one.
  3971. * @param otherVector the vector to add
  3972. * @returns the resulting vector
  3973. */
  3974. add(otherVector: DeepImmutable<Vector4>): Vector4;
  3975. /**
  3976. * Updates the given vector "result" with the result of the addition of the current Vector4 and the given one.
  3977. * @param otherVector the vector to add
  3978. * @param result the vector to store the result
  3979. * @returns the current Vector4.
  3980. */
  3981. addToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  3982. /**
  3983. * Subtract in place the given vector from the current Vector4.
  3984. * @param otherVector the vector to subtract
  3985. * @returns the updated Vector4.
  3986. */
  3987. subtractInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  3988. /**
  3989. * Returns a new Vector4 with the result of the subtraction of the given vector from the current Vector4.
  3990. * @param otherVector the vector to add
  3991. * @returns the new vector with the result
  3992. */
  3993. subtract(otherVector: DeepImmutable<Vector4>): Vector4;
  3994. /**
  3995. * Sets the given vector "result" with the result of the subtraction of the given vector from the current Vector4.
  3996. * @param otherVector the vector to subtract
  3997. * @param result the vector to store the result
  3998. * @returns the current Vector4.
  3999. */
  4000. subtractToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  4001. /**
  4002. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  4003. */
  4004. /**
  4005. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  4006. * @param x value to subtract
  4007. * @param y value to subtract
  4008. * @param z value to subtract
  4009. * @param w value to subtract
  4010. * @returns new vector containing the result
  4011. */
  4012. subtractFromFloats(x: number, y: number, z: number, w: number): Vector4;
  4013. /**
  4014. * Sets the given vector "result" set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  4015. * @param x value to subtract
  4016. * @param y value to subtract
  4017. * @param z value to subtract
  4018. * @param w value to subtract
  4019. * @param result the vector to store the result in
  4020. * @returns the current Vector4.
  4021. */
  4022. subtractFromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): Vector4;
  4023. /**
  4024. * Returns a new Vector4 set with the current Vector4 negated coordinates.
  4025. * @returns a new vector with the negated values
  4026. */
  4027. negate(): Vector4;
  4028. /**
  4029. * Negate this vector in place
  4030. * @returns this
  4031. */
  4032. negateInPlace(): Vector4;
  4033. /**
  4034. * Negate the current Vector4 and stores the result in the given vector "result" coordinates
  4035. * @param result defines the Vector3 object where to store the result
  4036. * @returns the current Vector4
  4037. */
  4038. negateToRef(result: Vector4): Vector4;
  4039. /**
  4040. * Multiplies the current Vector4 coordinates by scale (float).
  4041. * @param scale the number to scale with
  4042. * @returns the updated Vector4.
  4043. */
  4044. scaleInPlace(scale: number): Vector4;
  4045. /**
  4046. * Returns a new Vector4 set with the current Vector4 coordinates multiplied by scale (float).
  4047. * @param scale the number to scale with
  4048. * @returns a new vector with the result
  4049. */
  4050. scale(scale: number): Vector4;
  4051. /**
  4052. * Sets the given vector "result" with the current Vector4 coordinates multiplied by scale (float).
  4053. * @param scale the number to scale with
  4054. * @param result a vector to store the result in
  4055. * @returns the current Vector4.
  4056. */
  4057. scaleToRef(scale: number, result: Vector4): Vector4;
  4058. /**
  4059. * Scale the current Vector4 values by a factor and add the result to a given Vector4
  4060. * @param scale defines the scale factor
  4061. * @param result defines the Vector4 object where to store the result
  4062. * @returns the unmodified current Vector4
  4063. */
  4064. scaleAndAddToRef(scale: number, result: Vector4): Vector4;
  4065. /**
  4066. * Boolean : True if the current Vector4 coordinates are stricly equal to the given ones.
  4067. * @param otherVector the vector to compare against
  4068. * @returns true if they are equal
  4069. */
  4070. equals(otherVector: DeepImmutable<Vector4>): boolean;
  4071. /**
  4072. * Boolean : True if the current Vector4 coordinates are each beneath the distance "epsilon" from the given vector ones.
  4073. * @param otherVector vector to compare against
  4074. * @param epsilon (Default: very small number)
  4075. * @returns true if they are equal
  4076. */
  4077. equalsWithEpsilon(otherVector: DeepImmutable<Vector4>, epsilon?: number): boolean;
  4078. /**
  4079. * Boolean : True if the given floats are strictly equal to the current Vector4 coordinates.
  4080. * @param x x value to compare against
  4081. * @param y y value to compare against
  4082. * @param z z value to compare against
  4083. * @param w w value to compare against
  4084. * @returns true if equal
  4085. */
  4086. equalsToFloats(x: number, y: number, z: number, w: number): boolean;
  4087. /**
  4088. * Multiplies in place the current Vector4 by the given one.
  4089. * @param otherVector vector to multiple with
  4090. * @returns the updated Vector4.
  4091. */
  4092. multiplyInPlace(otherVector: Vector4): Vector4;
  4093. /**
  4094. * Returns a new Vector4 set with the multiplication result of the current Vector4 and the given one.
  4095. * @param otherVector vector to multiple with
  4096. * @returns resulting new vector
  4097. */
  4098. multiply(otherVector: DeepImmutable<Vector4>): Vector4;
  4099. /**
  4100. * Updates the given vector "result" with the multiplication result of the current Vector4 and the given one.
  4101. * @param otherVector vector to multiple with
  4102. * @param result vector to store the result
  4103. * @returns the current Vector4.
  4104. */
  4105. multiplyToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  4106. /**
  4107. * Returns a new Vector4 set with the multiplication result of the given floats and the current Vector4 coordinates.
  4108. * @param x x value multiply with
  4109. * @param y y value multiply with
  4110. * @param z z value multiply with
  4111. * @param w w value multiply with
  4112. * @returns resulting new vector
  4113. */
  4114. multiplyByFloats(x: number, y: number, z: number, w: number): Vector4;
  4115. /**
  4116. * Returns a new Vector4 set with the division result of the current Vector4 by the given one.
  4117. * @param otherVector vector to devide with
  4118. * @returns resulting new vector
  4119. */
  4120. divide(otherVector: DeepImmutable<Vector4>): Vector4;
  4121. /**
  4122. * Updates the given vector "result" with the division result of the current Vector4 by the given one.
  4123. * @param otherVector vector to devide with
  4124. * @param result vector to store the result
  4125. * @returns the current Vector4.
  4126. */
  4127. divideToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  4128. /**
  4129. * Divides the current Vector3 coordinates by the given ones.
  4130. * @param otherVector vector to devide with
  4131. * @returns the updated Vector3.
  4132. */
  4133. divideInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  4134. /**
  4135. * Updates the Vector4 coordinates with the minimum values between its own and the given vector ones
  4136. * @param other defines the second operand
  4137. * @returns the current updated Vector4
  4138. */
  4139. minimizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  4140. /**
  4141. * Updates the Vector4 coordinates with the maximum values between its own and the given vector ones
  4142. * @param other defines the second operand
  4143. * @returns the current updated Vector4
  4144. */
  4145. maximizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  4146. /**
  4147. * Gets a new Vector4 from current Vector4 floored values
  4148. * @returns a new Vector4
  4149. */
  4150. floor(): Vector4;
  4151. /**
  4152. * Gets a new Vector4 from current Vector3 floored values
  4153. * @returns a new Vector4
  4154. */
  4155. fract(): Vector4;
  4156. /**
  4157. * Returns the Vector4 length (float).
  4158. * @returns the length
  4159. */
  4160. length(): number;
  4161. /**
  4162. * Returns the Vector4 squared length (float).
  4163. * @returns the length squared
  4164. */
  4165. lengthSquared(): number;
  4166. /**
  4167. * Normalizes in place the Vector4.
  4168. * @returns the updated Vector4.
  4169. */
  4170. normalize(): Vector4;
  4171. /**
  4172. * Returns a new Vector3 from the Vector4 (x, y, z) coordinates.
  4173. * @returns this converted to a new vector3
  4174. */
  4175. toVector3(): Vector3;
  4176. /**
  4177. * Returns a new Vector4 copied from the current one.
  4178. * @returns the new cloned vector
  4179. */
  4180. clone(): Vector4;
  4181. /**
  4182. * Updates the current Vector4 with the given one coordinates.
  4183. * @param source the source vector to copy from
  4184. * @returns the updated Vector4.
  4185. */
  4186. copyFrom(source: DeepImmutable<Vector4>): Vector4;
  4187. /**
  4188. * Updates the current Vector4 coordinates with the given floats.
  4189. * @param x float to copy from
  4190. * @param y float to copy from
  4191. * @param z float to copy from
  4192. * @param w float to copy from
  4193. * @returns the updated Vector4.
  4194. */
  4195. copyFromFloats(x: number, y: number, z: number, w: number): Vector4;
  4196. /**
  4197. * Updates the current Vector4 coordinates with the given floats.
  4198. * @param x float to set from
  4199. * @param y float to set from
  4200. * @param z float to set from
  4201. * @param w float to set from
  4202. * @returns the updated Vector4.
  4203. */
  4204. set(x: number, y: number, z: number, w: number): Vector4;
  4205. /**
  4206. * Copies the given float to the current Vector3 coordinates
  4207. * @param v defines the x, y, z and w coordinates of the operand
  4208. * @returns the current updated Vector3
  4209. */
  4210. setAll(v: number): Vector4;
  4211. /**
  4212. * Returns a new Vector4 set from the starting index of the given array.
  4213. * @param array the array to pull values from
  4214. * @param offset the offset into the array to start at
  4215. * @returns the new vector
  4216. */
  4217. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector4;
  4218. /**
  4219. * Updates the given vector "result" from the starting index of the given array.
  4220. * @param array the array to pull values from
  4221. * @param offset the offset into the array to start at
  4222. * @param result the vector to store the result in
  4223. */
  4224. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector4): void;
  4225. /**
  4226. * Updates the given vector "result" from the starting index of the given Float32Array.
  4227. * @param array the array to pull values from
  4228. * @param offset the offset into the array to start at
  4229. * @param result the vector to store the result in
  4230. */
  4231. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector4): void;
  4232. /**
  4233. * Updates the given vector "result" coordinates from the given floats.
  4234. * @param x float to set from
  4235. * @param y float to set from
  4236. * @param z float to set from
  4237. * @param w float to set from
  4238. * @param result the vector to the floats in
  4239. */
  4240. static FromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): void;
  4241. /**
  4242. * Returns a new Vector4 set to (0.0, 0.0, 0.0, 0.0)
  4243. * @returns the new vector
  4244. */
  4245. static Zero(): Vector4;
  4246. /**
  4247. * Returns a new Vector4 set to (1.0, 1.0, 1.0, 1.0)
  4248. * @returns the new vector
  4249. */
  4250. static One(): Vector4;
  4251. /**
  4252. * Returns a new normalized Vector4 from the given one.
  4253. * @param vector the vector to normalize
  4254. * @returns the vector
  4255. */
  4256. static Normalize(vector: DeepImmutable<Vector4>): Vector4;
  4257. /**
  4258. * Updates the given vector "result" from the normalization of the given one.
  4259. * @param vector the vector to normalize
  4260. * @param result the vector to store the result in
  4261. */
  4262. static NormalizeToRef(vector: DeepImmutable<Vector4>, result: Vector4): void;
  4263. /**
  4264. * Returns a vector with the minimum values from the left and right vectors
  4265. * @param left left vector to minimize
  4266. * @param right right vector to minimize
  4267. * @returns a new vector with the minimum of the left and right vector values
  4268. */
  4269. static Minimize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  4270. /**
  4271. * Returns a vector with the maximum values from the left and right vectors
  4272. * @param left left vector to maximize
  4273. * @param right right vector to maximize
  4274. * @returns a new vector with the maximum of the left and right vector values
  4275. */
  4276. static Maximize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  4277. /**
  4278. * Returns the distance (float) between the vectors "value1" and "value2".
  4279. * @param value1 value to calulate the distance between
  4280. * @param value2 value to calulate the distance between
  4281. * @return the distance between the two vectors
  4282. */
  4283. static Distance(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  4284. /**
  4285. * Returns the squared distance (float) between the vectors "value1" and "value2".
  4286. * @param value1 value to calulate the distance between
  4287. * @param value2 value to calulate the distance between
  4288. * @return the distance between the two vectors squared
  4289. */
  4290. static DistanceSquared(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  4291. /**
  4292. * Returns a new Vector4 located at the center between the vectors "value1" and "value2".
  4293. * @param value1 value to calulate the center between
  4294. * @param value2 value to calulate the center between
  4295. * @return the center between the two vectors
  4296. */
  4297. static Center(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): Vector4;
  4298. /**
  4299. * Gets the center of the vectors "value1" and "value2" and stores the result in the vector "ref"
  4300. * @param value1 defines first vector
  4301. * @param value2 defines second vector
  4302. * @param ref defines third vector
  4303. * @returns ref
  4304. */
  4305. static CenterToRef(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>, ref: DeepImmutable<Vector4>): Vector4;
  4306. /**
  4307. * Returns a new Vector4 set with the result of the normal transformation by the given matrix of the given vector.
  4308. * This methods computes transformed normalized direction vectors only.
  4309. * @param vector the vector to transform
  4310. * @param transformation the transformation matrix to apply
  4311. * @returns the new vector
  4312. */
  4313. static TransformNormal(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>): Vector4;
  4314. /**
  4315. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector.
  4316. * This methods computes transformed normalized direction vectors only.
  4317. * @param vector the vector to transform
  4318. * @param transformation the transformation matrix to apply
  4319. * @param result the vector to store the result in
  4320. */
  4321. static TransformNormalToRef(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  4322. /**
  4323. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z, w).
  4324. * This methods computes transformed normalized direction vectors only.
  4325. * @param x value to transform
  4326. * @param y value to transform
  4327. * @param z value to transform
  4328. * @param w value to transform
  4329. * @param transformation the transformation matrix to apply
  4330. * @param result the vector to store the results in
  4331. */
  4332. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, w: number, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  4333. /**
  4334. * Creates a new Vector4 from a Vector3
  4335. * @param source defines the source data
  4336. * @param w defines the 4th component (default is 0)
  4337. * @returns a new Vector4
  4338. */
  4339. static FromVector3(source: Vector3, w?: number): Vector4;
  4340. }
  4341. /**
  4342. * Class used to store quaternion data
  4343. * @see https://en.wikipedia.org/wiki/Quaternion
  4344. * @see https://doc.babylonjs.com/features/position,_rotation,_scaling
  4345. */
  4346. export class Quaternion {
  4347. /** @hidden */
  4348. _x: number;
  4349. /** @hidden */
  4350. _y: number;
  4351. /** @hidden */
  4352. _z: number;
  4353. /** @hidden */
  4354. _w: number;
  4355. /** @hidden */
  4356. _isDirty: boolean;
  4357. /** Gets or sets the x coordinate */
  4358. get x(): number;
  4359. set x(value: number);
  4360. /** Gets or sets the y coordinate */
  4361. get y(): number;
  4362. set y(value: number);
  4363. /** Gets or sets the z coordinate */
  4364. get z(): number;
  4365. set z(value: number);
  4366. /** Gets or sets the w coordinate */
  4367. get w(): number;
  4368. set w(value: number);
  4369. /**
  4370. * Creates a new Quaternion from the given floats
  4371. * @param x defines the first component (0 by default)
  4372. * @param y defines the second component (0 by default)
  4373. * @param z defines the third component (0 by default)
  4374. * @param w defines the fourth component (1.0 by default)
  4375. */
  4376. constructor(x?: number, y?: number, z?: number, w?: number);
  4377. /**
  4378. * Gets a string representation for the current quaternion
  4379. * @returns a string with the Quaternion coordinates
  4380. */
  4381. toString(): string;
  4382. /**
  4383. * Gets the class name of the quaternion
  4384. * @returns the string "Quaternion"
  4385. */
  4386. getClassName(): string;
  4387. /**
  4388. * Gets a hash code for this quaternion
  4389. * @returns the quaternion hash code
  4390. */
  4391. getHashCode(): number;
  4392. /**
  4393. * Copy the quaternion to an array
  4394. * @returns a new array populated with 4 elements from the quaternion coordinates
  4395. */
  4396. asArray(): number[];
  4397. /**
  4398. * Check if two quaternions are equals
  4399. * @param otherQuaternion defines the second operand
  4400. * @return true if the current quaternion and the given one coordinates are strictly equals
  4401. */
  4402. equals(otherQuaternion: DeepImmutable<Quaternion>): boolean;
  4403. /**
  4404. * Gets a boolean if two quaternions are equals (using an epsilon value)
  4405. * @param otherQuaternion defines the other quaternion
  4406. * @param epsilon defines the minimal distance to consider equality
  4407. * @returns true if the given quaternion coordinates are close to the current ones by a distance of epsilon.
  4408. */
  4409. equalsWithEpsilon(otherQuaternion: DeepImmutable<Quaternion>, epsilon?: number): boolean;
  4410. /**
  4411. * Clone the current quaternion
  4412. * @returns a new quaternion copied from the current one
  4413. */
  4414. clone(): Quaternion;
  4415. /**
  4416. * Copy a quaternion to the current one
  4417. * @param other defines the other quaternion
  4418. * @returns the updated current quaternion
  4419. */
  4420. copyFrom(other: DeepImmutable<Quaternion>): Quaternion;
  4421. /**
  4422. * Updates the current quaternion with the given float coordinates
  4423. * @param x defines the x coordinate
  4424. * @param y defines the y coordinate
  4425. * @param z defines the z coordinate
  4426. * @param w defines the w coordinate
  4427. * @returns the updated current quaternion
  4428. */
  4429. copyFromFloats(x: number, y: number, z: number, w: number): Quaternion;
  4430. /**
  4431. * Updates the current quaternion from the given float coordinates
  4432. * @param x defines the x coordinate
  4433. * @param y defines the y coordinate
  4434. * @param z defines the z coordinate
  4435. * @param w defines the w coordinate
  4436. * @returns the updated current quaternion
  4437. */
  4438. set(x: number, y: number, z: number, w: number): Quaternion;
  4439. /**
  4440. * Adds two quaternions
  4441. * @param other defines the second operand
  4442. * @returns a new quaternion as the addition result of the given one and the current quaternion
  4443. */
  4444. add(other: DeepImmutable<Quaternion>): Quaternion;
  4445. /**
  4446. * Add a quaternion to the current one
  4447. * @param other defines the quaternion to add
  4448. * @returns the current quaternion
  4449. */
  4450. addInPlace(other: DeepImmutable<Quaternion>): Quaternion;
  4451. /**
  4452. * Subtract two quaternions
  4453. * @param other defines the second operand
  4454. * @returns a new quaternion as the subtraction result of the given one from the current one
  4455. */
  4456. subtract(other: Quaternion): Quaternion;
  4457. /**
  4458. * Multiplies the current quaternion by a scale factor
  4459. * @param value defines the scale factor
  4460. * @returns a new quaternion set by multiplying the current quaternion coordinates by the float "scale"
  4461. */
  4462. scale(value: number): Quaternion;
  4463. /**
  4464. * Scale the current quaternion values by a factor and stores the result to a given quaternion
  4465. * @param scale defines the scale factor
  4466. * @param result defines the Quaternion object where to store the result
  4467. * @returns the unmodified current quaternion
  4468. */
  4469. scaleToRef(scale: number, result: Quaternion): Quaternion;
  4470. /**
  4471. * Multiplies in place the current quaternion by a scale factor
  4472. * @param value defines the scale factor
  4473. * @returns the current modified quaternion
  4474. */
  4475. scaleInPlace(value: number): Quaternion;
  4476. /**
  4477. * Scale the current quaternion values by a factor and add the result to a given quaternion
  4478. * @param scale defines the scale factor
  4479. * @param result defines the Quaternion object where to store the result
  4480. * @returns the unmodified current quaternion
  4481. */
  4482. scaleAndAddToRef(scale: number, result: Quaternion): Quaternion;
  4483. /**
  4484. * Multiplies two quaternions
  4485. * @param q1 defines the second operand
  4486. * @returns a new quaternion set as the multiplication result of the current one with the given one "q1"
  4487. */
  4488. multiply(q1: DeepImmutable<Quaternion>): Quaternion;
  4489. /**
  4490. * Sets the given "result" as the the multiplication result of the current one with the given one "q1"
  4491. * @param q1 defines the second operand
  4492. * @param result defines the target quaternion
  4493. * @returns the current quaternion
  4494. */
  4495. multiplyToRef(q1: DeepImmutable<Quaternion>, result: Quaternion): Quaternion;
  4496. /**
  4497. * Updates the current quaternion with the multiplication of itself with the given one "q1"
  4498. * @param q1 defines the second operand
  4499. * @returns the currentupdated quaternion
  4500. */
  4501. multiplyInPlace(q1: DeepImmutable<Quaternion>): Quaternion;
  4502. /**
  4503. * Conjugates (1-q) the current quaternion and stores the result in the given quaternion
  4504. * @param ref defines the target quaternion
  4505. * @returns the current quaternion
  4506. */
  4507. conjugateToRef(ref: Quaternion): Quaternion;
  4508. /**
  4509. * Conjugates in place (1-q) the current quaternion
  4510. * @returns the current updated quaternion
  4511. */
  4512. conjugateInPlace(): Quaternion;
  4513. /**
  4514. * Conjugates in place (1-q) the current quaternion
  4515. * @returns a new quaternion
  4516. */
  4517. conjugate(): Quaternion;
  4518. /**
  4519. * Gets length of current quaternion
  4520. * @returns the quaternion length (float)
  4521. */
  4522. length(): number;
  4523. /**
  4524. * Normalize in place the current quaternion
  4525. * @returns the current updated quaternion
  4526. */
  4527. normalize(): Quaternion;
  4528. /**
  4529. * Returns a new Vector3 set with the Euler angles translated from the current quaternion
  4530. * @param order is a reserved parameter and is ignored for now
  4531. * @returns a new Vector3 containing the Euler angles
  4532. */
  4533. toEulerAngles(order?: string): Vector3;
  4534. /**
  4535. * Sets the given vector3 "result" with the Euler angles translated from the current quaternion
  4536. * @param result defines the vector which will be filled with the Euler angles
  4537. * @returns the current unchanged quaternion
  4538. */
  4539. toEulerAnglesToRef(result: Vector3): Quaternion;
  4540. /**
  4541. * Updates the given rotation matrix with the current quaternion values
  4542. * @param result defines the target matrix
  4543. * @returns the current unchanged quaternion
  4544. */
  4545. toRotationMatrix(result: Matrix): Quaternion;
  4546. /**
  4547. * Updates the current quaternion from the given rotation matrix values
  4548. * @param matrix defines the source matrix
  4549. * @returns the current updated quaternion
  4550. */
  4551. fromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  4552. /**
  4553. * Creates a new quaternion from a rotation matrix
  4554. * @param matrix defines the source matrix
  4555. * @returns a new quaternion created from the given rotation matrix values
  4556. */
  4557. static FromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  4558. /**
  4559. * Updates the given quaternion with the given rotation matrix values
  4560. * @param matrix defines the source matrix
  4561. * @param result defines the target quaternion
  4562. */
  4563. static FromRotationMatrixToRef(matrix: DeepImmutable<Matrix>, result: Quaternion): void;
  4564. /**
  4565. * Returns the dot product (float) between the quaternions "left" and "right"
  4566. * @param left defines the left operand
  4567. * @param right defines the right operand
  4568. * @returns the dot product
  4569. */
  4570. static Dot(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>): number;
  4571. /**
  4572. * Checks if the two quaternions are close to each other
  4573. * @param quat0 defines the first quaternion to check
  4574. * @param quat1 defines the second quaternion to check
  4575. * @returns true if the two quaternions are close to each other
  4576. */
  4577. static AreClose(quat0: DeepImmutable<Quaternion>, quat1: DeepImmutable<Quaternion>): boolean;
  4578. /**
  4579. * Creates an empty quaternion
  4580. * @returns a new quaternion set to (0.0, 0.0, 0.0)
  4581. */
  4582. static Zero(): Quaternion;
  4583. /**
  4584. * Inverse a given quaternion
  4585. * @param q defines the source quaternion
  4586. * @returns a new quaternion as the inverted current quaternion
  4587. */
  4588. static Inverse(q: DeepImmutable<Quaternion>): Quaternion;
  4589. /**
  4590. * Inverse a given quaternion
  4591. * @param q defines the source quaternion
  4592. * @param result the quaternion the result will be stored in
  4593. * @returns the result quaternion
  4594. */
  4595. static InverseToRef(q: Quaternion, result: Quaternion): Quaternion;
  4596. /**
  4597. * Creates an identity quaternion
  4598. * @returns the identity quaternion
  4599. */
  4600. static Identity(): Quaternion;
  4601. /**
  4602. * Gets a boolean indicating if the given quaternion is identity
  4603. * @param quaternion defines the quaternion to check
  4604. * @returns true if the quaternion is identity
  4605. */
  4606. static IsIdentity(quaternion: DeepImmutable<Quaternion>): boolean;
  4607. /**
  4608. * Creates a quaternion from a rotation around an axis
  4609. * @param axis defines the axis to use
  4610. * @param angle defines the angle to use
  4611. * @returns a new quaternion created from the given axis (Vector3) and angle in radians (float)
  4612. */
  4613. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Quaternion;
  4614. /**
  4615. * Creates a rotation around an axis and stores it into the given quaternion
  4616. * @param axis defines the axis to use
  4617. * @param angle defines the angle to use
  4618. * @param result defines the target quaternion
  4619. * @returns the target quaternion
  4620. */
  4621. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Quaternion): Quaternion;
  4622. /**
  4623. * Creates a new quaternion from data stored into an array
  4624. * @param array defines the data source
  4625. * @param offset defines the offset in the source array where the data starts
  4626. * @returns a new quaternion
  4627. */
  4628. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Quaternion;
  4629. /**
  4630. * Updates the given quaternion "result" from the starting index of the given array.
  4631. * @param array the array to pull values from
  4632. * @param offset the offset into the array to start at
  4633. * @param result the quaternion to store the result in
  4634. */
  4635. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Quaternion): void;
  4636. /**
  4637. * Create a quaternion from Euler rotation angles
  4638. * @param x Pitch
  4639. * @param y Yaw
  4640. * @param z Roll
  4641. * @returns the new Quaternion
  4642. */
  4643. static FromEulerAngles(x: number, y: number, z: number): Quaternion;
  4644. /**
  4645. * Updates a quaternion from Euler rotation angles
  4646. * @param x Pitch
  4647. * @param y Yaw
  4648. * @param z Roll
  4649. * @param result the quaternion to store the result
  4650. * @returns the updated quaternion
  4651. */
  4652. static FromEulerAnglesToRef(x: number, y: number, z: number, result: Quaternion): Quaternion;
  4653. /**
  4654. * Create a quaternion from Euler rotation vector
  4655. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  4656. * @returns the new Quaternion
  4657. */
  4658. static FromEulerVector(vec: DeepImmutable<Vector3>): Quaternion;
  4659. /**
  4660. * Updates a quaternion from Euler rotation vector
  4661. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  4662. * @param result the quaternion to store the result
  4663. * @returns the updated quaternion
  4664. */
  4665. static FromEulerVectorToRef(vec: DeepImmutable<Vector3>, result: Quaternion): Quaternion;
  4666. /**
  4667. * Updates a quaternion so that it rotates vector vecFrom to vector vecTo
  4668. * @param vecFrom defines the direction vector from which to rotate
  4669. * @param vecTo defines the direction vector to which to rotate
  4670. * @param result the quaternion to store the result
  4671. * @returns the updated quaternion
  4672. */
  4673. static FromUnitVectorsToRef(vecFrom: DeepImmutable<Vector3>, vecTo: DeepImmutable<Vector3>, result: Quaternion): Quaternion;
  4674. /**
  4675. * Creates a new quaternion from the given Euler float angles (y, x, z)
  4676. * @param yaw defines the rotation around Y axis
  4677. * @param pitch defines the rotation around X axis
  4678. * @param roll defines the rotation around Z axis
  4679. * @returns the new quaternion
  4680. */
  4681. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Quaternion;
  4682. /**
  4683. * Creates a new rotation from the given Euler float angles (y, x, z) and stores it in the target quaternion
  4684. * @param yaw defines the rotation around Y axis
  4685. * @param pitch defines the rotation around X axis
  4686. * @param roll defines the rotation around Z axis
  4687. * @param result defines the target quaternion
  4688. */
  4689. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Quaternion): void;
  4690. /**
  4691. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation
  4692. * @param alpha defines the rotation around first axis
  4693. * @param beta defines the rotation around second axis
  4694. * @param gamma defines the rotation around third axis
  4695. * @returns the new quaternion
  4696. */
  4697. static RotationAlphaBetaGamma(alpha: number, beta: number, gamma: number): Quaternion;
  4698. /**
  4699. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation and stores it in the target quaternion
  4700. * @param alpha defines the rotation around first axis
  4701. * @param beta defines the rotation around second axis
  4702. * @param gamma defines the rotation around third axis
  4703. * @param result defines the target quaternion
  4704. */
  4705. static RotationAlphaBetaGammaToRef(alpha: number, beta: number, gamma: number, result: Quaternion): void;
  4706. /**
  4707. * Creates a new quaternion containing the rotation value to reach the target (axis1, axis2, axis3) orientation as a rotated XYZ system (axis1, axis2 and axis3 are normalized during this operation)
  4708. * @param axis1 defines the first axis
  4709. * @param axis2 defines the second axis
  4710. * @param axis3 defines the third axis
  4711. * @returns the new quaternion
  4712. */
  4713. static RotationQuaternionFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Quaternion;
  4714. /**
  4715. * Creates a rotation value to reach the target (axis1, axis2, axis3) orientation as a rotated XYZ system (axis1, axis2 and axis3 are normalized during this operation) and stores it in the target quaternion
  4716. * @param axis1 defines the first axis
  4717. * @param axis2 defines the second axis
  4718. * @param axis3 defines the third axis
  4719. * @param ref defines the target quaternion
  4720. */
  4721. static RotationQuaternionFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Quaternion): void;
  4722. /**
  4723. * Interpolates between two quaternions
  4724. * @param left defines first quaternion
  4725. * @param right defines second quaternion
  4726. * @param amount defines the gradient to use
  4727. * @returns the new interpolated quaternion
  4728. */
  4729. static Slerp(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number): Quaternion;
  4730. /**
  4731. * Interpolates between two quaternions and stores it into a target quaternion
  4732. * @param left defines first quaternion
  4733. * @param right defines second quaternion
  4734. * @param amount defines the gradient to use
  4735. * @param result defines the target quaternion
  4736. */
  4737. static SlerpToRef(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number, result: Quaternion): void;
  4738. /**
  4739. * Interpolate between two quaternions using Hermite interpolation
  4740. * @param value1 defines first quaternion
  4741. * @param tangent1 defines the incoming tangent
  4742. * @param value2 defines second quaternion
  4743. * @param tangent2 defines the outgoing tangent
  4744. * @param amount defines the target quaternion
  4745. * @returns the new interpolated quaternion
  4746. */
  4747. static Hermite(value1: DeepImmutable<Quaternion>, tangent1: DeepImmutable<Quaternion>, value2: DeepImmutable<Quaternion>, tangent2: DeepImmutable<Quaternion>, amount: number): Quaternion;
  4748. }
  4749. /**
  4750. * Class used to store matrix data (4x4)
  4751. */
  4752. export class Matrix {
  4753. /**
  4754. * Gets the precision of matrix computations
  4755. */
  4756. static get Use64Bits(): boolean;
  4757. private static _updateFlagSeed;
  4758. private static _identityReadOnly;
  4759. private _isIdentity;
  4760. private _isIdentityDirty;
  4761. private _isIdentity3x2;
  4762. private _isIdentity3x2Dirty;
  4763. /**
  4764. * Gets the update flag of the matrix which is an unique number for the matrix.
  4765. * It will be incremented every time the matrix data change.
  4766. * You can use it to speed the comparison between two versions of the same matrix.
  4767. */
  4768. updateFlag: number;
  4769. private readonly _m;
  4770. /**
  4771. * Gets the internal data of the matrix
  4772. */
  4773. get m(): DeepImmutable<Float32Array | Array<number>>;
  4774. /** @hidden */
  4775. _markAsUpdated(): void;
  4776. /** @hidden */
  4777. private _updateIdentityStatus;
  4778. /**
  4779. * Creates an empty matrix (filled with zeros)
  4780. */
  4781. constructor();
  4782. /**
  4783. * Check if the current matrix is identity
  4784. * @returns true is the matrix is the identity matrix
  4785. */
  4786. isIdentity(): boolean;
  4787. /**
  4788. * Check if the current matrix is identity as a texture matrix (3x2 store in 4x4)
  4789. * @returns true is the matrix is the identity matrix
  4790. */
  4791. isIdentityAs3x2(): boolean;
  4792. /**
  4793. * Gets the determinant of the matrix
  4794. * @returns the matrix determinant
  4795. */
  4796. determinant(): number;
  4797. /**
  4798. * Returns the matrix as a Float32Array or Array<number>
  4799. * @returns the matrix underlying array
  4800. */
  4801. toArray(): DeepImmutable<Float32Array | Array<number>>;
  4802. /**
  4803. * Returns the matrix as a Float32Array or Array<number>
  4804. * @returns the matrix underlying array.
  4805. */
  4806. asArray(): DeepImmutable<Float32Array | Array<number>>;
  4807. /**
  4808. * Inverts the current matrix in place
  4809. * @returns the current inverted matrix
  4810. */
  4811. invert(): Matrix;
  4812. /**
  4813. * Sets all the matrix elements to zero
  4814. * @returns the current matrix
  4815. */
  4816. reset(): Matrix;
  4817. /**
  4818. * Adds the current matrix with a second one
  4819. * @param other defines the matrix to add
  4820. * @returns a new matrix as the addition of the current matrix and the given one
  4821. */
  4822. add(other: DeepImmutable<Matrix>): Matrix;
  4823. /**
  4824. * Sets the given matrix "result" to the addition of the current matrix and the given one
  4825. * @param other defines the matrix to add
  4826. * @param result defines the target matrix
  4827. * @returns the current matrix
  4828. */
  4829. addToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  4830. /**
  4831. * Adds in place the given matrix to the current matrix
  4832. * @param other defines the second operand
  4833. * @returns the current updated matrix
  4834. */
  4835. addToSelf(other: DeepImmutable<Matrix>): Matrix;
  4836. /**
  4837. * Sets the given matrix to the current inverted Matrix
  4838. * @param other defines the target matrix
  4839. * @returns the unmodified current matrix
  4840. */
  4841. invertToRef(other: Matrix): Matrix;
  4842. /**
  4843. * add a value at the specified position in the current Matrix
  4844. * @param index the index of the value within the matrix. between 0 and 15.
  4845. * @param value the value to be added
  4846. * @returns the current updated matrix
  4847. */
  4848. addAtIndex(index: number, value: number): Matrix;
  4849. /**
  4850. * mutiply the specified position in the current Matrix by a value
  4851. * @param index the index of the value within the matrix. between 0 and 15.
  4852. * @param value the value to be added
  4853. * @returns the current updated matrix
  4854. */
  4855. multiplyAtIndex(index: number, value: number): Matrix;
  4856. /**
  4857. * Inserts the translation vector (using 3 floats) in the current matrix
  4858. * @param x defines the 1st component of the translation
  4859. * @param y defines the 2nd component of the translation
  4860. * @param z defines the 3rd component of the translation
  4861. * @returns the current updated matrix
  4862. */
  4863. setTranslationFromFloats(x: number, y: number, z: number): Matrix;
  4864. /**
  4865. * Adds the translation vector (using 3 floats) in the current matrix
  4866. * @param x defines the 1st component of the translation
  4867. * @param y defines the 2nd component of the translation
  4868. * @param z defines the 3rd component of the translation
  4869. * @returns the current updated matrix
  4870. */
  4871. addTranslationFromFloats(x: number, y: number, z: number): Matrix;
  4872. /**
  4873. * Inserts the translation vector in the current matrix
  4874. * @param vector3 defines the translation to insert
  4875. * @returns the current updated matrix
  4876. */
  4877. setTranslation(vector3: DeepImmutable<Vector3>): Matrix;
  4878. /**
  4879. * Gets the translation value of the current matrix
  4880. * @returns a new Vector3 as the extracted translation from the matrix
  4881. */
  4882. getTranslation(): Vector3;
  4883. /**
  4884. * Fill a Vector3 with the extracted translation from the matrix
  4885. * @param result defines the Vector3 where to store the translation
  4886. * @returns the current matrix
  4887. */
  4888. getTranslationToRef(result: Vector3): Matrix;
  4889. /**
  4890. * Remove rotation and scaling part from the matrix
  4891. * @returns the updated matrix
  4892. */
  4893. removeRotationAndScaling(): Matrix;
  4894. /**
  4895. * Multiply two matrices
  4896. * @param other defines the second operand
  4897. * @returns a new matrix set with the multiplication result of the current Matrix and the given one
  4898. */
  4899. multiply(other: DeepImmutable<Matrix>): Matrix;
  4900. /**
  4901. * Copy the current matrix from the given one
  4902. * @param other defines the source matrix
  4903. * @returns the current updated matrix
  4904. */
  4905. copyFrom(other: DeepImmutable<Matrix>): Matrix;
  4906. /**
  4907. * Populates the given array from the starting index with the current matrix values
  4908. * @param array defines the target array
  4909. * @param offset defines the offset in the target array where to start storing values
  4910. * @returns the current matrix
  4911. */
  4912. copyToArray(array: Float32Array | Array<number>, offset?: number): Matrix;
  4913. /**
  4914. * Sets the given matrix "result" with the multiplication result of the current Matrix and the given one
  4915. * @param other defines the second operand
  4916. * @param result defines the matrix where to store the multiplication
  4917. * @returns the current matrix
  4918. */
  4919. multiplyToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  4920. /**
  4921. * Sets the Float32Array "result" from the given index "offset" with the multiplication of the current matrix and the given one
  4922. * @param other defines the second operand
  4923. * @param result defines the array where to store the multiplication
  4924. * @param offset defines the offset in the target array where to start storing values
  4925. * @returns the current matrix
  4926. */
  4927. multiplyToArray(other: DeepImmutable<Matrix>, result: Float32Array | Array<number>, offset: number): Matrix;
  4928. /**
  4929. * Check equality between this matrix and a second one
  4930. * @param value defines the second matrix to compare
  4931. * @returns true is the current matrix and the given one values are strictly equal
  4932. */
  4933. equals(value: DeepImmutable<Matrix>): boolean;
  4934. /**
  4935. * Clone the current matrix
  4936. * @returns a new matrix from the current matrix
  4937. */
  4938. clone(): Matrix;
  4939. /**
  4940. * Returns the name of the current matrix class
  4941. * @returns the string "Matrix"
  4942. */
  4943. getClassName(): string;
  4944. /**
  4945. * Gets the hash code of the current matrix
  4946. * @returns the hash code
  4947. */
  4948. getHashCode(): number;
  4949. /**
  4950. * Decomposes the current Matrix into a translation, rotation and scaling components
  4951. * @param scale defines the scale vector3 given as a reference to update
  4952. * @param rotation defines the rotation quaternion given as a reference to update
  4953. * @param translation defines the translation vector3 given as a reference to update
  4954. * @returns true if operation was successful
  4955. */
  4956. decompose(scale?: Vector3, rotation?: Quaternion, translation?: Vector3): boolean;
  4957. /**
  4958. * Gets specific row of the matrix
  4959. * @param index defines the number of the row to get
  4960. * @returns the index-th row of the current matrix as a new Vector4
  4961. */
  4962. getRow(index: number): Nullable<Vector4>;
  4963. /**
  4964. * Sets the index-th row of the current matrix to the vector4 values
  4965. * @param index defines the number of the row to set
  4966. * @param row defines the target vector4
  4967. * @returns the updated current matrix
  4968. */
  4969. setRow(index: number, row: Vector4): Matrix;
  4970. /**
  4971. * Compute the transpose of the matrix
  4972. * @returns the new transposed matrix
  4973. */
  4974. transpose(): Matrix;
  4975. /**
  4976. * Compute the transpose of the matrix and store it in a given matrix
  4977. * @param result defines the target matrix
  4978. * @returns the current matrix
  4979. */
  4980. transposeToRef(result: Matrix): Matrix;
  4981. /**
  4982. * Sets the index-th row of the current matrix with the given 4 x float values
  4983. * @param index defines the row index
  4984. * @param x defines the x component to set
  4985. * @param y defines the y component to set
  4986. * @param z defines the z component to set
  4987. * @param w defines the w component to set
  4988. * @returns the updated current matrix
  4989. */
  4990. setRowFromFloats(index: number, x: number, y: number, z: number, w: number): Matrix;
  4991. /**
  4992. * Compute a new matrix set with the current matrix values multiplied by scale (float)
  4993. * @param scale defines the scale factor
  4994. * @returns a new matrix
  4995. */
  4996. scale(scale: number): Matrix;
  4997. /**
  4998. * Scale the current matrix values by a factor to a given result matrix
  4999. * @param scale defines the scale factor
  5000. * @param result defines the matrix to store the result
  5001. * @returns the current matrix
  5002. */
  5003. scaleToRef(scale: number, result: Matrix): Matrix;
  5004. /**
  5005. * Scale the current matrix values by a factor and add the result to a given matrix
  5006. * @param scale defines the scale factor
  5007. * @param result defines the Matrix to store the result
  5008. * @returns the current matrix
  5009. */
  5010. scaleAndAddToRef(scale: number, result: Matrix): Matrix;
  5011. /**
  5012. * Writes to the given matrix a normal matrix, computed from this one (using values from identity matrix for fourth row and column).
  5013. * @param ref matrix to store the result
  5014. */
  5015. toNormalMatrix(ref: Matrix): void;
  5016. /**
  5017. * Gets only rotation part of the current matrix
  5018. * @returns a new matrix sets to the extracted rotation matrix from the current one
  5019. */
  5020. getRotationMatrix(): Matrix;
  5021. /**
  5022. * Extracts the rotation matrix from the current one and sets it as the given "result"
  5023. * @param result defines the target matrix to store data to
  5024. * @returns the current matrix
  5025. */
  5026. getRotationMatrixToRef(result: Matrix): Matrix;
  5027. /**
  5028. * Toggles model matrix from being right handed to left handed in place and vice versa
  5029. */
  5030. toggleModelMatrixHandInPlace(): void;
  5031. /**
  5032. * Toggles projection matrix from being right handed to left handed in place and vice versa
  5033. */
  5034. toggleProjectionMatrixHandInPlace(): void;
  5035. /**
  5036. * Creates a matrix from an array
  5037. * @param array defines the source array
  5038. * @param offset defines an offset in the source array
  5039. * @returns a new Matrix set from the starting index of the given array
  5040. */
  5041. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Matrix;
  5042. /**
  5043. * Copy the content of an array into a given matrix
  5044. * @param array defines the source array
  5045. * @param offset defines an offset in the source array
  5046. * @param result defines the target matrix
  5047. */
  5048. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Matrix): void;
  5049. /**
  5050. * Stores an array into a matrix after having multiplied each component by a given factor
  5051. * @param array defines the source array
  5052. * @param offset defines the offset in the source array
  5053. * @param scale defines the scaling factor
  5054. * @param result defines the target matrix
  5055. */
  5056. static FromFloat32ArrayToRefScaled(array: DeepImmutable<Float32Array | Array<number>>, offset: number, scale: number, result: Matrix): void;
  5057. /**
  5058. * Gets an identity matrix that must not be updated
  5059. */
  5060. static get IdentityReadOnly(): DeepImmutable<Matrix>;
  5061. /**
  5062. * Stores a list of values (16) inside a given matrix
  5063. * @param initialM11 defines 1st value of 1st row
  5064. * @param initialM12 defines 2nd value of 1st row
  5065. * @param initialM13 defines 3rd value of 1st row
  5066. * @param initialM14 defines 4th value of 1st row
  5067. * @param initialM21 defines 1st value of 2nd row
  5068. * @param initialM22 defines 2nd value of 2nd row
  5069. * @param initialM23 defines 3rd value of 2nd row
  5070. * @param initialM24 defines 4th value of 2nd row
  5071. * @param initialM31 defines 1st value of 3rd row
  5072. * @param initialM32 defines 2nd value of 3rd row
  5073. * @param initialM33 defines 3rd value of 3rd row
  5074. * @param initialM34 defines 4th value of 3rd row
  5075. * @param initialM41 defines 1st value of 4th row
  5076. * @param initialM42 defines 2nd value of 4th row
  5077. * @param initialM43 defines 3rd value of 4th row
  5078. * @param initialM44 defines 4th value of 4th row
  5079. * @param result defines the target matrix
  5080. */
  5081. static FromValuesToRef(initialM11: number, initialM12: number, initialM13: number, initialM14: number, initialM21: number, initialM22: number, initialM23: number, initialM24: number, initialM31: number, initialM32: number, initialM33: number, initialM34: number, initialM41: number, initialM42: number, initialM43: number, initialM44: number, result: Matrix): void;
  5082. /**
  5083. * Creates new matrix from a list of values (16)
  5084. * @param initialM11 defines 1st value of 1st row
  5085. * @param initialM12 defines 2nd value of 1st row
  5086. * @param initialM13 defines 3rd value of 1st row
  5087. * @param initialM14 defines 4th value of 1st row
  5088. * @param initialM21 defines 1st value of 2nd row
  5089. * @param initialM22 defines 2nd value of 2nd row
  5090. * @param initialM23 defines 3rd value of 2nd row
  5091. * @param initialM24 defines 4th value of 2nd row
  5092. * @param initialM31 defines 1st value of 3rd row
  5093. * @param initialM32 defines 2nd value of 3rd row
  5094. * @param initialM33 defines 3rd value of 3rd row
  5095. * @param initialM34 defines 4th value of 3rd row
  5096. * @param initialM41 defines 1st value of 4th row
  5097. * @param initialM42 defines 2nd value of 4th row
  5098. * @param initialM43 defines 3rd value of 4th row
  5099. * @param initialM44 defines 4th value of 4th row
  5100. * @returns the new matrix
  5101. */
  5102. static FromValues(initialM11: number, initialM12: number, initialM13: number, initialM14: number, initialM21: number, initialM22: number, initialM23: number, initialM24: number, initialM31: number, initialM32: number, initialM33: number, initialM34: number, initialM41: number, initialM42: number, initialM43: number, initialM44: number): Matrix;
  5103. /**
  5104. * Creates a new matrix composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  5105. * @param scale defines the scale vector3
  5106. * @param rotation defines the rotation quaternion
  5107. * @param translation defines the translation vector3
  5108. * @returns a new matrix
  5109. */
  5110. static Compose(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>): Matrix;
  5111. /**
  5112. * Sets a matrix to a value composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  5113. * @param scale defines the scale vector3
  5114. * @param rotation defines the rotation quaternion
  5115. * @param translation defines the translation vector3
  5116. * @param result defines the target matrix
  5117. */
  5118. static ComposeToRef(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>, result: Matrix): void;
  5119. /**
  5120. * Creates a new identity matrix
  5121. * @returns a new identity matrix
  5122. */
  5123. static Identity(): Matrix;
  5124. /**
  5125. * Creates a new identity matrix and stores the result in a given matrix
  5126. * @param result defines the target matrix
  5127. */
  5128. static IdentityToRef(result: Matrix): void;
  5129. /**
  5130. * Creates a new zero matrix
  5131. * @returns a new zero matrix
  5132. */
  5133. static Zero(): Matrix;
  5134. /**
  5135. * Creates a new rotation matrix for "angle" radians around the X axis
  5136. * @param angle defines the angle (in radians) to use
  5137. * @return the new matrix
  5138. */
  5139. static RotationX(angle: number): Matrix;
  5140. /**
  5141. * Creates a new matrix as the invert of a given matrix
  5142. * @param source defines the source matrix
  5143. * @returns the new matrix
  5144. */
  5145. static Invert(source: DeepImmutable<Matrix>): Matrix;
  5146. /**
  5147. * Creates a new rotation matrix for "angle" radians around the X axis and stores it in a given matrix
  5148. * @param angle defines the angle (in radians) to use
  5149. * @param result defines the target matrix
  5150. */
  5151. static RotationXToRef(angle: number, result: Matrix): void;
  5152. /**
  5153. * Creates a new rotation matrix for "angle" radians around the Y axis
  5154. * @param angle defines the angle (in radians) to use
  5155. * @return the new matrix
  5156. */
  5157. static RotationY(angle: number): Matrix;
  5158. /**
  5159. * Creates a new rotation matrix for "angle" radians around the Y axis and stores it in a given matrix
  5160. * @param angle defines the angle (in radians) to use
  5161. * @param result defines the target matrix
  5162. */
  5163. static RotationYToRef(angle: number, result: Matrix): void;
  5164. /**
  5165. * Creates a new rotation matrix for "angle" radians around the Z axis
  5166. * @param angle defines the angle (in radians) to use
  5167. * @return the new matrix
  5168. */
  5169. static RotationZ(angle: number): Matrix;
  5170. /**
  5171. * Creates a new rotation matrix for "angle" radians around the Z axis and stores it in a given matrix
  5172. * @param angle defines the angle (in radians) to use
  5173. * @param result defines the target matrix
  5174. */
  5175. static RotationZToRef(angle: number, result: Matrix): void;
  5176. /**
  5177. * Creates a new rotation matrix for "angle" radians around the given axis
  5178. * @param axis defines the axis to use
  5179. * @param angle defines the angle (in radians) to use
  5180. * @return the new matrix
  5181. */
  5182. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Matrix;
  5183. /**
  5184. * Creates a new rotation matrix for "angle" radians around the given axis and stores it in a given matrix
  5185. * @param axis defines the axis to use
  5186. * @param angle defines the angle (in radians) to use
  5187. * @param result defines the target matrix
  5188. */
  5189. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Matrix): void;
  5190. /**
  5191. * Takes normalised vectors and returns a rotation matrix to align "from" with "to".
  5192. * Taken from http://www.iquilezles.org/www/articles/noacos/noacos.htm
  5193. * @param from defines the vector to align
  5194. * @param to defines the vector to align to
  5195. * @param result defines the target matrix
  5196. */
  5197. static RotationAlignToRef(from: DeepImmutable<Vector3>, to: DeepImmutable<Vector3>, result: Matrix): void;
  5198. /**
  5199. * Creates a rotation matrix
  5200. * @param yaw defines the yaw angle in radians (Y axis)
  5201. * @param pitch defines the pitch angle in radians (X axis)
  5202. * @param roll defines the roll angle in radians (Z axis)
  5203. * @returns the new rotation matrix
  5204. */
  5205. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Matrix;
  5206. /**
  5207. * Creates a rotation matrix and stores it in a given matrix
  5208. * @param yaw defines the yaw angle in radians (Y axis)
  5209. * @param pitch defines the pitch angle in radians (X axis)
  5210. * @param roll defines the roll angle in radians (Z axis)
  5211. * @param result defines the target matrix
  5212. */
  5213. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Matrix): void;
  5214. /**
  5215. * Creates a scaling matrix
  5216. * @param x defines the scale factor on X axis
  5217. * @param y defines the scale factor on Y axis
  5218. * @param z defines the scale factor on Z axis
  5219. * @returns the new matrix
  5220. */
  5221. static Scaling(x: number, y: number, z: number): Matrix;
  5222. /**
  5223. * Creates a scaling matrix and stores it in a given matrix
  5224. * @param x defines the scale factor on X axis
  5225. * @param y defines the scale factor on Y axis
  5226. * @param z defines the scale factor on Z axis
  5227. * @param result defines the target matrix
  5228. */
  5229. static ScalingToRef(x: number, y: number, z: number, result: Matrix): void;
  5230. /**
  5231. * Creates a translation matrix
  5232. * @param x defines the translation on X axis
  5233. * @param y defines the translation on Y axis
  5234. * @param z defines the translationon Z axis
  5235. * @returns the new matrix
  5236. */
  5237. static Translation(x: number, y: number, z: number): Matrix;
  5238. /**
  5239. * Creates a translation matrix and stores it in a given matrix
  5240. * @param x defines the translation on X axis
  5241. * @param y defines the translation on Y axis
  5242. * @param z defines the translationon Z axis
  5243. * @param result defines the target matrix
  5244. */
  5245. static TranslationToRef(x: number, y: number, z: number, result: Matrix): void;
  5246. /**
  5247. * Returns a new Matrix whose values are the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  5248. * @param startValue defines the start value
  5249. * @param endValue defines the end value
  5250. * @param gradient defines the gradient factor
  5251. * @returns the new matrix
  5252. */
  5253. static Lerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  5254. /**
  5255. * Set the given matrix "result" as the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  5256. * @param startValue defines the start value
  5257. * @param endValue defines the end value
  5258. * @param gradient defines the gradient factor
  5259. * @param result defines the Matrix object where to store data
  5260. */
  5261. static LerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  5262. /**
  5263. * Builds a new matrix whose values are computed by:
  5264. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  5265. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  5266. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  5267. * @param startValue defines the first matrix
  5268. * @param endValue defines the second matrix
  5269. * @param gradient defines the gradient between the two matrices
  5270. * @returns the new matrix
  5271. */
  5272. static DecomposeLerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  5273. /**
  5274. * Update a matrix to values which are computed by:
  5275. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  5276. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  5277. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  5278. * @param startValue defines the first matrix
  5279. * @param endValue defines the second matrix
  5280. * @param gradient defines the gradient between the two matrices
  5281. * @param result defines the target matrix
  5282. */
  5283. static DecomposeLerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  5284. /**
  5285. * Gets a new rotation matrix used to rotate an entity so as it looks at the target vector3, from the eye vector3 position, the up vector3 being oriented like "up"
  5286. * This function works in left handed mode
  5287. * @param eye defines the final position of the entity
  5288. * @param target defines where the entity should look at
  5289. * @param up defines the up vector for the entity
  5290. * @returns the new matrix
  5291. */
  5292. static LookAtLH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  5293. /**
  5294. * Sets the given "result" Matrix to a rotation matrix used to rotate an entity so that it looks at the target vector3, from the eye vector3 position, the up vector3 being oriented like "up".
  5295. * This function works in left handed mode
  5296. * @param eye defines the final position of the entity
  5297. * @param target defines where the entity should look at
  5298. * @param up defines the up vector for the entity
  5299. * @param result defines the target matrix
  5300. */
  5301. static LookAtLHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  5302. /**
  5303. * Gets a new rotation matrix used to rotate an entity so as it looks at the target vector3, from the eye vector3 position, the up vector3 being oriented like "up"
  5304. * This function works in right handed mode
  5305. * @param eye defines the final position of the entity
  5306. * @param target defines where the entity should look at
  5307. * @param up defines the up vector for the entity
  5308. * @returns the new matrix
  5309. */
  5310. static LookAtRH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  5311. /**
  5312. * Sets the given "result" Matrix to a rotation matrix used to rotate an entity so that it looks at the target vector3, from the eye vector3 position, the up vector3 being oriented like "up".
  5313. * This function works in right handed mode
  5314. * @param eye defines the final position of the entity
  5315. * @param target defines where the entity should look at
  5316. * @param up defines the up vector for the entity
  5317. * @param result defines the target matrix
  5318. */
  5319. static LookAtRHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  5320. /**
  5321. * Create a left-handed orthographic projection matrix
  5322. * @param width defines the viewport width
  5323. * @param height defines the viewport height
  5324. * @param znear defines the near clip plane
  5325. * @param zfar defines the far clip plane
  5326. * @returns a new matrix as a left-handed orthographic projection matrix
  5327. */
  5328. static OrthoLH(width: number, height: number, znear: number, zfar: number): Matrix;
  5329. /**
  5330. * Store a left-handed orthographic projection to a given matrix
  5331. * @param width defines the viewport width
  5332. * @param height defines the viewport height
  5333. * @param znear defines the near clip plane
  5334. * @param zfar defines the far clip plane
  5335. * @param result defines the target matrix
  5336. */
  5337. static OrthoLHToRef(width: number, height: number, znear: number, zfar: number, result: Matrix): void;
  5338. /**
  5339. * Create a left-handed orthographic projection matrix
  5340. * @param left defines the viewport left coordinate
  5341. * @param right defines the viewport right coordinate
  5342. * @param bottom defines the viewport bottom coordinate
  5343. * @param top defines the viewport top coordinate
  5344. * @param znear defines the near clip plane
  5345. * @param zfar defines the far clip plane
  5346. * @returns a new matrix as a left-handed orthographic projection matrix
  5347. */
  5348. static OrthoOffCenterLH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  5349. /**
  5350. * Stores a left-handed orthographic projection into a given matrix
  5351. * @param left defines the viewport left coordinate
  5352. * @param right defines the viewport right coordinate
  5353. * @param bottom defines the viewport bottom coordinate
  5354. * @param top defines the viewport top coordinate
  5355. * @param znear defines the near clip plane
  5356. * @param zfar defines the far clip plane
  5357. * @param result defines the target matrix
  5358. */
  5359. static OrthoOffCenterLHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  5360. /**
  5361. * Creates a right-handed orthographic projection matrix
  5362. * @param left defines the viewport left coordinate
  5363. * @param right defines the viewport right coordinate
  5364. * @param bottom defines the viewport bottom coordinate
  5365. * @param top defines the viewport top coordinate
  5366. * @param znear defines the near clip plane
  5367. * @param zfar defines the far clip plane
  5368. * @returns a new matrix as a right-handed orthographic projection matrix
  5369. */
  5370. static OrthoOffCenterRH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  5371. /**
  5372. * Stores a right-handed orthographic projection into a given matrix
  5373. * @param left defines the viewport left coordinate
  5374. * @param right defines the viewport right coordinate
  5375. * @param bottom defines the viewport bottom coordinate
  5376. * @param top defines the viewport top coordinate
  5377. * @param znear defines the near clip plane
  5378. * @param zfar defines the far clip plane
  5379. * @param result defines the target matrix
  5380. */
  5381. static OrthoOffCenterRHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  5382. /**
  5383. * Creates a left-handed perspective projection matrix
  5384. * @param width defines the viewport width
  5385. * @param height defines the viewport height
  5386. * @param znear defines the near clip plane
  5387. * @param zfar defines the far clip plane
  5388. * @returns a new matrix as a left-handed perspective projection matrix
  5389. */
  5390. static PerspectiveLH(width: number, height: number, znear: number, zfar: number): Matrix;
  5391. /**
  5392. * Creates a left-handed perspective projection matrix
  5393. * @param fov defines the horizontal field of view
  5394. * @param aspect defines the aspect ratio
  5395. * @param znear defines the near clip plane
  5396. * @param zfar defines the far clip plane
  5397. * @returns a new matrix as a left-handed perspective projection matrix
  5398. */
  5399. static PerspectiveFovLH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  5400. /**
  5401. * Stores a left-handed perspective projection into a given matrix
  5402. * @param fov defines the horizontal field of view
  5403. * @param aspect defines the aspect ratio
  5404. * @param znear defines the near clip plane
  5405. * @param zfar defines the far clip plane
  5406. * @param result defines the target matrix
  5407. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  5408. */
  5409. static PerspectiveFovLHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  5410. /**
  5411. * Stores a left-handed perspective projection into a given matrix with depth reversed
  5412. * @param fov defines the horizontal field of view
  5413. * @param aspect defines the aspect ratio
  5414. * @param znear defines the near clip plane
  5415. * @param zfar not used as infinity is used as far clip
  5416. * @param result defines the target matrix
  5417. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  5418. */
  5419. static PerspectiveFovReverseLHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  5420. /**
  5421. * Creates a right-handed perspective projection matrix
  5422. * @param fov defines the horizontal field of view
  5423. * @param aspect defines the aspect ratio
  5424. * @param znear defines the near clip plane
  5425. * @param zfar defines the far clip plane
  5426. * @returns a new matrix as a right-handed perspective projection matrix
  5427. */
  5428. static PerspectiveFovRH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  5429. /**
  5430. * Stores a right-handed perspective projection into a given matrix
  5431. * @param fov defines the horizontal field of view
  5432. * @param aspect defines the aspect ratio
  5433. * @param znear defines the near clip plane
  5434. * @param zfar defines the far clip plane
  5435. * @param result defines the target matrix
  5436. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  5437. */
  5438. static PerspectiveFovRHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  5439. /**
  5440. * Stores a right-handed perspective projection into a given matrix
  5441. * @param fov defines the horizontal field of view
  5442. * @param aspect defines the aspect ratio
  5443. * @param znear defines the near clip plane
  5444. * @param zfar not used as infinity is used as far clip
  5445. * @param result defines the target matrix
  5446. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  5447. */
  5448. static PerspectiveFovReverseRHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  5449. /**
  5450. * Stores a perspective projection for WebVR info a given matrix
  5451. * @param fov defines the field of view
  5452. * @param znear defines the near clip plane
  5453. * @param zfar defines the far clip plane
  5454. * @param result defines the target matrix
  5455. * @param rightHanded defines if the matrix must be in right-handed mode (false by default)
  5456. */
  5457. static PerspectiveFovWebVRToRef(fov: {
  5458. upDegrees: number;
  5459. downDegrees: number;
  5460. leftDegrees: number;
  5461. rightDegrees: number;
  5462. }, znear: number, zfar: number, result: Matrix, rightHanded?: boolean): void;
  5463. /**
  5464. * Computes a complete transformation matrix
  5465. * @param viewport defines the viewport to use
  5466. * @param world defines the world matrix
  5467. * @param view defines the view matrix
  5468. * @param projection defines the projection matrix
  5469. * @param zmin defines the near clip plane
  5470. * @param zmax defines the far clip plane
  5471. * @returns the transformation matrix
  5472. */
  5473. static GetFinalMatrix(viewport: DeepImmutable<Viewport>, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, zmin: number, zmax: number): Matrix;
  5474. /**
  5475. * Extracts a 2x2 matrix from a given matrix and store the result in a Float32Array
  5476. * @param matrix defines the matrix to use
  5477. * @returns a new Float32Array array with 4 elements : the 2x2 matrix extracted from the given matrix
  5478. */
  5479. static GetAsMatrix2x2(matrix: DeepImmutable<Matrix>): Float32Array | Array<number>;
  5480. /**
  5481. * Extracts a 3x3 matrix from a given matrix and store the result in a Float32Array
  5482. * @param matrix defines the matrix to use
  5483. * @returns a new Float32Array array with 9 elements : the 3x3 matrix extracted from the given matrix
  5484. */
  5485. static GetAsMatrix3x3(matrix: DeepImmutable<Matrix>): Float32Array | Array<number>;
  5486. /**
  5487. * Compute the transpose of a given matrix
  5488. * @param matrix defines the matrix to transpose
  5489. * @returns the new matrix
  5490. */
  5491. static Transpose(matrix: DeepImmutable<Matrix>): Matrix;
  5492. /**
  5493. * Compute the transpose of a matrix and store it in a target matrix
  5494. * @param matrix defines the matrix to transpose
  5495. * @param result defines the target matrix
  5496. */
  5497. static TransposeToRef(matrix: DeepImmutable<Matrix>, result: Matrix): void;
  5498. /**
  5499. * Computes a reflection matrix from a plane
  5500. * @param plane defines the reflection plane
  5501. * @returns a new matrix
  5502. */
  5503. static Reflection(plane: DeepImmutable<IPlaneLike>): Matrix;
  5504. /**
  5505. * Computes a reflection matrix from a plane
  5506. * @param plane defines the reflection plane
  5507. * @param result defines the target matrix
  5508. */
  5509. static ReflectionToRef(plane: DeepImmutable<IPlaneLike>, result: Matrix): void;
  5510. /**
  5511. * Sets the given matrix as a rotation matrix composed from the 3 left handed axes
  5512. * @param xaxis defines the value of the 1st axis
  5513. * @param yaxis defines the value of the 2nd axis
  5514. * @param zaxis defines the value of the 3rd axis
  5515. * @param result defines the target matrix
  5516. */
  5517. static FromXYZAxesToRef(xaxis: DeepImmutable<Vector3>, yaxis: DeepImmutable<Vector3>, zaxis: DeepImmutable<Vector3>, result: Matrix): void;
  5518. /**
  5519. * Creates a rotation matrix from a quaternion and stores it in a target matrix
  5520. * @param quat defines the quaternion to use
  5521. * @param result defines the target matrix
  5522. */
  5523. static FromQuaternionToRef(quat: DeepImmutable<Quaternion>, result: Matrix): void;
  5524. }
  5525. /**
  5526. * @hidden
  5527. */
  5528. export class TmpVectors {
  5529. static Vector2: Vector2[];
  5530. static Vector3: Vector3[];
  5531. static Vector4: Vector4[];
  5532. static Quaternion: Quaternion[];
  5533. static Matrix: Matrix[];
  5534. }
  5535. }
  5536. declare module BABYLON {
  5537. /**
  5538. * Defines potential orientation for back face culling
  5539. */
  5540. export enum Orientation {
  5541. /**
  5542. * Clockwise
  5543. */
  5544. CW = 0,
  5545. /** Counter clockwise */
  5546. CCW = 1
  5547. }
  5548. /** Class used to represent a Bezier curve */
  5549. export class BezierCurve {
  5550. /**
  5551. * Returns the cubic Bezier interpolated value (float) at "t" (float) from the given x1, y1, x2, y2 floats
  5552. * @param t defines the time
  5553. * @param x1 defines the left coordinate on X axis
  5554. * @param y1 defines the left coordinate on Y axis
  5555. * @param x2 defines the right coordinate on X axis
  5556. * @param y2 defines the right coordinate on Y axis
  5557. * @returns the interpolated value
  5558. */
  5559. static Interpolate(t: number, x1: number, y1: number, x2: number, y2: number): number;
  5560. }
  5561. /**
  5562. * Defines angle representation
  5563. */
  5564. export class Angle {
  5565. private _radians;
  5566. /**
  5567. * Creates an Angle object of "radians" radians (float).
  5568. * @param radians the angle in radians
  5569. */
  5570. constructor(radians: number);
  5571. /**
  5572. * Get value in degrees
  5573. * @returns the Angle value in degrees (float)
  5574. */
  5575. degrees(): number;
  5576. /**
  5577. * Get value in radians
  5578. * @returns the Angle value in radians (float)
  5579. */
  5580. radians(): number;
  5581. /**
  5582. * Gets a new Angle object valued with the gradient angle, in radians, of the line joining two points
  5583. * @param a defines first point as the origin
  5584. * @param b defines point
  5585. * @returns a new Angle
  5586. */
  5587. static BetweenTwoPoints(a: DeepImmutable<Vector2>, b: DeepImmutable<Vector2>): Angle;
  5588. /**
  5589. * Gets a new Angle object from the given float in radians
  5590. * @param radians defines the angle value in radians
  5591. * @returns a new Angle
  5592. */
  5593. static FromRadians(radians: number): Angle;
  5594. /**
  5595. * Gets a new Angle object from the given float in degrees
  5596. * @param degrees defines the angle value in degrees
  5597. * @returns a new Angle
  5598. */
  5599. static FromDegrees(degrees: number): Angle;
  5600. }
  5601. /**
  5602. * This represents an arc in a 2d space.
  5603. */
  5604. export class Arc2 {
  5605. /** Defines the start point of the arc */
  5606. startPoint: Vector2;
  5607. /** Defines the mid point of the arc */
  5608. midPoint: Vector2;
  5609. /** Defines the end point of the arc */
  5610. endPoint: Vector2;
  5611. /**
  5612. * Defines the center point of the arc.
  5613. */
  5614. centerPoint: Vector2;
  5615. /**
  5616. * Defines the radius of the arc.
  5617. */
  5618. radius: number;
  5619. /**
  5620. * Defines the angle of the arc (from mid point to end point).
  5621. */
  5622. angle: Angle;
  5623. /**
  5624. * Defines the start angle of the arc (from start point to middle point).
  5625. */
  5626. startAngle: Angle;
  5627. /**
  5628. * Defines the orientation of the arc (clock wise/counter clock wise).
  5629. */
  5630. orientation: Orientation;
  5631. /**
  5632. * Creates an Arc object from the three given points : start, middle and end.
  5633. * @param startPoint Defines the start point of the arc
  5634. * @param midPoint Defines the midlle point of the arc
  5635. * @param endPoint Defines the end point of the arc
  5636. */
  5637. constructor(
  5638. /** Defines the start point of the arc */
  5639. startPoint: Vector2,
  5640. /** Defines the mid point of the arc */
  5641. midPoint: Vector2,
  5642. /** Defines the end point of the arc */
  5643. endPoint: Vector2);
  5644. }
  5645. /**
  5646. * Represents a 2D path made up of multiple 2D points
  5647. */
  5648. export class Path2 {
  5649. private _points;
  5650. private _length;
  5651. /**
  5652. * If the path start and end point are the same
  5653. */
  5654. closed: boolean;
  5655. /**
  5656. * Creates a Path2 object from the starting 2D coordinates x and y.
  5657. * @param x the starting points x value
  5658. * @param y the starting points y value
  5659. */
  5660. constructor(x: number, y: number);
  5661. /**
  5662. * Adds a new segment until the given coordinates (x, y) to the current Path2.
  5663. * @param x the added points x value
  5664. * @param y the added points y value
  5665. * @returns the updated Path2.
  5666. */
  5667. addLineTo(x: number, y: number): Path2;
  5668. /**
  5669. * Adds _numberOfSegments_ segments according to the arc definition (middle point coordinates, end point coordinates, the arc start point being the current Path2 last point) to the current Path2.
  5670. * @param midX middle point x value
  5671. * @param midY middle point y value
  5672. * @param endX end point x value
  5673. * @param endY end point y value
  5674. * @param numberOfSegments (default: 36)
  5675. * @returns the updated Path2.
  5676. */
  5677. addArcTo(midX: number, midY: number, endX: number, endY: number, numberOfSegments?: number): Path2;
  5678. /**
  5679. * Closes the Path2.
  5680. * @returns the Path2.
  5681. */
  5682. close(): Path2;
  5683. /**
  5684. * Gets the sum of the distance between each sequential point in the path
  5685. * @returns the Path2 total length (float).
  5686. */
  5687. length(): number;
  5688. /**
  5689. * Gets the points which construct the path
  5690. * @returns the Path2 internal array of points.
  5691. */
  5692. getPoints(): Vector2[];
  5693. /**
  5694. * Retreives the point at the distance aways from the starting point
  5695. * @param normalizedLengthPosition the length along the path to retreive the point from
  5696. * @returns a new Vector2 located at a percentage of the Path2 total length on this path.
  5697. */
  5698. getPointAtLengthPosition(normalizedLengthPosition: number): Vector2;
  5699. /**
  5700. * Creates a new path starting from an x and y position
  5701. * @param x starting x value
  5702. * @param y starting y value
  5703. * @returns a new Path2 starting at the coordinates (x, y).
  5704. */
  5705. static StartingAt(x: number, y: number): Path2;
  5706. }
  5707. /**
  5708. * Represents a 3D path made up of multiple 3D points
  5709. */
  5710. export class Path3D {
  5711. /**
  5712. * an array of Vector3, the curve axis of the Path3D
  5713. */
  5714. path: Vector3[];
  5715. private _curve;
  5716. private _distances;
  5717. private _tangents;
  5718. private _normals;
  5719. private _binormals;
  5720. private _raw;
  5721. private _alignTangentsWithPath;
  5722. private readonly _pointAtData;
  5723. /**
  5724. * new Path3D(path, normal, raw)
  5725. * Creates a Path3D. A Path3D is a logical math object, so not a mesh.
  5726. * please read the description in the tutorial : https://doc.babylonjs.com/how_to/how_to_use_path3d
  5727. * @param path an array of Vector3, the curve axis of the Path3D
  5728. * @param firstNormal (options) Vector3, the first wanted normal to the curve. Ex (0, 1, 0) for a vertical normal.
  5729. * @param raw (optional, default false) : boolean, if true the returned Path3D isn't normalized. Useful to depict path acceleration or speed.
  5730. * @param alignTangentsWithPath (optional, default false) : boolean, if true the tangents will be aligned with the path.
  5731. */
  5732. constructor(
  5733. /**
  5734. * an array of Vector3, the curve axis of the Path3D
  5735. */
  5736. path: Vector3[], firstNormal?: Nullable<Vector3>, raw?: boolean, alignTangentsWithPath?: boolean);
  5737. /**
  5738. * Returns the Path3D array of successive Vector3 designing its curve.
  5739. * @returns the Path3D array of successive Vector3 designing its curve.
  5740. */
  5741. getCurve(): Vector3[];
  5742. /**
  5743. * Returns the Path3D array of successive Vector3 designing its curve.
  5744. * @returns the Path3D array of successive Vector3 designing its curve.
  5745. */
  5746. getPoints(): Vector3[];
  5747. /**
  5748. * @returns the computed length (float) of the path.
  5749. */
  5750. length(): number;
  5751. /**
  5752. * Returns an array populated with tangent vectors on each Path3D curve point.
  5753. * @returns an array populated with tangent vectors on each Path3D curve point.
  5754. */
  5755. getTangents(): Vector3[];
  5756. /**
  5757. * Returns an array populated with normal vectors on each Path3D curve point.
  5758. * @returns an array populated with normal vectors on each Path3D curve point.
  5759. */
  5760. getNormals(): Vector3[];
  5761. /**
  5762. * Returns an array populated with binormal vectors on each Path3D curve point.
  5763. * @returns an array populated with binormal vectors on each Path3D curve point.
  5764. */
  5765. getBinormals(): Vector3[];
  5766. /**
  5767. * Returns an array populated with distances (float) of the i-th point from the first curve point.
  5768. * @returns an array populated with distances (float) of the i-th point from the first curve point.
  5769. */
  5770. getDistances(): number[];
  5771. /**
  5772. * Returns an interpolated point along this path
  5773. * @param position the position of the point along this path, from 0.0 to 1.0
  5774. * @returns a new Vector3 as the point
  5775. */
  5776. getPointAt(position: number): Vector3;
  5777. /**
  5778. * Returns the tangent vector of an interpolated Path3D curve point at the specified position along this path.
  5779. * @param position the position of the point along this path, from 0.0 to 1.0
  5780. * @param interpolated (optional, default false) : boolean, if true returns an interpolated tangent instead of the tangent of the previous path point.
  5781. * @returns a tangent vector corresponding to the interpolated Path3D curve point, if not interpolated, the tangent is taken from the precomputed tangents array.
  5782. */
  5783. getTangentAt(position: number, interpolated?: boolean): Vector3;
  5784. /**
  5785. * Returns the tangent vector of an interpolated Path3D curve point at the specified position along this path.
  5786. * @param position the position of the point along this path, from 0.0 to 1.0
  5787. * @param interpolated (optional, default false) : boolean, if true returns an interpolated normal instead of the normal of the previous path point.
  5788. * @returns a normal vector corresponding to the interpolated Path3D curve point, if not interpolated, the normal is taken from the precomputed normals array.
  5789. */
  5790. getNormalAt(position: number, interpolated?: boolean): Vector3;
  5791. /**
  5792. * Returns the binormal vector of an interpolated Path3D curve point at the specified position along this path.
  5793. * @param position the position of the point along this path, from 0.0 to 1.0
  5794. * @param interpolated (optional, default false) : boolean, if true returns an interpolated binormal instead of the binormal of the previous path point.
  5795. * @returns a binormal vector corresponding to the interpolated Path3D curve point, if not interpolated, the binormal is taken from the precomputed binormals array.
  5796. */
  5797. getBinormalAt(position: number, interpolated?: boolean): Vector3;
  5798. /**
  5799. * Returns the distance (float) of an interpolated Path3D curve point at the specified position along this path.
  5800. * @param position the position of the point along this path, from 0.0 to 1.0
  5801. * @returns the distance of the interpolated Path3D curve point at the specified position along this path.
  5802. */
  5803. getDistanceAt(position: number): number;
  5804. /**
  5805. * Returns the array index of the previous point of an interpolated point along this path
  5806. * @param position the position of the point to interpolate along this path, from 0.0 to 1.0
  5807. * @returns the array index
  5808. */
  5809. getPreviousPointIndexAt(position: number): number;
  5810. /**
  5811. * Returns the position of an interpolated point relative to the two path points it lies between, from 0.0 (point A) to 1.0 (point B)
  5812. * @param position the position of the point to interpolate along this path, from 0.0 to 1.0
  5813. * @returns the sub position
  5814. */
  5815. getSubPositionAt(position: number): number;
  5816. /**
  5817. * Returns the position of the closest virtual point on this path to an arbitrary Vector3, from 0.0 to 1.0
  5818. * @param target the vector of which to get the closest position to
  5819. * @returns the position of the closest virtual point on this path to the target vector
  5820. */
  5821. getClosestPositionTo(target: Vector3): number;
  5822. /**
  5823. * Returns a sub path (slice) of this path
  5824. * @param start the position of the fist path point, from 0.0 to 1.0, or a negative value, which will get wrapped around from the end of the path to 0.0 to 1.0 values
  5825. * @param end the position of the last path point, from 0.0 to 1.0, or a negative value, which will get wrapped around from the end of the path to 0.0 to 1.0 values
  5826. * @returns a sub path (slice) of this path
  5827. */
  5828. slice(start?: number, end?: number): Path3D;
  5829. /**
  5830. * Forces the Path3D tangent, normal, binormal and distance recomputation.
  5831. * @param path path which all values are copied into the curves points
  5832. * @param firstNormal which should be projected onto the curve
  5833. * @param alignTangentsWithPath (optional, default false) : boolean, if true the tangents will be aligned with the path
  5834. * @returns the same object updated.
  5835. */
  5836. update(path: Vector3[], firstNormal?: Nullable<Vector3>, alignTangentsWithPath?: boolean): Path3D;
  5837. private _compute;
  5838. private _getFirstNonNullVector;
  5839. private _getLastNonNullVector;
  5840. private _normalVector;
  5841. /**
  5842. * Updates the point at data for an interpolated point along this curve
  5843. * @param position the position of the point along this curve, from 0.0 to 1.0
  5844. * @interpolateTNB wether to compute the interpolated tangent, normal and binormal
  5845. * @returns the (updated) point at data
  5846. */
  5847. private _updatePointAtData;
  5848. /**
  5849. * Updates the point at data from the specified parameters
  5850. * @param position where along the path the interpolated point is, from 0.0 to 1.0
  5851. * @param point the interpolated point
  5852. * @param parentIndex the index of an existing curve point that is on, or else positionally the first behind, the interpolated point
  5853. */
  5854. private _setPointAtData;
  5855. /**
  5856. * Updates the point at interpolation matrix for the tangents, normals and binormals
  5857. */
  5858. private _updateInterpolationMatrix;
  5859. }
  5860. /**
  5861. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  5862. * A Curve3 is designed from a series of successive Vector3.
  5863. * @see https://doc.babylonjs.com/how_to/how_to_use_curve3
  5864. */
  5865. export class Curve3 {
  5866. private _points;
  5867. private _length;
  5868. /**
  5869. * Returns a Curve3 object along a Quadratic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#quadratic-bezier-curve
  5870. * @param v0 (Vector3) the origin point of the Quadratic Bezier
  5871. * @param v1 (Vector3) the control point
  5872. * @param v2 (Vector3) the end point of the Quadratic Bezier
  5873. * @param nbPoints (integer) the wanted number of points in the curve
  5874. * @returns the created Curve3
  5875. */
  5876. static CreateQuadraticBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  5877. /**
  5878. * Returns a Curve3 object along a Cubic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#cubic-bezier-curve
  5879. * @param v0 (Vector3) the origin point of the Cubic Bezier
  5880. * @param v1 (Vector3) the first control point
  5881. * @param v2 (Vector3) the second control point
  5882. * @param v3 (Vector3) the end point of the Cubic Bezier
  5883. * @param nbPoints (integer) the wanted number of points in the curve
  5884. * @returns the created Curve3
  5885. */
  5886. static CreateCubicBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, v3: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  5887. /**
  5888. * Returns a Curve3 object along a Hermite Spline curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#hermite-spline
  5889. * @param p1 (Vector3) the origin point of the Hermite Spline
  5890. * @param t1 (Vector3) the tangent vector at the origin point
  5891. * @param p2 (Vector3) the end point of the Hermite Spline
  5892. * @param t2 (Vector3) the tangent vector at the end point
  5893. * @param nbPoints (integer) the wanted number of points in the curve
  5894. * @returns the created Curve3
  5895. */
  5896. static CreateHermiteSpline(p1: DeepImmutable<Vector3>, t1: DeepImmutable<Vector3>, p2: DeepImmutable<Vector3>, t2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  5897. /**
  5898. * Returns a Curve3 object along a CatmullRom Spline curve :
  5899. * @param points (array of Vector3) the points the spline must pass through. At least, four points required
  5900. * @param nbPoints (integer) the wanted number of points between each curve control points
  5901. * @param closed (boolean) optional with default false, when true forms a closed loop from the points
  5902. * @returns the created Curve3
  5903. */
  5904. static CreateCatmullRomSpline(points: DeepImmutable<Vector3[]>, nbPoints: number, closed?: boolean): Curve3;
  5905. /**
  5906. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  5907. * A Curve3 is designed from a series of successive Vector3.
  5908. * Tuto : https://doc.babylonjs.com/how_to/how_to_use_curve3#curve3-object
  5909. * @param points points which make up the curve
  5910. */
  5911. constructor(points: Vector3[]);
  5912. /**
  5913. * @returns the Curve3 stored array of successive Vector3
  5914. */
  5915. getPoints(): Vector3[];
  5916. /**
  5917. * @returns the computed length (float) of the curve.
  5918. */
  5919. length(): number;
  5920. /**
  5921. * Returns a new instance of Curve3 object : var curve = curveA.continue(curveB);
  5922. * This new Curve3 is built by translating and sticking the curveB at the end of the curveA.
  5923. * curveA and curveB keep unchanged.
  5924. * @param curve the curve to continue from this curve
  5925. * @returns the newly constructed curve
  5926. */
  5927. continue(curve: DeepImmutable<Curve3>): Curve3;
  5928. private _computeLength;
  5929. }
  5930. }
  5931. declare module BABYLON {
  5932. /**
  5933. * This represents the main contract an easing function should follow.
  5934. * Easing functions are used throughout the animation system.
  5935. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  5936. */
  5937. export interface IEasingFunction {
  5938. /**
  5939. * Given an input gradient between 0 and 1, this returns the corresponding value
  5940. * of the easing function.
  5941. * The link below provides some of the most common examples of easing functions.
  5942. * @see https://easings.net/
  5943. * @param gradient Defines the value between 0 and 1 we want the easing value for
  5944. * @returns the corresponding value on the curve defined by the easing function
  5945. */
  5946. ease(gradient: number): number;
  5947. }
  5948. /**
  5949. * Base class used for every default easing function.
  5950. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  5951. */
  5952. export class EasingFunction implements IEasingFunction {
  5953. /**
  5954. * Interpolation follows the mathematical formula associated with the easing function.
  5955. */
  5956. static readonly EASINGMODE_EASEIN: number;
  5957. /**
  5958. * Interpolation follows 100% interpolation minus the output of the formula associated with the easing function.
  5959. */
  5960. static readonly EASINGMODE_EASEOUT: number;
  5961. /**
  5962. * Interpolation uses EaseIn for the first half of the animation and EaseOut for the second half.
  5963. */
  5964. static readonly EASINGMODE_EASEINOUT: number;
  5965. private _easingMode;
  5966. /**
  5967. * Sets the easing mode of the current function.
  5968. * @param easingMode Defines the willing mode (EASINGMODE_EASEIN, EASINGMODE_EASEOUT or EASINGMODE_EASEINOUT)
  5969. */
  5970. setEasingMode(easingMode: number): void;
  5971. /**
  5972. * Gets the current easing mode.
  5973. * @returns the easing mode
  5974. */
  5975. getEasingMode(): number;
  5976. /**
  5977. * @hidden
  5978. */
  5979. easeInCore(gradient: number): number;
  5980. /**
  5981. * Given an input gradient between 0 and 1, this returns the corresponding value
  5982. * of the easing function.
  5983. * @param gradient Defines the value between 0 and 1 we want the easing value for
  5984. * @returns the corresponding value on the curve defined by the easing function
  5985. */
  5986. ease(gradient: number): number;
  5987. }
  5988. /**
  5989. * Easing function with a circle shape (see link below).
  5990. * @see https://easings.net/#easeInCirc
  5991. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  5992. */
  5993. export class CircleEase extends EasingFunction implements IEasingFunction {
  5994. /** @hidden */
  5995. easeInCore(gradient: number): number;
  5996. }
  5997. /**
  5998. * Easing function with a ease back shape (see link below).
  5999. * @see https://easings.net/#easeInBack
  6000. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  6001. */
  6002. export class BackEase extends EasingFunction implements IEasingFunction {
  6003. /** Defines the amplitude of the function */
  6004. amplitude: number;
  6005. /**
  6006. * Instantiates a back ease easing
  6007. * @see https://easings.net/#easeInBack
  6008. * @param amplitude Defines the amplitude of the function
  6009. */
  6010. constructor(
  6011. /** Defines the amplitude of the function */
  6012. amplitude?: number);
  6013. /** @hidden */
  6014. easeInCore(gradient: number): number;
  6015. }
  6016. /**
  6017. * Easing function with a bouncing shape (see link below).
  6018. * @see https://easings.net/#easeInBounce
  6019. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  6020. */
  6021. export class BounceEase extends EasingFunction implements IEasingFunction {
  6022. /** Defines the number of bounces */
  6023. bounces: number;
  6024. /** Defines the amplitude of the bounce */
  6025. bounciness: number;
  6026. /**
  6027. * Instantiates a bounce easing
  6028. * @see https://easings.net/#easeInBounce
  6029. * @param bounces Defines the number of bounces
  6030. * @param bounciness Defines the amplitude of the bounce
  6031. */
  6032. constructor(
  6033. /** Defines the number of bounces */
  6034. bounces?: number,
  6035. /** Defines the amplitude of the bounce */
  6036. bounciness?: number);
  6037. /** @hidden */
  6038. easeInCore(gradient: number): number;
  6039. }
  6040. /**
  6041. * Easing function with a power of 3 shape (see link below).
  6042. * @see https://easings.net/#easeInCubic
  6043. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  6044. */
  6045. export class CubicEase extends EasingFunction implements IEasingFunction {
  6046. /** @hidden */
  6047. easeInCore(gradient: number): number;
  6048. }
  6049. /**
  6050. * Easing function with an elastic shape (see link below).
  6051. * @see https://easings.net/#easeInElastic
  6052. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  6053. */
  6054. export class ElasticEase extends EasingFunction implements IEasingFunction {
  6055. /** Defines the number of oscillations*/
  6056. oscillations: number;
  6057. /** Defines the amplitude of the oscillations*/
  6058. springiness: number;
  6059. /**
  6060. * Instantiates an elastic easing function
  6061. * @see https://easings.net/#easeInElastic
  6062. * @param oscillations Defines the number of oscillations
  6063. * @param springiness Defines the amplitude of the oscillations
  6064. */
  6065. constructor(
  6066. /** Defines the number of oscillations*/
  6067. oscillations?: number,
  6068. /** Defines the amplitude of the oscillations*/
  6069. springiness?: number);
  6070. /** @hidden */
  6071. easeInCore(gradient: number): number;
  6072. }
  6073. /**
  6074. * Easing function with an exponential shape (see link below).
  6075. * @see https://easings.net/#easeInExpo
  6076. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  6077. */
  6078. export class ExponentialEase extends EasingFunction implements IEasingFunction {
  6079. /** Defines the exponent of the function */
  6080. exponent: number;
  6081. /**
  6082. * Instantiates an exponential easing function
  6083. * @see https://easings.net/#easeInExpo
  6084. * @param exponent Defines the exponent of the function
  6085. */
  6086. constructor(
  6087. /** Defines the exponent of the function */
  6088. exponent?: number);
  6089. /** @hidden */
  6090. easeInCore(gradient: number): number;
  6091. }
  6092. /**
  6093. * Easing function with a power shape (see link below).
  6094. * @see https://easings.net/#easeInQuad
  6095. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  6096. */
  6097. export class PowerEase extends EasingFunction implements IEasingFunction {
  6098. /** Defines the power of the function */
  6099. power: number;
  6100. /**
  6101. * Instantiates an power base easing function
  6102. * @see https://easings.net/#easeInQuad
  6103. * @param power Defines the power of the function
  6104. */
  6105. constructor(
  6106. /** Defines the power of the function */
  6107. power?: number);
  6108. /** @hidden */
  6109. easeInCore(gradient: number): number;
  6110. }
  6111. /**
  6112. * Easing function with a power of 2 shape (see link below).
  6113. * @see https://easings.net/#easeInQuad
  6114. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  6115. */
  6116. export class QuadraticEase extends EasingFunction implements IEasingFunction {
  6117. /** @hidden */
  6118. easeInCore(gradient: number): number;
  6119. }
  6120. /**
  6121. * Easing function with a power of 4 shape (see link below).
  6122. * @see https://easings.net/#easeInQuart
  6123. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  6124. */
  6125. export class QuarticEase extends EasingFunction implements IEasingFunction {
  6126. /** @hidden */
  6127. easeInCore(gradient: number): number;
  6128. }
  6129. /**
  6130. * Easing function with a power of 5 shape (see link below).
  6131. * @see https://easings.net/#easeInQuint
  6132. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  6133. */
  6134. export class QuinticEase extends EasingFunction implements IEasingFunction {
  6135. /** @hidden */
  6136. easeInCore(gradient: number): number;
  6137. }
  6138. /**
  6139. * Easing function with a sin shape (see link below).
  6140. * @see https://easings.net/#easeInSine
  6141. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  6142. */
  6143. export class SineEase extends EasingFunction implements IEasingFunction {
  6144. /** @hidden */
  6145. easeInCore(gradient: number): number;
  6146. }
  6147. /**
  6148. * Easing function with a bezier shape (see link below).
  6149. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  6150. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  6151. */
  6152. export class BezierCurveEase extends EasingFunction implements IEasingFunction {
  6153. /** Defines the x component of the start tangent in the bezier curve */
  6154. x1: number;
  6155. /** Defines the y component of the start tangent in the bezier curve */
  6156. y1: number;
  6157. /** Defines the x component of the end tangent in the bezier curve */
  6158. x2: number;
  6159. /** Defines the y component of the end tangent in the bezier curve */
  6160. y2: number;
  6161. /**
  6162. * Instantiates a bezier function
  6163. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  6164. * @param x1 Defines the x component of the start tangent in the bezier curve
  6165. * @param y1 Defines the y component of the start tangent in the bezier curve
  6166. * @param x2 Defines the x component of the end tangent in the bezier curve
  6167. * @param y2 Defines the y component of the end tangent in the bezier curve
  6168. */
  6169. constructor(
  6170. /** Defines the x component of the start tangent in the bezier curve */
  6171. x1?: number,
  6172. /** Defines the y component of the start tangent in the bezier curve */
  6173. y1?: number,
  6174. /** Defines the x component of the end tangent in the bezier curve */
  6175. x2?: number,
  6176. /** Defines the y component of the end tangent in the bezier curve */
  6177. y2?: number);
  6178. /** @hidden */
  6179. easeInCore(gradient: number): number;
  6180. }
  6181. }
  6182. declare module BABYLON {
  6183. /**
  6184. * Class used to hold a RGB color
  6185. */
  6186. export class Color3 {
  6187. /**
  6188. * Defines the red component (between 0 and 1, default is 0)
  6189. */
  6190. r: number;
  6191. /**
  6192. * Defines the green component (between 0 and 1, default is 0)
  6193. */
  6194. g: number;
  6195. /**
  6196. * Defines the blue component (between 0 and 1, default is 0)
  6197. */
  6198. b: number;
  6199. /**
  6200. * Creates a new Color3 object from red, green, blue values, all between 0 and 1
  6201. * @param r defines the red component (between 0 and 1, default is 0)
  6202. * @param g defines the green component (between 0 and 1, default is 0)
  6203. * @param b defines the blue component (between 0 and 1, default is 0)
  6204. */
  6205. constructor(
  6206. /**
  6207. * Defines the red component (between 0 and 1, default is 0)
  6208. */
  6209. r?: number,
  6210. /**
  6211. * Defines the green component (between 0 and 1, default is 0)
  6212. */
  6213. g?: number,
  6214. /**
  6215. * Defines the blue component (between 0 and 1, default is 0)
  6216. */
  6217. b?: number);
  6218. /**
  6219. * Creates a string with the Color3 current values
  6220. * @returns the string representation of the Color3 object
  6221. */
  6222. toString(): string;
  6223. /**
  6224. * Returns the string "Color3"
  6225. * @returns "Color3"
  6226. */
  6227. getClassName(): string;
  6228. /**
  6229. * Compute the Color3 hash code
  6230. * @returns an unique number that can be used to hash Color3 objects
  6231. */
  6232. getHashCode(): number;
  6233. /**
  6234. * Stores in the given array from the given starting index the red, green, blue values as successive elements
  6235. * @param array defines the array where to store the r,g,b components
  6236. * @param index defines an optional index in the target array to define where to start storing values
  6237. * @returns the current Color3 object
  6238. */
  6239. toArray(array: FloatArray, index?: number): Color3;
  6240. /**
  6241. * Update the current color with values stored in an array from the starting index of the given array
  6242. * @param array defines the source array
  6243. * @param offset defines an offset in the source array
  6244. * @returns the current Color3 object
  6245. */
  6246. fromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color3;
  6247. /**
  6248. * Returns a new Color4 object from the current Color3 and the given alpha
  6249. * @param alpha defines the alpha component on the new Color4 object (default is 1)
  6250. * @returns a new Color4 object
  6251. */
  6252. toColor4(alpha?: number): Color4;
  6253. /**
  6254. * Returns a new array populated with 3 numeric elements : red, green and blue values
  6255. * @returns the new array
  6256. */
  6257. asArray(): number[];
  6258. /**
  6259. * Returns the luminance value
  6260. * @returns a float value
  6261. */
  6262. toLuminance(): number;
  6263. /**
  6264. * Multiply each Color3 rgb values by the given Color3 rgb values in a new Color3 object
  6265. * @param otherColor defines the second operand
  6266. * @returns the new Color3 object
  6267. */
  6268. multiply(otherColor: DeepImmutable<Color3>): Color3;
  6269. /**
  6270. * Multiply the rgb values of the Color3 and the given Color3 and stores the result in the object "result"
  6271. * @param otherColor defines the second operand
  6272. * @param result defines the Color3 object where to store the result
  6273. * @returns the current Color3
  6274. */
  6275. multiplyToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  6276. /**
  6277. * Determines equality between Color3 objects
  6278. * @param otherColor defines the second operand
  6279. * @returns true if the rgb values are equal to the given ones
  6280. */
  6281. equals(otherColor: DeepImmutable<Color3>): boolean;
  6282. /**
  6283. * Determines equality between the current Color3 object and a set of r,b,g values
  6284. * @param r defines the red component to check
  6285. * @param g defines the green component to check
  6286. * @param b defines the blue component to check
  6287. * @returns true if the rgb values are equal to the given ones
  6288. */
  6289. equalsFloats(r: number, g: number, b: number): boolean;
  6290. /**
  6291. * Multiplies in place each rgb value by scale
  6292. * @param scale defines the scaling factor
  6293. * @returns the updated Color3
  6294. */
  6295. scale(scale: number): Color3;
  6296. /**
  6297. * Multiplies the rgb values by scale and stores the result into "result"
  6298. * @param scale defines the scaling factor
  6299. * @param result defines the Color3 object where to store the result
  6300. * @returns the unmodified current Color3
  6301. */
  6302. scaleToRef(scale: number, result: Color3): Color3;
  6303. /**
  6304. * Scale the current Color3 values by a factor and add the result to a given Color3
  6305. * @param scale defines the scale factor
  6306. * @param result defines color to store the result into
  6307. * @returns the unmodified current Color3
  6308. */
  6309. scaleAndAddToRef(scale: number, result: Color3): Color3;
  6310. /**
  6311. * Clamps the rgb values by the min and max values and stores the result into "result"
  6312. * @param min defines minimum clamping value (default is 0)
  6313. * @param max defines maximum clamping value (default is 1)
  6314. * @param result defines color to store the result into
  6315. * @returns the original Color3
  6316. */
  6317. clampToRef(min: number | undefined, max: number | undefined, result: Color3): Color3;
  6318. /**
  6319. * Creates a new Color3 set with the added values of the current Color3 and of the given one
  6320. * @param otherColor defines the second operand
  6321. * @returns the new Color3
  6322. */
  6323. add(otherColor: DeepImmutable<Color3>): Color3;
  6324. /**
  6325. * Stores the result of the addition of the current Color3 and given one rgb values into "result"
  6326. * @param otherColor defines the second operand
  6327. * @param result defines Color3 object to store the result into
  6328. * @returns the unmodified current Color3
  6329. */
  6330. addToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  6331. /**
  6332. * Returns a new Color3 set with the subtracted values of the given one from the current Color3
  6333. * @param otherColor defines the second operand
  6334. * @returns the new Color3
  6335. */
  6336. subtract(otherColor: DeepImmutable<Color3>): Color3;
  6337. /**
  6338. * Stores the result of the subtraction of given one from the current Color3 rgb values into "result"
  6339. * @param otherColor defines the second operand
  6340. * @param result defines Color3 object to store the result into
  6341. * @returns the unmodified current Color3
  6342. */
  6343. subtractToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  6344. /**
  6345. * Copy the current object
  6346. * @returns a new Color3 copied the current one
  6347. */
  6348. clone(): Color3;
  6349. /**
  6350. * Copies the rgb values from the source in the current Color3
  6351. * @param source defines the source Color3 object
  6352. * @returns the updated Color3 object
  6353. */
  6354. copyFrom(source: DeepImmutable<Color3>): Color3;
  6355. /**
  6356. * Updates the Color3 rgb values from the given floats
  6357. * @param r defines the red component to read from
  6358. * @param g defines the green component to read from
  6359. * @param b defines the blue component to read from
  6360. * @returns the current Color3 object
  6361. */
  6362. copyFromFloats(r: number, g: number, b: number): Color3;
  6363. /**
  6364. * Updates the Color3 rgb values from the given floats
  6365. * @param r defines the red component to read from
  6366. * @param g defines the green component to read from
  6367. * @param b defines the blue component to read from
  6368. * @returns the current Color3 object
  6369. */
  6370. set(r: number, g: number, b: number): Color3;
  6371. /**
  6372. * Compute the Color3 hexadecimal code as a string
  6373. * @returns a string containing the hexadecimal representation of the Color3 object
  6374. */
  6375. toHexString(): string;
  6376. /**
  6377. * Computes a new Color3 converted from the current one to linear space
  6378. * @returns a new Color3 object
  6379. */
  6380. toLinearSpace(): Color3;
  6381. /**
  6382. * Converts current color in rgb space to HSV values
  6383. * @returns a new color3 representing the HSV values
  6384. */
  6385. toHSV(): Color3;
  6386. /**
  6387. * Converts current color in rgb space to HSV values
  6388. * @param result defines the Color3 where to store the HSV values
  6389. */
  6390. toHSVToRef(result: Color3): void;
  6391. /**
  6392. * Converts the Color3 values to linear space and stores the result in "convertedColor"
  6393. * @param convertedColor defines the Color3 object where to store the linear space version
  6394. * @returns the unmodified Color3
  6395. */
  6396. toLinearSpaceToRef(convertedColor: Color3): Color3;
  6397. /**
  6398. * Computes a new Color3 converted from the current one to gamma space
  6399. * @returns a new Color3 object
  6400. */
  6401. toGammaSpace(): Color3;
  6402. /**
  6403. * Converts the Color3 values to gamma space and stores the result in "convertedColor"
  6404. * @param convertedColor defines the Color3 object where to store the gamma space version
  6405. * @returns the unmodified Color3
  6406. */
  6407. toGammaSpaceToRef(convertedColor: Color3): Color3;
  6408. private static _BlackReadOnly;
  6409. /**
  6410. * Convert Hue, saturation and value to a Color3 (RGB)
  6411. * @param hue defines the hue
  6412. * @param saturation defines the saturation
  6413. * @param value defines the value
  6414. * @param result defines the Color3 where to store the RGB values
  6415. */
  6416. static HSVtoRGBToRef(hue: number, saturation: number, value: number, result: Color3): void;
  6417. /**
  6418. * Creates a new Color3 from the string containing valid hexadecimal values
  6419. * @param hex defines a string containing valid hexadecimal values
  6420. * @returns a new Color3 object
  6421. */
  6422. static FromHexString(hex: string): Color3;
  6423. /**
  6424. * Creates a new Color3 from the starting index of the given array
  6425. * @param array defines the source array
  6426. * @param offset defines an offset in the source array
  6427. * @returns a new Color3 object
  6428. */
  6429. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color3;
  6430. /**
  6431. * Creates a new Color3 from the starting index element of the given array
  6432. * @param array defines the source array to read from
  6433. * @param offset defines the offset in the source array
  6434. * @param result defines the target Color3 object
  6435. */
  6436. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number | undefined, result: Color3): void;
  6437. /**
  6438. * Creates a new Color3 from integer values (< 256)
  6439. * @param r defines the red component to read from (value between 0 and 255)
  6440. * @param g defines the green component to read from (value between 0 and 255)
  6441. * @param b defines the blue component to read from (value between 0 and 255)
  6442. * @returns a new Color3 object
  6443. */
  6444. static FromInts(r: number, g: number, b: number): Color3;
  6445. /**
  6446. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  6447. * @param start defines the start Color3 value
  6448. * @param end defines the end Color3 value
  6449. * @param amount defines the gradient value between start and end
  6450. * @returns a new Color3 object
  6451. */
  6452. static Lerp(start: DeepImmutable<Color3>, end: DeepImmutable<Color3>, amount: number): Color3;
  6453. /**
  6454. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  6455. * @param left defines the start value
  6456. * @param right defines the end value
  6457. * @param amount defines the gradient factor
  6458. * @param result defines the Color3 object where to store the result
  6459. */
  6460. static LerpToRef(left: DeepImmutable<Color3>, right: DeepImmutable<Color3>, amount: number, result: Color3): void;
  6461. /**
  6462. * Returns a Color3 value containing a red color
  6463. * @returns a new Color3 object
  6464. */
  6465. static Red(): Color3;
  6466. /**
  6467. * Returns a Color3 value containing a green color
  6468. * @returns a new Color3 object
  6469. */
  6470. static Green(): Color3;
  6471. /**
  6472. * Returns a Color3 value containing a blue color
  6473. * @returns a new Color3 object
  6474. */
  6475. static Blue(): Color3;
  6476. /**
  6477. * Returns a Color3 value containing a black color
  6478. * @returns a new Color3 object
  6479. */
  6480. static Black(): Color3;
  6481. /**
  6482. * Gets a Color3 value containing a black color that must not be updated
  6483. */
  6484. static get BlackReadOnly(): DeepImmutable<Color3>;
  6485. /**
  6486. * Returns a Color3 value containing a white color
  6487. * @returns a new Color3 object
  6488. */
  6489. static White(): Color3;
  6490. /**
  6491. * Returns a Color3 value containing a purple color
  6492. * @returns a new Color3 object
  6493. */
  6494. static Purple(): Color3;
  6495. /**
  6496. * Returns a Color3 value containing a magenta color
  6497. * @returns a new Color3 object
  6498. */
  6499. static Magenta(): Color3;
  6500. /**
  6501. * Returns a Color3 value containing a yellow color
  6502. * @returns a new Color3 object
  6503. */
  6504. static Yellow(): Color3;
  6505. /**
  6506. * Returns a Color3 value containing a gray color
  6507. * @returns a new Color3 object
  6508. */
  6509. static Gray(): Color3;
  6510. /**
  6511. * Returns a Color3 value containing a teal color
  6512. * @returns a new Color3 object
  6513. */
  6514. static Teal(): Color3;
  6515. /**
  6516. * Returns a Color3 value containing a random color
  6517. * @returns a new Color3 object
  6518. */
  6519. static Random(): Color3;
  6520. }
  6521. /**
  6522. * Class used to hold a RBGA color
  6523. */
  6524. export class Color4 {
  6525. /**
  6526. * Defines the red component (between 0 and 1, default is 0)
  6527. */
  6528. r: number;
  6529. /**
  6530. * Defines the green component (between 0 and 1, default is 0)
  6531. */
  6532. g: number;
  6533. /**
  6534. * Defines the blue component (between 0 and 1, default is 0)
  6535. */
  6536. b: number;
  6537. /**
  6538. * Defines the alpha component (between 0 and 1, default is 1)
  6539. */
  6540. a: number;
  6541. /**
  6542. * Creates a new Color4 object from red, green, blue values, all between 0 and 1
  6543. * @param r defines the red component (between 0 and 1, default is 0)
  6544. * @param g defines the green component (between 0 and 1, default is 0)
  6545. * @param b defines the blue component (between 0 and 1, default is 0)
  6546. * @param a defines the alpha component (between 0 and 1, default is 1)
  6547. */
  6548. constructor(
  6549. /**
  6550. * Defines the red component (between 0 and 1, default is 0)
  6551. */
  6552. r?: number,
  6553. /**
  6554. * Defines the green component (between 0 and 1, default is 0)
  6555. */
  6556. g?: number,
  6557. /**
  6558. * Defines the blue component (between 0 and 1, default is 0)
  6559. */
  6560. b?: number,
  6561. /**
  6562. * Defines the alpha component (between 0 and 1, default is 1)
  6563. */
  6564. a?: number);
  6565. /**
  6566. * Adds in place the given Color4 values to the current Color4 object
  6567. * @param right defines the second operand
  6568. * @returns the current updated Color4 object
  6569. */
  6570. addInPlace(right: DeepImmutable<Color4>): Color4;
  6571. /**
  6572. * Creates a new array populated with 4 numeric elements : red, green, blue, alpha values
  6573. * @returns the new array
  6574. */
  6575. asArray(): number[];
  6576. /**
  6577. * Stores from the starting index in the given array the Color4 successive values
  6578. * @param array defines the array where to store the r,g,b components
  6579. * @param index defines an optional index in the target array to define where to start storing values
  6580. * @returns the current Color4 object
  6581. */
  6582. toArray(array: number[], index?: number): Color4;
  6583. /**
  6584. * Update the current color with values stored in an array from the starting index of the given array
  6585. * @param array defines the source array
  6586. * @param offset defines an offset in the source array
  6587. * @returns the current Color4 object
  6588. */
  6589. fromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color4;
  6590. /**
  6591. * Determines equality between Color4 objects
  6592. * @param otherColor defines the second operand
  6593. * @returns true if the rgba values are equal to the given ones
  6594. */
  6595. equals(otherColor: DeepImmutable<Color4>): boolean;
  6596. /**
  6597. * Creates a new Color4 set with the added values of the current Color4 and of the given one
  6598. * @param right defines the second operand
  6599. * @returns a new Color4 object
  6600. */
  6601. add(right: DeepImmutable<Color4>): Color4;
  6602. /**
  6603. * Creates a new Color4 set with the subtracted values of the given one from the current Color4
  6604. * @param right defines the second operand
  6605. * @returns a new Color4 object
  6606. */
  6607. subtract(right: DeepImmutable<Color4>): Color4;
  6608. /**
  6609. * Subtracts the given ones from the current Color4 values and stores the results in "result"
  6610. * @param right defines the second operand
  6611. * @param result defines the Color4 object where to store the result
  6612. * @returns the current Color4 object
  6613. */
  6614. subtractToRef(right: DeepImmutable<Color4>, result: Color4): Color4;
  6615. /**
  6616. * Creates a new Color4 with the current Color4 values multiplied by scale
  6617. * @param scale defines the scaling factor to apply
  6618. * @returns a new Color4 object
  6619. */
  6620. scale(scale: number): Color4;
  6621. /**
  6622. * Multiplies the current Color4 values by scale and stores the result in "result"
  6623. * @param scale defines the scaling factor to apply
  6624. * @param result defines the Color4 object where to store the result
  6625. * @returns the current unmodified Color4
  6626. */
  6627. scaleToRef(scale: number, result: Color4): Color4;
  6628. /**
  6629. * Scale the current Color4 values by a factor and add the result to a given Color4
  6630. * @param scale defines the scale factor
  6631. * @param result defines the Color4 object where to store the result
  6632. * @returns the unmodified current Color4
  6633. */
  6634. scaleAndAddToRef(scale: number, result: Color4): Color4;
  6635. /**
  6636. * Clamps the rgb values by the min and max values and stores the result into "result"
  6637. * @param min defines minimum clamping value (default is 0)
  6638. * @param max defines maximum clamping value (default is 1)
  6639. * @param result defines color to store the result into.
  6640. * @returns the cuurent Color4
  6641. */
  6642. clampToRef(min: number | undefined, max: number | undefined, result: Color4): Color4;
  6643. /**
  6644. * Multipy an Color4 value by another and return a new Color4 object
  6645. * @param color defines the Color4 value to multiply by
  6646. * @returns a new Color4 object
  6647. */
  6648. multiply(color: Color4): Color4;
  6649. /**
  6650. * Multipy a Color4 value by another and push the result in a reference value
  6651. * @param color defines the Color4 value to multiply by
  6652. * @param result defines the Color4 to fill the result in
  6653. * @returns the result Color4
  6654. */
  6655. multiplyToRef(color: Color4, result: Color4): Color4;
  6656. /**
  6657. * Creates a string with the Color4 current values
  6658. * @returns the string representation of the Color4 object
  6659. */
  6660. toString(): string;
  6661. /**
  6662. * Returns the string "Color4"
  6663. * @returns "Color4"
  6664. */
  6665. getClassName(): string;
  6666. /**
  6667. * Compute the Color4 hash code
  6668. * @returns an unique number that can be used to hash Color4 objects
  6669. */
  6670. getHashCode(): number;
  6671. /**
  6672. * Creates a new Color4 copied from the current one
  6673. * @returns a new Color4 object
  6674. */
  6675. clone(): Color4;
  6676. /**
  6677. * Copies the given Color4 values into the current one
  6678. * @param source defines the source Color4 object
  6679. * @returns the current updated Color4 object
  6680. */
  6681. copyFrom(source: Color4): Color4;
  6682. /**
  6683. * Copies the given float values into the current one
  6684. * @param r defines the red component to read from
  6685. * @param g defines the green component to read from
  6686. * @param b defines the blue component to read from
  6687. * @param a defines the alpha component to read from
  6688. * @returns the current updated Color4 object
  6689. */
  6690. copyFromFloats(r: number, g: number, b: number, a: number): Color4;
  6691. /**
  6692. * Copies the given float values into the current one
  6693. * @param r defines the red component to read from
  6694. * @param g defines the green component to read from
  6695. * @param b defines the blue component to read from
  6696. * @param a defines the alpha component to read from
  6697. * @returns the current updated Color4 object
  6698. */
  6699. set(r: number, g: number, b: number, a: number): Color4;
  6700. /**
  6701. * Compute the Color4 hexadecimal code as a string
  6702. * @param returnAsColor3 defines if the string should only contains RGB values (off by default)
  6703. * @returns a string containing the hexadecimal representation of the Color4 object
  6704. */
  6705. toHexString(returnAsColor3?: boolean): string;
  6706. /**
  6707. * Computes a new Color4 converted from the current one to linear space
  6708. * @returns a new Color4 object
  6709. */
  6710. toLinearSpace(): Color4;
  6711. /**
  6712. * Converts the Color4 values to linear space and stores the result in "convertedColor"
  6713. * @param convertedColor defines the Color4 object where to store the linear space version
  6714. * @returns the unmodified Color4
  6715. */
  6716. toLinearSpaceToRef(convertedColor: Color4): Color4;
  6717. /**
  6718. * Computes a new Color4 converted from the current one to gamma space
  6719. * @returns a new Color4 object
  6720. */
  6721. toGammaSpace(): Color4;
  6722. /**
  6723. * Converts the Color4 values to gamma space and stores the result in "convertedColor"
  6724. * @param convertedColor defines the Color4 object where to store the gamma space version
  6725. * @returns the unmodified Color4
  6726. */
  6727. toGammaSpaceToRef(convertedColor: Color4): Color4;
  6728. /**
  6729. * Creates a new Color4 from the string containing valid hexadecimal values
  6730. * @param hex defines a string containing valid hexadecimal values
  6731. * @returns a new Color4 object
  6732. */
  6733. static FromHexString(hex: string): Color4;
  6734. /**
  6735. * Creates a new Color4 object set with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  6736. * @param left defines the start value
  6737. * @param right defines the end value
  6738. * @param amount defines the gradient factor
  6739. * @returns a new Color4 object
  6740. */
  6741. static Lerp(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number): Color4;
  6742. /**
  6743. * Set the given "result" with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  6744. * @param left defines the start value
  6745. * @param right defines the end value
  6746. * @param amount defines the gradient factor
  6747. * @param result defines the Color4 object where to store data
  6748. */
  6749. static LerpToRef(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number, result: Color4): void;
  6750. /**
  6751. * Creates a new Color4 from a Color3 and an alpha value
  6752. * @param color3 defines the source Color3 to read from
  6753. * @param alpha defines the alpha component (1.0 by default)
  6754. * @returns a new Color4 object
  6755. */
  6756. static FromColor3(color3: DeepImmutable<Color3>, alpha?: number): Color4;
  6757. /**
  6758. * Creates a new Color4 from the starting index element of the given array
  6759. * @param array defines the source array to read from
  6760. * @param offset defines the offset in the source array
  6761. * @returns a new Color4 object
  6762. */
  6763. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color4;
  6764. /**
  6765. * Creates a new Color4 from the starting index element of the given array
  6766. * @param array defines the source array to read from
  6767. * @param offset defines the offset in the source array
  6768. * @param result defines the target Color4 object
  6769. */
  6770. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number | undefined, result: Color4): void;
  6771. /**
  6772. * Creates a new Color3 from integer values (< 256)
  6773. * @param r defines the red component to read from (value between 0 and 255)
  6774. * @param g defines the green component to read from (value between 0 and 255)
  6775. * @param b defines the blue component to read from (value between 0 and 255)
  6776. * @param a defines the alpha component to read from (value between 0 and 255)
  6777. * @returns a new Color3 object
  6778. */
  6779. static FromInts(r: number, g: number, b: number, a: number): Color4;
  6780. /**
  6781. * Check the content of a given array and convert it to an array containing RGBA data
  6782. * If the original array was already containing count * 4 values then it is returned directly
  6783. * @param colors defines the array to check
  6784. * @param count defines the number of RGBA data to expect
  6785. * @returns an array containing count * 4 values (RGBA)
  6786. */
  6787. static CheckColors4(colors: number[], count: number): number[];
  6788. }
  6789. /**
  6790. * @hidden
  6791. */
  6792. export class TmpColors {
  6793. static Color3: Color3[];
  6794. static Color4: Color4[];
  6795. }
  6796. }
  6797. declare module BABYLON {
  6798. /**
  6799. * Defines an interface which represents an animation key frame
  6800. */
  6801. export interface IAnimationKey {
  6802. /**
  6803. * Frame of the key frame
  6804. */
  6805. frame: number;
  6806. /**
  6807. * Value at the specifies key frame
  6808. */
  6809. value: any;
  6810. /**
  6811. * The input tangent for the cubic hermite spline
  6812. */
  6813. inTangent?: any;
  6814. /**
  6815. * The output tangent for the cubic hermite spline
  6816. */
  6817. outTangent?: any;
  6818. /**
  6819. * The animation interpolation type
  6820. */
  6821. interpolation?: AnimationKeyInterpolation;
  6822. }
  6823. /**
  6824. * Enum for the animation key frame interpolation type
  6825. */
  6826. export enum AnimationKeyInterpolation {
  6827. /**
  6828. * Do not interpolate between keys and use the start key value only. Tangents are ignored
  6829. */
  6830. STEP = 1
  6831. }
  6832. }
  6833. declare module BABYLON {
  6834. /**
  6835. * Represents the range of an animation
  6836. */
  6837. export class AnimationRange {
  6838. /**The name of the animation range**/
  6839. name: string;
  6840. /**The starting frame of the animation */
  6841. from: number;
  6842. /**The ending frame of the animation*/
  6843. to: number;
  6844. /**
  6845. * Initializes the range of an animation
  6846. * @param name The name of the animation range
  6847. * @param from The starting frame of the animation
  6848. * @param to The ending frame of the animation
  6849. */
  6850. constructor(
  6851. /**The name of the animation range**/
  6852. name: string,
  6853. /**The starting frame of the animation */
  6854. from: number,
  6855. /**The ending frame of the animation*/
  6856. to: number);
  6857. /**
  6858. * Makes a copy of the animation range
  6859. * @returns A copy of the animation range
  6860. */
  6861. clone(): AnimationRange;
  6862. }
  6863. }
  6864. declare module BABYLON {
  6865. /**
  6866. * Composed of a frame, and an action function
  6867. */
  6868. export class AnimationEvent {
  6869. /** The frame for which the event is triggered **/
  6870. frame: number;
  6871. /** The event to perform when triggered **/
  6872. action: (currentFrame: number) => void;
  6873. /** Specifies if the event should be triggered only once**/
  6874. onlyOnce?: boolean | undefined;
  6875. /**
  6876. * Specifies if the animation event is done
  6877. */
  6878. isDone: boolean;
  6879. /**
  6880. * Initializes the animation event
  6881. * @param frame The frame for which the event is triggered
  6882. * @param action The event to perform when triggered
  6883. * @param onlyOnce Specifies if the event should be triggered only once
  6884. */
  6885. constructor(
  6886. /** The frame for which the event is triggered **/
  6887. frame: number,
  6888. /** The event to perform when triggered **/
  6889. action: (currentFrame: number) => void,
  6890. /** Specifies if the event should be triggered only once**/
  6891. onlyOnce?: boolean | undefined);
  6892. /** @hidden */
  6893. _clone(): AnimationEvent;
  6894. }
  6895. }
  6896. declare module BABYLON {
  6897. /**
  6898. * Interface used to define a behavior
  6899. */
  6900. export interface Behavior<T> {
  6901. /** gets or sets behavior's name */
  6902. name: string;
  6903. /**
  6904. * Function called when the behavior needs to be initialized (after attaching it to a target)
  6905. */
  6906. init(): void;
  6907. /**
  6908. * Called when the behavior is attached to a target
  6909. * @param target defines the target where the behavior is attached to
  6910. */
  6911. attach(target: T): void;
  6912. /**
  6913. * Called when the behavior is detached from its target
  6914. */
  6915. detach(): void;
  6916. }
  6917. /**
  6918. * Interface implemented by classes supporting behaviors
  6919. */
  6920. export interface IBehaviorAware<T> {
  6921. /**
  6922. * Attach a behavior
  6923. * @param behavior defines the behavior to attach
  6924. * @returns the current host
  6925. */
  6926. addBehavior(behavior: Behavior<T>): T;
  6927. /**
  6928. * Remove a behavior from the current object
  6929. * @param behavior defines the behavior to detach
  6930. * @returns the current host
  6931. */
  6932. removeBehavior(behavior: Behavior<T>): T;
  6933. /**
  6934. * Gets a behavior using its name to search
  6935. * @param name defines the name to search
  6936. * @returns the behavior or null if not found
  6937. */
  6938. getBehaviorByName(name: string): Nullable<Behavior<T>>;
  6939. }
  6940. }
  6941. declare module BABYLON {
  6942. /**
  6943. * Class used to provide helpers for slicing
  6944. */
  6945. export class SliceTools {
  6946. /**
  6947. * Provides a slice function that will work even on IE
  6948. * @param data defines the array to slice
  6949. * @param start defines the start of the data (optional)
  6950. * @param end defines the end of the data (optional)
  6951. * @returns the new sliced array
  6952. */
  6953. static Slice<T>(data: T, start?: number, end?: number): T;
  6954. /**
  6955. * Provides a slice function that will work even on IE
  6956. * The difference between this and Slice is that this will force-convert to array
  6957. * @param data defines the array to slice
  6958. * @param start defines the start of the data (optional)
  6959. * @param end defines the end of the data (optional)
  6960. * @returns the new sliced array
  6961. */
  6962. static SliceToArray<T, P>(data: T, start?: number, end?: number): Array<P>;
  6963. }
  6964. }
  6965. declare module BABYLON {
  6966. /**
  6967. * Class used to store data that will be store in GPU memory
  6968. */
  6969. export class Buffer {
  6970. private _engine;
  6971. private _buffer;
  6972. /** @hidden */
  6973. _data: Nullable<DataArray>;
  6974. private _updatable;
  6975. private _instanced;
  6976. private _divisor;
  6977. private _isAlreadyOwned;
  6978. /**
  6979. * Gets the byte stride.
  6980. */
  6981. readonly byteStride: number;
  6982. /**
  6983. * Constructor
  6984. * @param engine the engine
  6985. * @param data the data to use for this buffer
  6986. * @param updatable whether the data is updatable
  6987. * @param stride the stride (optional)
  6988. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  6989. * @param instanced whether the buffer is instanced (optional)
  6990. * @param useBytes set to true if the stride in in bytes (optional)
  6991. * @param divisor sets an optional divisor for instances (1 by default)
  6992. */
  6993. constructor(engine: any, data: DataArray, updatable: boolean, stride?: number, postponeInternalCreation?: boolean, instanced?: boolean, useBytes?: boolean, divisor?: number);
  6994. /**
  6995. * Create a new VertexBuffer based on the current buffer
  6996. * @param kind defines the vertex buffer kind (position, normal, etc.)
  6997. * @param offset defines offset in the buffer (0 by default)
  6998. * @param size defines the size in floats of attributes (position is 3 for instance)
  6999. * @param stride defines the stride size in floats in the buffer (the offset to apply to reach next value when data is interleaved)
  7000. * @param instanced defines if the vertex buffer contains indexed data
  7001. * @param useBytes defines if the offset and stride are in bytes *
  7002. * @param divisor sets an optional divisor for instances (1 by default)
  7003. * @returns the new vertex buffer
  7004. */
  7005. createVertexBuffer(kind: string, offset: number, size: number, stride?: number, instanced?: boolean, useBytes?: boolean, divisor?: number): VertexBuffer;
  7006. /**
  7007. * Gets a boolean indicating if the Buffer is updatable?
  7008. * @returns true if the buffer is updatable
  7009. */
  7010. isUpdatable(): boolean;
  7011. /**
  7012. * Gets current buffer's data
  7013. * @returns a DataArray or null
  7014. */
  7015. getData(): Nullable<DataArray>;
  7016. /**
  7017. * Gets underlying native buffer
  7018. * @returns underlying native buffer
  7019. */
  7020. getBuffer(): Nullable<DataBuffer>;
  7021. /**
  7022. * Gets the stride in float32 units (i.e. byte stride / 4).
  7023. * May not be an integer if the byte stride is not divisible by 4.
  7024. * @returns the stride in float32 units
  7025. * @deprecated Please use byteStride instead.
  7026. */
  7027. getStrideSize(): number;
  7028. /**
  7029. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  7030. * @param data defines the data to store
  7031. */
  7032. create(data?: Nullable<DataArray>): void;
  7033. /** @hidden */
  7034. _rebuild(): void;
  7035. /**
  7036. * Update current buffer data
  7037. * @param data defines the data to store
  7038. */
  7039. update(data: DataArray): void;
  7040. /**
  7041. * Updates the data directly.
  7042. * @param data the new data
  7043. * @param offset the new offset
  7044. * @param vertexCount the vertex count (optional)
  7045. * @param useBytes set to true if the offset is in bytes
  7046. */
  7047. updateDirectly(data: DataArray, offset: number, vertexCount?: number, useBytes?: boolean): void;
  7048. /** @hidden */
  7049. _increaseReferences(): void;
  7050. /**
  7051. * Release all resources
  7052. */
  7053. dispose(): void;
  7054. }
  7055. /**
  7056. * Specialized buffer used to store vertex data
  7057. */
  7058. export class VertexBuffer {
  7059. private static _Counter;
  7060. /** @hidden */
  7061. _buffer: Buffer;
  7062. private _kind;
  7063. private _size;
  7064. private _ownsBuffer;
  7065. private _instanced;
  7066. private _instanceDivisor;
  7067. /**
  7068. * The byte type.
  7069. */
  7070. static readonly BYTE: number;
  7071. /**
  7072. * The unsigned byte type.
  7073. */
  7074. static readonly UNSIGNED_BYTE: number;
  7075. /**
  7076. * The short type.
  7077. */
  7078. static readonly SHORT: number;
  7079. /**
  7080. * The unsigned short type.
  7081. */
  7082. static readonly UNSIGNED_SHORT: number;
  7083. /**
  7084. * The integer type.
  7085. */
  7086. static readonly INT: number;
  7087. /**
  7088. * The unsigned integer type.
  7089. */
  7090. static readonly UNSIGNED_INT: number;
  7091. /**
  7092. * The float type.
  7093. */
  7094. static readonly FLOAT: number;
  7095. /**
  7096. * Gets or sets the instance divisor when in instanced mode
  7097. */
  7098. get instanceDivisor(): number;
  7099. set instanceDivisor(value: number);
  7100. /**
  7101. * Gets the byte stride.
  7102. */
  7103. readonly byteStride: number;
  7104. /**
  7105. * Gets the byte offset.
  7106. */
  7107. readonly byteOffset: number;
  7108. /**
  7109. * Gets whether integer data values should be normalized into a certain range when being casted to a float.
  7110. */
  7111. readonly normalized: boolean;
  7112. /**
  7113. * Gets the data type of each component in the array.
  7114. */
  7115. readonly type: number;
  7116. /**
  7117. * Gets the unique id of this vertex buffer
  7118. */
  7119. readonly uniqueId: number;
  7120. /**
  7121. * Constructor
  7122. * @param engine the engine
  7123. * @param data the data to use for this vertex buffer
  7124. * @param kind the vertex buffer kind
  7125. * @param updatable whether the data is updatable
  7126. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  7127. * @param stride the stride (optional)
  7128. * @param instanced whether the buffer is instanced (optional)
  7129. * @param offset the offset of the data (optional)
  7130. * @param size the number of components (optional)
  7131. * @param type the type of the component (optional)
  7132. * @param normalized whether the data contains normalized data (optional)
  7133. * @param useBytes set to true if stride and offset are in bytes (optional)
  7134. * @param divisor defines the instance divisor to use (1 by default)
  7135. * @param takeBufferOwnership defines if the buffer should be released when the vertex buffer is disposed
  7136. */
  7137. 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);
  7138. /** @hidden */
  7139. _rebuild(): void;
  7140. /**
  7141. * Returns the kind of the VertexBuffer (string)
  7142. * @returns a string
  7143. */
  7144. getKind(): string;
  7145. /**
  7146. * Gets a boolean indicating if the VertexBuffer is updatable?
  7147. * @returns true if the buffer is updatable
  7148. */
  7149. isUpdatable(): boolean;
  7150. /**
  7151. * Gets current buffer's data
  7152. * @returns a DataArray or null
  7153. */
  7154. getData(): Nullable<DataArray>;
  7155. /**
  7156. * Gets current buffer's data as a float array. Float data is constructed if the vertex buffer data cannot be returned directly.
  7157. * @param totalVertices number of vertices in the buffer to take into account
  7158. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  7159. * @returns a float array containing vertex data
  7160. */
  7161. getFloatData(totalVertices: number, forceCopy?: boolean): Nullable<FloatArray>;
  7162. /**
  7163. * Gets underlying native buffer
  7164. * @returns underlying native buffer
  7165. */
  7166. getBuffer(): Nullable<DataBuffer>;
  7167. /**
  7168. * Gets the stride in float32 units (i.e. byte stride / 4).
  7169. * May not be an integer if the byte stride is not divisible by 4.
  7170. * @returns the stride in float32 units
  7171. * @deprecated Please use byteStride instead.
  7172. */
  7173. getStrideSize(): number;
  7174. /**
  7175. * Returns the offset as a multiple of the type byte length.
  7176. * @returns the offset in bytes
  7177. * @deprecated Please use byteOffset instead.
  7178. */
  7179. getOffset(): number;
  7180. /**
  7181. * Returns the number of components per vertex attribute (integer)
  7182. * @returns the size in float
  7183. */
  7184. getSize(): number;
  7185. /**
  7186. * Gets a boolean indicating is the internal buffer of the VertexBuffer is instanced
  7187. * @returns true if this buffer is instanced
  7188. */
  7189. getIsInstanced(): boolean;
  7190. /**
  7191. * Returns the instancing divisor, zero for non-instanced (integer).
  7192. * @returns a number
  7193. */
  7194. getInstanceDivisor(): number;
  7195. /**
  7196. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  7197. * @param data defines the data to store
  7198. */
  7199. create(data?: DataArray): void;
  7200. /**
  7201. * Updates the underlying buffer according to the passed numeric array or Float32Array.
  7202. * This function will create a new buffer if the current one is not updatable
  7203. * @param data defines the data to store
  7204. */
  7205. update(data: DataArray): void;
  7206. /**
  7207. * Updates directly the underlying WebGLBuffer according to the passed numeric array or Float32Array.
  7208. * Returns the directly updated WebGLBuffer.
  7209. * @param data the new data
  7210. * @param offset the new offset
  7211. * @param useBytes set to true if the offset is in bytes
  7212. */
  7213. updateDirectly(data: DataArray, offset: number, useBytes?: boolean): void;
  7214. /**
  7215. * Disposes the VertexBuffer and the underlying WebGLBuffer.
  7216. */
  7217. dispose(): void;
  7218. /**
  7219. * Enumerates each value of this vertex buffer as numbers.
  7220. * @param count the number of values to enumerate
  7221. * @param callback the callback function called for each value
  7222. */
  7223. forEach(count: number, callback: (value: number, index: number) => void): void;
  7224. /**
  7225. * Positions
  7226. */
  7227. static readonly PositionKind: string;
  7228. /**
  7229. * Normals
  7230. */
  7231. static readonly NormalKind: string;
  7232. /**
  7233. * Tangents
  7234. */
  7235. static readonly TangentKind: string;
  7236. /**
  7237. * Texture coordinates
  7238. */
  7239. static readonly UVKind: string;
  7240. /**
  7241. * Texture coordinates 2
  7242. */
  7243. static readonly UV2Kind: string;
  7244. /**
  7245. * Texture coordinates 3
  7246. */
  7247. static readonly UV3Kind: string;
  7248. /**
  7249. * Texture coordinates 4
  7250. */
  7251. static readonly UV4Kind: string;
  7252. /**
  7253. * Texture coordinates 5
  7254. */
  7255. static readonly UV5Kind: string;
  7256. /**
  7257. * Texture coordinates 6
  7258. */
  7259. static readonly UV6Kind: string;
  7260. /**
  7261. * Colors
  7262. */
  7263. static readonly ColorKind: string;
  7264. /**
  7265. * Matrix indices (for bones)
  7266. */
  7267. static readonly MatricesIndicesKind: string;
  7268. /**
  7269. * Matrix weights (for bones)
  7270. */
  7271. static readonly MatricesWeightsKind: string;
  7272. /**
  7273. * Additional matrix indices (for bones)
  7274. */
  7275. static readonly MatricesIndicesExtraKind: string;
  7276. /**
  7277. * Additional matrix weights (for bones)
  7278. */
  7279. static readonly MatricesWeightsExtraKind: string;
  7280. /**
  7281. * Deduces the stride given a kind.
  7282. * @param kind The kind string to deduce
  7283. * @returns The deduced stride
  7284. */
  7285. static DeduceStride(kind: string): number;
  7286. /**
  7287. * Gets the byte length of the given type.
  7288. * @param type the type
  7289. * @returns the number of bytes
  7290. */
  7291. static GetTypeByteLength(type: number): number;
  7292. /**
  7293. * Enumerates each value of the given parameters as numbers.
  7294. * @param data the data to enumerate
  7295. * @param byteOffset the byte offset of the data
  7296. * @param byteStride the byte stride of the data
  7297. * @param componentCount the number of components per element
  7298. * @param componentType the type of the component
  7299. * @param count the number of values to enumerate
  7300. * @param normalized whether the data is normalized
  7301. * @param callback the callback function called for each value
  7302. */
  7303. static ForEach(data: DataArray, byteOffset: number, byteStride: number, componentCount: number, componentType: number, count: number, normalized: boolean, callback: (value: number, index: number) => void): void;
  7304. private static _GetFloatValue;
  7305. }
  7306. }
  7307. declare module BABYLON {
  7308. /**
  7309. * @hidden
  7310. */
  7311. export class IntersectionInfo {
  7312. bu: Nullable<number>;
  7313. bv: Nullable<number>;
  7314. distance: number;
  7315. faceId: number;
  7316. subMeshId: number;
  7317. constructor(bu: Nullable<number>, bv: Nullable<number>, distance: number);
  7318. }
  7319. }
  7320. declare module BABYLON {
  7321. /**
  7322. * Class used to store bounding sphere information
  7323. */
  7324. export class BoundingSphere {
  7325. /**
  7326. * Gets the center of the bounding sphere in local space
  7327. */
  7328. readonly center: Vector3;
  7329. /**
  7330. * Radius of the bounding sphere in local space
  7331. */
  7332. radius: number;
  7333. /**
  7334. * Gets the center of the bounding sphere in world space
  7335. */
  7336. readonly centerWorld: Vector3;
  7337. /**
  7338. * Radius of the bounding sphere in world space
  7339. */
  7340. radiusWorld: number;
  7341. /**
  7342. * Gets the minimum vector in local space
  7343. */
  7344. readonly minimum: Vector3;
  7345. /**
  7346. * Gets the maximum vector in local space
  7347. */
  7348. readonly maximum: Vector3;
  7349. private _worldMatrix;
  7350. private static readonly TmpVector3;
  7351. /**
  7352. * Creates a new bounding sphere
  7353. * @param min defines the minimum vector (in local space)
  7354. * @param max defines the maximum vector (in local space)
  7355. * @param worldMatrix defines the new world matrix
  7356. */
  7357. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  7358. /**
  7359. * Recreates the entire bounding sphere from scratch as if we call the constructor in place
  7360. * @param min defines the new minimum vector (in local space)
  7361. * @param max defines the new maximum vector (in local space)
  7362. * @param worldMatrix defines the new world matrix
  7363. */
  7364. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  7365. /**
  7366. * Scale the current bounding sphere by applying a scale factor
  7367. * @param factor defines the scale factor to apply
  7368. * @returns the current bounding box
  7369. */
  7370. scale(factor: number): BoundingSphere;
  7371. /**
  7372. * Gets the world matrix of the bounding box
  7373. * @returns a matrix
  7374. */
  7375. getWorldMatrix(): DeepImmutable<Matrix>;
  7376. /** @hidden */
  7377. _update(worldMatrix: DeepImmutable<Matrix>): void;
  7378. /**
  7379. * Tests if the bounding sphere is intersecting the frustum planes
  7380. * @param frustumPlanes defines the frustum planes to test
  7381. * @returns true if there is an intersection
  7382. */
  7383. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7384. /**
  7385. * Tests if the bounding sphere center is in between the frustum planes.
  7386. * Used for optimistic fast inclusion.
  7387. * @param frustumPlanes defines the frustum planes to test
  7388. * @returns true if the sphere center is in between the frustum planes
  7389. */
  7390. isCenterInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7391. /**
  7392. * Tests if a point is inside the bounding sphere
  7393. * @param point defines the point to test
  7394. * @returns true if the point is inside the bounding sphere
  7395. */
  7396. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  7397. /**
  7398. * Checks if two sphere intersect
  7399. * @param sphere0 sphere 0
  7400. * @param sphere1 sphere 1
  7401. * @returns true if the spheres intersect
  7402. */
  7403. static Intersects(sphere0: DeepImmutable<BoundingSphere>, sphere1: DeepImmutable<BoundingSphere>): boolean;
  7404. }
  7405. }
  7406. declare module BABYLON {
  7407. /**
  7408. * Class used to store bounding box information
  7409. */
  7410. export class BoundingBox implements ICullable {
  7411. /**
  7412. * Gets the 8 vectors representing the bounding box in local space
  7413. */
  7414. readonly vectors: Vector3[];
  7415. /**
  7416. * Gets the center of the bounding box in local space
  7417. */
  7418. readonly center: Vector3;
  7419. /**
  7420. * Gets the center of the bounding box in world space
  7421. */
  7422. readonly centerWorld: Vector3;
  7423. /**
  7424. * Gets the extend size in local space
  7425. */
  7426. readonly extendSize: Vector3;
  7427. /**
  7428. * Gets the extend size in world space
  7429. */
  7430. readonly extendSizeWorld: Vector3;
  7431. /**
  7432. * Gets the OBB (object bounding box) directions
  7433. */
  7434. readonly directions: Vector3[];
  7435. /**
  7436. * Gets the 8 vectors representing the bounding box in world space
  7437. */
  7438. readonly vectorsWorld: Vector3[];
  7439. /**
  7440. * Gets the minimum vector in world space
  7441. */
  7442. readonly minimumWorld: Vector3;
  7443. /**
  7444. * Gets the maximum vector in world space
  7445. */
  7446. readonly maximumWorld: Vector3;
  7447. /**
  7448. * Gets the minimum vector in local space
  7449. */
  7450. readonly minimum: Vector3;
  7451. /**
  7452. * Gets the maximum vector in local space
  7453. */
  7454. readonly maximum: Vector3;
  7455. private _worldMatrix;
  7456. private static readonly TmpVector3;
  7457. /**
  7458. * @hidden
  7459. */
  7460. _tag: number;
  7461. /**
  7462. * Creates a new bounding box
  7463. * @param min defines the minimum vector (in local space)
  7464. * @param max defines the maximum vector (in local space)
  7465. * @param worldMatrix defines the new world matrix
  7466. */
  7467. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  7468. /**
  7469. * Recreates the entire bounding box from scratch as if we call the constructor in place
  7470. * @param min defines the new minimum vector (in local space)
  7471. * @param max defines the new maximum vector (in local space)
  7472. * @param worldMatrix defines the new world matrix
  7473. */
  7474. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  7475. /**
  7476. * Scale the current bounding box by applying a scale factor
  7477. * @param factor defines the scale factor to apply
  7478. * @returns the current bounding box
  7479. */
  7480. scale(factor: number): BoundingBox;
  7481. /**
  7482. * Gets the world matrix of the bounding box
  7483. * @returns a matrix
  7484. */
  7485. getWorldMatrix(): DeepImmutable<Matrix>;
  7486. /** @hidden */
  7487. _update(world: DeepImmutable<Matrix>): void;
  7488. /**
  7489. * Tests if the bounding box is intersecting the frustum planes
  7490. * @param frustumPlanes defines the frustum planes to test
  7491. * @returns true if there is an intersection
  7492. */
  7493. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7494. /**
  7495. * Tests if the bounding box is entirely inside the frustum planes
  7496. * @param frustumPlanes defines the frustum planes to test
  7497. * @returns true if there is an inclusion
  7498. */
  7499. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7500. /**
  7501. * Tests if a point is inside the bounding box
  7502. * @param point defines the point to test
  7503. * @returns true if the point is inside the bounding box
  7504. */
  7505. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  7506. /**
  7507. * Tests if the bounding box intersects with a bounding sphere
  7508. * @param sphere defines the sphere to test
  7509. * @returns true if there is an intersection
  7510. */
  7511. intersectsSphere(sphere: DeepImmutable<BoundingSphere>): boolean;
  7512. /**
  7513. * Tests if the bounding box intersects with a box defined by a min and max vectors
  7514. * @param min defines the min vector to use
  7515. * @param max defines the max vector to use
  7516. * @returns true if there is an intersection
  7517. */
  7518. intersectsMinMax(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): boolean;
  7519. /**
  7520. * Tests if two bounding boxes are intersections
  7521. * @param box0 defines the first box to test
  7522. * @param box1 defines the second box to test
  7523. * @returns true if there is an intersection
  7524. */
  7525. static Intersects(box0: DeepImmutable<BoundingBox>, box1: DeepImmutable<BoundingBox>): boolean;
  7526. /**
  7527. * Tests if a bounding box defines by a min/max vectors intersects a sphere
  7528. * @param minPoint defines the minimum vector of the bounding box
  7529. * @param maxPoint defines the maximum vector of the bounding box
  7530. * @param sphereCenter defines the sphere center
  7531. * @param sphereRadius defines the sphere radius
  7532. * @returns true if there is an intersection
  7533. */
  7534. static IntersectsSphere(minPoint: DeepImmutable<Vector3>, maxPoint: DeepImmutable<Vector3>, sphereCenter: DeepImmutable<Vector3>, sphereRadius: number): boolean;
  7535. /**
  7536. * Tests if a bounding box defined with 8 vectors is entirely inside frustum planes
  7537. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  7538. * @param frustumPlanes defines the frustum planes to test
  7539. * @return true if there is an inclusion
  7540. */
  7541. static IsCompletelyInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7542. /**
  7543. * Tests if a bounding box defined with 8 vectors intersects frustum planes
  7544. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  7545. * @param frustumPlanes defines the frustum planes to test
  7546. * @return true if there is an intersection
  7547. */
  7548. static IsInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7549. }
  7550. }
  7551. declare module BABYLON {
  7552. /** @hidden */
  7553. export class Collider {
  7554. /** Define if a collision was found */
  7555. collisionFound: boolean;
  7556. /**
  7557. * Define last intersection point in local space
  7558. */
  7559. intersectionPoint: Vector3;
  7560. /**
  7561. * Define last collided mesh
  7562. */
  7563. collidedMesh: Nullable<AbstractMesh>;
  7564. private _collisionPoint;
  7565. private _planeIntersectionPoint;
  7566. private _tempVector;
  7567. private _tempVector2;
  7568. private _tempVector3;
  7569. private _tempVector4;
  7570. private _edge;
  7571. private _baseToVertex;
  7572. private _destinationPoint;
  7573. private _slidePlaneNormal;
  7574. private _displacementVector;
  7575. /** @hidden */
  7576. _radius: Vector3;
  7577. /** @hidden */
  7578. _retry: number;
  7579. private _velocity;
  7580. private _basePoint;
  7581. private _epsilon;
  7582. /** @hidden */
  7583. _velocityWorldLength: number;
  7584. /** @hidden */
  7585. _basePointWorld: Vector3;
  7586. private _velocityWorld;
  7587. private _normalizedVelocity;
  7588. /** @hidden */
  7589. _initialVelocity: Vector3;
  7590. /** @hidden */
  7591. _initialPosition: Vector3;
  7592. private _nearestDistance;
  7593. private _collisionMask;
  7594. get collisionMask(): number;
  7595. set collisionMask(mask: number);
  7596. /**
  7597. * Gets the plane normal used to compute the sliding response (in local space)
  7598. */
  7599. get slidePlaneNormal(): Vector3;
  7600. /** @hidden */
  7601. _initialize(source: Vector3, dir: Vector3, e: number): void;
  7602. /** @hidden */
  7603. _checkPointInTriangle(point: Vector3, pa: Vector3, pb: Vector3, pc: Vector3, n: Vector3): boolean;
  7604. /** @hidden */
  7605. _canDoCollision(sphereCenter: Vector3, sphereRadius: number, vecMin: Vector3, vecMax: Vector3): boolean;
  7606. /** @hidden */
  7607. _testTriangle(faceIndex: number, trianglePlaneArray: Array<Plane>, p1: Vector3, p2: Vector3, p3: Vector3, hasMaterial: boolean, hostMesh: AbstractMesh): void;
  7608. /** @hidden */
  7609. _collide(trianglePlaneArray: Array<Plane>, pts: Vector3[], indices: IndicesArray, indexStart: number, indexEnd: number, decal: number, hasMaterial: boolean, hostMesh: AbstractMesh): void;
  7610. /** @hidden */
  7611. _getResponse(pos: Vector3, vel: Vector3): void;
  7612. }
  7613. }
  7614. declare module BABYLON {
  7615. /**
  7616. * Interface for cullable objects
  7617. * @see https://doc.babylonjs.com/babylon101/materials#back-face-culling
  7618. */
  7619. export interface ICullable {
  7620. /**
  7621. * Checks if the object or part of the object is in the frustum
  7622. * @param frustumPlanes Camera near/planes
  7623. * @returns true if the object is in frustum otherwise false
  7624. */
  7625. isInFrustum(frustumPlanes: Plane[]): boolean;
  7626. /**
  7627. * Checks if a cullable object (mesh...) is in the camera frustum
  7628. * Unlike isInFrustum this checks the full bounding box
  7629. * @param frustumPlanes Camera near/planes
  7630. * @returns true if the object is in frustum otherwise false
  7631. */
  7632. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  7633. }
  7634. /**
  7635. * Info for a bounding data of a mesh
  7636. */
  7637. export class BoundingInfo implements ICullable {
  7638. /**
  7639. * Bounding box for the mesh
  7640. */
  7641. readonly boundingBox: BoundingBox;
  7642. /**
  7643. * Bounding sphere for the mesh
  7644. */
  7645. readonly boundingSphere: BoundingSphere;
  7646. private _isLocked;
  7647. private static readonly TmpVector3;
  7648. /**
  7649. * Constructs bounding info
  7650. * @param minimum min vector of the bounding box/sphere
  7651. * @param maximum max vector of the bounding box/sphere
  7652. * @param worldMatrix defines the new world matrix
  7653. */
  7654. constructor(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  7655. /**
  7656. * Recreates the entire bounding info from scratch as if we call the constructor in place
  7657. * @param min defines the new minimum vector (in local space)
  7658. * @param max defines the new maximum vector (in local space)
  7659. * @param worldMatrix defines the new world matrix
  7660. */
  7661. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  7662. /**
  7663. * min vector of the bounding box/sphere
  7664. */
  7665. get minimum(): Vector3;
  7666. /**
  7667. * max vector of the bounding box/sphere
  7668. */
  7669. get maximum(): Vector3;
  7670. /**
  7671. * If the info is locked and won't be updated to avoid perf overhead
  7672. */
  7673. get isLocked(): boolean;
  7674. set isLocked(value: boolean);
  7675. /**
  7676. * Updates the bounding sphere and box
  7677. * @param world world matrix to be used to update
  7678. */
  7679. update(world: DeepImmutable<Matrix>): void;
  7680. /**
  7681. * Recreate the bounding info to be centered around a specific point given a specific extend.
  7682. * @param center New center of the bounding info
  7683. * @param extend New extend of the bounding info
  7684. * @returns the current bounding info
  7685. */
  7686. centerOn(center: DeepImmutable<Vector3>, extend: DeepImmutable<Vector3>): BoundingInfo;
  7687. /**
  7688. * Grows the bounding info to include the given point.
  7689. * @param point The point that will be included in the current bounding info
  7690. * @returns the current bounding info
  7691. */
  7692. encapsulate(point: Vector3): BoundingInfo;
  7693. /**
  7694. * Grows the bounding info to encapsulate the given bounding info.
  7695. * @param toEncapsulate The bounding info that will be encapsulated in the current bounding info
  7696. * @returns the current bounding info
  7697. */
  7698. encapsulateBoundingInfo(toEncapsulate: BoundingInfo): BoundingInfo;
  7699. /**
  7700. * Scale the current bounding info by applying a scale factor
  7701. * @param factor defines the scale factor to apply
  7702. * @returns the current bounding info
  7703. */
  7704. scale(factor: number): BoundingInfo;
  7705. /**
  7706. * Returns `true` if the bounding info is within the frustum defined by the passed array of planes.
  7707. * @param frustumPlanes defines the frustum to test
  7708. * @param strategy defines the strategy to use for the culling (default is BABYLON.AbstractMesh.CULLINGSTRATEGY_STANDARD)
  7709. * @returns true if the bounding info is in the frustum planes
  7710. */
  7711. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>, strategy?: number): boolean;
  7712. /**
  7713. * Gets the world distance between the min and max points of the bounding box
  7714. */
  7715. get diagonalLength(): number;
  7716. /**
  7717. * Checks if a cullable object (mesh...) is in the camera frustum
  7718. * Unlike isInFrustum this checks the full bounding box
  7719. * @param frustumPlanes Camera near/planes
  7720. * @returns true if the object is in frustum otherwise false
  7721. */
  7722. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7723. /** @hidden */
  7724. _checkCollision(collider: Collider): boolean;
  7725. /**
  7726. * Checks if a point is inside the bounding box and bounding sphere or the mesh
  7727. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  7728. * @param point the point to check intersection with
  7729. * @returns if the point intersects
  7730. */
  7731. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  7732. /**
  7733. * Checks if another bounding info intersects the bounding box and bounding sphere or the mesh
  7734. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  7735. * @param boundingInfo the bounding info to check intersection with
  7736. * @param precise if the intersection should be done using OBB
  7737. * @returns if the bounding info intersects
  7738. */
  7739. intersects(boundingInfo: DeepImmutable<BoundingInfo>, precise: boolean): boolean;
  7740. }
  7741. }
  7742. declare module BABYLON {
  7743. /**
  7744. * Extracts minimum and maximum values from a list of indexed positions
  7745. * @param positions defines the positions to use
  7746. * @param indices defines the indices to the positions
  7747. * @param indexStart defines the start index
  7748. * @param indexCount defines the end index
  7749. * @param bias defines bias value to add to the result
  7750. * @return minimum and maximum values
  7751. */
  7752. export function extractMinAndMaxIndexed(positions: FloatArray, indices: IndicesArray, indexStart: number, indexCount: number, bias?: Nullable<Vector2>): {
  7753. minimum: Vector3;
  7754. maximum: Vector3;
  7755. };
  7756. /**
  7757. * Extracts minimum and maximum values from a list of positions
  7758. * @param positions defines the positions to use
  7759. * @param start defines the start index in the positions array
  7760. * @param count defines the number of positions to handle
  7761. * @param bias defines bias value to add to the result
  7762. * @param stride defines the stride size to use (distance between two positions in the positions array)
  7763. * @return minimum and maximum values
  7764. */
  7765. export function extractMinAndMax(positions: FloatArray, start: number, count: number, bias?: Nullable<Vector2>, stride?: number): {
  7766. minimum: Vector3;
  7767. maximum: Vector3;
  7768. };
  7769. }
  7770. declare module BABYLON {
  7771. /**
  7772. * Class used to manipulate GUIDs
  7773. */
  7774. export class GUID {
  7775. /**
  7776. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  7777. * Be aware Math.random() could cause collisions, but:
  7778. * "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"
  7779. * @returns a pseudo random id
  7780. */
  7781. static RandomId(): string;
  7782. }
  7783. }
  7784. declare module BABYLON {
  7785. /**
  7786. * Base class of all the textures in babylon.
  7787. * It groups all the common properties the materials, post process, lights... might need
  7788. * in order to make a correct use of the texture.
  7789. */
  7790. export class BaseTexture extends ThinTexture implements IAnimatable {
  7791. /**
  7792. * Default anisotropic filtering level for the application.
  7793. * It is set to 4 as a good tradeoff between perf and quality.
  7794. */
  7795. static DEFAULT_ANISOTROPIC_FILTERING_LEVEL: number;
  7796. /**
  7797. * Gets or sets the unique id of the texture
  7798. */
  7799. uniqueId: number;
  7800. /**
  7801. * Define the name of the texture.
  7802. */
  7803. name: string;
  7804. /**
  7805. * Gets or sets an object used to store user defined information.
  7806. */
  7807. metadata: any;
  7808. /**
  7809. * For internal use only. Please do not use.
  7810. */
  7811. reservedDataStore: any;
  7812. private _hasAlpha;
  7813. /**
  7814. * Define if the texture is having a usable alpha value (can be use for transparency or glossiness for instance).
  7815. */
  7816. set hasAlpha(value: boolean);
  7817. get hasAlpha(): boolean;
  7818. /**
  7819. * Defines if the alpha value should be determined via the rgb values.
  7820. * If true the luminance of the pixel might be used to find the corresponding alpha value.
  7821. */
  7822. getAlphaFromRGB: boolean;
  7823. /**
  7824. * Intensity or strength of the texture.
  7825. * It is commonly used by materials to fine tune the intensity of the texture
  7826. */
  7827. level: number;
  7828. /**
  7829. * Define the UV channel to use starting from 0 and defaulting to 0.
  7830. * This is part of the texture as textures usually maps to one uv set.
  7831. */
  7832. coordinatesIndex: number;
  7833. protected _coordinatesMode: number;
  7834. /**
  7835. * How a texture is mapped.
  7836. *
  7837. * | Value | Type | Description |
  7838. * | ----- | ----------------------------------- | ----------- |
  7839. * | 0 | EXPLICIT_MODE | |
  7840. * | 1 | SPHERICAL_MODE | |
  7841. * | 2 | PLANAR_MODE | |
  7842. * | 3 | CUBIC_MODE | |
  7843. * | 4 | PROJECTION_MODE | |
  7844. * | 5 | SKYBOX_MODE | |
  7845. * | 6 | INVCUBIC_MODE | |
  7846. * | 7 | EQUIRECTANGULAR_MODE | |
  7847. * | 8 | FIXED_EQUIRECTANGULAR_MODE | |
  7848. * | 9 | FIXED_EQUIRECTANGULAR_MIRRORED_MODE | |
  7849. */
  7850. set coordinatesMode(value: number);
  7851. get coordinatesMode(): number;
  7852. /**
  7853. * | Value | Type | Description |
  7854. * | ----- | ------------------ | ----------- |
  7855. * | 0 | CLAMP_ADDRESSMODE | |
  7856. * | 1 | WRAP_ADDRESSMODE | |
  7857. * | 2 | MIRROR_ADDRESSMODE | |
  7858. */
  7859. get wrapU(): number;
  7860. set wrapU(value: number);
  7861. /**
  7862. * | Value | Type | Description |
  7863. * | ----- | ------------------ | ----------- |
  7864. * | 0 | CLAMP_ADDRESSMODE | |
  7865. * | 1 | WRAP_ADDRESSMODE | |
  7866. * | 2 | MIRROR_ADDRESSMODE | |
  7867. */
  7868. get wrapV(): number;
  7869. set wrapV(value: number);
  7870. /**
  7871. * | Value | Type | Description |
  7872. * | ----- | ------------------ | ----------- |
  7873. * | 0 | CLAMP_ADDRESSMODE | |
  7874. * | 1 | WRAP_ADDRESSMODE | |
  7875. * | 2 | MIRROR_ADDRESSMODE | |
  7876. */
  7877. wrapR: number;
  7878. /**
  7879. * With compliant hardware and browser (supporting anisotropic filtering)
  7880. * this defines the level of anisotropic filtering in the texture.
  7881. * The higher the better but the slower. This defaults to 4 as it seems to be the best tradeoff.
  7882. */
  7883. anisotropicFilteringLevel: number;
  7884. private _isCube;
  7885. /**
  7886. * Define if the texture is a cube texture or if false a 2d texture.
  7887. */
  7888. get isCube(): boolean;
  7889. set isCube(value: boolean);
  7890. /**
  7891. * Define if the texture is a 3d texture (webgl 2) or if false a 2d texture.
  7892. */
  7893. get is3D(): boolean;
  7894. set is3D(value: boolean);
  7895. /**
  7896. * Define if the texture is a 2d array texture (webgl 2) or if false a 2d texture.
  7897. */
  7898. get is2DArray(): boolean;
  7899. set is2DArray(value: boolean);
  7900. private _gammaSpace;
  7901. /**
  7902. * Define if the texture contains data in gamma space (most of the png/jpg aside bump).
  7903. * HDR texture are usually stored in linear space.
  7904. * This only impacts the PBR and Background materials
  7905. */
  7906. get gammaSpace(): boolean;
  7907. set gammaSpace(gamma: boolean);
  7908. /**
  7909. * Gets or sets whether or not the texture contains RGBD data.
  7910. */
  7911. get isRGBD(): boolean;
  7912. set isRGBD(value: boolean);
  7913. /**
  7914. * Is Z inverted in the texture (useful in a cube texture).
  7915. */
  7916. invertZ: boolean;
  7917. /**
  7918. * Are mip maps generated for this texture or not.
  7919. */
  7920. get noMipmap(): boolean;
  7921. /**
  7922. * @hidden
  7923. */
  7924. lodLevelInAlpha: boolean;
  7925. /**
  7926. * With prefiltered texture, defined the offset used during the prefiltering steps.
  7927. */
  7928. get lodGenerationOffset(): number;
  7929. set lodGenerationOffset(value: number);
  7930. /**
  7931. * With prefiltered texture, defined the scale used during the prefiltering steps.
  7932. */
  7933. get lodGenerationScale(): number;
  7934. set lodGenerationScale(value: number);
  7935. /**
  7936. * With prefiltered texture, defined if the specular generation is based on a linear ramp.
  7937. * By default we are using a log2 of the linear roughness helping to keep a better resolution for
  7938. * average roughness values.
  7939. */
  7940. get linearSpecularLOD(): boolean;
  7941. set linearSpecularLOD(value: boolean);
  7942. /**
  7943. * In case a better definition than spherical harmonics is required for the diffuse part of the environment.
  7944. * You can set the irradiance texture to rely on a texture instead of the spherical approach.
  7945. * This texture need to have the same characteristics than its parent (Cube vs 2d, coordinates mode, Gamma/Linear, RGBD).
  7946. */
  7947. get irradianceTexture(): Nullable<BaseTexture>;
  7948. set irradianceTexture(value: Nullable<BaseTexture>);
  7949. /**
  7950. * Define if the texture is a render target.
  7951. */
  7952. isRenderTarget: boolean;
  7953. /**
  7954. * Define the unique id of the texture in the scene.
  7955. */
  7956. get uid(): string;
  7957. /** @hidden */
  7958. _prefiltered: boolean;
  7959. /**
  7960. * Return a string representation of the texture.
  7961. * @returns the texture as a string
  7962. */
  7963. toString(): string;
  7964. /**
  7965. * Get the class name of the texture.
  7966. * @returns "BaseTexture"
  7967. */
  7968. getClassName(): string;
  7969. /**
  7970. * Define the list of animation attached to the texture.
  7971. */
  7972. animations: Animation[];
  7973. /**
  7974. * An event triggered when the texture is disposed.
  7975. */
  7976. onDisposeObservable: Observable<BaseTexture>;
  7977. private _onDisposeObserver;
  7978. /**
  7979. * Callback triggered when the texture has been disposed.
  7980. * Kept for back compatibility, you can use the onDisposeObservable instead.
  7981. */
  7982. set onDispose(callback: () => void);
  7983. protected _scene: Nullable<Scene>;
  7984. /** @hidden */
  7985. _texture: Nullable<InternalTexture>;
  7986. private _uid;
  7987. /**
  7988. * Define if the texture is preventing a material to render or not.
  7989. * If not and the texture is not ready, the engine will use a default black texture instead.
  7990. */
  7991. get isBlocking(): boolean;
  7992. /**
  7993. * Instantiates a new BaseTexture.
  7994. * Base class of all the textures in babylon.
  7995. * It groups all the common properties the materials, post process, lights... might need
  7996. * in order to make a correct use of the texture.
  7997. * @param sceneOrEngine Define the scene or engine the texture belongs to
  7998. */
  7999. constructor(sceneOrEngine: Nullable<Scene | ThinEngine>);
  8000. /**
  8001. * Get the scene the texture belongs to.
  8002. * @returns the scene or null if undefined
  8003. */
  8004. getScene(): Nullable<Scene>;
  8005. /** @hidden */
  8006. protected _getEngine(): Nullable<ThinEngine>;
  8007. /**
  8008. * Checks if the texture has the same transform matrix than another texture
  8009. * @param texture texture to check against
  8010. * @returns true if the transforms are the same, else false
  8011. */
  8012. checkTransformsAreIdentical(texture: Nullable<BaseTexture>): boolean;
  8013. /**
  8014. * Get the texture transform matrix used to offset tile the texture for instance.
  8015. * @returns the transformation matrix
  8016. */
  8017. getTextureMatrix(): Matrix;
  8018. /**
  8019. * Get the texture reflection matrix used to rotate/transform the reflection.
  8020. * @returns the reflection matrix
  8021. */
  8022. getReflectionTextureMatrix(): Matrix;
  8023. /**
  8024. * Get if the texture is ready to be consumed (either it is ready or it is not blocking)
  8025. * @returns true if ready or not blocking
  8026. */
  8027. isReadyOrNotBlocking(): boolean;
  8028. /**
  8029. * Scales the texture if is `canRescale()`
  8030. * @param ratio the resize factor we want to use to rescale
  8031. */
  8032. scale(ratio: number): void;
  8033. /**
  8034. * Get if the texture can rescale.
  8035. */
  8036. get canRescale(): boolean;
  8037. /** @hidden */
  8038. _getFromCache(url: Nullable<string>, noMipmap: boolean, sampling?: number, invertY?: boolean): Nullable<InternalTexture>;
  8039. /** @hidden */
  8040. _rebuild(): void;
  8041. /**
  8042. * Clones the texture.
  8043. * @returns the cloned texture
  8044. */
  8045. clone(): Nullable<BaseTexture>;
  8046. /**
  8047. * Get the texture underlying type (INT, FLOAT...)
  8048. */
  8049. get textureType(): number;
  8050. /**
  8051. * Get the texture underlying format (RGB, RGBA...)
  8052. */
  8053. get textureFormat(): number;
  8054. /**
  8055. * Indicates that textures need to be re-calculated for all materials
  8056. */
  8057. protected _markAllSubMeshesAsTexturesDirty(): void;
  8058. /**
  8059. * Reads the pixels stored in the webgl texture and returns them as an ArrayBuffer.
  8060. * This will returns an RGBA array buffer containing either in values (0-255) or
  8061. * float values (0-1) depending of the underlying buffer type.
  8062. * @param faceIndex defines the face of the texture to read (in case of cube texture)
  8063. * @param level defines the LOD level of the texture to read (in case of Mip Maps)
  8064. * @param buffer defines a user defined buffer to fill with data (can be null)
  8065. * @param flushRenderer true to flush the renderer from the pending commands before reading the pixels
  8066. * @returns The Array buffer promise containing the pixels data.
  8067. */
  8068. readPixels(faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>, flushRenderer?: boolean): Nullable<Promise<ArrayBufferView>>;
  8069. /** @hidden */
  8070. _readPixelsSync(faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>, flushRenderer?: boolean): Nullable<ArrayBufferView>;
  8071. /** @hidden */
  8072. get _lodTextureHigh(): Nullable<BaseTexture>;
  8073. /** @hidden */
  8074. get _lodTextureMid(): Nullable<BaseTexture>;
  8075. /** @hidden */
  8076. get _lodTextureLow(): Nullable<BaseTexture>;
  8077. /**
  8078. * Dispose the texture and release its associated resources.
  8079. */
  8080. dispose(): void;
  8081. /**
  8082. * Serialize the texture into a JSON representation that can be parsed later on.
  8083. * @returns the JSON representation of the texture
  8084. */
  8085. serialize(): any;
  8086. /**
  8087. * Helper function to be called back once a list of texture contains only ready textures.
  8088. * @param textures Define the list of textures to wait for
  8089. * @param callback Define the callback triggered once the entire list will be ready
  8090. */
  8091. static WhenAllReady(textures: BaseTexture[], callback: () => void): void;
  8092. private static _isScene;
  8093. }
  8094. }
  8095. declare module BABYLON {
  8096. /** @hidden */
  8097. export class WebGLDataBuffer extends DataBuffer {
  8098. private _buffer;
  8099. constructor(resource: WebGLBuffer);
  8100. get underlyingResource(): any;
  8101. }
  8102. }
  8103. declare module BABYLON {
  8104. /** @hidden */
  8105. export class WebGLPipelineContext implements IPipelineContext {
  8106. private _valueCache;
  8107. private _uniforms;
  8108. engine: ThinEngine;
  8109. program: Nullable<WebGLProgram>;
  8110. context?: WebGLRenderingContext;
  8111. vertexShader?: WebGLShader;
  8112. fragmentShader?: WebGLShader;
  8113. isParallelCompiled: boolean;
  8114. onCompiled?: () => void;
  8115. transformFeedback?: WebGLTransformFeedback | null;
  8116. vertexCompilationError: Nullable<string>;
  8117. fragmentCompilationError: Nullable<string>;
  8118. programLinkError: Nullable<string>;
  8119. programValidationError: Nullable<string>;
  8120. get isAsync(): boolean;
  8121. get isReady(): boolean;
  8122. _handlesSpectorRebuildCallback(onCompiled: (program: WebGLProgram) => void): void;
  8123. _fillEffectInformation(effect: Effect, uniformBuffersNames: {
  8124. [key: string]: number;
  8125. }, uniformsNames: string[], uniforms: {
  8126. [key: string]: Nullable<WebGLUniformLocation>;
  8127. }, samplerList: string[], samplers: {
  8128. [key: string]: number;
  8129. }, attributesNames: string[], attributes: number[]): void;
  8130. /**
  8131. * Release all associated resources.
  8132. **/
  8133. dispose(): void;
  8134. /** @hidden */
  8135. _cacheMatrix(uniformName: string, matrix: IMatrixLike): boolean;
  8136. /** @hidden */
  8137. _cacheFloat2(uniformName: string, x: number, y: number): boolean;
  8138. /** @hidden */
  8139. _cacheFloat3(uniformName: string, x: number, y: number, z: number): boolean;
  8140. /** @hidden */
  8141. _cacheFloat4(uniformName: string, x: number, y: number, z: number, w: number): boolean;
  8142. /**
  8143. * Sets an integer value on a uniform variable.
  8144. * @param uniformName Name of the variable.
  8145. * @param value Value to be set.
  8146. */
  8147. setInt(uniformName: string, value: number): void;
  8148. /**
  8149. * Sets a int2 on a uniform variable.
  8150. * @param uniformName Name of the variable.
  8151. * @param x First int in int2.
  8152. * @param y Second int in int2.
  8153. */
  8154. setInt2(uniformName: string, x: number, y: number): void;
  8155. /**
  8156. * Sets a int3 on a uniform variable.
  8157. * @param uniformName Name of the variable.
  8158. * @param x First int in int3.
  8159. * @param y Second int in int3.
  8160. * @param y Third int in int3.
  8161. */
  8162. setInt3(uniformName: string, x: number, y: number, z: number): void;
  8163. /**
  8164. * Sets a int4 on a uniform variable.
  8165. * @param uniformName Name of the variable.
  8166. * @param x First int in int4.
  8167. * @param y Second int in int4.
  8168. * @param y Third int in int4.
  8169. * @param w Fourth int in int4.
  8170. */
  8171. setInt4(uniformName: string, x: number, y: number, z: number, w: number): void;
  8172. /**
  8173. * Sets an int array on a uniform variable.
  8174. * @param uniformName Name of the variable.
  8175. * @param array array to be set.
  8176. */
  8177. setIntArray(uniformName: string, array: Int32Array): void;
  8178. /**
  8179. * 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)
  8180. * @param uniformName Name of the variable.
  8181. * @param array array to be set.
  8182. */
  8183. setIntArray2(uniformName: string, array: Int32Array): void;
  8184. /**
  8185. * 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)
  8186. * @param uniformName Name of the variable.
  8187. * @param array array to be set.
  8188. */
  8189. setIntArray3(uniformName: string, array: Int32Array): void;
  8190. /**
  8191. * 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)
  8192. * @param uniformName Name of the variable.
  8193. * @param array array to be set.
  8194. */
  8195. setIntArray4(uniformName: string, array: Int32Array): void;
  8196. /**
  8197. * Sets an array on a uniform variable.
  8198. * @param uniformName Name of the variable.
  8199. * @param array array to be set.
  8200. */
  8201. setArray(uniformName: string, array: number[]): void;
  8202. /**
  8203. * 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)
  8204. * @param uniformName Name of the variable.
  8205. * @param array array to be set.
  8206. */
  8207. setArray2(uniformName: string, array: number[]): void;
  8208. /**
  8209. * 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)
  8210. * @param uniformName Name of the variable.
  8211. * @param array array to be set.
  8212. * @returns this effect.
  8213. */
  8214. setArray3(uniformName: string, array: number[]): void;
  8215. /**
  8216. * 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)
  8217. * @param uniformName Name of the variable.
  8218. * @param array array to be set.
  8219. */
  8220. setArray4(uniformName: string, array: number[]): void;
  8221. /**
  8222. * Sets matrices on a uniform variable.
  8223. * @param uniformName Name of the variable.
  8224. * @param matrices matrices to be set.
  8225. */
  8226. setMatrices(uniformName: string, matrices: Float32Array): void;
  8227. /**
  8228. * Sets matrix on a uniform variable.
  8229. * @param uniformName Name of the variable.
  8230. * @param matrix matrix to be set.
  8231. */
  8232. setMatrix(uniformName: string, matrix: IMatrixLike): void;
  8233. /**
  8234. * Sets a 3x3 matrix on a uniform variable. (Specified as [1,2,3,4,5,6,7,8,9] will result in [1,2,3][4,5,6][7,8,9] matrix)
  8235. * @param uniformName Name of the variable.
  8236. * @param matrix matrix to be set.
  8237. */
  8238. setMatrix3x3(uniformName: string, matrix: Float32Array): void;
  8239. /**
  8240. * Sets a 2x2 matrix on a uniform variable. (Specified as [1,2,3,4] will result in [1,2][3,4] matrix)
  8241. * @param uniformName Name of the variable.
  8242. * @param matrix matrix to be set.
  8243. */
  8244. setMatrix2x2(uniformName: string, matrix: Float32Array): void;
  8245. /**
  8246. * Sets a float on a uniform variable.
  8247. * @param uniformName Name of the variable.
  8248. * @param value value to be set.
  8249. * @returns this effect.
  8250. */
  8251. setFloat(uniformName: string, value: number): void;
  8252. /**
  8253. * Sets a Vector2 on a uniform variable.
  8254. * @param uniformName Name of the variable.
  8255. * @param vector2 vector2 to be set.
  8256. */
  8257. setVector2(uniformName: string, vector2: IVector2Like): void;
  8258. /**
  8259. * Sets a float2 on a uniform variable.
  8260. * @param uniformName Name of the variable.
  8261. * @param x First float in float2.
  8262. * @param y Second float in float2.
  8263. */
  8264. setFloat2(uniformName: string, x: number, y: number): void;
  8265. /**
  8266. * Sets a Vector3 on a uniform variable.
  8267. * @param uniformName Name of the variable.
  8268. * @param vector3 Value to be set.
  8269. */
  8270. setVector3(uniformName: string, vector3: IVector3Like): void;
  8271. /**
  8272. * Sets a float3 on a uniform variable.
  8273. * @param uniformName Name of the variable.
  8274. * @param x First float in float3.
  8275. * @param y Second float in float3.
  8276. * @param z Third float in float3.
  8277. */
  8278. setFloat3(uniformName: string, x: number, y: number, z: number): void;
  8279. /**
  8280. * Sets a Vector4 on a uniform variable.
  8281. * @param uniformName Name of the variable.
  8282. * @param vector4 Value to be set.
  8283. */
  8284. setVector4(uniformName: string, vector4: IVector4Like): void;
  8285. /**
  8286. * Sets a float4 on a uniform variable.
  8287. * @param uniformName Name of the variable.
  8288. * @param x First float in float4.
  8289. * @param y Second float in float4.
  8290. * @param z Third float in float4.
  8291. * @param w Fourth float in float4.
  8292. * @returns this effect.
  8293. */
  8294. setFloat4(uniformName: string, x: number, y: number, z: number, w: number): void;
  8295. /**
  8296. * Sets a Color3 on a uniform variable.
  8297. * @param uniformName Name of the variable.
  8298. * @param color3 Value to be set.
  8299. */
  8300. setColor3(uniformName: string, color3: IColor3Like): void;
  8301. /**
  8302. * Sets a Color4 on a uniform variable.
  8303. * @param uniformName Name of the variable.
  8304. * @param color3 Value to be set.
  8305. * @param alpha Alpha value to be set.
  8306. */
  8307. setColor4(uniformName: string, color3: IColor3Like, alpha: number): void;
  8308. /**
  8309. * Sets a Color4 on a uniform variable
  8310. * @param uniformName defines the name of the variable
  8311. * @param color4 defines the value to be set
  8312. */
  8313. setDirectColor4(uniformName: string, color4: IColor4Like): void;
  8314. _getVertexShaderCode(): string | null;
  8315. _getFragmentShaderCode(): string | null;
  8316. }
  8317. }
  8318. declare module BABYLON {
  8319. interface ThinEngine {
  8320. /**
  8321. * Create an uniform buffer
  8322. * @see https://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  8323. * @param elements defines the content of the uniform buffer
  8324. * @returns the webGL uniform buffer
  8325. */
  8326. createUniformBuffer(elements: FloatArray): DataBuffer;
  8327. /**
  8328. * Create a dynamic uniform buffer
  8329. * @see https://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  8330. * @param elements defines the content of the uniform buffer
  8331. * @returns the webGL uniform buffer
  8332. */
  8333. createDynamicUniformBuffer(elements: FloatArray): DataBuffer;
  8334. /**
  8335. * Update an existing uniform buffer
  8336. * @see https://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  8337. * @param uniformBuffer defines the target uniform buffer
  8338. * @param elements defines the content to update
  8339. * @param offset defines the offset in the uniform buffer where update should start
  8340. * @param count defines the size of the data to update
  8341. */
  8342. updateUniformBuffer(uniformBuffer: DataBuffer, elements: FloatArray, offset?: number, count?: number): void;
  8343. /**
  8344. * Bind an uniform buffer to the current webGL context
  8345. * @param buffer defines the buffer to bind
  8346. */
  8347. bindUniformBuffer(buffer: Nullable<DataBuffer>): void;
  8348. /**
  8349. * Bind a buffer to the current webGL context at a given location
  8350. * @param buffer defines the buffer to bind
  8351. * @param location defines the index where to bind the buffer
  8352. * @param name Name of the uniform variable to bind
  8353. */
  8354. bindUniformBufferBase(buffer: DataBuffer, location: number, name: string): void;
  8355. /**
  8356. * Bind a specific block at a given index in a specific shader program
  8357. * @param pipelineContext defines the pipeline context to use
  8358. * @param blockName defines the block name
  8359. * @param index defines the index where to bind the block
  8360. */
  8361. bindUniformBlock(pipelineContext: IPipelineContext, blockName: string, index: number): void;
  8362. }
  8363. }
  8364. declare module BABYLON {
  8365. /**
  8366. * Uniform buffer objects.
  8367. *
  8368. * Handles blocks of uniform on the GPU.
  8369. *
  8370. * If WebGL 2 is not available, this class falls back on traditional setUniformXXX calls.
  8371. *
  8372. * For more information, please refer to :
  8373. * https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  8374. */
  8375. export class UniformBuffer {
  8376. /** @hidden */
  8377. static _updatedUbosInFrame: {
  8378. [name: string]: number;
  8379. };
  8380. private _engine;
  8381. private _buffer;
  8382. private _buffers;
  8383. private _bufferIndex;
  8384. private _createBufferOnWrite;
  8385. private _data;
  8386. private _bufferData;
  8387. private _dynamic?;
  8388. private _uniformLocations;
  8389. private _uniformSizes;
  8390. private _uniformArraySizes;
  8391. private _uniformLocationPointer;
  8392. private _needSync;
  8393. private _noUBO;
  8394. private _currentEffect;
  8395. private _currentEffectName;
  8396. private _name;
  8397. private _currentFrameId;
  8398. /** @hidden */
  8399. _alreadyBound: boolean;
  8400. private static _MAX_UNIFORM_SIZE;
  8401. private static _tempBuffer;
  8402. private static _tempBufferInt32View;
  8403. /**
  8404. * Lambda to Update a 3x3 Matrix 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. updateMatrix3x3: (name: string, matrix: Float32Array) => void;
  8409. /**
  8410. * Lambda to Update a 2x2 Matrix in a uniform buffer.
  8411. * This is dynamic to allow compat with webgl 1 and 2.
  8412. * You will need to pass the name of the uniform as well as the value.
  8413. */
  8414. updateMatrix2x2: (name: string, matrix: Float32Array) => void;
  8415. /**
  8416. * Lambda to Update a single float 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. updateFloat: (name: string, x: number) => void;
  8421. /**
  8422. * Lambda to Update a vec2 of float in a uniform buffer.
  8423. * This is dynamic to allow compat with webgl 1 and 2.
  8424. * You will need to pass the name of the uniform as well as the value.
  8425. */
  8426. updateFloat2: (name: string, x: number, y: number, suffix?: string) => void;
  8427. /**
  8428. * Lambda to Update a vec3 of float in a uniform buffer.
  8429. * This is dynamic to allow compat with webgl 1 and 2.
  8430. * You will need to pass the name of the uniform as well as the value.
  8431. */
  8432. updateFloat3: (name: string, x: number, y: number, z: number, suffix?: string) => void;
  8433. /**
  8434. * Lambda to Update a vec4 of float in a uniform buffer.
  8435. * This is dynamic to allow compat with webgl 1 and 2.
  8436. * You will need to pass the name of the uniform as well as the value.
  8437. */
  8438. updateFloat4: (name: string, x: number, y: number, z: number, w: number, suffix?: string) => void;
  8439. /**
  8440. * Lambda to Update an array of float in a uniform buffer.
  8441. * This is dynamic to allow compat with webgl 1 and 2.
  8442. * You will need to pass the name of the uniform as well as the value.
  8443. */
  8444. updateFloatArray: (name: string, array: Float32Array) => void;
  8445. /**
  8446. * Lambda to Update an array of number in a uniform buffer.
  8447. * This is dynamic to allow compat with webgl 1 and 2.
  8448. * You will need to pass the name of the uniform as well as the value.
  8449. */
  8450. updateArray: (name: string, array: number[]) => void;
  8451. /**
  8452. * Lambda to Update an array of number in a uniform buffer.
  8453. * This is dynamic to allow compat with webgl 1 and 2.
  8454. * You will need to pass the name of the uniform as well as the value.
  8455. */
  8456. updateIntArray: (name: string, array: Int32Array) => void;
  8457. /**
  8458. * Lambda to Update a 4x4 Matrix in a uniform buffer.
  8459. * This is dynamic to allow compat with webgl 1 and 2.
  8460. * You will need to pass the name of the uniform as well as the value.
  8461. */
  8462. updateMatrix: (name: string, mat: IMatrixLike) => void;
  8463. /**
  8464. * Lambda to Update an array of 4x4 Matrix in a uniform buffer.
  8465. * This is dynamic to allow compat with webgl 1 and 2.
  8466. * You will need to pass the name of the uniform as well as the value.
  8467. */
  8468. updateMatrices: (name: string, mat: Float32Array) => void;
  8469. /**
  8470. * Lambda to Update vec3 of float from a Vector in a uniform buffer.
  8471. * This is dynamic to allow compat with webgl 1 and 2.
  8472. * You will need to pass the name of the uniform as well as the value.
  8473. */
  8474. updateVector3: (name: string, vector: Vector3) => void;
  8475. /**
  8476. * Lambda to Update vec4 of float from a Vector in a uniform buffer.
  8477. * This is dynamic to allow compat with webgl 1 and 2.
  8478. * You will need to pass the name of the uniform as well as the value.
  8479. */
  8480. updateVector4: (name: string, vector: Vector4) => void;
  8481. /**
  8482. * Lambda to Update vec3 of float from a Color in a uniform buffer.
  8483. * This is dynamic to allow compat with webgl 1 and 2.
  8484. * You will need to pass the name of the uniform as well as the value.
  8485. */
  8486. updateColor3: (name: string, color: Color3, suffix?: string) => void;
  8487. /**
  8488. * Lambda to Update vec4 of float from a Color in a uniform buffer.
  8489. * This is dynamic to allow compat with webgl 1 and 2.
  8490. * You will need to pass the name of the uniform as well as the value.
  8491. */
  8492. updateColor4: (name: string, color: Color3, alpha: number, suffix?: string) => void;
  8493. /**
  8494. * Lambda to Update a int a uniform buffer.
  8495. * This is dynamic to allow compat with webgl 1 and 2.
  8496. * You will need to pass the name of the uniform as well as the value.
  8497. */
  8498. updateInt: (name: string, x: number, suffix?: string) => void;
  8499. /**
  8500. * Lambda to Update a vec2 of int in a uniform buffer.
  8501. * This is dynamic to allow compat with webgl 1 and 2.
  8502. * You will need to pass the name of the uniform as well as the value.
  8503. */
  8504. updateInt2: (name: string, x: number, y: number, suffix?: string) => void;
  8505. /**
  8506. * Lambda to Update a vec3 of int in a uniform buffer.
  8507. * This is dynamic to allow compat with webgl 1 and 2.
  8508. * You will need to pass the name of the uniform as well as the value.
  8509. */
  8510. updateInt3: (name: string, x: number, y: number, z: number, suffix?: string) => void;
  8511. /**
  8512. * Lambda to Update a vec4 of int in a uniform buffer.
  8513. * This is dynamic to allow compat with webgl 1 and 2.
  8514. * You will need to pass the name of the uniform as well as the value.
  8515. */
  8516. updateInt4: (name: string, x: number, y: number, z: number, w: number, suffix?: string) => void;
  8517. /**
  8518. * Instantiates a new Uniform buffer objects.
  8519. *
  8520. * Handles blocks of uniform on the GPU.
  8521. *
  8522. * If WebGL 2 is not available, this class falls back on traditional setUniformXXX calls.
  8523. *
  8524. * For more information, please refer to :
  8525. * @see https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  8526. * @param engine Define the engine the buffer is associated with
  8527. * @param data Define the data contained in the buffer
  8528. * @param dynamic Define if the buffer is updatable
  8529. * @param name to assign to the buffer (debugging purpose)
  8530. */
  8531. constructor(engine: Engine, data?: number[], dynamic?: boolean, name?: string);
  8532. /**
  8533. * Indicates if the buffer is using the WebGL2 UBO implementation,
  8534. * or just falling back on setUniformXXX calls.
  8535. */
  8536. get useUbo(): boolean;
  8537. /**
  8538. * Indicates if the WebGL underlying uniform buffer is in sync
  8539. * with the javascript cache data.
  8540. */
  8541. get isSync(): boolean;
  8542. /**
  8543. * Indicates if the WebGL underlying uniform buffer is dynamic.
  8544. * Also, a dynamic UniformBuffer will disable cache verification and always
  8545. * update the underlying WebGL uniform buffer to the GPU.
  8546. * @returns if Dynamic, otherwise false
  8547. */
  8548. isDynamic(): boolean;
  8549. /**
  8550. * The data cache on JS side.
  8551. * @returns the underlying data as a float array
  8552. */
  8553. getData(): Float32Array;
  8554. /**
  8555. * The underlying WebGL Uniform buffer.
  8556. * @returns the webgl buffer
  8557. */
  8558. getBuffer(): Nullable<DataBuffer>;
  8559. /**
  8560. * std140 layout specifies how to align data within an UBO structure.
  8561. * See https://khronos.org/registry/OpenGL/specs/gl/glspec45.core.pdf#page=159
  8562. * for specs.
  8563. */
  8564. private _fillAlignment;
  8565. /**
  8566. * Adds an uniform in the buffer.
  8567. * Warning : the subsequents calls of this function must be in the same order as declared in the shader
  8568. * for the layout to be correct !
  8569. * @param name Name of the uniform, as used in the uniform block in the shader.
  8570. * @param size Data size, or data directly.
  8571. * @param arraySize The number of elements in the array, 0 if not an array.
  8572. */
  8573. addUniform(name: string, size: number | number[], arraySize?: number): void;
  8574. /**
  8575. * Adds a Matrix 4x4 to the uniform buffer.
  8576. * @param name Name of the uniform, as used in the uniform block in the shader.
  8577. * @param mat A 4x4 matrix.
  8578. */
  8579. addMatrix(name: string, mat: Matrix): void;
  8580. /**
  8581. * Adds a vec2 to the uniform buffer.
  8582. * @param name Name of the uniform, as used in the uniform block in the shader.
  8583. * @param x Define the x component value of the vec2
  8584. * @param y Define the y component value of the vec2
  8585. */
  8586. addFloat2(name: string, x: number, y: number): void;
  8587. /**
  8588. * Adds a vec3 to the uniform buffer.
  8589. * @param name Name of the uniform, as used in the uniform block in the shader.
  8590. * @param x Define the x component value of the vec3
  8591. * @param y Define the y component value of the vec3
  8592. * @param z Define the z component value of the vec3
  8593. */
  8594. addFloat3(name: string, x: number, y: number, z: number): void;
  8595. /**
  8596. * Adds a vec3 to the uniform buffer.
  8597. * @param name Name of the uniform, as used in the uniform block in the shader.
  8598. * @param color Define the vec3 from a Color
  8599. */
  8600. addColor3(name: string, color: Color3): void;
  8601. /**
  8602. * Adds a vec4 to the uniform buffer.
  8603. * @param name Name of the uniform, as used in the uniform block in the shader.
  8604. * @param color Define the rgb components from a Color
  8605. * @param alpha Define the a component of the vec4
  8606. */
  8607. addColor4(name: string, color: Color3, alpha: number): void;
  8608. /**
  8609. * Adds a vec3 to the uniform buffer.
  8610. * @param name Name of the uniform, as used in the uniform block in the shader.
  8611. * @param vector Define the vec3 components from a Vector
  8612. */
  8613. addVector3(name: string, vector: Vector3): void;
  8614. /**
  8615. * Adds a Matrix 3x3 to the uniform buffer.
  8616. * @param name Name of the uniform, as used in the uniform block in the shader.
  8617. */
  8618. addMatrix3x3(name: string): void;
  8619. /**
  8620. * Adds a Matrix 2x2 to the uniform buffer.
  8621. * @param name Name of the uniform, as used in the uniform block in the shader.
  8622. */
  8623. addMatrix2x2(name: string): void;
  8624. /**
  8625. * Effectively creates the WebGL Uniform Buffer, once layout is completed with `addUniform`.
  8626. */
  8627. create(): void;
  8628. /** @hidden */
  8629. _rebuild(): void;
  8630. /** @hidden */
  8631. get _numBuffers(): number;
  8632. /** @hidden */
  8633. get _indexBuffer(): number;
  8634. /** Gets the name of this buffer */
  8635. get name(): string;
  8636. /**
  8637. * Updates the WebGL Uniform Buffer on the GPU.
  8638. * If the `dynamic` flag is set to true, no cache comparison is done.
  8639. * Otherwise, the buffer will be updated only if the cache differs.
  8640. */
  8641. update(): void;
  8642. private _createNewBuffer;
  8643. private _checkNewFrame;
  8644. /**
  8645. * Updates the value of an uniform. The `update` method must be called afterwards to make it effective in the GPU.
  8646. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  8647. * @param data Define the flattened data
  8648. * @param size Define the size of the data.
  8649. */
  8650. updateUniform(uniformName: string, data: FloatArray, size: number): void;
  8651. /**
  8652. * Updates the value of an uniform. The `update` method must be called afterwards to make it effective in the GPU.
  8653. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  8654. * @param data Define the flattened data
  8655. * @param size Define the size of the data.
  8656. */
  8657. updateUniformArray(uniformName: string, data: FloatArray, size: number): void;
  8658. private _valueCache;
  8659. private _cacheMatrix;
  8660. private _updateMatrix3x3ForUniform;
  8661. private _updateMatrix3x3ForEffect;
  8662. private _updateMatrix2x2ForEffect;
  8663. private _updateMatrix2x2ForUniform;
  8664. private _updateFloatForEffect;
  8665. private _updateFloatForUniform;
  8666. private _updateFloat2ForEffect;
  8667. private _updateFloat2ForUniform;
  8668. private _updateFloat3ForEffect;
  8669. private _updateFloat3ForUniform;
  8670. private _updateFloat4ForEffect;
  8671. private _updateFloat4ForUniform;
  8672. private _updateFloatArrayForEffect;
  8673. private _updateFloatArrayForUniform;
  8674. private _updateArrayForEffect;
  8675. private _updateArrayForUniform;
  8676. private _updateIntArrayForEffect;
  8677. private _updateIntArrayForUniform;
  8678. private _updateMatrixForEffect;
  8679. private _updateMatrixForUniform;
  8680. private _updateMatricesForEffect;
  8681. private _updateMatricesForUniform;
  8682. private _updateVector3ForEffect;
  8683. private _updateVector3ForUniform;
  8684. private _updateVector4ForEffect;
  8685. private _updateVector4ForUniform;
  8686. private _updateColor3ForEffect;
  8687. private _updateColor3ForUniform;
  8688. private _updateColor4ForEffect;
  8689. private _updateColor4ForUniform;
  8690. private _updateIntForEffect;
  8691. private _updateIntForUniform;
  8692. private _updateInt2ForEffect;
  8693. private _updateInt2ForUniform;
  8694. private _updateInt3ForEffect;
  8695. private _updateInt3ForUniform;
  8696. private _updateInt4ForEffect;
  8697. private _updateInt4ForUniform;
  8698. /**
  8699. * Sets a sampler uniform on the effect.
  8700. * @param name Define the name of the sampler.
  8701. * @param texture Define the texture to set in the sampler
  8702. */
  8703. setTexture(name: string, texture: Nullable<BaseTexture>): void;
  8704. /**
  8705. * Directly updates the value of the uniform in the cache AND on the GPU.
  8706. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  8707. * @param data Define the flattened data
  8708. */
  8709. updateUniformDirectly(uniformName: string, data: FloatArray): void;
  8710. /**
  8711. * Binds this uniform buffer to an effect.
  8712. * @param effect Define the effect to bind the buffer to
  8713. * @param name Name of the uniform block in the shader.
  8714. */
  8715. bindToEffect(effect: Effect, name: string): void;
  8716. /**
  8717. * Disposes the uniform buffer.
  8718. */
  8719. dispose(): void;
  8720. }
  8721. }
  8722. declare module BABYLON {
  8723. /**
  8724. * Manages the defines for the Material
  8725. */
  8726. export class MaterialDefines {
  8727. /** @hidden */
  8728. protected _keys: string[];
  8729. private _isDirty;
  8730. /** @hidden */
  8731. _renderId: number;
  8732. /** @hidden */
  8733. _areLightsDirty: boolean;
  8734. /** @hidden */
  8735. _areLightsDisposed: boolean;
  8736. /** @hidden */
  8737. _areAttributesDirty: boolean;
  8738. /** @hidden */
  8739. _areTexturesDirty: boolean;
  8740. /** @hidden */
  8741. _areFresnelDirty: boolean;
  8742. /** @hidden */
  8743. _areMiscDirty: boolean;
  8744. /** @hidden */
  8745. _arePrePassDirty: boolean;
  8746. /** @hidden */
  8747. _areImageProcessingDirty: boolean;
  8748. /** @hidden */
  8749. _normals: boolean;
  8750. /** @hidden */
  8751. _uvs: boolean;
  8752. /** @hidden */
  8753. _needNormals: boolean;
  8754. /** @hidden */
  8755. _needUVs: boolean;
  8756. [id: string]: any;
  8757. /**
  8758. * Specifies if the material needs to be re-calculated
  8759. */
  8760. get isDirty(): boolean;
  8761. /**
  8762. * Marks the material to indicate that it has been re-calculated
  8763. */
  8764. markAsProcessed(): void;
  8765. /**
  8766. * Marks the material to indicate that it needs to be re-calculated
  8767. */
  8768. markAsUnprocessed(): void;
  8769. /**
  8770. * Marks the material to indicate all of its defines need to be re-calculated
  8771. */
  8772. markAllAsDirty(): void;
  8773. /**
  8774. * Marks the material to indicate that image processing needs to be re-calculated
  8775. */
  8776. markAsImageProcessingDirty(): void;
  8777. /**
  8778. * Marks the material to indicate the lights need to be re-calculated
  8779. * @param disposed Defines whether the light is dirty due to dispose or not
  8780. */
  8781. markAsLightDirty(disposed?: boolean): void;
  8782. /**
  8783. * Marks the attribute state as changed
  8784. */
  8785. markAsAttributesDirty(): void;
  8786. /**
  8787. * Marks the texture state as changed
  8788. */
  8789. markAsTexturesDirty(): void;
  8790. /**
  8791. * Marks the fresnel state as changed
  8792. */
  8793. markAsFresnelDirty(): void;
  8794. /**
  8795. * Marks the misc state as changed
  8796. */
  8797. markAsMiscDirty(): void;
  8798. /**
  8799. * Marks the prepass state as changed
  8800. */
  8801. markAsPrePassDirty(): void;
  8802. /**
  8803. * Rebuilds the material defines
  8804. */
  8805. rebuild(): void;
  8806. /**
  8807. * Specifies if two material defines are equal
  8808. * @param other - A material define instance to compare to
  8809. * @returns - Boolean indicating if the material defines are equal (true) or not (false)
  8810. */
  8811. isEqual(other: MaterialDefines): boolean;
  8812. /**
  8813. * Clones this instance's defines to another instance
  8814. * @param other - material defines to clone values to
  8815. */
  8816. cloneTo(other: MaterialDefines): void;
  8817. /**
  8818. * Resets the material define values
  8819. */
  8820. reset(): void;
  8821. /**
  8822. * Converts the material define values to a string
  8823. * @returns - String of material define information
  8824. */
  8825. toString(): string;
  8826. }
  8827. }
  8828. declare module BABYLON {
  8829. /**
  8830. * Enum that determines the text-wrapping mode to use.
  8831. */
  8832. export enum InspectableType {
  8833. /**
  8834. * Checkbox for booleans
  8835. */
  8836. Checkbox = 0,
  8837. /**
  8838. * Sliders for numbers
  8839. */
  8840. Slider = 1,
  8841. /**
  8842. * Vector3
  8843. */
  8844. Vector3 = 2,
  8845. /**
  8846. * Quaternions
  8847. */
  8848. Quaternion = 3,
  8849. /**
  8850. * Color3
  8851. */
  8852. Color3 = 4,
  8853. /**
  8854. * String
  8855. */
  8856. String = 5
  8857. }
  8858. /**
  8859. * Interface used to define custom inspectable properties.
  8860. * This interface is used by the inspector to display custom property grids
  8861. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  8862. */
  8863. export interface IInspectable {
  8864. /**
  8865. * Gets the label to display
  8866. */
  8867. label: string;
  8868. /**
  8869. * Gets the name of the property to edit
  8870. */
  8871. propertyName: string;
  8872. /**
  8873. * Gets the type of the editor to use
  8874. */
  8875. type: InspectableType;
  8876. /**
  8877. * Gets the minimum value of the property when using in "slider" mode
  8878. */
  8879. min?: number;
  8880. /**
  8881. * Gets the maximum value of the property when using in "slider" mode
  8882. */
  8883. max?: number;
  8884. /**
  8885. * Gets the setp to use when using in "slider" mode
  8886. */
  8887. step?: number;
  8888. }
  8889. }
  8890. declare module BABYLON {
  8891. /**
  8892. * Base class of all the lights in Babylon. It groups all the generic information about lights.
  8893. * Lights are used, as you would expect, to affect how meshes are seen, in terms of both illumination and colour.
  8894. * 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.
  8895. */
  8896. export abstract class Light extends Node {
  8897. /**
  8898. * Falloff Default: light is falling off following the material specification:
  8899. * standard material is using standard falloff whereas pbr material can request special falloff per materials.
  8900. */
  8901. static readonly FALLOFF_DEFAULT: number;
  8902. /**
  8903. * Falloff Physical: light is falling off following the inverse squared distance law.
  8904. */
  8905. static readonly FALLOFF_PHYSICAL: number;
  8906. /**
  8907. * Falloff gltf: light is falling off as described in the gltf moving to PBR document
  8908. * to enhance interoperability with other engines.
  8909. */
  8910. static readonly FALLOFF_GLTF: number;
  8911. /**
  8912. * Falloff Standard: light is falling off like in the standard material
  8913. * to enhance interoperability with other materials.
  8914. */
  8915. static readonly FALLOFF_STANDARD: number;
  8916. /**
  8917. * If every light affecting the material is in this lightmapMode,
  8918. * material.lightmapTexture adds or multiplies
  8919. * (depends on material.useLightmapAsShadowmap)
  8920. * after every other light calculations.
  8921. */
  8922. static readonly LIGHTMAP_DEFAULT: number;
  8923. /**
  8924. * material.lightmapTexture as only diffuse lighting from this light
  8925. * adds only specular lighting from this light
  8926. * adds dynamic shadows
  8927. */
  8928. static readonly LIGHTMAP_SPECULAR: number;
  8929. /**
  8930. * material.lightmapTexture as only lighting
  8931. * no light calculation from this light
  8932. * only adds dynamic shadows from this light
  8933. */
  8934. static readonly LIGHTMAP_SHADOWSONLY: number;
  8935. /**
  8936. * Each light type uses the default quantity according to its type:
  8937. * point/spot lights use luminous intensity
  8938. * directional lights use illuminance
  8939. */
  8940. static readonly INTENSITYMODE_AUTOMATIC: number;
  8941. /**
  8942. * lumen (lm)
  8943. */
  8944. static readonly INTENSITYMODE_LUMINOUSPOWER: number;
  8945. /**
  8946. * candela (lm/sr)
  8947. */
  8948. static readonly INTENSITYMODE_LUMINOUSINTENSITY: number;
  8949. /**
  8950. * lux (lm/m^2)
  8951. */
  8952. static readonly INTENSITYMODE_ILLUMINANCE: number;
  8953. /**
  8954. * nit (cd/m^2)
  8955. */
  8956. static readonly INTENSITYMODE_LUMINANCE: number;
  8957. /**
  8958. * Light type const id of the point light.
  8959. */
  8960. static readonly LIGHTTYPEID_POINTLIGHT: number;
  8961. /**
  8962. * Light type const id of the directional light.
  8963. */
  8964. static readonly LIGHTTYPEID_DIRECTIONALLIGHT: number;
  8965. /**
  8966. * Light type const id of the spot light.
  8967. */
  8968. static readonly LIGHTTYPEID_SPOTLIGHT: number;
  8969. /**
  8970. * Light type const id of the hemispheric light.
  8971. */
  8972. static readonly LIGHTTYPEID_HEMISPHERICLIGHT: number;
  8973. /**
  8974. * Diffuse gives the basic color to an object.
  8975. */
  8976. diffuse: Color3;
  8977. /**
  8978. * Specular produces a highlight color on an object.
  8979. * Note: This is note affecting PBR materials.
  8980. */
  8981. specular: Color3;
  8982. /**
  8983. * Defines the falloff type for this light. This lets overriding how punctual light are
  8984. * falling off base on range or angle.
  8985. * This can be set to any values in Light.FALLOFF_x.
  8986. *
  8987. * Note: This is only useful for PBR Materials at the moment. This could be extended if required to
  8988. * other types of materials.
  8989. */
  8990. falloffType: number;
  8991. /**
  8992. * Strength of the light.
  8993. * Note: By default it is define in the framework own unit.
  8994. * Note: In PBR materials the intensityMode can be use to chose what unit the intensity is defined in.
  8995. */
  8996. intensity: number;
  8997. private _range;
  8998. protected _inverseSquaredRange: number;
  8999. /**
  9000. * Defines how far from the source the light is impacting in scene units.
  9001. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  9002. */
  9003. get range(): number;
  9004. /**
  9005. * Defines how far from the source the light is impacting in scene units.
  9006. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  9007. */
  9008. set range(value: number);
  9009. /**
  9010. * Cached photometric scale default to 1.0 as the automatic intensity mode defaults to 1.0 for every type
  9011. * of light.
  9012. */
  9013. private _photometricScale;
  9014. private _intensityMode;
  9015. /**
  9016. * Gets the photometric scale used to interpret the intensity.
  9017. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  9018. */
  9019. get intensityMode(): number;
  9020. /**
  9021. * Sets the photometric scale used to interpret the intensity.
  9022. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  9023. */
  9024. set intensityMode(value: number);
  9025. private _radius;
  9026. /**
  9027. * Gets the light radius used by PBR Materials to simulate soft area lights.
  9028. */
  9029. get radius(): number;
  9030. /**
  9031. * sets the light radius used by PBR Materials to simulate soft area lights.
  9032. */
  9033. set radius(value: number);
  9034. private _renderPriority;
  9035. /**
  9036. * Defines the rendering priority of the lights. It can help in case of fallback or number of lights
  9037. * exceeding the number allowed of the materials.
  9038. */
  9039. renderPriority: number;
  9040. private _shadowEnabled;
  9041. /**
  9042. * Gets whether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  9043. * the current shadow generator.
  9044. */
  9045. get shadowEnabled(): boolean;
  9046. /**
  9047. * Sets whether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  9048. * the current shadow generator.
  9049. */
  9050. set shadowEnabled(value: boolean);
  9051. private _includedOnlyMeshes;
  9052. /**
  9053. * Gets the only meshes impacted by this light.
  9054. */
  9055. get includedOnlyMeshes(): AbstractMesh[];
  9056. /**
  9057. * Sets the only meshes impacted by this light.
  9058. */
  9059. set includedOnlyMeshes(value: AbstractMesh[]);
  9060. private _excludedMeshes;
  9061. /**
  9062. * Gets the meshes not impacted by this light.
  9063. */
  9064. get excludedMeshes(): AbstractMesh[];
  9065. /**
  9066. * Sets the meshes not impacted by this light.
  9067. */
  9068. set excludedMeshes(value: AbstractMesh[]);
  9069. private _excludeWithLayerMask;
  9070. /**
  9071. * Gets the layer id use to find what meshes are not impacted by the light.
  9072. * Inactive if 0
  9073. */
  9074. get excludeWithLayerMask(): number;
  9075. /**
  9076. * Sets the layer id use to find what meshes are not impacted by the light.
  9077. * Inactive if 0
  9078. */
  9079. set excludeWithLayerMask(value: number);
  9080. private _includeOnlyWithLayerMask;
  9081. /**
  9082. * Gets the layer id use to find what meshes are impacted by the light.
  9083. * Inactive if 0
  9084. */
  9085. get includeOnlyWithLayerMask(): number;
  9086. /**
  9087. * Sets the layer id use to find what meshes are impacted by the light.
  9088. * Inactive if 0
  9089. */
  9090. set includeOnlyWithLayerMask(value: number);
  9091. private _lightmapMode;
  9092. /**
  9093. * Gets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  9094. */
  9095. get lightmapMode(): number;
  9096. /**
  9097. * Sets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  9098. */
  9099. set lightmapMode(value: number);
  9100. /**
  9101. * Shadow generator associated to the light.
  9102. * @hidden Internal use only.
  9103. */
  9104. _shadowGenerator: Nullable<IShadowGenerator>;
  9105. /**
  9106. * @hidden Internal use only.
  9107. */
  9108. _excludedMeshesIds: string[];
  9109. /**
  9110. * @hidden Internal use only.
  9111. */
  9112. _includedOnlyMeshesIds: string[];
  9113. /**
  9114. * The current light uniform buffer.
  9115. * @hidden Internal use only.
  9116. */
  9117. _uniformBuffer: UniformBuffer;
  9118. /** @hidden */
  9119. _renderId: number;
  9120. /**
  9121. * Creates a Light object in the scene.
  9122. * Documentation : https://doc.babylonjs.com/babylon101/lights
  9123. * @param name The friendly name of the light
  9124. * @param scene The scene the light belongs too
  9125. */
  9126. constructor(name: string, scene: Scene);
  9127. protected abstract _buildUniformLayout(): void;
  9128. /**
  9129. * Sets the passed Effect "effect" with the Light information.
  9130. * @param effect The effect to update
  9131. * @param lightIndex The index of the light in the effect to update
  9132. * @returns The light
  9133. */
  9134. abstract transferToEffect(effect: Effect, lightIndex: string): Light;
  9135. /**
  9136. * Sets the passed Effect "effect" with the Light textures.
  9137. * @param effect The effect to update
  9138. * @param lightIndex The index of the light in the effect to update
  9139. * @returns The light
  9140. */
  9141. transferTexturesToEffect(effect: Effect, lightIndex: string): Light;
  9142. /**
  9143. * Binds the lights information from the scene to the effect for the given mesh.
  9144. * @param lightIndex Light index
  9145. * @param scene The scene where the light belongs to
  9146. * @param effect The effect we are binding the data to
  9147. * @param useSpecular Defines if specular is supported
  9148. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  9149. */
  9150. _bindLight(lightIndex: number, scene: Scene, effect: Effect, useSpecular: boolean, rebuildInParallel?: boolean): void;
  9151. /**
  9152. * Sets the passed Effect "effect" with the Light information.
  9153. * @param effect The effect to update
  9154. * @param lightDataUniformName The uniform used to store light data (position or direction)
  9155. * @returns The light
  9156. */
  9157. abstract transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): Light;
  9158. /**
  9159. * Returns the string "Light".
  9160. * @returns the class name
  9161. */
  9162. getClassName(): string;
  9163. /** @hidden */
  9164. readonly _isLight: boolean;
  9165. /**
  9166. * Converts the light information to a readable string for debug purpose.
  9167. * @param fullDetails Supports for multiple levels of logging within scene loading
  9168. * @returns the human readable light info
  9169. */
  9170. toString(fullDetails?: boolean): string;
  9171. /** @hidden */
  9172. protected _syncParentEnabledState(): void;
  9173. /**
  9174. * Set the enabled state of this node.
  9175. * @param value - the new enabled state
  9176. */
  9177. setEnabled(value: boolean): void;
  9178. /**
  9179. * Returns the Light associated shadow generator if any.
  9180. * @return the associated shadow generator.
  9181. */
  9182. getShadowGenerator(): Nullable<IShadowGenerator>;
  9183. /**
  9184. * Returns a Vector3, the absolute light position in the World.
  9185. * @returns the world space position of the light
  9186. */
  9187. getAbsolutePosition(): Vector3;
  9188. /**
  9189. * Specifies if the light will affect the passed mesh.
  9190. * @param mesh The mesh to test against the light
  9191. * @return true the mesh is affected otherwise, false.
  9192. */
  9193. canAffectMesh(mesh: AbstractMesh): boolean;
  9194. /**
  9195. * Sort function to order lights for rendering.
  9196. * @param a First Light object to compare to second.
  9197. * @param b Second Light object to compare first.
  9198. * @return -1 to reduce's a's index relative to be, 0 for no change, 1 to increase a's index relative to b.
  9199. */
  9200. static CompareLightsPriority(a: Light, b: Light): number;
  9201. /**
  9202. * Releases resources associated with this node.
  9203. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  9204. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  9205. */
  9206. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  9207. /**
  9208. * Returns the light type ID (integer).
  9209. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  9210. */
  9211. getTypeID(): number;
  9212. /**
  9213. * Returns the intensity scaled by the Photometric Scale according to the light type and intensity mode.
  9214. * @returns the scaled intensity in intensity mode unit
  9215. */
  9216. getScaledIntensity(): number;
  9217. /**
  9218. * Returns a new Light object, named "name", from the current one.
  9219. * @param name The name of the cloned light
  9220. * @param newParent The parent of this light, if it has one
  9221. * @returns the new created light
  9222. */
  9223. clone(name: string, newParent?: Nullable<Node>): Nullable<Light>;
  9224. /**
  9225. * Serializes the current light into a Serialization object.
  9226. * @returns the serialized object.
  9227. */
  9228. serialize(): any;
  9229. /**
  9230. * Creates a new typed light from the passed type (integer) : point light = 0, directional light = 1, spot light = 2, hemispheric light = 3.
  9231. * This new light is named "name" and added to the passed scene.
  9232. * @param type Type according to the types available in Light.LIGHTTYPEID_x
  9233. * @param name The friendly name of the light
  9234. * @param scene The scene the new light will belong to
  9235. * @returns the constructor function
  9236. */
  9237. static GetConstructorFromName(type: number, name: string, scene: Scene): Nullable<() => Light>;
  9238. /**
  9239. * Parses the passed "parsedLight" and returns a new instanced Light from this parsing.
  9240. * @param parsedLight The JSON representation of the light
  9241. * @param scene The scene to create the parsed light in
  9242. * @returns the created light after parsing
  9243. */
  9244. static Parse(parsedLight: any, scene: Scene): Nullable<Light>;
  9245. private _hookArrayForExcluded;
  9246. private _hookArrayForIncludedOnly;
  9247. private _resyncMeshes;
  9248. /**
  9249. * Forces the meshes to update their light related information in their rendering used effects
  9250. * @hidden Internal Use Only
  9251. */
  9252. _markMeshesAsLightDirty(): void;
  9253. /**
  9254. * Recomputes the cached photometric scale if needed.
  9255. */
  9256. private _computePhotometricScale;
  9257. /**
  9258. * Returns the Photometric Scale according to the light type and intensity mode.
  9259. */
  9260. private _getPhotometricScale;
  9261. /**
  9262. * Reorder the light in the scene according to their defined priority.
  9263. * @hidden Internal Use Only
  9264. */
  9265. _reorderLightsInScene(): void;
  9266. /**
  9267. * Prepares the list of defines specific to the light type.
  9268. * @param defines the list of defines
  9269. * @param lightIndex defines the index of the light for the effect
  9270. */
  9271. abstract prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  9272. }
  9273. }
  9274. declare module BABYLON {
  9275. /** Defines supported spaces */
  9276. export enum Space {
  9277. /** Local (object) space */
  9278. LOCAL = 0,
  9279. /** World space */
  9280. WORLD = 1,
  9281. /** Bone space */
  9282. BONE = 2
  9283. }
  9284. /** Defines the 3 main axes */
  9285. export class Axis {
  9286. /** X axis */
  9287. static X: Vector3;
  9288. /** Y axis */
  9289. static Y: Vector3;
  9290. /** Z axis */
  9291. static Z: Vector3;
  9292. }
  9293. /**
  9294. * Defines cartesian components.
  9295. */
  9296. export enum Coordinate {
  9297. /** X axis */
  9298. X = 0,
  9299. /** Y axis */
  9300. Y = 1,
  9301. /** Z axis */
  9302. Z = 2
  9303. }
  9304. }
  9305. declare module BABYLON {
  9306. /**
  9307. * Interface describing all the common properties and methods a shadow light needs to implement.
  9308. * This helps both the shadow generator and materials to generate the corresponding shadow maps
  9309. * as well as binding the different shadow properties to the effects.
  9310. */
  9311. export interface IShadowLight extends Light {
  9312. /**
  9313. * The light id in the scene (used in scene.findLightById for instance)
  9314. */
  9315. id: string;
  9316. /**
  9317. * The position the shadow will be casted from.
  9318. */
  9319. position: Vector3;
  9320. /**
  9321. * In 2d mode (needCube being false), the direction used to cast the shadow.
  9322. */
  9323. direction: Vector3;
  9324. /**
  9325. * The transformed position. Position of the light in world space taking parenting in account.
  9326. */
  9327. transformedPosition: Vector3;
  9328. /**
  9329. * The transformed direction. Direction of the light in world space taking parenting in account.
  9330. */
  9331. transformedDirection: Vector3;
  9332. /**
  9333. * The friendly name of the light in the scene.
  9334. */
  9335. name: string;
  9336. /**
  9337. * Defines the shadow projection clipping minimum z value.
  9338. */
  9339. shadowMinZ: number;
  9340. /**
  9341. * Defines the shadow projection clipping maximum z value.
  9342. */
  9343. shadowMaxZ: number;
  9344. /**
  9345. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  9346. * @returns true if the information has been computed, false if it does not need to (no parenting)
  9347. */
  9348. computeTransformedInformation(): boolean;
  9349. /**
  9350. * Gets the scene the light belongs to.
  9351. * @returns The scene
  9352. */
  9353. getScene(): Scene;
  9354. /**
  9355. * Callback defining a custom Projection Matrix Builder.
  9356. * This can be used to override the default projection matrix computation.
  9357. */
  9358. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  9359. /**
  9360. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  9361. * @param matrix The matrix to updated with the projection information
  9362. * @param viewMatrix The transform matrix of the light
  9363. * @param renderList The list of mesh to render in the map
  9364. * @returns The current light
  9365. */
  9366. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  9367. /**
  9368. * Gets the current depth scale used in ESM.
  9369. * @returns The scale
  9370. */
  9371. getDepthScale(): number;
  9372. /**
  9373. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  9374. * @returns true if a cube texture needs to be use
  9375. */
  9376. needCube(): boolean;
  9377. /**
  9378. * Detects if the projection matrix requires to be recomputed this frame.
  9379. * @returns true if it requires to be recomputed otherwise, false.
  9380. */
  9381. needProjectionMatrixCompute(): boolean;
  9382. /**
  9383. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  9384. */
  9385. forceProjectionMatrixCompute(): void;
  9386. /**
  9387. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  9388. * @param faceIndex The index of the face we are computed the direction to generate shadow
  9389. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  9390. */
  9391. getShadowDirection(faceIndex?: number): Vector3;
  9392. /**
  9393. * Gets the minZ used for shadow according to both the scene and the light.
  9394. * @param activeCamera The camera we are returning the min for
  9395. * @returns the depth min z
  9396. */
  9397. getDepthMinZ(activeCamera: Camera): number;
  9398. /**
  9399. * Gets the maxZ used for shadow according to both the scene and the light.
  9400. * @param activeCamera The camera we are returning the max for
  9401. * @returns the depth max z
  9402. */
  9403. getDepthMaxZ(activeCamera: Camera): number;
  9404. }
  9405. /**
  9406. * Base implementation IShadowLight
  9407. * It groups all the common behaviour in order to reduce duplication and better follow the DRY pattern.
  9408. */
  9409. export abstract class ShadowLight extends Light implements IShadowLight {
  9410. protected abstract _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  9411. protected _position: Vector3;
  9412. protected _setPosition(value: Vector3): void;
  9413. /**
  9414. * Sets the position the shadow will be casted from. Also use as the light position for both
  9415. * point and spot lights.
  9416. */
  9417. get position(): Vector3;
  9418. /**
  9419. * Sets the position the shadow will be casted from. Also use as the light position for both
  9420. * point and spot lights.
  9421. */
  9422. set position(value: Vector3);
  9423. protected _direction: Vector3;
  9424. protected _setDirection(value: Vector3): void;
  9425. /**
  9426. * In 2d mode (needCube being false), gets the direction used to cast the shadow.
  9427. * Also use as the light direction on spot and directional lights.
  9428. */
  9429. get direction(): Vector3;
  9430. /**
  9431. * In 2d mode (needCube being false), sets the direction used to cast the shadow.
  9432. * Also use as the light direction on spot and directional lights.
  9433. */
  9434. set direction(value: Vector3);
  9435. protected _shadowMinZ: number;
  9436. /**
  9437. * Gets the shadow projection clipping minimum z value.
  9438. */
  9439. get shadowMinZ(): number;
  9440. /**
  9441. * Sets the shadow projection clipping minimum z value.
  9442. */
  9443. set shadowMinZ(value: number);
  9444. protected _shadowMaxZ: number;
  9445. /**
  9446. * Sets the shadow projection clipping maximum z value.
  9447. */
  9448. get shadowMaxZ(): number;
  9449. /**
  9450. * Gets the shadow projection clipping maximum z value.
  9451. */
  9452. set shadowMaxZ(value: number);
  9453. /**
  9454. * Callback defining a custom Projection Matrix Builder.
  9455. * This can be used to override the default projection matrix computation.
  9456. */
  9457. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  9458. /**
  9459. * The transformed position. Position of the light in world space taking parenting in account.
  9460. */
  9461. transformedPosition: Vector3;
  9462. /**
  9463. * The transformed direction. Direction of the light in world space taking parenting in account.
  9464. */
  9465. transformedDirection: Vector3;
  9466. private _needProjectionMatrixCompute;
  9467. /**
  9468. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  9469. * @returns true if the information has been computed, false if it does not need to (no parenting)
  9470. */
  9471. computeTransformedInformation(): boolean;
  9472. /**
  9473. * Return the depth scale used for the shadow map.
  9474. * @returns the depth scale.
  9475. */
  9476. getDepthScale(): number;
  9477. /**
  9478. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  9479. * @param faceIndex The index of the face we are computed the direction to generate shadow
  9480. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  9481. */
  9482. getShadowDirection(faceIndex?: number): Vector3;
  9483. /**
  9484. * Returns the ShadowLight absolute position in the World.
  9485. * @returns the position vector in world space
  9486. */
  9487. getAbsolutePosition(): Vector3;
  9488. /**
  9489. * Sets the ShadowLight direction toward the passed target.
  9490. * @param target The point to target in local space
  9491. * @returns the updated ShadowLight direction
  9492. */
  9493. setDirectionToTarget(target: Vector3): Vector3;
  9494. /**
  9495. * Returns the light rotation in euler definition.
  9496. * @returns the x y z rotation in local space.
  9497. */
  9498. getRotation(): Vector3;
  9499. /**
  9500. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  9501. * @returns true if a cube texture needs to be use
  9502. */
  9503. needCube(): boolean;
  9504. /**
  9505. * Detects if the projection matrix requires to be recomputed this frame.
  9506. * @returns true if it requires to be recomputed otherwise, false.
  9507. */
  9508. needProjectionMatrixCompute(): boolean;
  9509. /**
  9510. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  9511. */
  9512. forceProjectionMatrixCompute(): void;
  9513. /** @hidden */
  9514. _initCache(): void;
  9515. /** @hidden */
  9516. _isSynchronized(): boolean;
  9517. /**
  9518. * Computes the world matrix of the node
  9519. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  9520. * @returns the world matrix
  9521. */
  9522. computeWorldMatrix(force?: boolean): Matrix;
  9523. /**
  9524. * Gets the minZ used for shadow according to both the scene and the light.
  9525. * @param activeCamera The camera we are returning the min for
  9526. * @returns the depth min z
  9527. */
  9528. getDepthMinZ(activeCamera: Camera): number;
  9529. /**
  9530. * Gets the maxZ used for shadow according to both the scene and the light.
  9531. * @param activeCamera The camera we are returning the max for
  9532. * @returns the depth max z
  9533. */
  9534. getDepthMaxZ(activeCamera: Camera): number;
  9535. /**
  9536. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  9537. * @param matrix The matrix to updated with the projection information
  9538. * @param viewMatrix The transform matrix of the light
  9539. * @param renderList The list of mesh to render in the map
  9540. * @returns The current light
  9541. */
  9542. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  9543. }
  9544. }
  9545. declare module BABYLON {
  9546. /**
  9547. * Configuration needed for prepass-capable materials
  9548. */
  9549. export class PrePassConfiguration {
  9550. /**
  9551. * Previous world matrices of meshes carrying this material
  9552. * Used for computing velocity
  9553. */
  9554. previousWorldMatrices: {
  9555. [index: number]: Matrix;
  9556. };
  9557. /**
  9558. * Previous view project matrix
  9559. * Used for computing velocity
  9560. */
  9561. previousViewProjection: Matrix;
  9562. /**
  9563. * Previous bones of meshes carrying this material
  9564. * Used for computing velocity
  9565. */
  9566. previousBones: {
  9567. [index: number]: Float32Array;
  9568. };
  9569. /**
  9570. * Add the required uniforms to the current list.
  9571. * @param uniforms defines the current uniform list.
  9572. */
  9573. static AddUniforms(uniforms: string[]): void;
  9574. /**
  9575. * Add the required samplers to the current list.
  9576. * @param samplers defines the current sampler list.
  9577. */
  9578. static AddSamplers(samplers: string[]): void;
  9579. /**
  9580. * Binds the material data.
  9581. * @param effect defines the effect to update
  9582. * @param scene defines the scene the material belongs to.
  9583. * @param mesh The mesh
  9584. * @param world World matrix of this mesh
  9585. * @param isFrozen Is the material frozen
  9586. */
  9587. bindForSubMesh(effect: Effect, scene: Scene, mesh: Mesh, world: Matrix, isFrozen: boolean): void;
  9588. }
  9589. }
  9590. declare module BABYLON {
  9591. /**
  9592. * A target camera takes a mesh or position as a target and continues to look at it while it moves.
  9593. * This is the base of the follow, arc rotate cameras and Free camera
  9594. * @see https://doc.babylonjs.com/features/cameras
  9595. */
  9596. export class TargetCamera extends Camera {
  9597. private static _RigCamTransformMatrix;
  9598. private static _TargetTransformMatrix;
  9599. private static _TargetFocalPoint;
  9600. private _tmpUpVector;
  9601. private _tmpTargetVector;
  9602. /**
  9603. * Define the current direction the camera is moving to
  9604. */
  9605. cameraDirection: Vector3;
  9606. /**
  9607. * Define the current rotation the camera is rotating to
  9608. */
  9609. cameraRotation: Vector2;
  9610. /** Gets or sets a boolean indicating that the scaling of the parent hierarchy will not be taken in account by the camera */
  9611. ignoreParentScaling: boolean;
  9612. /**
  9613. * When set, the up vector of the camera will be updated by the rotation of the camera
  9614. */
  9615. updateUpVectorFromRotation: boolean;
  9616. private _tmpQuaternion;
  9617. /**
  9618. * Define the current rotation of the camera
  9619. */
  9620. rotation: Vector3;
  9621. /**
  9622. * Define the current rotation of the camera as a quaternion to prevent Gimbal lock
  9623. */
  9624. rotationQuaternion: Quaternion;
  9625. /**
  9626. * Define the current speed of the camera
  9627. */
  9628. speed: number;
  9629. /**
  9630. * Add constraint to the camera to prevent it to move freely in all directions and
  9631. * around all axis.
  9632. */
  9633. noRotationConstraint: boolean;
  9634. /**
  9635. * Reverses mouselook direction to 'natural' panning as opposed to traditional direct
  9636. * panning
  9637. */
  9638. invertRotation: boolean;
  9639. /**
  9640. * Speed multiplier for inverse camera panning
  9641. */
  9642. inverseRotationSpeed: number;
  9643. /**
  9644. * Define the current target of the camera as an object or a position.
  9645. */
  9646. lockedTarget: any;
  9647. /** @hidden */
  9648. _currentTarget: Vector3;
  9649. /** @hidden */
  9650. _initialFocalDistance: number;
  9651. /** @hidden */
  9652. _viewMatrix: Matrix;
  9653. /** @hidden */
  9654. _camMatrix: Matrix;
  9655. /** @hidden */
  9656. _cameraTransformMatrix: Matrix;
  9657. /** @hidden */
  9658. _cameraRotationMatrix: Matrix;
  9659. /** @hidden */
  9660. _referencePoint: Vector3;
  9661. /** @hidden */
  9662. _transformedReferencePoint: Vector3;
  9663. /** @hidden */
  9664. _reset: () => void;
  9665. private _defaultUp;
  9666. /**
  9667. * Instantiates a target camera that takes a mesh or position as a target and continues to look at it while it moves.
  9668. * This is the base of the follow, arc rotate cameras and Free camera
  9669. * @see https://doc.babylonjs.com/features/cameras
  9670. * @param name Defines the name of the camera in the scene
  9671. * @param position Defines the start position of the camera in the scene
  9672. * @param scene Defines the scene the camera belongs to
  9673. * @param setActiveOnSceneIfNoneActive Defines whether the camera should be marked as active if not other active cameras have been defined
  9674. */
  9675. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  9676. /**
  9677. * Gets the position in front of the camera at a given distance.
  9678. * @param distance The distance from the camera we want the position to be
  9679. * @returns the position
  9680. */
  9681. getFrontPosition(distance: number): Vector3;
  9682. /** @hidden */
  9683. _getLockedTargetPosition(): Nullable<Vector3>;
  9684. private _storedPosition;
  9685. private _storedRotation;
  9686. private _storedRotationQuaternion;
  9687. /**
  9688. * Store current camera state of the camera (fov, position, rotation, etc..)
  9689. * @returns the camera
  9690. */
  9691. storeState(): Camera;
  9692. /**
  9693. * Restored camera state. You must call storeState() first
  9694. * @returns whether it was successful or not
  9695. * @hidden
  9696. */
  9697. _restoreStateValues(): boolean;
  9698. /** @hidden */
  9699. _initCache(): void;
  9700. /** @hidden */
  9701. _updateCache(ignoreParentClass?: boolean): void;
  9702. /** @hidden */
  9703. _isSynchronizedViewMatrix(): boolean;
  9704. /** @hidden */
  9705. _computeLocalCameraSpeed(): number;
  9706. /**
  9707. * Defines the target the camera should look at.
  9708. * @param target Defines the new target as a Vector or a mesh
  9709. */
  9710. setTarget(target: Vector3): void;
  9711. /**
  9712. * Defines the target point of the camera.
  9713. * The camera looks towards it form the radius distance.
  9714. */
  9715. get target(): Vector3;
  9716. set target(value: Vector3);
  9717. /**
  9718. * Return the current target position of the camera. This value is expressed in local space.
  9719. * @returns the target position
  9720. */
  9721. getTarget(): Vector3;
  9722. /** @hidden */
  9723. _decideIfNeedsToMove(): boolean;
  9724. /** @hidden */
  9725. _updatePosition(): void;
  9726. /** @hidden */
  9727. _checkInputs(): void;
  9728. protected _updateCameraRotationMatrix(): void;
  9729. /**
  9730. * 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)
  9731. * @returns the current camera
  9732. */
  9733. private _rotateUpVectorWithCameraRotationMatrix;
  9734. private _cachedRotationZ;
  9735. private _cachedQuaternionRotationZ;
  9736. /** @hidden */
  9737. _getViewMatrix(): Matrix;
  9738. protected _computeViewMatrix(position: Vector3, target: Vector3, up: Vector3): void;
  9739. /**
  9740. * @hidden
  9741. */
  9742. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  9743. /**
  9744. * @hidden
  9745. */
  9746. _updateRigCameras(): void;
  9747. private _getRigCamPositionAndTarget;
  9748. /**
  9749. * Gets the current object class name.
  9750. * @return the class name
  9751. */
  9752. getClassName(): string;
  9753. }
  9754. }
  9755. declare module BABYLON {
  9756. /**
  9757. * @ignore
  9758. * This is a list of all the different input types that are available in the application.
  9759. * Fo instance: ArcRotateCameraGamepadInput...
  9760. */
  9761. export var CameraInputTypes: {};
  9762. /**
  9763. * This is the contract to implement in order to create a new input class.
  9764. * Inputs are dealing with listening to user actions and moving the camera accordingly.
  9765. */
  9766. export interface ICameraInput<TCamera extends Camera> {
  9767. /**
  9768. * Defines the camera the input is attached to.
  9769. */
  9770. camera: Nullable<TCamera>;
  9771. /**
  9772. * Gets the class name of the current input.
  9773. * @returns the class name
  9774. */
  9775. getClassName(): string;
  9776. /**
  9777. * Get the friendly name associated with the input class.
  9778. * @returns the input friendly name
  9779. */
  9780. getSimpleName(): string;
  9781. /**
  9782. * Attach the input controls to a specific dom element to get the input from.
  9783. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  9784. */
  9785. attachControl(noPreventDefault?: boolean): void;
  9786. /**
  9787. * Detach the current controls from the specified dom element.
  9788. */
  9789. detachControl(): void;
  9790. /**
  9791. * Update the current camera state depending on the inputs that have been used this frame.
  9792. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  9793. */
  9794. checkInputs?: () => void;
  9795. }
  9796. /**
  9797. * Represents a map of input types to input instance or input index to input instance.
  9798. */
  9799. export interface CameraInputsMap<TCamera extends Camera> {
  9800. /**
  9801. * Accessor to the input by input type.
  9802. */
  9803. [name: string]: ICameraInput<TCamera>;
  9804. /**
  9805. * Accessor to the input by input index.
  9806. */
  9807. [idx: number]: ICameraInput<TCamera>;
  9808. }
  9809. /**
  9810. * This represents the input manager used within a camera.
  9811. * It helps dealing with all the different kind of input attached to a camera.
  9812. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  9813. */
  9814. export class CameraInputsManager<TCamera extends Camera> {
  9815. /**
  9816. * Defines the list of inputs attached to the camera.
  9817. */
  9818. attached: CameraInputsMap<TCamera>;
  9819. /**
  9820. * Defines the dom element the camera is collecting inputs from.
  9821. * This is null if the controls have not been attached.
  9822. */
  9823. attachedToElement: boolean;
  9824. /**
  9825. * Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  9826. */
  9827. noPreventDefault: boolean;
  9828. /**
  9829. * Defined the camera the input manager belongs to.
  9830. */
  9831. camera: TCamera;
  9832. /**
  9833. * Update the current camera state depending on the inputs that have been used this frame.
  9834. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  9835. */
  9836. checkInputs: () => void;
  9837. /**
  9838. * Instantiate a new Camera Input Manager.
  9839. * @param camera Defines the camera the input manager belongs to
  9840. */
  9841. constructor(camera: TCamera);
  9842. /**
  9843. * Add an input method to a camera
  9844. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  9845. * @param input camera input method
  9846. */
  9847. add(input: ICameraInput<TCamera>): void;
  9848. /**
  9849. * Remove a specific input method from a camera
  9850. * example: camera.inputs.remove(camera.inputs.attached.mouse);
  9851. * @param inputToRemove camera input method
  9852. */
  9853. remove(inputToRemove: ICameraInput<TCamera>): void;
  9854. /**
  9855. * Remove a specific input type from a camera
  9856. * example: camera.inputs.remove("ArcRotateCameraGamepadInput");
  9857. * @param inputType the type of the input to remove
  9858. */
  9859. removeByType(inputType: string): void;
  9860. private _addCheckInputs;
  9861. /**
  9862. * Attach the input controls to the currently attached dom element to listen the events from.
  9863. * @param input Defines the input to attach
  9864. */
  9865. attachInput(input: ICameraInput<TCamera>): void;
  9866. /**
  9867. * Attach the current manager inputs controls to a specific dom element to listen the events from.
  9868. * @param element Defines the dom element to collect the events from
  9869. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  9870. */
  9871. attachElement(noPreventDefault?: boolean): void;
  9872. /**
  9873. * Detach the current manager inputs controls from a specific dom element.
  9874. * @param element Defines the dom element to collect the events from
  9875. * @param disconnect Defines whether the input should be removed from the current list of attached inputs
  9876. */
  9877. detachElement(disconnect?: boolean): void;
  9878. /**
  9879. * Rebuild the dynamic inputCheck function from the current list of
  9880. * defined inputs in the manager.
  9881. */
  9882. rebuildInputCheck(): void;
  9883. /**
  9884. * Remove all attached input methods from a camera
  9885. */
  9886. clear(): void;
  9887. /**
  9888. * Serialize the current input manager attached to a camera.
  9889. * This ensures than once parsed,
  9890. * the input associated to the camera will be identical to the current ones
  9891. * @param serializedCamera Defines the camera serialization JSON the input serialization should write to
  9892. */
  9893. serialize(serializedCamera: any): void;
  9894. /**
  9895. * Parses an input manager serialized JSON to restore the previous list of inputs
  9896. * and states associated to a camera.
  9897. * @param parsedCamera Defines the JSON to parse
  9898. */
  9899. parse(parsedCamera: any): void;
  9900. }
  9901. }
  9902. declare module BABYLON {
  9903. /**
  9904. * Gather the list of keyboard event types as constants.
  9905. */
  9906. export class KeyboardEventTypes {
  9907. /**
  9908. * The keydown event is fired when a key becomes active (pressed).
  9909. */
  9910. static readonly KEYDOWN: number;
  9911. /**
  9912. * The keyup event is fired when a key has been released.
  9913. */
  9914. static readonly KEYUP: number;
  9915. }
  9916. /**
  9917. * This class is used to store keyboard related info for the onKeyboardObservable event.
  9918. */
  9919. export class KeyboardInfo {
  9920. /**
  9921. * Defines the type of event (KeyboardEventTypes)
  9922. */
  9923. type: number;
  9924. /**
  9925. * Defines the related dom event
  9926. */
  9927. event: KeyboardEvent;
  9928. /**
  9929. * Instantiates a new keyboard info.
  9930. * This class is used to store keyboard related info for the onKeyboardObservable event.
  9931. * @param type Defines the type of event (KeyboardEventTypes)
  9932. * @param event Defines the related dom event
  9933. */
  9934. constructor(
  9935. /**
  9936. * Defines the type of event (KeyboardEventTypes)
  9937. */
  9938. type: number,
  9939. /**
  9940. * Defines the related dom event
  9941. */
  9942. event: KeyboardEvent);
  9943. }
  9944. /**
  9945. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  9946. * Set the skipOnKeyboardObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onKeyboardObservable
  9947. */
  9948. export class KeyboardInfoPre extends KeyboardInfo {
  9949. /**
  9950. * Defines the type of event (KeyboardEventTypes)
  9951. */
  9952. type: number;
  9953. /**
  9954. * Defines the related dom event
  9955. */
  9956. event: KeyboardEvent;
  9957. /**
  9958. * Defines whether the engine should skip the next onKeyboardObservable associated to this pre.
  9959. */
  9960. skipOnPointerObservable: boolean;
  9961. /**
  9962. * Instantiates a new keyboard pre info.
  9963. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  9964. * @param type Defines the type of event (KeyboardEventTypes)
  9965. * @param event Defines the related dom event
  9966. */
  9967. constructor(
  9968. /**
  9969. * Defines the type of event (KeyboardEventTypes)
  9970. */
  9971. type: number,
  9972. /**
  9973. * Defines the related dom event
  9974. */
  9975. event: KeyboardEvent);
  9976. }
  9977. }
  9978. declare module BABYLON {
  9979. /**
  9980. * Manage the keyboard inputs to control the movement of a free camera.
  9981. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  9982. */
  9983. export class FreeCameraKeyboardMoveInput implements ICameraInput<FreeCamera> {
  9984. /**
  9985. * Defines the camera the input is attached to.
  9986. */
  9987. camera: FreeCamera;
  9988. /**
  9989. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  9990. */
  9991. keysUp: number[];
  9992. /**
  9993. * Gets or Set the list of keyboard keys used to control the upward move of the camera.
  9994. */
  9995. keysUpward: number[];
  9996. /**
  9997. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  9998. */
  9999. keysDown: number[];
  10000. /**
  10001. * Gets or Set the list of keyboard keys used to control the downward move of the camera.
  10002. */
  10003. keysDownward: number[];
  10004. /**
  10005. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  10006. */
  10007. keysLeft: number[];
  10008. /**
  10009. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  10010. */
  10011. keysRight: number[];
  10012. private _keys;
  10013. private _onCanvasBlurObserver;
  10014. private _onKeyboardObserver;
  10015. private _engine;
  10016. private _scene;
  10017. /**
  10018. * Attach the input controls to a specific dom element to get the input from.
  10019. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  10020. */
  10021. attachControl(noPreventDefault?: boolean): void;
  10022. /**
  10023. * Detach the current controls from the specified dom element.
  10024. */
  10025. detachControl(): void;
  10026. /**
  10027. * Update the current camera state depending on the inputs that have been used this frame.
  10028. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  10029. */
  10030. checkInputs(): void;
  10031. /**
  10032. * Gets the class name of the current input.
  10033. * @returns the class name
  10034. */
  10035. getClassName(): string;
  10036. /** @hidden */
  10037. _onLostFocus(): void;
  10038. /**
  10039. * Get the friendly name associated with the input class.
  10040. * @returns the input friendly name
  10041. */
  10042. getSimpleName(): string;
  10043. }
  10044. }
  10045. declare module BABYLON {
  10046. /**
  10047. * Interface used to define Action
  10048. */
  10049. export interface IAction {
  10050. /**
  10051. * Trigger for the action
  10052. */
  10053. trigger: number;
  10054. /** Options of the trigger */
  10055. triggerOptions: any;
  10056. /**
  10057. * Gets the trigger parameters
  10058. * @returns the trigger parameters
  10059. */
  10060. getTriggerParameter(): any;
  10061. /**
  10062. * Internal only - executes current action event
  10063. * @hidden
  10064. */
  10065. _executeCurrent(evt?: ActionEvent): void;
  10066. /**
  10067. * Serialize placeholder for child classes
  10068. * @param parent of child
  10069. * @returns the serialized object
  10070. */
  10071. serialize(parent: any): any;
  10072. /**
  10073. * Internal only
  10074. * @hidden
  10075. */
  10076. _prepare(): void;
  10077. /**
  10078. * Internal only - manager for action
  10079. * @hidden
  10080. */
  10081. _actionManager: Nullable<AbstractActionManager>;
  10082. /**
  10083. * Adds action to chain of actions, may be a DoNothingAction
  10084. * @param action defines the next action to execute
  10085. * @returns The action passed in
  10086. * @see https://www.babylonjs-playground.com/#1T30HR#0
  10087. */
  10088. then(action: IAction): IAction;
  10089. }
  10090. /**
  10091. * The action to be carried out following a trigger
  10092. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#available-actions
  10093. */
  10094. export class Action implements IAction {
  10095. /** the trigger, with or without parameters, for the action */
  10096. triggerOptions: any;
  10097. /**
  10098. * Trigger for the action
  10099. */
  10100. trigger: number;
  10101. /**
  10102. * Internal only - manager for action
  10103. * @hidden
  10104. */
  10105. _actionManager: ActionManager;
  10106. private _nextActiveAction;
  10107. private _child;
  10108. private _condition?;
  10109. private _triggerParameter;
  10110. /**
  10111. * An event triggered prior to action being executed.
  10112. */
  10113. onBeforeExecuteObservable: Observable<Action>;
  10114. /**
  10115. * Creates a new Action
  10116. * @param triggerOptions the trigger, with or without parameters, for the action
  10117. * @param condition an optional determinant of action
  10118. */
  10119. constructor(
  10120. /** the trigger, with or without parameters, for the action */
  10121. triggerOptions: any, condition?: Condition);
  10122. /**
  10123. * Internal only
  10124. * @hidden
  10125. */
  10126. _prepare(): void;
  10127. /**
  10128. * Gets the trigger parameter
  10129. * @returns the trigger parameter
  10130. */
  10131. getTriggerParameter(): any;
  10132. /**
  10133. * Sets the trigger parameter
  10134. * @param value defines the new trigger parameter
  10135. */
  10136. setTriggerParameter(value: any): void;
  10137. /**
  10138. * Internal only - executes current action event
  10139. * @hidden
  10140. */
  10141. _executeCurrent(evt?: ActionEvent): void;
  10142. /**
  10143. * Execute placeholder for child classes
  10144. * @param evt optional action event
  10145. */
  10146. execute(evt?: ActionEvent): void;
  10147. /**
  10148. * Skips to next active action
  10149. */
  10150. skipToNextActiveAction(): void;
  10151. /**
  10152. * Adds action to chain of actions, may be a DoNothingAction
  10153. * @param action defines the next action to execute
  10154. * @returns The action passed in
  10155. * @see https://www.babylonjs-playground.com/#1T30HR#0
  10156. */
  10157. then(action: Action): Action;
  10158. /**
  10159. * Internal only
  10160. * @hidden
  10161. */
  10162. _getProperty(propertyPath: string): string;
  10163. /**
  10164. * Internal only
  10165. * @hidden
  10166. */
  10167. _getEffectiveTarget(target: any, propertyPath: string): any;
  10168. /**
  10169. * Serialize placeholder for child classes
  10170. * @param parent of child
  10171. * @returns the serialized object
  10172. */
  10173. serialize(parent: any): any;
  10174. /**
  10175. * Internal only called by serialize
  10176. * @hidden
  10177. */
  10178. protected _serialize(serializedAction: any, parent?: any): any;
  10179. /**
  10180. * Internal only
  10181. * @hidden
  10182. */
  10183. static _SerializeValueAsString: (value: any) => string;
  10184. /**
  10185. * Internal only
  10186. * @hidden
  10187. */
  10188. static _GetTargetProperty: (target: Scene | Node) => {
  10189. name: string;
  10190. targetType: string;
  10191. value: string;
  10192. };
  10193. }
  10194. }
  10195. declare module BABYLON {
  10196. /**
  10197. * A Condition applied to an Action
  10198. */
  10199. export class Condition {
  10200. /**
  10201. * Internal only - manager for action
  10202. * @hidden
  10203. */
  10204. _actionManager: ActionManager;
  10205. /**
  10206. * Internal only
  10207. * @hidden
  10208. */
  10209. _evaluationId: number;
  10210. /**
  10211. * Internal only
  10212. * @hidden
  10213. */
  10214. _currentResult: boolean;
  10215. /**
  10216. * Creates a new Condition
  10217. * @param actionManager the manager of the action the condition is applied to
  10218. */
  10219. constructor(actionManager: ActionManager);
  10220. /**
  10221. * Check if the current condition is valid
  10222. * @returns a boolean
  10223. */
  10224. isValid(): boolean;
  10225. /**
  10226. * Internal only
  10227. * @hidden
  10228. */
  10229. _getProperty(propertyPath: string): string;
  10230. /**
  10231. * Internal only
  10232. * @hidden
  10233. */
  10234. _getEffectiveTarget(target: any, propertyPath: string): any;
  10235. /**
  10236. * Serialize placeholder for child classes
  10237. * @returns the serialized object
  10238. */
  10239. serialize(): any;
  10240. /**
  10241. * Internal only
  10242. * @hidden
  10243. */
  10244. protected _serialize(serializedCondition: any): any;
  10245. }
  10246. /**
  10247. * Defines specific conditional operators as extensions of Condition
  10248. */
  10249. export class ValueCondition extends Condition {
  10250. /** path to specify the property of the target the conditional operator uses */
  10251. propertyPath: string;
  10252. /** the value compared by the conditional operator against the current value of the property */
  10253. value: any;
  10254. /** the conditional operator, default ValueCondition.IsEqual */
  10255. operator: number;
  10256. /**
  10257. * Internal only
  10258. * @hidden
  10259. */
  10260. private static _IsEqual;
  10261. /**
  10262. * Internal only
  10263. * @hidden
  10264. */
  10265. private static _IsDifferent;
  10266. /**
  10267. * Internal only
  10268. * @hidden
  10269. */
  10270. private static _IsGreater;
  10271. /**
  10272. * Internal only
  10273. * @hidden
  10274. */
  10275. private static _IsLesser;
  10276. /**
  10277. * returns the number for IsEqual
  10278. */
  10279. static get IsEqual(): number;
  10280. /**
  10281. * Returns the number for IsDifferent
  10282. */
  10283. static get IsDifferent(): number;
  10284. /**
  10285. * Returns the number for IsGreater
  10286. */
  10287. static get IsGreater(): number;
  10288. /**
  10289. * Returns the number for IsLesser
  10290. */
  10291. static get IsLesser(): number;
  10292. /**
  10293. * Internal only The action manager for the condition
  10294. * @hidden
  10295. */
  10296. _actionManager: ActionManager;
  10297. /**
  10298. * Internal only
  10299. * @hidden
  10300. */
  10301. private _target;
  10302. /**
  10303. * Internal only
  10304. * @hidden
  10305. */
  10306. private _effectiveTarget;
  10307. /**
  10308. * Internal only
  10309. * @hidden
  10310. */
  10311. private _property;
  10312. /**
  10313. * Creates a new ValueCondition
  10314. * @param actionManager manager for the action the condition applies to
  10315. * @param target for the action
  10316. * @param propertyPath path to specify the property of the target the conditional operator uses
  10317. * @param value the value compared by the conditional operator against the current value of the property
  10318. * @param operator the conditional operator, default ValueCondition.IsEqual
  10319. */
  10320. constructor(actionManager: ActionManager, target: any,
  10321. /** path to specify the property of the target the conditional operator uses */
  10322. propertyPath: string,
  10323. /** the value compared by the conditional operator against the current value of the property */
  10324. value: any,
  10325. /** the conditional operator, default ValueCondition.IsEqual */
  10326. operator?: number);
  10327. /**
  10328. * Compares the given value with the property value for the specified conditional operator
  10329. * @returns the result of the comparison
  10330. */
  10331. isValid(): boolean;
  10332. /**
  10333. * Serialize the ValueCondition into a JSON compatible object
  10334. * @returns serialization object
  10335. */
  10336. serialize(): any;
  10337. /**
  10338. * Gets the name of the conditional operator for the ValueCondition
  10339. * @param operator the conditional operator
  10340. * @returns the name
  10341. */
  10342. static GetOperatorName(operator: number): string;
  10343. }
  10344. /**
  10345. * Defines a predicate condition as an extension of Condition
  10346. */
  10347. export class PredicateCondition extends Condition {
  10348. /** defines the predicate function used to validate the condition */
  10349. predicate: () => boolean;
  10350. /**
  10351. * Internal only - manager for action
  10352. * @hidden
  10353. */
  10354. _actionManager: ActionManager;
  10355. /**
  10356. * Creates a new PredicateCondition
  10357. * @param actionManager manager for the action the condition applies to
  10358. * @param predicate defines the predicate function used to validate the condition
  10359. */
  10360. constructor(actionManager: ActionManager,
  10361. /** defines the predicate function used to validate the condition */
  10362. predicate: () => boolean);
  10363. /**
  10364. * @returns the validity of the predicate condition
  10365. */
  10366. isValid(): boolean;
  10367. }
  10368. /**
  10369. * Defines a state condition as an extension of Condition
  10370. */
  10371. export class StateCondition extends Condition {
  10372. /** Value to compare with target state */
  10373. value: string;
  10374. /**
  10375. * Internal only - manager for action
  10376. * @hidden
  10377. */
  10378. _actionManager: ActionManager;
  10379. /**
  10380. * Internal only
  10381. * @hidden
  10382. */
  10383. private _target;
  10384. /**
  10385. * Creates a new StateCondition
  10386. * @param actionManager manager for the action the condition applies to
  10387. * @param target of the condition
  10388. * @param value to compare with target state
  10389. */
  10390. constructor(actionManager: ActionManager, target: any,
  10391. /** Value to compare with target state */
  10392. value: string);
  10393. /**
  10394. * Gets a boolean indicating if the current condition is met
  10395. * @returns the validity of the state
  10396. */
  10397. isValid(): boolean;
  10398. /**
  10399. * Serialize the StateCondition into a JSON compatible object
  10400. * @returns serialization object
  10401. */
  10402. serialize(): any;
  10403. }
  10404. }
  10405. declare module BABYLON {
  10406. /**
  10407. * This defines an action responsible to toggle a boolean once triggered.
  10408. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  10409. */
  10410. export class SwitchBooleanAction extends Action {
  10411. /**
  10412. * The path to the boolean property in the target object
  10413. */
  10414. propertyPath: string;
  10415. private _target;
  10416. private _effectiveTarget;
  10417. private _property;
  10418. /**
  10419. * Instantiate the action
  10420. * @param triggerOptions defines the trigger options
  10421. * @param target defines the object containing the boolean
  10422. * @param propertyPath defines the path to the boolean property in the target object
  10423. * @param condition defines the trigger related conditions
  10424. */
  10425. constructor(triggerOptions: any, target: any, propertyPath: string, condition?: Condition);
  10426. /** @hidden */
  10427. _prepare(): void;
  10428. /**
  10429. * Execute the action toggle the boolean value.
  10430. */
  10431. execute(): void;
  10432. /**
  10433. * Serializes the actions and its related information.
  10434. * @param parent defines the object to serialize in
  10435. * @returns the serialized object
  10436. */
  10437. serialize(parent: any): any;
  10438. }
  10439. /**
  10440. * This defines an action responsible to set a the state field of the target
  10441. * to a desired value once triggered.
  10442. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  10443. */
  10444. export class SetStateAction extends Action {
  10445. /**
  10446. * The value to store in the state field.
  10447. */
  10448. value: string;
  10449. private _target;
  10450. /**
  10451. * Instantiate the action
  10452. * @param triggerOptions defines the trigger options
  10453. * @param target defines the object containing the state property
  10454. * @param value defines the value to store in the state field
  10455. * @param condition defines the trigger related conditions
  10456. */
  10457. constructor(triggerOptions: any, target: any, value: string, condition?: Condition);
  10458. /**
  10459. * Execute the action and store the value on the target state property.
  10460. */
  10461. execute(): void;
  10462. /**
  10463. * Serializes the actions and its related information.
  10464. * @param parent defines the object to serialize in
  10465. * @returns the serialized object
  10466. */
  10467. serialize(parent: any): any;
  10468. }
  10469. /**
  10470. * This defines an action responsible to set a property of the target
  10471. * to a desired value once triggered.
  10472. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  10473. */
  10474. export class SetValueAction extends Action {
  10475. /**
  10476. * The path of the property to set in the target.
  10477. */
  10478. propertyPath: string;
  10479. /**
  10480. * The value to set in the property
  10481. */
  10482. value: any;
  10483. private _target;
  10484. private _effectiveTarget;
  10485. private _property;
  10486. /**
  10487. * Instantiate the action
  10488. * @param triggerOptions defines the trigger options
  10489. * @param target defines the object containing the property
  10490. * @param propertyPath defines the path of the property to set in the target
  10491. * @param value defines the value to set in the property
  10492. * @param condition defines the trigger related conditions
  10493. */
  10494. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  10495. /** @hidden */
  10496. _prepare(): void;
  10497. /**
  10498. * Execute the action and set the targeted property to the desired value.
  10499. */
  10500. execute(): void;
  10501. /**
  10502. * Serializes the actions and its related information.
  10503. * @param parent defines the object to serialize in
  10504. * @returns the serialized object
  10505. */
  10506. serialize(parent: any): any;
  10507. }
  10508. /**
  10509. * This defines an action responsible to increment the target value
  10510. * to a desired value once triggered.
  10511. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  10512. */
  10513. export class IncrementValueAction extends Action {
  10514. /**
  10515. * The path of the property to increment in the target.
  10516. */
  10517. propertyPath: string;
  10518. /**
  10519. * The value we should increment the property by.
  10520. */
  10521. value: any;
  10522. private _target;
  10523. private _effectiveTarget;
  10524. private _property;
  10525. /**
  10526. * Instantiate the action
  10527. * @param triggerOptions defines the trigger options
  10528. * @param target defines the object containing the property
  10529. * @param propertyPath defines the path of the property to increment in the target
  10530. * @param value defines the value value we should increment the property by
  10531. * @param condition defines the trigger related conditions
  10532. */
  10533. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  10534. /** @hidden */
  10535. _prepare(): void;
  10536. /**
  10537. * Execute the action and increment the target of the value amount.
  10538. */
  10539. execute(): void;
  10540. /**
  10541. * Serializes the actions and its related information.
  10542. * @param parent defines the object to serialize in
  10543. * @returns the serialized object
  10544. */
  10545. serialize(parent: any): any;
  10546. }
  10547. /**
  10548. * This defines an action responsible to start an animation once triggered.
  10549. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  10550. */
  10551. export class PlayAnimationAction extends Action {
  10552. /**
  10553. * Where the animation should start (animation frame)
  10554. */
  10555. from: number;
  10556. /**
  10557. * Where the animation should stop (animation frame)
  10558. */
  10559. to: number;
  10560. /**
  10561. * Define if the animation should loop or stop after the first play.
  10562. */
  10563. loop?: boolean;
  10564. private _target;
  10565. /**
  10566. * Instantiate the action
  10567. * @param triggerOptions defines the trigger options
  10568. * @param target defines the target animation or animation name
  10569. * @param from defines from where the animation should start (animation frame)
  10570. * @param to defines where the animation should stop (animation frame)
  10571. * @param loop defines if the animation should loop or stop after the first play
  10572. * @param condition defines the trigger related conditions
  10573. */
  10574. constructor(triggerOptions: any, target: any, from: number, to: number, loop?: boolean, condition?: Condition);
  10575. /** @hidden */
  10576. _prepare(): void;
  10577. /**
  10578. * Execute the action and play the animation.
  10579. */
  10580. execute(): void;
  10581. /**
  10582. * Serializes the actions and its related information.
  10583. * @param parent defines the object to serialize in
  10584. * @returns the serialized object
  10585. */
  10586. serialize(parent: any): any;
  10587. }
  10588. /**
  10589. * This defines an action responsible to stop an animation once triggered.
  10590. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  10591. */
  10592. export class StopAnimationAction extends Action {
  10593. private _target;
  10594. /**
  10595. * Instantiate the action
  10596. * @param triggerOptions defines the trigger options
  10597. * @param target defines the target animation or animation name
  10598. * @param condition defines the trigger related conditions
  10599. */
  10600. constructor(triggerOptions: any, target: any, condition?: Condition);
  10601. /** @hidden */
  10602. _prepare(): void;
  10603. /**
  10604. * Execute the action and stop the animation.
  10605. */
  10606. execute(): void;
  10607. /**
  10608. * Serializes the actions and its related information.
  10609. * @param parent defines the object to serialize in
  10610. * @returns the serialized object
  10611. */
  10612. serialize(parent: any): any;
  10613. }
  10614. /**
  10615. * This defines an action responsible that does nothing once triggered.
  10616. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  10617. */
  10618. export class DoNothingAction extends Action {
  10619. /**
  10620. * Instantiate the action
  10621. * @param triggerOptions defines the trigger options
  10622. * @param condition defines the trigger related conditions
  10623. */
  10624. constructor(triggerOptions?: any, condition?: Condition);
  10625. /**
  10626. * Execute the action and do nothing.
  10627. */
  10628. execute(): void;
  10629. /**
  10630. * Serializes the actions and its related information.
  10631. * @param parent defines the object to serialize in
  10632. * @returns the serialized object
  10633. */
  10634. serialize(parent: any): any;
  10635. }
  10636. /**
  10637. * This defines an action responsible to trigger several actions once triggered.
  10638. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  10639. */
  10640. export class CombineAction extends Action {
  10641. /**
  10642. * The list of aggregated animations to run.
  10643. */
  10644. children: Action[];
  10645. /**
  10646. * Instantiate the action
  10647. * @param triggerOptions defines the trigger options
  10648. * @param children defines the list of aggregated animations to run
  10649. * @param condition defines the trigger related conditions
  10650. */
  10651. constructor(triggerOptions: any, children: Action[], condition?: Condition);
  10652. /** @hidden */
  10653. _prepare(): void;
  10654. /**
  10655. * Execute the action and executes all the aggregated actions.
  10656. */
  10657. execute(evt: ActionEvent): void;
  10658. /**
  10659. * Serializes the actions and its related information.
  10660. * @param parent defines the object to serialize in
  10661. * @returns the serialized object
  10662. */
  10663. serialize(parent: any): any;
  10664. }
  10665. /**
  10666. * This defines an action responsible to run code (external event) once triggered.
  10667. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  10668. */
  10669. export class ExecuteCodeAction extends Action {
  10670. /**
  10671. * The callback function to run.
  10672. */
  10673. func: (evt: ActionEvent) => void;
  10674. /**
  10675. * Instantiate the action
  10676. * @param triggerOptions defines the trigger options
  10677. * @param func defines the callback function to run
  10678. * @param condition defines the trigger related conditions
  10679. */
  10680. constructor(triggerOptions: any, func: (evt: ActionEvent) => void, condition?: Condition);
  10681. /**
  10682. * Execute the action and run the attached code.
  10683. */
  10684. execute(evt: ActionEvent): void;
  10685. }
  10686. /**
  10687. * This defines an action responsible to set the parent property of the target once triggered.
  10688. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  10689. */
  10690. export class SetParentAction extends Action {
  10691. private _parent;
  10692. private _target;
  10693. /**
  10694. * Instantiate the action
  10695. * @param triggerOptions defines the trigger options
  10696. * @param target defines the target containing the parent property
  10697. * @param parent defines from where the animation should start (animation frame)
  10698. * @param condition defines the trigger related conditions
  10699. */
  10700. constructor(triggerOptions: any, target: any, parent: any, condition?: Condition);
  10701. /** @hidden */
  10702. _prepare(): void;
  10703. /**
  10704. * Execute the action and set the parent property.
  10705. */
  10706. execute(): void;
  10707. /**
  10708. * Serializes the actions and its related information.
  10709. * @param parent defines the object to serialize in
  10710. * @returns the serialized object
  10711. */
  10712. serialize(parent: any): any;
  10713. }
  10714. }
  10715. declare module BABYLON {
  10716. /**
  10717. * Action Manager manages all events to be triggered on a given mesh or the global scene.
  10718. * A single scene can have many Action Managers to handle predefined actions on specific meshes.
  10719. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  10720. */
  10721. export class ActionManager extends AbstractActionManager {
  10722. /**
  10723. * Nothing
  10724. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10725. */
  10726. static readonly NothingTrigger: number;
  10727. /**
  10728. * On pick
  10729. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10730. */
  10731. static readonly OnPickTrigger: number;
  10732. /**
  10733. * On left pick
  10734. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10735. */
  10736. static readonly OnLeftPickTrigger: number;
  10737. /**
  10738. * On right pick
  10739. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10740. */
  10741. static readonly OnRightPickTrigger: number;
  10742. /**
  10743. * On center pick
  10744. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10745. */
  10746. static readonly OnCenterPickTrigger: number;
  10747. /**
  10748. * On pick down
  10749. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10750. */
  10751. static readonly OnPickDownTrigger: number;
  10752. /**
  10753. * On double pick
  10754. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10755. */
  10756. static readonly OnDoublePickTrigger: number;
  10757. /**
  10758. * On pick up
  10759. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10760. */
  10761. static readonly OnPickUpTrigger: number;
  10762. /**
  10763. * On pick out.
  10764. * This trigger will only be raised if you also declared a OnPickDown
  10765. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10766. */
  10767. static readonly OnPickOutTrigger: number;
  10768. /**
  10769. * On long press
  10770. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10771. */
  10772. static readonly OnLongPressTrigger: number;
  10773. /**
  10774. * On pointer over
  10775. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10776. */
  10777. static readonly OnPointerOverTrigger: number;
  10778. /**
  10779. * On pointer out
  10780. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10781. */
  10782. static readonly OnPointerOutTrigger: number;
  10783. /**
  10784. * On every frame
  10785. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10786. */
  10787. static readonly OnEveryFrameTrigger: number;
  10788. /**
  10789. * On intersection enter
  10790. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10791. */
  10792. static readonly OnIntersectionEnterTrigger: number;
  10793. /**
  10794. * On intersection exit
  10795. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10796. */
  10797. static readonly OnIntersectionExitTrigger: number;
  10798. /**
  10799. * On key down
  10800. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10801. */
  10802. static readonly OnKeyDownTrigger: number;
  10803. /**
  10804. * On key up
  10805. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10806. */
  10807. static readonly OnKeyUpTrigger: number;
  10808. private _scene;
  10809. /**
  10810. * Creates a new action manager
  10811. * @param scene defines the hosting scene
  10812. */
  10813. constructor(scene: Scene);
  10814. /**
  10815. * Releases all associated resources
  10816. */
  10817. dispose(): void;
  10818. /**
  10819. * Gets hosting scene
  10820. * @returns the hosting scene
  10821. */
  10822. getScene(): Scene;
  10823. /**
  10824. * Does this action manager handles actions of any of the given triggers
  10825. * @param triggers defines the triggers to be tested
  10826. * @return a boolean indicating whether one (or more) of the triggers is handled
  10827. */
  10828. hasSpecificTriggers(triggers: number[]): boolean;
  10829. /**
  10830. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  10831. * speed.
  10832. * @param triggerA defines the trigger to be tested
  10833. * @param triggerB defines the trigger to be tested
  10834. * @return a boolean indicating whether one (or more) of the triggers is handled
  10835. */
  10836. hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  10837. /**
  10838. * Does this action manager handles actions of a given trigger
  10839. * @param trigger defines the trigger to be tested
  10840. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  10841. * @return whether the trigger is handled
  10842. */
  10843. hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  10844. /**
  10845. * Does this action manager has pointer triggers
  10846. */
  10847. get hasPointerTriggers(): boolean;
  10848. /**
  10849. * Does this action manager has pick triggers
  10850. */
  10851. get hasPickTriggers(): boolean;
  10852. /**
  10853. * Registers an action to this action manager
  10854. * @param action defines the action to be registered
  10855. * @return the action amended (prepared) after registration
  10856. */
  10857. registerAction(action: IAction): Nullable<IAction>;
  10858. /**
  10859. * Unregisters an action to this action manager
  10860. * @param action defines the action to be unregistered
  10861. * @return a boolean indicating whether the action has been unregistered
  10862. */
  10863. unregisterAction(action: IAction): Boolean;
  10864. /**
  10865. * Process a specific trigger
  10866. * @param trigger defines the trigger to process
  10867. * @param evt defines the event details to be processed
  10868. */
  10869. processTrigger(trigger: number, evt?: IActionEvent): void;
  10870. /** @hidden */
  10871. _getEffectiveTarget(target: any, propertyPath: string): any;
  10872. /** @hidden */
  10873. _getProperty(propertyPath: string): string;
  10874. /**
  10875. * Serialize this manager to a JSON object
  10876. * @param name defines the property name to store this manager
  10877. * @returns a JSON representation of this manager
  10878. */
  10879. serialize(name: string): any;
  10880. /**
  10881. * Creates a new ActionManager from a JSON data
  10882. * @param parsedActions defines the JSON data to read from
  10883. * @param object defines the hosting mesh
  10884. * @param scene defines the hosting scene
  10885. */
  10886. static Parse(parsedActions: any, object: Nullable<AbstractMesh>, scene: Scene): void;
  10887. /**
  10888. * Get a trigger name by index
  10889. * @param trigger defines the trigger index
  10890. * @returns a trigger name
  10891. */
  10892. static GetTriggerName(trigger: number): string;
  10893. }
  10894. }
  10895. declare module BABYLON {
  10896. /**
  10897. * Class representing a ray with position and direction
  10898. */
  10899. export class Ray {
  10900. /** origin point */
  10901. origin: Vector3;
  10902. /** direction */
  10903. direction: Vector3;
  10904. /** length of the ray */
  10905. length: number;
  10906. private static readonly _TmpVector3;
  10907. private _tmpRay;
  10908. /**
  10909. * Creates a new ray
  10910. * @param origin origin point
  10911. * @param direction direction
  10912. * @param length length of the ray
  10913. */
  10914. constructor(
  10915. /** origin point */
  10916. origin: Vector3,
  10917. /** direction */
  10918. direction: Vector3,
  10919. /** length of the ray */
  10920. length?: number);
  10921. /**
  10922. * Checks if the ray intersects a box
  10923. * This does not account for the ray length by design to improve perfs.
  10924. * @param minimum bound of the box
  10925. * @param maximum bound of the box
  10926. * @param intersectionTreshold extra extend to be added to the box in all direction
  10927. * @returns if the box was hit
  10928. */
  10929. intersectsBoxMinMax(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, intersectionTreshold?: number): boolean;
  10930. /**
  10931. * Checks if the ray intersects a box
  10932. * This does not account for the ray lenght by design to improve perfs.
  10933. * @param box the bounding box to check
  10934. * @param intersectionTreshold extra extend to be added to the BoundingBox in all direction
  10935. * @returns if the box was hit
  10936. */
  10937. intersectsBox(box: DeepImmutable<BoundingBox>, intersectionTreshold?: number): boolean;
  10938. /**
  10939. * If the ray hits a sphere
  10940. * @param sphere the bounding sphere to check
  10941. * @param intersectionTreshold extra extend to be added to the BoundingSphere in all direction
  10942. * @returns true if it hits the sphere
  10943. */
  10944. intersectsSphere(sphere: DeepImmutable<BoundingSphere>, intersectionTreshold?: number): boolean;
  10945. /**
  10946. * If the ray hits a triange
  10947. * @param vertex0 triangle vertex
  10948. * @param vertex1 triangle vertex
  10949. * @param vertex2 triangle vertex
  10950. * @returns intersection information if hit
  10951. */
  10952. intersectsTriangle(vertex0: DeepImmutable<Vector3>, vertex1: DeepImmutable<Vector3>, vertex2: DeepImmutable<Vector3>): Nullable<IntersectionInfo>;
  10953. /**
  10954. * Checks if ray intersects a plane
  10955. * @param plane the plane to check
  10956. * @returns the distance away it was hit
  10957. */
  10958. intersectsPlane(plane: DeepImmutable<Plane>): Nullable<number>;
  10959. /**
  10960. * Calculate the intercept of a ray on a given axis
  10961. * @param axis to check 'x' | 'y' | 'z'
  10962. * @param offset from axis interception (i.e. an offset of 1y is intercepted above ground)
  10963. * @returns a vector containing the coordinates where 'axis' is equal to zero (else offset), or null if there is no intercept.
  10964. */
  10965. intersectsAxis(axis: string, offset?: number): Nullable<Vector3>;
  10966. /**
  10967. * Checks if ray intersects a mesh
  10968. * @param mesh the mesh to check
  10969. * @param fastCheck defines if the first intersection will be used (and not the closest)
  10970. * @returns picking info of the intersection
  10971. */
  10972. intersectsMesh(mesh: DeepImmutable<AbstractMesh>, fastCheck?: boolean): PickingInfo;
  10973. /**
  10974. * Checks if ray intersects a mesh
  10975. * @param meshes the meshes to check
  10976. * @param fastCheck defines if the first intersection will be used (and not the closest)
  10977. * @param results array to store result in
  10978. * @returns Array of picking infos
  10979. */
  10980. intersectsMeshes(meshes: Array<DeepImmutable<AbstractMesh>>, fastCheck?: boolean, results?: Array<PickingInfo>): Array<PickingInfo>;
  10981. private _comparePickingInfo;
  10982. private static smallnum;
  10983. private static rayl;
  10984. /**
  10985. * Intersection test between the ray and a given segment within a given tolerance (threshold)
  10986. * @param sega the first point of the segment to test the intersection against
  10987. * @param segb the second point of the segment to test the intersection against
  10988. * @param threshold the tolerance margin, if the ray doesn't intersect the segment but is close to the given threshold, the intersection is successful
  10989. * @return the distance from the ray origin to the intersection point if there's intersection, or -1 if there's no intersection
  10990. */
  10991. intersectionSegment(sega: DeepImmutable<Vector3>, segb: DeepImmutable<Vector3>, threshold: number): number;
  10992. /**
  10993. * Update the ray from viewport position
  10994. * @param x position
  10995. * @param y y position
  10996. * @param viewportWidth viewport width
  10997. * @param viewportHeight viewport height
  10998. * @param world world matrix
  10999. * @param view view matrix
  11000. * @param projection projection matrix
  11001. * @returns this ray updated
  11002. */
  11003. update(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  11004. /**
  11005. * Creates a ray with origin and direction of 0,0,0
  11006. * @returns the new ray
  11007. */
  11008. static Zero(): Ray;
  11009. /**
  11010. * Creates a new ray from screen space and viewport
  11011. * @param x position
  11012. * @param y y position
  11013. * @param viewportWidth viewport width
  11014. * @param viewportHeight viewport height
  11015. * @param world world matrix
  11016. * @param view view matrix
  11017. * @param projection projection matrix
  11018. * @returns new ray
  11019. */
  11020. static CreateNew(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  11021. /**
  11022. * 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
  11023. * transformed to the given world matrix.
  11024. * @param origin The origin point
  11025. * @param end The end point
  11026. * @param world a matrix to transform the ray to. Default is the identity matrix.
  11027. * @returns the new ray
  11028. */
  11029. static CreateNewFromTo(origin: Vector3, end: Vector3, world?: DeepImmutable<Matrix>): Ray;
  11030. /**
  11031. * Transforms a ray by a matrix
  11032. * @param ray ray to transform
  11033. * @param matrix matrix to apply
  11034. * @returns the resulting new ray
  11035. */
  11036. static Transform(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>): Ray;
  11037. /**
  11038. * Transforms a ray by a matrix
  11039. * @param ray ray to transform
  11040. * @param matrix matrix to apply
  11041. * @param result ray to store result in
  11042. */
  11043. static TransformToRef(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>, result: Ray): void;
  11044. /**
  11045. * Unproject a ray from screen space to object space
  11046. * @param sourceX defines the screen space x coordinate to use
  11047. * @param sourceY defines the screen space y coordinate to use
  11048. * @param viewportWidth defines the current width of the viewport
  11049. * @param viewportHeight defines the current height of the viewport
  11050. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  11051. * @param view defines the view matrix to use
  11052. * @param projection defines the projection matrix to use
  11053. */
  11054. unprojectRayToRef(sourceX: float, sourceY: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): void;
  11055. }
  11056. /**
  11057. * Type used to define predicate used to select faces when a mesh intersection is detected
  11058. */
  11059. export type TrianglePickingPredicate = (p0: Vector3, p1: Vector3, p2: Vector3, ray: Ray) => boolean;
  11060. interface Scene {
  11061. /** @hidden */
  11062. _tempPickingRay: Nullable<Ray>;
  11063. /** @hidden */
  11064. _cachedRayForTransform: Ray;
  11065. /** @hidden */
  11066. _pickWithRayInverseMatrix: Matrix;
  11067. /** @hidden */
  11068. _internalPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, onlyBoundingInfo?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  11069. /** @hidden */
  11070. _internalMultiPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  11071. /** @hidden */
  11072. _internalPickForMesh(pickingInfo: Nullable<PickingInfo>, rayFunction: (world: Matrix) => Ray, mesh: AbstractMesh, world: Matrix, fastCheck?: boolean, onlyBoundingInfo?: boolean, trianglePredicate?: TrianglePickingPredicate, skipBoundingInfo?: boolean): Nullable<PickingInfo>;
  11073. }
  11074. }
  11075. declare module BABYLON {
  11076. /**
  11077. * Groups all the scene component constants in one place to ease maintenance.
  11078. * @hidden
  11079. */
  11080. export class SceneComponentConstants {
  11081. static readonly NAME_EFFECTLAYER: string;
  11082. static readonly NAME_LAYER: string;
  11083. static readonly NAME_LENSFLARESYSTEM: string;
  11084. static readonly NAME_BOUNDINGBOXRENDERER: string;
  11085. static readonly NAME_PARTICLESYSTEM: string;
  11086. static readonly NAME_GAMEPAD: string;
  11087. static readonly NAME_SIMPLIFICATIONQUEUE: string;
  11088. static readonly NAME_GEOMETRYBUFFERRENDERER: string;
  11089. static readonly NAME_PREPASSRENDERER: string;
  11090. static readonly NAME_DEPTHRENDERER: string;
  11091. static readonly NAME_POSTPROCESSRENDERPIPELINEMANAGER: string;
  11092. static readonly NAME_SPRITE: string;
  11093. static readonly NAME_SUBSURFACE: string;
  11094. static readonly NAME_OUTLINERENDERER: string;
  11095. static readonly NAME_PROCEDURALTEXTURE: string;
  11096. static readonly NAME_SHADOWGENERATOR: string;
  11097. static readonly NAME_OCTREE: string;
  11098. static readonly NAME_PHYSICSENGINE: string;
  11099. static readonly NAME_AUDIO: string;
  11100. static readonly STEP_ISREADYFORMESH_EFFECTLAYER: number;
  11101. static readonly STEP_BEFOREEVALUATEACTIVEMESH_BOUNDINGBOXRENDERER: number;
  11102. static readonly STEP_EVALUATESUBMESH_BOUNDINGBOXRENDERER: number;
  11103. static readonly STEP_PREACTIVEMESH_BOUNDINGBOXRENDERER: number;
  11104. static readonly STEP_CAMERADRAWRENDERTARGET_EFFECTLAYER: number;
  11105. static readonly STEP_BEFORECAMERADRAW_PREPASS: number;
  11106. static readonly STEP_BEFORECAMERADRAW_EFFECTLAYER: number;
  11107. static readonly STEP_BEFORECAMERADRAW_LAYER: number;
  11108. static readonly STEP_BEFORERENDERTARGETDRAW_PREPASS: number;
  11109. static readonly STEP_BEFORERENDERTARGETDRAW_LAYER: number;
  11110. static readonly STEP_BEFORERENDERINGMESH_PREPASS: number;
  11111. static readonly STEP_BEFORERENDERINGMESH_OUTLINE: number;
  11112. static readonly STEP_AFTERRENDERINGMESH_PREPASS: number;
  11113. static readonly STEP_AFTERRENDERINGMESH_OUTLINE: number;
  11114. static readonly STEP_AFTERRENDERINGGROUPDRAW_EFFECTLAYER_DRAW: number;
  11115. static readonly STEP_AFTERRENDERINGGROUPDRAW_BOUNDINGBOXRENDERER: number;
  11116. static readonly STEP_BEFORECAMERAUPDATE_SIMPLIFICATIONQUEUE: number;
  11117. static readonly STEP_BEFORECAMERAUPDATE_GAMEPAD: number;
  11118. static readonly STEP_BEFORECLEAR_PROCEDURALTEXTURE: number;
  11119. static readonly STEP_AFTERRENDERTARGETDRAW_PREPASS: number;
  11120. static readonly STEP_AFTERRENDERTARGETDRAW_LAYER: number;
  11121. static readonly STEP_AFTERCAMERADRAW_PREPASS: number;
  11122. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER: number;
  11123. static readonly STEP_AFTERCAMERADRAW_LENSFLARESYSTEM: number;
  11124. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER_DRAW: number;
  11125. static readonly STEP_AFTERCAMERADRAW_LAYER: number;
  11126. static readonly STEP_AFTERRENDER_AUDIO: number;
  11127. static readonly STEP_GATHERRENDERTARGETS_DEPTHRENDERER: number;
  11128. static readonly STEP_GATHERRENDERTARGETS_GEOMETRYBUFFERRENDERER: number;
  11129. static readonly STEP_GATHERRENDERTARGETS_SHADOWGENERATOR: number;
  11130. static readonly STEP_GATHERRENDERTARGETS_POSTPROCESSRENDERPIPELINEMANAGER: number;
  11131. static readonly STEP_GATHERACTIVECAMERARENDERTARGETS_DEPTHRENDERER: number;
  11132. static readonly STEP_BEFORECLEARSTAGE_PREPASS: number;
  11133. static readonly STEP_BEFORERENDERTARGETCLEARSTAGE_PREPASS: number;
  11134. static readonly STEP_POINTERMOVE_SPRITE: number;
  11135. static readonly STEP_POINTERDOWN_SPRITE: number;
  11136. static readonly STEP_POINTERUP_SPRITE: number;
  11137. }
  11138. /**
  11139. * This represents a scene component.
  11140. *
  11141. * This is used to decouple the dependency the scene is having on the different workloads like
  11142. * layers, post processes...
  11143. */
  11144. export interface ISceneComponent {
  11145. /**
  11146. * The name of the component. Each component must have a unique name.
  11147. */
  11148. name: string;
  11149. /**
  11150. * The scene the component belongs to.
  11151. */
  11152. scene: Scene;
  11153. /**
  11154. * Register the component to one instance of a scene.
  11155. */
  11156. register(): void;
  11157. /**
  11158. * Rebuilds the elements related to this component in case of
  11159. * context lost for instance.
  11160. */
  11161. rebuild(): void;
  11162. /**
  11163. * Disposes the component and the associated ressources.
  11164. */
  11165. dispose(): void;
  11166. }
  11167. /**
  11168. * This represents a SERIALIZABLE scene component.
  11169. *
  11170. * This extends Scene Component to add Serialization methods on top.
  11171. */
  11172. export interface ISceneSerializableComponent extends ISceneComponent {
  11173. /**
  11174. * Adds all the elements from the container to the scene
  11175. * @param container the container holding the elements
  11176. */
  11177. addFromContainer(container: AbstractScene): void;
  11178. /**
  11179. * Removes all the elements in the container from the scene
  11180. * @param container contains the elements to remove
  11181. * @param dispose if the removed element should be disposed (default: false)
  11182. */
  11183. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  11184. /**
  11185. * Serializes the component data to the specified json object
  11186. * @param serializationObject The object to serialize to
  11187. */
  11188. serialize(serializationObject: any): void;
  11189. }
  11190. /**
  11191. * Strong typing of a Mesh related stage step action
  11192. */
  11193. export type MeshStageAction = (mesh: AbstractMesh, hardwareInstancedRendering: boolean) => boolean;
  11194. /**
  11195. * Strong typing of a Evaluate Sub Mesh related stage step action
  11196. */
  11197. export type EvaluateSubMeshStageAction = (mesh: AbstractMesh, subMesh: SubMesh) => void;
  11198. /**
  11199. * Strong typing of a pre active Mesh related stage step action
  11200. */
  11201. export type PreActiveMeshStageAction = (mesh: AbstractMesh) => void;
  11202. /**
  11203. * Strong typing of a Camera related stage step action
  11204. */
  11205. export type CameraStageAction = (camera: Camera) => void;
  11206. /**
  11207. * Strong typing of a Camera Frame buffer related stage step action
  11208. */
  11209. export type CameraStageFrameBufferAction = (camera: Camera) => boolean;
  11210. /**
  11211. * Strong typing of a Render Target related stage step action
  11212. */
  11213. export type RenderTargetStageAction = (renderTarget: RenderTargetTexture, faceIndex?: number, layer?: number) => void;
  11214. /**
  11215. * Strong typing of a RenderingGroup related stage step action
  11216. */
  11217. export type RenderingGroupStageAction = (renderingGroupId: number) => void;
  11218. /**
  11219. * Strong typing of a Mesh Render related stage step action
  11220. */
  11221. export type RenderingMeshStageAction = (mesh: Mesh, subMesh: SubMesh, batch: _InstancesBatch, effect: Nullable<Effect>) => void;
  11222. /**
  11223. * Strong typing of a simple stage step action
  11224. */
  11225. export type SimpleStageAction = () => void;
  11226. /**
  11227. * Strong typing of a render target action.
  11228. */
  11229. export type RenderTargetsStageAction = (renderTargets: SmartArrayNoDuplicate<RenderTargetTexture>) => void;
  11230. /**
  11231. * Strong typing of a pointer move action.
  11232. */
  11233. export type PointerMoveStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, isMeshPicked: boolean, element: HTMLElement) => Nullable<PickingInfo>;
  11234. /**
  11235. * Strong typing of a pointer up/down action.
  11236. */
  11237. export type PointerUpDownStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, evt: PointerEvent) => Nullable<PickingInfo>;
  11238. /**
  11239. * Representation of a stage in the scene (Basically a list of ordered steps)
  11240. * @hidden
  11241. */
  11242. export class Stage<T extends Function> extends Array<{
  11243. index: number;
  11244. component: ISceneComponent;
  11245. action: T;
  11246. }> {
  11247. /**
  11248. * Hide ctor from the rest of the world.
  11249. * @param items The items to add.
  11250. */
  11251. private constructor();
  11252. /**
  11253. * Creates a new Stage.
  11254. * @returns A new instance of a Stage
  11255. */
  11256. static Create<T extends Function>(): Stage<T>;
  11257. /**
  11258. * Registers a step in an ordered way in the targeted stage.
  11259. * @param index Defines the position to register the step in
  11260. * @param component Defines the component attached to the step
  11261. * @param action Defines the action to launch during the step
  11262. */
  11263. registerStep(index: number, component: ISceneComponent, action: T): void;
  11264. /**
  11265. * Clears all the steps from the stage.
  11266. */
  11267. clear(): void;
  11268. }
  11269. }
  11270. declare module BABYLON {
  11271. interface Scene {
  11272. /** @hidden */
  11273. _pointerOverSprite: Nullable<Sprite>;
  11274. /** @hidden */
  11275. _pickedDownSprite: Nullable<Sprite>;
  11276. /** @hidden */
  11277. _tempSpritePickingRay: Nullable<Ray>;
  11278. /**
  11279. * All of the sprite managers added to this scene
  11280. * @see https://doc.babylonjs.com/babylon101/sprites
  11281. */
  11282. spriteManagers: Array<ISpriteManager>;
  11283. /**
  11284. * An event triggered when sprites rendering is about to start
  11285. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  11286. */
  11287. onBeforeSpritesRenderingObservable: Observable<Scene>;
  11288. /**
  11289. * An event triggered when sprites rendering is done
  11290. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  11291. */
  11292. onAfterSpritesRenderingObservable: Observable<Scene>;
  11293. /** @hidden */
  11294. _internalPickSprites(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  11295. /** Launch a ray to try to pick a sprite in the scene
  11296. * @param x position on screen
  11297. * @param y position on screen
  11298. * @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
  11299. * @param fastCheck defines if the first intersection will be used (and not the closest)
  11300. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  11301. * @returns a PickingInfo
  11302. */
  11303. pickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  11304. /** Use the given ray to pick a sprite in the scene
  11305. * @param ray The ray (in world space) to use to pick meshes
  11306. * @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
  11307. * @param fastCheck defines if the first intersection will be used (and not the closest)
  11308. * @param camera camera to use. Can be set to null. In this case, the scene.activeCamera will be used
  11309. * @returns a PickingInfo
  11310. */
  11311. pickSpriteWithRay(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  11312. /** @hidden */
  11313. _internalMultiPickSprites(ray: Ray, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  11314. /** Launch a ray to try to pick sprites in the scene
  11315. * @param x position on screen
  11316. * @param y position on screen
  11317. * @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
  11318. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  11319. * @returns a PickingInfo array
  11320. */
  11321. multiPickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  11322. /** Use the given ray to pick sprites in the scene
  11323. * @param ray The ray (in world space) to use to pick meshes
  11324. * @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
  11325. * @param camera camera to use. Can be set to null. In this case, the scene.activeCamera will be used
  11326. * @returns a PickingInfo array
  11327. */
  11328. multiPickSpriteWithRay(ray: Ray, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  11329. /**
  11330. * Force the sprite under the pointer
  11331. * @param sprite defines the sprite to use
  11332. */
  11333. setPointerOverSprite(sprite: Nullable<Sprite>): void;
  11334. /**
  11335. * Gets the sprite under the pointer
  11336. * @returns a Sprite or null if no sprite is under the pointer
  11337. */
  11338. getPointerOverSprite(): Nullable<Sprite>;
  11339. }
  11340. /**
  11341. * Defines the sprite scene component responsible to manage sprites
  11342. * in a given scene.
  11343. */
  11344. export class SpriteSceneComponent implements ISceneComponent {
  11345. /**
  11346. * The component name helpfull to identify the component in the list of scene components.
  11347. */
  11348. readonly name: string;
  11349. /**
  11350. * The scene the component belongs to.
  11351. */
  11352. scene: Scene;
  11353. /** @hidden */
  11354. private _spritePredicate;
  11355. /**
  11356. * Creates a new instance of the component for the given scene
  11357. * @param scene Defines the scene to register the component in
  11358. */
  11359. constructor(scene: Scene);
  11360. /**
  11361. * Registers the component in a given scene
  11362. */
  11363. register(): void;
  11364. /**
  11365. * Rebuilds the elements related to this component in case of
  11366. * context lost for instance.
  11367. */
  11368. rebuild(): void;
  11369. /**
  11370. * Disposes the component and the associated ressources.
  11371. */
  11372. dispose(): void;
  11373. private _pickSpriteButKeepRay;
  11374. private _pointerMove;
  11375. private _pointerDown;
  11376. private _pointerUp;
  11377. }
  11378. }
  11379. declare module BABYLON {
  11380. /**
  11381. * Class used to provide helper for timing
  11382. */
  11383. export class TimingTools {
  11384. /**
  11385. * Polyfill for setImmediate
  11386. * @param action defines the action to execute after the current execution block
  11387. */
  11388. static SetImmediate(action: () => void): void;
  11389. }
  11390. }
  11391. declare module BABYLON {
  11392. /**
  11393. * Class used to enable instantiation of objects by class name
  11394. */
  11395. export class InstantiationTools {
  11396. /**
  11397. * Use this object to register external classes like custom textures or material
  11398. * to allow the loaders to instantiate them
  11399. */
  11400. static RegisteredExternalClasses: {
  11401. [key: string]: Object;
  11402. };
  11403. /**
  11404. * Tries to instantiate a new object from a given class name
  11405. * @param className defines the class name to instantiate
  11406. * @returns the new object or null if the system was not able to do the instantiation
  11407. */
  11408. static Instantiate(className: string): any;
  11409. }
  11410. }
  11411. declare module BABYLON {
  11412. /**
  11413. * Class used to host copy specific utilities
  11414. */
  11415. export class CopyTools {
  11416. /**
  11417. * Transform some pixel data to a base64 string
  11418. * @param pixels defines the pixel data to transform to base64
  11419. * @param size defines the width and height of the (texture) data
  11420. * @param invertY true if the data must be inverted for the Y coordinate during the conversion
  11421. * @returns The base64 encoded string or null
  11422. */
  11423. static GenerateBase64StringFromPixelData(pixels: ArrayBufferView, size: ISize, invertY?: boolean): Nullable<string>;
  11424. /**
  11425. * Reads the pixels stored in the webgl texture and returns them as a base64 string
  11426. * @param texture defines the texture to read pixels from
  11427. * @param faceIndex defines the face of the texture to read (in case of cube texture)
  11428. * @param level defines the LOD level of the texture to read (in case of Mip Maps)
  11429. * @returns The base64 encoded string or null
  11430. */
  11431. static GenerateBase64StringFromTexture(texture: BaseTexture, faceIndex?: number, level?: number): Nullable<string>;
  11432. /**
  11433. * Reads the pixels stored in the webgl texture and returns them as a base64 string
  11434. * @param texture defines the texture to read pixels from
  11435. * @param faceIndex defines the face of the texture to read (in case of cube texture)
  11436. * @param level defines the LOD level of the texture to read (in case of Mip Maps)
  11437. * @returns The base64 encoded string or null wrapped in a promise
  11438. */
  11439. static GenerateBase64StringFromTextureAsync(texture: BaseTexture, faceIndex?: number, level?: number): Promise<Nullable<string>>;
  11440. }
  11441. }
  11442. declare module BABYLON {
  11443. /**
  11444. * Define options used to create a depth texture
  11445. */
  11446. export class DepthTextureCreationOptions {
  11447. /** Specifies whether or not a stencil should be allocated in the texture */
  11448. generateStencil?: boolean;
  11449. /** Specifies whether or not bilinear filtering is enable on the texture */
  11450. bilinearFiltering?: boolean;
  11451. /** Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode */
  11452. comparisonFunction?: number;
  11453. /** Specifies if the created texture is a cube texture */
  11454. isCube?: boolean;
  11455. /** Specifies the sample count of the depth/stencil texture texture */
  11456. samples?: number;
  11457. }
  11458. }
  11459. declare module BABYLON {
  11460. interface ThinEngine {
  11461. /**
  11462. * Creates a depth stencil cube texture.
  11463. * This is only available in WebGL 2.
  11464. * @param size The size of face edge in the cube texture.
  11465. * @param options The options defining the cube texture.
  11466. * @returns The cube texture
  11467. */
  11468. _createDepthStencilCubeTexture(size: number, options: DepthTextureCreationOptions): InternalTexture;
  11469. /**
  11470. * Creates a cube texture
  11471. * @param rootUrl defines the url where the files to load is located
  11472. * @param scene defines the current scene
  11473. * @param files defines the list of files to load (1 per face)
  11474. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  11475. * @param onLoad defines an optional callback raised when the texture is loaded
  11476. * @param onError defines an optional callback raised if there is an issue to load the texture
  11477. * @param format defines the format of the data
  11478. * @param forcedExtension defines the extension to use to pick the right loader
  11479. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  11480. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  11481. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  11482. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  11483. * @param loaderOptions options to be passed to the loader
  11484. * @returns the cube texture as an InternalTexture
  11485. */
  11486. 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;
  11487. /**
  11488. * Creates a cube texture
  11489. * @param rootUrl defines the url where the files to load is located
  11490. * @param scene defines the current scene
  11491. * @param files defines the list of files to load (1 per face)
  11492. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  11493. * @param onLoad defines an optional callback raised when the texture is loaded
  11494. * @param onError defines an optional callback raised if there is an issue to load the texture
  11495. * @param format defines the format of the data
  11496. * @param forcedExtension defines the extension to use to pick the right loader
  11497. * @returns the cube texture as an InternalTexture
  11498. */
  11499. 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;
  11500. /**
  11501. * Creates a cube texture
  11502. * @param rootUrl defines the url where the files to load is located
  11503. * @param scene defines the current scene
  11504. * @param files defines the list of files to load (1 per face)
  11505. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  11506. * @param onLoad defines an optional callback raised when the texture is loaded
  11507. * @param onError defines an optional callback raised if there is an issue to load the texture
  11508. * @param format defines the format of the data
  11509. * @param forcedExtension defines the extension to use to pick the right loader
  11510. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  11511. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  11512. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  11513. * @returns the cube texture as an InternalTexture
  11514. */
  11515. 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;
  11516. /** @hidden */
  11517. 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;
  11518. /** @hidden */
  11519. _partialLoadFile(url: string, index: number, loadedFiles: ArrayBuffer[], onfinish: (files: ArrayBuffer[]) => void, onErrorCallBack: Nullable<(message?: string, exception?: any) => void>): void;
  11520. /** @hidden */
  11521. _cascadeLoadFiles(scene: Nullable<Scene>, onfinish: (images: ArrayBuffer[]) => void, files: string[], onError: Nullable<(message?: string, exception?: any) => void>): void;
  11522. /** @hidden */
  11523. _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;
  11524. /** @hidden */
  11525. _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;
  11526. /**
  11527. * @hidden
  11528. */
  11529. _setCubeMapTextureParams(texture: InternalTexture, loadMipmap: boolean): void;
  11530. }
  11531. }
  11532. declare module BABYLON {
  11533. /**
  11534. * Class for creating a cube texture
  11535. */
  11536. export class CubeTexture extends BaseTexture {
  11537. private _delayedOnLoad;
  11538. /**
  11539. * Observable triggered once the texture has been loaded.
  11540. */
  11541. onLoadObservable: Observable<CubeTexture>;
  11542. /**
  11543. * The url of the texture
  11544. */
  11545. url: string;
  11546. /**
  11547. * Gets or sets the center of the bounding box associated with the cube texture.
  11548. * It must define where the camera used to render the texture was set
  11549. * @see https://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  11550. */
  11551. boundingBoxPosition: Vector3;
  11552. private _boundingBoxSize;
  11553. /**
  11554. * Gets or sets the size of the bounding box associated with the cube texture
  11555. * When defined, the cubemap will switch to local mode
  11556. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  11557. * @example https://www.babylonjs-playground.com/#RNASML
  11558. */
  11559. set boundingBoxSize(value: Vector3);
  11560. /**
  11561. * Returns the bounding box size
  11562. * @see https://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  11563. */
  11564. get boundingBoxSize(): Vector3;
  11565. protected _rotationY: number;
  11566. /**
  11567. * Sets texture matrix rotation angle around Y axis in radians.
  11568. */
  11569. set rotationY(value: number);
  11570. /**
  11571. * Gets texture matrix rotation angle around Y axis radians.
  11572. */
  11573. get rotationY(): number;
  11574. /**
  11575. * Are mip maps generated for this texture or not.
  11576. */
  11577. get noMipmap(): boolean;
  11578. private _noMipmap;
  11579. private _files;
  11580. protected _forcedExtension: Nullable<string>;
  11581. private _extensions;
  11582. private _textureMatrix;
  11583. private _format;
  11584. private _createPolynomials;
  11585. private _loaderOptions;
  11586. /**
  11587. * Creates a cube texture from an array of image urls
  11588. * @param files defines an array of image urls
  11589. * @param scene defines the hosting scene
  11590. * @param noMipmap specifies if mip maps are not used
  11591. * @returns a cube texture
  11592. */
  11593. static CreateFromImages(files: string[], scene: Scene, noMipmap?: boolean): CubeTexture;
  11594. /**
  11595. * Creates and return a texture created from prefilterd data by tools like IBL Baker or Lys.
  11596. * @param url defines the url of the prefiltered texture
  11597. * @param scene defines the scene the texture is attached to
  11598. * @param forcedExtension defines the extension of the file if different from the url
  11599. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  11600. * @return the prefiltered texture
  11601. */
  11602. static CreateFromPrefilteredData(url: string, scene: Scene, forcedExtension?: any, createPolynomials?: boolean): CubeTexture;
  11603. /**
  11604. * Creates a cube texture to use with reflection for instance. It can be based upon dds or six images as well
  11605. * as prefiltered data.
  11606. * @param rootUrl defines the url of the texture or the root name of the six images
  11607. * @param null defines the scene or engine the texture is attached to
  11608. * @param extensions defines the suffixes add to the picture name in case six images are in use like _px.jpg...
  11609. * @param noMipmap defines if mipmaps should be created or not
  11610. * @param files defines the six files to load for the different faces in that order: px, py, pz, nx, ny, nz
  11611. * @param onLoad defines a callback triggered at the end of the file load if no errors occurred
  11612. * @param onError defines a callback triggered in case of error during load
  11613. * @param format defines the internal format to use for the texture once loaded
  11614. * @param prefiltered defines whether or not the texture is created from prefiltered data
  11615. * @param forcedExtension defines the extensions to use (force a special type of file to load) in case it is different from the file name
  11616. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  11617. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  11618. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  11619. * @param loaderOptions options to be passed to the loader
  11620. * @return the cube texture
  11621. */
  11622. 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);
  11623. /**
  11624. * Get the current class name of the texture useful for serialization or dynamic coding.
  11625. * @returns "CubeTexture"
  11626. */
  11627. getClassName(): string;
  11628. /**
  11629. * Update the url (and optional buffer) of this texture if url was null during construction.
  11630. * @param url the url of the texture
  11631. * @param forcedExtension defines the extension to use
  11632. * @param onLoad callback called when the texture is loaded (defaults to null)
  11633. * @param prefiltered Defines whether the updated texture is prefiltered or not
  11634. */
  11635. updateURL(url: string, forcedExtension?: string, onLoad?: () => void, prefiltered?: boolean): void;
  11636. /**
  11637. * Delays loading of the cube texture
  11638. * @param forcedExtension defines the extension to use
  11639. */
  11640. delayLoad(forcedExtension?: string): void;
  11641. /**
  11642. * Returns the reflection texture matrix
  11643. * @returns the reflection texture matrix
  11644. */
  11645. getReflectionTextureMatrix(): Matrix;
  11646. /**
  11647. * Sets the reflection texture matrix
  11648. * @param value Reflection texture matrix
  11649. */
  11650. setReflectionTextureMatrix(value: Matrix): void;
  11651. /**
  11652. * Parses text to create a cube texture
  11653. * @param parsedTexture define the serialized text to read from
  11654. * @param scene defines the hosting scene
  11655. * @param rootUrl defines the root url of the cube texture
  11656. * @returns a cube texture
  11657. */
  11658. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): CubeTexture;
  11659. /**
  11660. * Makes a clone, or deep copy, of the cube texture
  11661. * @returns a new cube texture
  11662. */
  11663. clone(): CubeTexture;
  11664. }
  11665. }
  11666. declare module BABYLON {
  11667. /**
  11668. * The color grading curves provide additional color adjustment that is applied after any color grading transform (3D LUT).
  11669. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  11670. * 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;
  11671. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  11672. */
  11673. export class ColorCurves {
  11674. private _dirty;
  11675. private _tempColor;
  11676. private _globalCurve;
  11677. private _highlightsCurve;
  11678. private _midtonesCurve;
  11679. private _shadowsCurve;
  11680. private _positiveCurve;
  11681. private _negativeCurve;
  11682. private _globalHue;
  11683. private _globalDensity;
  11684. private _globalSaturation;
  11685. private _globalExposure;
  11686. /**
  11687. * Gets the global Hue value.
  11688. * 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).
  11689. */
  11690. get globalHue(): number;
  11691. /**
  11692. * Sets the global Hue value.
  11693. * 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).
  11694. */
  11695. set globalHue(value: number);
  11696. /**
  11697. * Gets the global Density value.
  11698. * 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.
  11699. * Values less than zero provide a filter of opposite hue.
  11700. */
  11701. get globalDensity(): number;
  11702. /**
  11703. * Sets the global Density value.
  11704. * The density value is in range [-100,+100] where 0 means the color filter has no effect and +100 means the color filter has maximum effect.
  11705. * Values less than zero provide a filter of opposite hue.
  11706. */
  11707. set globalDensity(value: number);
  11708. /**
  11709. * Gets the global Saturation value.
  11710. * 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.
  11711. */
  11712. get globalSaturation(): number;
  11713. /**
  11714. * Sets the global Saturation value.
  11715. * 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.
  11716. */
  11717. set globalSaturation(value: number);
  11718. /**
  11719. * Gets the global Exposure value.
  11720. * 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.
  11721. */
  11722. get globalExposure(): number;
  11723. /**
  11724. * Sets the global Exposure value.
  11725. * 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.
  11726. */
  11727. set globalExposure(value: number);
  11728. private _highlightsHue;
  11729. private _highlightsDensity;
  11730. private _highlightsSaturation;
  11731. private _highlightsExposure;
  11732. /**
  11733. * Gets the highlights Hue value.
  11734. * 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).
  11735. */
  11736. get highlightsHue(): number;
  11737. /**
  11738. * Sets the highlights Hue value.
  11739. * 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).
  11740. */
  11741. set highlightsHue(value: number);
  11742. /**
  11743. * Gets the highlights Density value.
  11744. * 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.
  11745. * Values less than zero provide a filter of opposite hue.
  11746. */
  11747. get highlightsDensity(): number;
  11748. /**
  11749. * Sets the highlights Density value.
  11750. * The density value is in range [-100,+100] where 0 means the color filter has no effect and +100 means the color filter has maximum effect.
  11751. * Values less than zero provide a filter of opposite hue.
  11752. */
  11753. set highlightsDensity(value: number);
  11754. /**
  11755. * Gets the highlights Saturation value.
  11756. * 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.
  11757. */
  11758. get highlightsSaturation(): number;
  11759. /**
  11760. * Sets the highlights Saturation value.
  11761. * 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.
  11762. */
  11763. set highlightsSaturation(value: number);
  11764. /**
  11765. * Gets the highlights Exposure value.
  11766. * 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.
  11767. */
  11768. get highlightsExposure(): number;
  11769. /**
  11770. * Sets the highlights Exposure value.
  11771. * 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.
  11772. */
  11773. set highlightsExposure(value: number);
  11774. private _midtonesHue;
  11775. private _midtonesDensity;
  11776. private _midtonesSaturation;
  11777. private _midtonesExposure;
  11778. /**
  11779. * Gets the midtones Hue value.
  11780. * 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).
  11781. */
  11782. get midtonesHue(): number;
  11783. /**
  11784. * Sets the midtones Hue value.
  11785. * 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).
  11786. */
  11787. set midtonesHue(value: number);
  11788. /**
  11789. * Gets the midtones Density value.
  11790. * 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.
  11791. * Values less than zero provide a filter of opposite hue.
  11792. */
  11793. get midtonesDensity(): number;
  11794. /**
  11795. * Sets the midtones Density value.
  11796. * The density value is in range [-100,+100] where 0 means the color filter has no effect and +100 means the color filter has maximum effect.
  11797. * Values less than zero provide a filter of opposite hue.
  11798. */
  11799. set midtonesDensity(value: number);
  11800. /**
  11801. * Gets the midtones Saturation value.
  11802. * 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.
  11803. */
  11804. get midtonesSaturation(): number;
  11805. /**
  11806. * Sets the midtones Saturation value.
  11807. * 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.
  11808. */
  11809. set midtonesSaturation(value: number);
  11810. /**
  11811. * Gets the midtones Exposure value.
  11812. * 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.
  11813. */
  11814. get midtonesExposure(): number;
  11815. /**
  11816. * Sets the midtones Exposure value.
  11817. * 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.
  11818. */
  11819. set midtonesExposure(value: number);
  11820. private _shadowsHue;
  11821. private _shadowsDensity;
  11822. private _shadowsSaturation;
  11823. private _shadowsExposure;
  11824. /**
  11825. * Gets the shadows Hue value.
  11826. * 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).
  11827. */
  11828. get shadowsHue(): number;
  11829. /**
  11830. * Sets the shadows Hue value.
  11831. * 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).
  11832. */
  11833. set shadowsHue(value: number);
  11834. /**
  11835. * Gets the shadows Density value.
  11836. * 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.
  11837. * Values less than zero provide a filter of opposite hue.
  11838. */
  11839. get shadowsDensity(): number;
  11840. /**
  11841. * Sets the shadows Density value.
  11842. * The density value is in range [-100,+100] where 0 means the color filter has no effect and +100 means the color filter has maximum effect.
  11843. * Values less than zero provide a filter of opposite hue.
  11844. */
  11845. set shadowsDensity(value: number);
  11846. /**
  11847. * Gets the shadows Saturation value.
  11848. * 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.
  11849. */
  11850. get shadowsSaturation(): number;
  11851. /**
  11852. * Sets the shadows Saturation value.
  11853. * 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.
  11854. */
  11855. set shadowsSaturation(value: number);
  11856. /**
  11857. * Gets the shadows Exposure value.
  11858. * 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.
  11859. */
  11860. get shadowsExposure(): number;
  11861. /**
  11862. * Sets the shadows Exposure value.
  11863. * 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.
  11864. */
  11865. set shadowsExposure(value: number);
  11866. /**
  11867. * Returns the class name
  11868. * @returns The class name
  11869. */
  11870. getClassName(): string;
  11871. /**
  11872. * Binds the color curves to the shader.
  11873. * @param colorCurves The color curve to bind
  11874. * @param effect The effect to bind to
  11875. * @param positiveUniform The positive uniform shader parameter
  11876. * @param neutralUniform The neutral uniform shader parameter
  11877. * @param negativeUniform The negative uniform shader parameter
  11878. */
  11879. static Bind(colorCurves: ColorCurves, effect: Effect, positiveUniform?: string, neutralUniform?: string, negativeUniform?: string): void;
  11880. /**
  11881. * Prepare the list of uniforms associated with the ColorCurves effects.
  11882. * @param uniformsList The list of uniforms used in the effect
  11883. */
  11884. static PrepareUniforms(uniformsList: string[]): void;
  11885. /**
  11886. * Returns color grading data based on a hue, density, saturation and exposure value.
  11887. * @param filterHue The hue of the color filter.
  11888. * @param filterDensity The density of the color filter.
  11889. * @param saturation The saturation.
  11890. * @param exposure The exposure.
  11891. * @param result The result data container.
  11892. */
  11893. private getColorGradingDataToRef;
  11894. /**
  11895. * Takes an input slider value and returns an adjusted value that provides extra control near the centre.
  11896. * @param value The input slider value in range [-100,100].
  11897. * @returns Adjusted value.
  11898. */
  11899. private static applyColorGradingSliderNonlinear;
  11900. /**
  11901. * Returns an RGBA Color4 based on Hue, Saturation and Brightness (also referred to as value, HSV).
  11902. * @param hue The hue (H) input.
  11903. * @param saturation The saturation (S) input.
  11904. * @param brightness The brightness (B) input.
  11905. * @result An RGBA color represented as Vector4.
  11906. */
  11907. private static fromHSBToRef;
  11908. /**
  11909. * Returns a value clamped between min and max
  11910. * @param value The value to clamp
  11911. * @param min The minimum of value
  11912. * @param max The maximum of value
  11913. * @returns The clamped value.
  11914. */
  11915. private static clamp;
  11916. /**
  11917. * Clones the current color curve instance.
  11918. * @return The cloned curves
  11919. */
  11920. clone(): ColorCurves;
  11921. /**
  11922. * Serializes the current color curve instance to a json representation.
  11923. * @return a JSON representation
  11924. */
  11925. serialize(): any;
  11926. /**
  11927. * Parses the color curve from a json representation.
  11928. * @param source the JSON source to parse
  11929. * @return The parsed curves
  11930. */
  11931. static Parse(source: any): ColorCurves;
  11932. }
  11933. }
  11934. declare module BABYLON {
  11935. /**
  11936. * Interface to follow in your material defines to integrate easily the
  11937. * Image processing functions.
  11938. * @hidden
  11939. */
  11940. export interface IImageProcessingConfigurationDefines {
  11941. IMAGEPROCESSING: boolean;
  11942. VIGNETTE: boolean;
  11943. VIGNETTEBLENDMODEMULTIPLY: boolean;
  11944. VIGNETTEBLENDMODEOPAQUE: boolean;
  11945. TONEMAPPING: boolean;
  11946. TONEMAPPING_ACES: boolean;
  11947. CONTRAST: boolean;
  11948. EXPOSURE: boolean;
  11949. COLORCURVES: boolean;
  11950. COLORGRADING: boolean;
  11951. COLORGRADING3D: boolean;
  11952. SAMPLER3DGREENDEPTH: boolean;
  11953. SAMPLER3DBGRMAP: boolean;
  11954. IMAGEPROCESSINGPOSTPROCESS: boolean;
  11955. }
  11956. /**
  11957. * @hidden
  11958. */
  11959. export class ImageProcessingConfigurationDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  11960. IMAGEPROCESSING: boolean;
  11961. VIGNETTE: boolean;
  11962. VIGNETTEBLENDMODEMULTIPLY: boolean;
  11963. VIGNETTEBLENDMODEOPAQUE: boolean;
  11964. TONEMAPPING: boolean;
  11965. TONEMAPPING_ACES: boolean;
  11966. CONTRAST: boolean;
  11967. COLORCURVES: boolean;
  11968. COLORGRADING: boolean;
  11969. COLORGRADING3D: boolean;
  11970. SAMPLER3DGREENDEPTH: boolean;
  11971. SAMPLER3DBGRMAP: boolean;
  11972. IMAGEPROCESSINGPOSTPROCESS: boolean;
  11973. EXPOSURE: boolean;
  11974. constructor();
  11975. }
  11976. /**
  11977. * This groups together the common properties used for image processing either in direct forward pass
  11978. * or through post processing effect depending on the use of the image processing pipeline in your scene
  11979. * or not.
  11980. */
  11981. export class ImageProcessingConfiguration {
  11982. /**
  11983. * Default tone mapping applied in BabylonJS.
  11984. */
  11985. static readonly TONEMAPPING_STANDARD: number;
  11986. /**
  11987. * ACES Tone mapping (used by default in unreal and unity). This can help getting closer
  11988. * to other engines rendering to increase portability.
  11989. */
  11990. static readonly TONEMAPPING_ACES: number;
  11991. /**
  11992. * Color curves setup used in the effect if colorCurvesEnabled is set to true
  11993. */
  11994. colorCurves: Nullable<ColorCurves>;
  11995. private _colorCurvesEnabled;
  11996. /**
  11997. * Gets whether the color curves effect is enabled.
  11998. */
  11999. get colorCurvesEnabled(): boolean;
  12000. /**
  12001. * Sets whether the color curves effect is enabled.
  12002. */
  12003. set colorCurvesEnabled(value: boolean);
  12004. private _colorGradingTexture;
  12005. /**
  12006. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  12007. */
  12008. get colorGradingTexture(): Nullable<BaseTexture>;
  12009. /**
  12010. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  12011. */
  12012. set colorGradingTexture(value: Nullable<BaseTexture>);
  12013. private _colorGradingEnabled;
  12014. /**
  12015. * Gets whether the color grading effect is enabled.
  12016. */
  12017. get colorGradingEnabled(): boolean;
  12018. /**
  12019. * Sets whether the color grading effect is enabled.
  12020. */
  12021. set colorGradingEnabled(value: boolean);
  12022. private _colorGradingWithGreenDepth;
  12023. /**
  12024. * Gets whether the color grading effect is using a green depth for the 3d Texture.
  12025. */
  12026. get colorGradingWithGreenDepth(): boolean;
  12027. /**
  12028. * Sets whether the color grading effect is using a green depth for the 3d Texture.
  12029. */
  12030. set colorGradingWithGreenDepth(value: boolean);
  12031. private _colorGradingBGR;
  12032. /**
  12033. * Gets whether the color grading texture contains BGR values.
  12034. */
  12035. get colorGradingBGR(): boolean;
  12036. /**
  12037. * Sets whether the color grading texture contains BGR values.
  12038. */
  12039. set colorGradingBGR(value: boolean);
  12040. /** @hidden */
  12041. _exposure: number;
  12042. /**
  12043. * Gets the Exposure used in the effect.
  12044. */
  12045. get exposure(): number;
  12046. /**
  12047. * Sets the Exposure used in the effect.
  12048. */
  12049. set exposure(value: number);
  12050. private _toneMappingEnabled;
  12051. /**
  12052. * Gets whether the tone mapping effect is enabled.
  12053. */
  12054. get toneMappingEnabled(): boolean;
  12055. /**
  12056. * Sets whether the tone mapping effect is enabled.
  12057. */
  12058. set toneMappingEnabled(value: boolean);
  12059. private _toneMappingType;
  12060. /**
  12061. * Gets the type of tone mapping effect.
  12062. */
  12063. get toneMappingType(): number;
  12064. /**
  12065. * Sets the type of tone mapping effect used in BabylonJS.
  12066. */
  12067. set toneMappingType(value: number);
  12068. protected _contrast: number;
  12069. /**
  12070. * Gets the contrast used in the effect.
  12071. */
  12072. get contrast(): number;
  12073. /**
  12074. * Sets the contrast used in the effect.
  12075. */
  12076. set contrast(value: number);
  12077. /**
  12078. * Vignette stretch size.
  12079. */
  12080. vignetteStretch: number;
  12081. /**
  12082. * Vignette centre X Offset.
  12083. */
  12084. vignetteCentreX: number;
  12085. /**
  12086. * Vignette centre Y Offset.
  12087. */
  12088. vignetteCentreY: number;
  12089. /**
  12090. * Vignette weight or intensity of the vignette effect.
  12091. */
  12092. vignetteWeight: number;
  12093. /**
  12094. * Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  12095. * if vignetteEnabled is set to true.
  12096. */
  12097. vignetteColor: Color4;
  12098. /**
  12099. * Camera field of view used by the Vignette effect.
  12100. */
  12101. vignetteCameraFov: number;
  12102. private _vignetteBlendMode;
  12103. /**
  12104. * Gets the vignette blend mode allowing different kind of effect.
  12105. */
  12106. get vignetteBlendMode(): number;
  12107. /**
  12108. * Sets the vignette blend mode allowing different kind of effect.
  12109. */
  12110. set vignetteBlendMode(value: number);
  12111. private _vignetteEnabled;
  12112. /**
  12113. * Gets whether the vignette effect is enabled.
  12114. */
  12115. get vignetteEnabled(): boolean;
  12116. /**
  12117. * Sets whether the vignette effect is enabled.
  12118. */
  12119. set vignetteEnabled(value: boolean);
  12120. private _applyByPostProcess;
  12121. /**
  12122. * Gets whether the image processing is applied through a post process or not.
  12123. */
  12124. get applyByPostProcess(): boolean;
  12125. /**
  12126. * Sets whether the image processing is applied through a post process or not.
  12127. */
  12128. set applyByPostProcess(value: boolean);
  12129. private _isEnabled;
  12130. /**
  12131. * Gets whether the image processing is enabled or not.
  12132. */
  12133. get isEnabled(): boolean;
  12134. /**
  12135. * Sets whether the image processing is enabled or not.
  12136. */
  12137. set isEnabled(value: boolean);
  12138. /**
  12139. * An event triggered when the configuration changes and requires Shader to Update some parameters.
  12140. */
  12141. onUpdateParameters: Observable<ImageProcessingConfiguration>;
  12142. /**
  12143. * Method called each time the image processing information changes requires to recompile the effect.
  12144. */
  12145. protected _updateParameters(): void;
  12146. /**
  12147. * Gets the current class name.
  12148. * @return "ImageProcessingConfiguration"
  12149. */
  12150. getClassName(): string;
  12151. /**
  12152. * Prepare the list of uniforms associated with the Image Processing effects.
  12153. * @param uniforms The list of uniforms used in the effect
  12154. * @param defines the list of defines currently in use
  12155. */
  12156. static PrepareUniforms(uniforms: string[], defines: IImageProcessingConfigurationDefines): void;
  12157. /**
  12158. * Prepare the list of samplers associated with the Image Processing effects.
  12159. * @param samplersList The list of uniforms used in the effect
  12160. * @param defines the list of defines currently in use
  12161. */
  12162. static PrepareSamplers(samplersList: string[], defines: IImageProcessingConfigurationDefines): void;
  12163. /**
  12164. * Prepare the list of defines associated to the shader.
  12165. * @param defines the list of defines to complete
  12166. * @param forPostProcess Define if we are currently in post process mode or not
  12167. */
  12168. prepareDefines(defines: IImageProcessingConfigurationDefines, forPostProcess?: boolean): void;
  12169. /**
  12170. * Returns true if all the image processing information are ready.
  12171. * @returns True if ready, otherwise, false
  12172. */
  12173. isReady(): boolean;
  12174. /**
  12175. * Binds the image processing to the shader.
  12176. * @param effect The effect to bind to
  12177. * @param overrideAspectRatio Override the aspect ratio of the effect
  12178. */
  12179. bind(effect: Effect, overrideAspectRatio?: number): void;
  12180. /**
  12181. * Clones the current image processing instance.
  12182. * @return The cloned image processing
  12183. */
  12184. clone(): ImageProcessingConfiguration;
  12185. /**
  12186. * Serializes the current image processing instance to a json representation.
  12187. * @return a JSON representation
  12188. */
  12189. serialize(): any;
  12190. /**
  12191. * Parses the image processing from a json representation.
  12192. * @param source the JSON source to parse
  12193. * @return The parsed image processing
  12194. */
  12195. static Parse(source: any): ImageProcessingConfiguration;
  12196. private static _VIGNETTEMODE_MULTIPLY;
  12197. private static _VIGNETTEMODE_OPAQUE;
  12198. /**
  12199. * Used to apply the vignette as a mix with the pixel color.
  12200. */
  12201. static get VIGNETTEMODE_MULTIPLY(): number;
  12202. /**
  12203. * Used to apply the vignette as a replacement of the pixel color.
  12204. */
  12205. static get VIGNETTEMODE_OPAQUE(): number;
  12206. }
  12207. }
  12208. declare module BABYLON {
  12209. /** @hidden */
  12210. export var postprocessVertexShader: {
  12211. name: string;
  12212. shader: string;
  12213. };
  12214. }
  12215. declare module BABYLON {
  12216. /**
  12217. * Type used to define a render target texture size (either with a number or with a rect width and height)
  12218. */
  12219. export type RenderTargetTextureSize = number | {
  12220. width: number;
  12221. height: number;
  12222. layers?: number;
  12223. };
  12224. interface ThinEngine {
  12225. /**
  12226. * Creates a new render target texture
  12227. * @param size defines the size of the texture
  12228. * @param options defines the options used to create the texture
  12229. * @returns a new render target texture stored in an InternalTexture
  12230. */
  12231. createRenderTargetTexture(size: RenderTargetTextureSize, options: boolean | RenderTargetCreationOptions): InternalTexture;
  12232. /**
  12233. * Creates a depth stencil texture.
  12234. * This is only available in WebGL 2 or with the depth texture extension available.
  12235. * @param size The size of face edge in the texture.
  12236. * @param options The options defining the texture.
  12237. * @returns The texture
  12238. */
  12239. createDepthStencilTexture(size: RenderTargetTextureSize, options: DepthTextureCreationOptions): InternalTexture;
  12240. /** @hidden */
  12241. _createDepthStencilTexture(size: RenderTargetTextureSize, options: DepthTextureCreationOptions): InternalTexture;
  12242. }
  12243. }
  12244. declare module BABYLON {
  12245. /**
  12246. * Defines the kind of connection point for node based material
  12247. */
  12248. export enum NodeMaterialBlockConnectionPointTypes {
  12249. /** Float */
  12250. Float = 1,
  12251. /** Int */
  12252. Int = 2,
  12253. /** Vector2 */
  12254. Vector2 = 4,
  12255. /** Vector3 */
  12256. Vector3 = 8,
  12257. /** Vector4 */
  12258. Vector4 = 16,
  12259. /** Color3 */
  12260. Color3 = 32,
  12261. /** Color4 */
  12262. Color4 = 64,
  12263. /** Matrix */
  12264. Matrix = 128,
  12265. /** Custom object */
  12266. Object = 256,
  12267. /** Detect type based on connection */
  12268. AutoDetect = 1024,
  12269. /** Output type that will be defined by input type */
  12270. BasedOnInput = 2048
  12271. }
  12272. }
  12273. declare module BABYLON {
  12274. /**
  12275. * Enum used to define the target of a block
  12276. */
  12277. export enum NodeMaterialBlockTargets {
  12278. /** Vertex shader */
  12279. Vertex = 1,
  12280. /** Fragment shader */
  12281. Fragment = 2,
  12282. /** Neutral */
  12283. Neutral = 4,
  12284. /** Vertex and Fragment */
  12285. VertexAndFragment = 3
  12286. }
  12287. }
  12288. declare module BABYLON {
  12289. /**
  12290. * Enum defining the mode of a NodeMaterialBlockConnectionPoint
  12291. */
  12292. export enum NodeMaterialBlockConnectionPointMode {
  12293. /** Value is an uniform */
  12294. Uniform = 0,
  12295. /** Value is a mesh attribute */
  12296. Attribute = 1,
  12297. /** Value is a varying between vertex and fragment shaders */
  12298. Varying = 2,
  12299. /** Mode is undefined */
  12300. Undefined = 3
  12301. }
  12302. }
  12303. declare module BABYLON {
  12304. /**
  12305. * Enum used to define system values e.g. values automatically provided by the system
  12306. */
  12307. export enum NodeMaterialSystemValues {
  12308. /** World */
  12309. World = 1,
  12310. /** View */
  12311. View = 2,
  12312. /** Projection */
  12313. Projection = 3,
  12314. /** ViewProjection */
  12315. ViewProjection = 4,
  12316. /** WorldView */
  12317. WorldView = 5,
  12318. /** WorldViewProjection */
  12319. WorldViewProjection = 6,
  12320. /** CameraPosition */
  12321. CameraPosition = 7,
  12322. /** Fog Color */
  12323. FogColor = 8,
  12324. /** Delta time */
  12325. DeltaTime = 9
  12326. }
  12327. }
  12328. declare module BABYLON {
  12329. /**
  12330. * Represents a camera frustum
  12331. */
  12332. export class Frustum {
  12333. /**
  12334. * Gets the planes representing the frustum
  12335. * @param transform matrix to be applied to the returned planes
  12336. * @returns a new array of 6 Frustum planes computed by the given transformation matrix.
  12337. */
  12338. static GetPlanes(transform: DeepImmutable<Matrix>): Plane[];
  12339. /**
  12340. * Gets the near frustum plane transformed by the transform matrix
  12341. * @param transform transformation matrix to be applied to the resulting frustum plane
  12342. * @param frustumPlane the resuling frustum plane
  12343. */
  12344. static GetNearPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  12345. /**
  12346. * Gets the far frustum plane transformed by the transform matrix
  12347. * @param transform transformation matrix to be applied to the resulting frustum plane
  12348. * @param frustumPlane the resuling frustum plane
  12349. */
  12350. static GetFarPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  12351. /**
  12352. * Gets the left frustum plane transformed by the transform matrix
  12353. * @param transform transformation matrix to be applied to the resulting frustum plane
  12354. * @param frustumPlane the resuling frustum plane
  12355. */
  12356. static GetLeftPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  12357. /**
  12358. * Gets the right frustum plane transformed by the transform matrix
  12359. * @param transform transformation matrix to be applied to the resulting frustum plane
  12360. * @param frustumPlane the resuling frustum plane
  12361. */
  12362. static GetRightPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  12363. /**
  12364. * Gets the top frustum plane transformed by the transform matrix
  12365. * @param transform transformation matrix to be applied to the resulting frustum plane
  12366. * @param frustumPlane the resuling frustum plane
  12367. */
  12368. static GetTopPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  12369. /**
  12370. * Gets the bottom frustum plane transformed by the transform matrix
  12371. * @param transform transformation matrix to be applied to the resulting frustum plane
  12372. * @param frustumPlane the resuling frustum plane
  12373. */
  12374. static GetBottomPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  12375. /**
  12376. * Sets the given array "frustumPlanes" with the 6 Frustum planes computed by the given transformation matrix.
  12377. * @param transform transformation matrix to be applied to the resulting frustum planes
  12378. * @param frustumPlanes the resuling frustum planes
  12379. */
  12380. static GetPlanesToRef(transform: DeepImmutable<Matrix>, frustumPlanes: Plane[]): void;
  12381. }
  12382. }
  12383. declare module BABYLON {
  12384. /**
  12385. * Contains position and normal vectors for a vertex
  12386. */
  12387. export class PositionNormalVertex {
  12388. /** the position of the vertex (defaut: 0,0,0) */
  12389. position: Vector3;
  12390. /** the normal of the vertex (defaut: 0,1,0) */
  12391. normal: Vector3;
  12392. /**
  12393. * Creates a PositionNormalVertex
  12394. * @param position the position of the vertex (defaut: 0,0,0)
  12395. * @param normal the normal of the vertex (defaut: 0,1,0)
  12396. */
  12397. constructor(
  12398. /** the position of the vertex (defaut: 0,0,0) */
  12399. position?: Vector3,
  12400. /** the normal of the vertex (defaut: 0,1,0) */
  12401. normal?: Vector3);
  12402. /**
  12403. * Clones the PositionNormalVertex
  12404. * @returns the cloned PositionNormalVertex
  12405. */
  12406. clone(): PositionNormalVertex;
  12407. }
  12408. /**
  12409. * Contains position, normal and uv vectors for a vertex
  12410. */
  12411. export class PositionNormalTextureVertex {
  12412. /** the position of the vertex (defaut: 0,0,0) */
  12413. position: Vector3;
  12414. /** the normal of the vertex (defaut: 0,1,0) */
  12415. normal: Vector3;
  12416. /** the uv of the vertex (default: 0,0) */
  12417. uv: Vector2;
  12418. /**
  12419. * Creates a PositionNormalTextureVertex
  12420. * @param position the position of the vertex (defaut: 0,0,0)
  12421. * @param normal the normal of the vertex (defaut: 0,1,0)
  12422. * @param uv the uv of the vertex (default: 0,0)
  12423. */
  12424. constructor(
  12425. /** the position of the vertex (defaut: 0,0,0) */
  12426. position?: Vector3,
  12427. /** the normal of the vertex (defaut: 0,1,0) */
  12428. normal?: Vector3,
  12429. /** the uv of the vertex (default: 0,0) */
  12430. uv?: Vector2);
  12431. /**
  12432. * Clones the PositionNormalTextureVertex
  12433. * @returns the cloned PositionNormalTextureVertex
  12434. */
  12435. clone(): PositionNormalTextureVertex;
  12436. }
  12437. }
  12438. declare module BABYLON {
  12439. /**
  12440. * Enum defining the type of animations supported by InputBlock
  12441. */
  12442. export enum AnimatedInputBlockTypes {
  12443. /** No animation */
  12444. None = 0,
  12445. /** Time based animation. Will only work for floats */
  12446. Time = 1
  12447. }
  12448. }
  12449. declare module BABYLON {
  12450. /**
  12451. * Block used to expose an input value
  12452. */
  12453. export class InputBlock extends NodeMaterialBlock {
  12454. private _mode;
  12455. private _associatedVariableName;
  12456. private _storedValue;
  12457. private _valueCallback;
  12458. private _type;
  12459. private _animationType;
  12460. /** Gets or set a value used to limit the range of float values */
  12461. min: number;
  12462. /** Gets or set a value used to limit the range of float values */
  12463. max: number;
  12464. /** Gets or set a value indicating that this input can only get 0 and 1 values */
  12465. isBoolean: boolean;
  12466. /** Gets or sets a value used by the Node Material editor to determine how to configure the current value if it is a matrix */
  12467. matrixMode: number;
  12468. /** @hidden */
  12469. _systemValue: Nullable<NodeMaterialSystemValues>;
  12470. /** Gets or sets a boolean indicating that the value of this input will not change after a build */
  12471. isConstant: boolean;
  12472. /** Gets or sets the group to use to display this block in the Inspector */
  12473. groupInInspector: string;
  12474. /** Gets an observable raised when the value is changed */
  12475. onValueChangedObservable: Observable<InputBlock>;
  12476. /** Gets or sets a boolean indicating if content needs to be converted to gamma space (for color3/4 only) */
  12477. convertToGammaSpace: boolean;
  12478. /** Gets or sets a boolean indicating if content needs to be converted to linear space (for color3/4 only) */
  12479. convertToLinearSpace: boolean;
  12480. /**
  12481. * Gets or sets the connection point type (default is float)
  12482. */
  12483. get type(): NodeMaterialBlockConnectionPointTypes;
  12484. /**
  12485. * Creates a new InputBlock
  12486. * @param name defines the block name
  12487. * @param target defines the target of that block (Vertex by default)
  12488. * @param type defines the type of the input (can be set to NodeMaterialBlockConnectionPointTypes.AutoDetect)
  12489. */
  12490. constructor(name: string, target?: NodeMaterialBlockTargets, type?: NodeMaterialBlockConnectionPointTypes);
  12491. /**
  12492. * Validates if a name is a reserve word.
  12493. * @param newName the new name to be given to the node.
  12494. * @returns false if the name is a reserve word, else true.
  12495. */
  12496. validateBlockName(newName: string): boolean;
  12497. /**
  12498. * Gets the output component
  12499. */
  12500. get output(): NodeMaterialConnectionPoint;
  12501. /**
  12502. * Set the source of this connection point to a vertex attribute
  12503. * @param attributeName defines the attribute name (position, uv, normal, etc...). If not specified it will take the connection point name
  12504. * @returns the current connection point
  12505. */
  12506. setAsAttribute(attributeName?: string): InputBlock;
  12507. /**
  12508. * Set the source of this connection point to a system value
  12509. * @param value define the system value to use (world, view, etc...) or null to switch to manual value
  12510. * @returns the current connection point
  12511. */
  12512. setAsSystemValue(value: Nullable<NodeMaterialSystemValues>): InputBlock;
  12513. /**
  12514. * Gets or sets the value of that point.
  12515. * Please note that this value will be ignored if valueCallback is defined
  12516. */
  12517. get value(): any;
  12518. set value(value: any);
  12519. /**
  12520. * Gets or sets a callback used to get the value of that point.
  12521. * Please note that setting this value will force the connection point to ignore the value property
  12522. */
  12523. get valueCallback(): () => any;
  12524. set valueCallback(value: () => any);
  12525. /**
  12526. * Gets or sets the associated variable name in the shader
  12527. */
  12528. get associatedVariableName(): string;
  12529. set associatedVariableName(value: string);
  12530. /** Gets or sets the type of animation applied to the input */
  12531. get animationType(): AnimatedInputBlockTypes;
  12532. set animationType(value: AnimatedInputBlockTypes);
  12533. /**
  12534. * Gets a boolean indicating that this connection point not defined yet
  12535. */
  12536. get isUndefined(): boolean;
  12537. /**
  12538. * Gets or sets a boolean indicating that this connection point is coming from an uniform.
  12539. * In this case the connection point name must be the name of the uniform to use.
  12540. * Can only be set on inputs
  12541. */
  12542. get isUniform(): boolean;
  12543. set isUniform(value: boolean);
  12544. /**
  12545. * Gets or sets a boolean indicating that this connection point is coming from an attribute.
  12546. * In this case the connection point name must be the name of the attribute to use
  12547. * Can only be set on inputs
  12548. */
  12549. get isAttribute(): boolean;
  12550. set isAttribute(value: boolean);
  12551. /**
  12552. * Gets or sets a boolean indicating that this connection point is generating a varying variable.
  12553. * Can only be set on exit points
  12554. */
  12555. get isVarying(): boolean;
  12556. set isVarying(value: boolean);
  12557. /**
  12558. * Gets a boolean indicating that the current connection point is a system value
  12559. */
  12560. get isSystemValue(): boolean;
  12561. /**
  12562. * Gets or sets the current well known value or null if not defined as a system value
  12563. */
  12564. get systemValue(): Nullable<NodeMaterialSystemValues>;
  12565. set systemValue(value: Nullable<NodeMaterialSystemValues>);
  12566. /**
  12567. * Gets the current class name
  12568. * @returns the class name
  12569. */
  12570. getClassName(): string;
  12571. /**
  12572. * Animate the input if animationType !== None
  12573. * @param scene defines the rendering scene
  12574. */
  12575. animate(scene: Scene): void;
  12576. private _emitDefine;
  12577. initialize(state: NodeMaterialBuildState): void;
  12578. /**
  12579. * Set the input block to its default value (based on its type)
  12580. */
  12581. setDefaultValue(): void;
  12582. private _emitConstant;
  12583. /** @hidden */
  12584. get _noContextSwitch(): boolean;
  12585. private _emit;
  12586. /** @hidden */
  12587. _transmitWorld(effect: Effect, world: Matrix, worldView: Matrix, worldViewProjection: Matrix): void;
  12588. /** @hidden */
  12589. _transmit(effect: Effect, scene: Scene): void;
  12590. protected _buildBlock(state: NodeMaterialBuildState): void;
  12591. protected _dumpPropertiesCode(): string;
  12592. dispose(): void;
  12593. serialize(): any;
  12594. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  12595. }
  12596. }
  12597. declare module BABYLON {
  12598. /**
  12599. * Enum used to define the compatibility state between two connection points
  12600. */
  12601. export enum NodeMaterialConnectionPointCompatibilityStates {
  12602. /** Points are compatibles */
  12603. Compatible = 0,
  12604. /** Points are incompatible because of their types */
  12605. TypeIncompatible = 1,
  12606. /** Points are incompatible because of their targets (vertex vs fragment) */
  12607. TargetIncompatible = 2
  12608. }
  12609. /**
  12610. * Defines the direction of a connection point
  12611. */
  12612. export enum NodeMaterialConnectionPointDirection {
  12613. /** Input */
  12614. Input = 0,
  12615. /** Output */
  12616. Output = 1
  12617. }
  12618. /**
  12619. * Defines a connection point for a block
  12620. */
  12621. export class NodeMaterialConnectionPoint {
  12622. /**
  12623. * Checks if two types are equivalent
  12624. * @param type1 type 1 to check
  12625. * @param type2 type 2 to check
  12626. * @returns true if both types are equivalent, else false
  12627. */
  12628. static AreEquivalentTypes(type1: number, type2: number): boolean;
  12629. /** @hidden */
  12630. _ownerBlock: NodeMaterialBlock;
  12631. /** @hidden */
  12632. _connectedPoint: Nullable<NodeMaterialConnectionPoint>;
  12633. private _endpoints;
  12634. private _associatedVariableName;
  12635. private _direction;
  12636. /** @hidden */
  12637. _typeConnectionSource: Nullable<NodeMaterialConnectionPoint>;
  12638. /** @hidden */
  12639. _linkedConnectionSource: Nullable<NodeMaterialConnectionPoint>;
  12640. /** @hidden */
  12641. _acceptedConnectionPointType: Nullable<NodeMaterialConnectionPoint>;
  12642. private _type;
  12643. /** @hidden */
  12644. _enforceAssociatedVariableName: boolean;
  12645. /** Gets the direction of the point */
  12646. get direction(): NodeMaterialConnectionPointDirection;
  12647. /** Indicates that this connection point needs dual validation before being connected to another point */
  12648. needDualDirectionValidation: boolean;
  12649. /**
  12650. * Gets or sets the additional types supported by this connection point
  12651. */
  12652. acceptedConnectionPointTypes: NodeMaterialBlockConnectionPointTypes[];
  12653. /**
  12654. * Gets or sets the additional types excluded by this connection point
  12655. */
  12656. excludedConnectionPointTypes: NodeMaterialBlockConnectionPointTypes[];
  12657. /**
  12658. * Observable triggered when this point is connected
  12659. */
  12660. onConnectionObservable: Observable<NodeMaterialConnectionPoint>;
  12661. /**
  12662. * Gets or sets the associated variable name in the shader
  12663. */
  12664. get associatedVariableName(): string;
  12665. set associatedVariableName(value: string);
  12666. /** Get the inner type (ie AutoDetect for instance instead of the inferred one) */
  12667. get innerType(): NodeMaterialBlockConnectionPointTypes;
  12668. /**
  12669. * Gets or sets the connection point type (default is float)
  12670. */
  12671. get type(): NodeMaterialBlockConnectionPointTypes;
  12672. set type(value: NodeMaterialBlockConnectionPointTypes);
  12673. /**
  12674. * Gets or sets the connection point name
  12675. */
  12676. name: string;
  12677. /**
  12678. * Gets or sets the connection point name
  12679. */
  12680. displayName: string;
  12681. /**
  12682. * Gets or sets a boolean indicating that this connection point can be omitted
  12683. */
  12684. isOptional: boolean;
  12685. /**
  12686. * Gets or sets a boolean indicating that this connection point is exposed on a frame
  12687. */
  12688. isExposedOnFrame: boolean;
  12689. /**
  12690. * Gets or sets number indicating the position that the port is exposed to on a frame
  12691. */
  12692. exposedPortPosition: number;
  12693. /**
  12694. * Gets or sets a string indicating that this uniform must be defined under a #ifdef
  12695. */
  12696. define: string;
  12697. /** @hidden */
  12698. _prioritizeVertex: boolean;
  12699. private _target;
  12700. /** Gets or sets the target of that connection point */
  12701. get target(): NodeMaterialBlockTargets;
  12702. set target(value: NodeMaterialBlockTargets);
  12703. /**
  12704. * Gets a boolean indicating that the current point is connected to another NodeMaterialBlock
  12705. */
  12706. get isConnected(): boolean;
  12707. /**
  12708. * Gets a boolean indicating that the current point is connected to an input block
  12709. */
  12710. get isConnectedToInputBlock(): boolean;
  12711. /**
  12712. * Gets a the connected input block (if any)
  12713. */
  12714. get connectInputBlock(): Nullable<InputBlock>;
  12715. /** Get the other side of the connection (if any) */
  12716. get connectedPoint(): Nullable<NodeMaterialConnectionPoint>;
  12717. /** Get the block that owns this connection point */
  12718. get ownerBlock(): NodeMaterialBlock;
  12719. /** Get the block connected on the other side of this connection (if any) */
  12720. get sourceBlock(): Nullable<NodeMaterialBlock>;
  12721. /** Get the block connected on the endpoints of this connection (if any) */
  12722. get connectedBlocks(): Array<NodeMaterialBlock>;
  12723. /** Gets the list of connected endpoints */
  12724. get endpoints(): NodeMaterialConnectionPoint[];
  12725. /** Gets a boolean indicating if that output point is connected to at least one input */
  12726. get hasEndpoints(): boolean;
  12727. /** Gets a boolean indicating that this connection will be used in the vertex shader */
  12728. get isConnectedInVertexShader(): boolean;
  12729. /** Gets a boolean indicating that this connection will be used in the fragment shader */
  12730. get isConnectedInFragmentShader(): boolean;
  12731. /**
  12732. * Creates a block suitable to be used as an input for this input point.
  12733. * If null is returned, a block based on the point type will be created.
  12734. * @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
  12735. */
  12736. createCustomInputBlock(): Nullable<[NodeMaterialBlock, string]>;
  12737. /**
  12738. * Creates a new connection point
  12739. * @param name defines the connection point name
  12740. * @param ownerBlock defines the block hosting this connection point
  12741. * @param direction defines the direction of the connection point
  12742. */
  12743. constructor(name: string, ownerBlock: NodeMaterialBlock, direction: NodeMaterialConnectionPointDirection);
  12744. /**
  12745. * Gets the current class name e.g. "NodeMaterialConnectionPoint"
  12746. * @returns the class name
  12747. */
  12748. getClassName(): string;
  12749. /**
  12750. * Gets a boolean indicating if the current point can be connected to another point
  12751. * @param connectionPoint defines the other connection point
  12752. * @returns a boolean
  12753. */
  12754. canConnectTo(connectionPoint: NodeMaterialConnectionPoint): boolean;
  12755. /**
  12756. * Gets a number indicating if the current point can be connected to another point
  12757. * @param connectionPoint defines the other connection point
  12758. * @returns a number defining the compatibility state
  12759. */
  12760. checkCompatibilityState(connectionPoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPointCompatibilityStates;
  12761. /**
  12762. * Connect this point to another connection point
  12763. * @param connectionPoint defines the other connection point
  12764. * @param ignoreConstraints defines if the system will ignore connection type constraints (default is false)
  12765. * @returns the current connection point
  12766. */
  12767. connectTo(connectionPoint: NodeMaterialConnectionPoint, ignoreConstraints?: boolean): NodeMaterialConnectionPoint;
  12768. /**
  12769. * Disconnect this point from one of his endpoint
  12770. * @param endpoint defines the other connection point
  12771. * @returns the current connection point
  12772. */
  12773. disconnectFrom(endpoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPoint;
  12774. /**
  12775. * Serializes this point in a JSON representation
  12776. * @param isInput defines if the connection point is an input (default is true)
  12777. * @returns the serialized point object
  12778. */
  12779. serialize(isInput?: boolean): any;
  12780. /**
  12781. * Release resources
  12782. */
  12783. dispose(): void;
  12784. }
  12785. }
  12786. declare module BABYLON {
  12787. /**
  12788. * Enum used to define the material modes
  12789. */
  12790. export enum NodeMaterialModes {
  12791. /** Regular material */
  12792. Material = 0,
  12793. /** For post process */
  12794. PostProcess = 1,
  12795. /** For particle system */
  12796. Particle = 2,
  12797. /** For procedural texture */
  12798. ProceduralTexture = 3
  12799. }
  12800. }
  12801. declare module BABYLON {
  12802. /** @hidden */
  12803. export var helperFunctions: {
  12804. name: string;
  12805. shader: string;
  12806. };
  12807. }
  12808. declare module BABYLON {
  12809. /**
  12810. * Block used to read a texture from a sampler
  12811. */
  12812. export class TextureBlock extends NodeMaterialBlock {
  12813. private _defineName;
  12814. private _linearDefineName;
  12815. private _gammaDefineName;
  12816. private _tempTextureRead;
  12817. private _samplerName;
  12818. private _transformedUVName;
  12819. private _textureTransformName;
  12820. private _textureInfoName;
  12821. private _mainUVName;
  12822. private _mainUVDefineName;
  12823. private _fragmentOnly;
  12824. /**
  12825. * Gets or sets the texture associated with the node
  12826. */
  12827. texture: Nullable<Texture>;
  12828. /**
  12829. * Gets or sets a boolean indicating if content needs to be converted to gamma space
  12830. */
  12831. convertToGammaSpace: boolean;
  12832. /**
  12833. * Gets or sets a boolean indicating if content needs to be converted to linear space
  12834. */
  12835. convertToLinearSpace: boolean;
  12836. /**
  12837. * Create a new TextureBlock
  12838. * @param name defines the block name
  12839. */
  12840. constructor(name: string, fragmentOnly?: boolean);
  12841. /**
  12842. * Gets the current class name
  12843. * @returns the class name
  12844. */
  12845. getClassName(): string;
  12846. /**
  12847. * Gets the uv input component
  12848. */
  12849. get uv(): NodeMaterialConnectionPoint;
  12850. /**
  12851. * Gets the rgba output component
  12852. */
  12853. get rgba(): NodeMaterialConnectionPoint;
  12854. /**
  12855. * Gets the rgb output component
  12856. */
  12857. get rgb(): NodeMaterialConnectionPoint;
  12858. /**
  12859. * Gets the r output component
  12860. */
  12861. get r(): NodeMaterialConnectionPoint;
  12862. /**
  12863. * Gets the g output component
  12864. */
  12865. get g(): NodeMaterialConnectionPoint;
  12866. /**
  12867. * Gets the b output component
  12868. */
  12869. get b(): NodeMaterialConnectionPoint;
  12870. /**
  12871. * Gets the a output component
  12872. */
  12873. get a(): NodeMaterialConnectionPoint;
  12874. get target(): NodeMaterialBlockTargets;
  12875. autoConfigure(material: NodeMaterial): void;
  12876. initializeDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  12877. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  12878. isReady(): boolean;
  12879. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  12880. private get _isMixed();
  12881. private _injectVertexCode;
  12882. private _writeTextureRead;
  12883. private _writeOutput;
  12884. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  12885. protected _dumpPropertiesCode(): string;
  12886. serialize(): any;
  12887. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  12888. dispose(): void;
  12889. }
  12890. }
  12891. declare module BABYLON {
  12892. /** @hidden */
  12893. export var reflectionFunction: {
  12894. name: string;
  12895. shader: string;
  12896. };
  12897. }
  12898. declare module BABYLON {
  12899. /**
  12900. * Base block used to read a reflection texture from a sampler
  12901. */
  12902. export abstract class ReflectionTextureBaseBlock extends NodeMaterialBlock {
  12903. /** @hidden */
  12904. _define3DName: string;
  12905. /** @hidden */
  12906. _defineCubicName: string;
  12907. /** @hidden */
  12908. _defineExplicitName: string;
  12909. /** @hidden */
  12910. _defineProjectionName: string;
  12911. /** @hidden */
  12912. _defineLocalCubicName: string;
  12913. /** @hidden */
  12914. _defineSphericalName: string;
  12915. /** @hidden */
  12916. _definePlanarName: string;
  12917. /** @hidden */
  12918. _defineEquirectangularName: string;
  12919. /** @hidden */
  12920. _defineMirroredEquirectangularFixedName: string;
  12921. /** @hidden */
  12922. _defineEquirectangularFixedName: string;
  12923. /** @hidden */
  12924. _defineSkyboxName: string;
  12925. /** @hidden */
  12926. _defineOppositeZ: string;
  12927. /** @hidden */
  12928. _cubeSamplerName: string;
  12929. /** @hidden */
  12930. _2DSamplerName: string;
  12931. protected _positionUVWName: string;
  12932. protected _directionWName: string;
  12933. protected _reflectionVectorName: string;
  12934. /** @hidden */
  12935. _reflectionCoordsName: string;
  12936. /** @hidden */
  12937. _reflectionMatrixName: string;
  12938. protected _reflectionColorName: string;
  12939. /**
  12940. * Gets or sets the texture associated with the node
  12941. */
  12942. texture: Nullable<BaseTexture>;
  12943. /**
  12944. * Create a new ReflectionTextureBaseBlock
  12945. * @param name defines the block name
  12946. */
  12947. constructor(name: string);
  12948. /**
  12949. * Gets the current class name
  12950. * @returns the class name
  12951. */
  12952. getClassName(): string;
  12953. /**
  12954. * Gets the world position input component
  12955. */
  12956. abstract get position(): NodeMaterialConnectionPoint;
  12957. /**
  12958. * Gets the world position input component
  12959. */
  12960. abstract get worldPosition(): NodeMaterialConnectionPoint;
  12961. /**
  12962. * Gets the world normal input component
  12963. */
  12964. abstract get worldNormal(): NodeMaterialConnectionPoint;
  12965. /**
  12966. * Gets the world input component
  12967. */
  12968. abstract get world(): NodeMaterialConnectionPoint;
  12969. /**
  12970. * Gets the camera (or eye) position component
  12971. */
  12972. abstract get cameraPosition(): NodeMaterialConnectionPoint;
  12973. /**
  12974. * Gets the view input component
  12975. */
  12976. abstract get view(): NodeMaterialConnectionPoint;
  12977. protected _getTexture(): Nullable<BaseTexture>;
  12978. autoConfigure(material: NodeMaterial): void;
  12979. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  12980. isReady(): boolean;
  12981. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  12982. /**
  12983. * Gets the code to inject in the vertex shader
  12984. * @param state current state of the node material building
  12985. * @returns the shader code
  12986. */
  12987. handleVertexSide(state: NodeMaterialBuildState): string;
  12988. /**
  12989. * Handles the inits for the fragment code path
  12990. * @param state node material build state
  12991. */
  12992. handleFragmentSideInits(state: NodeMaterialBuildState): void;
  12993. /**
  12994. * Generates the reflection coords code for the fragment code path
  12995. * @param worldNormalVarName name of the world normal variable
  12996. * @param worldPos name of the world position variable. If not provided, will use the world position connected to this block
  12997. * @param onlyReflectionVector if true, generates code only for the reflection vector computation, not for the reflection coordinates
  12998. * @returns the shader code
  12999. */
  13000. handleFragmentSideCodeReflectionCoords(worldNormalVarName: string, worldPos?: string, onlyReflectionVector?: boolean): string;
  13001. /**
  13002. * Generates the reflection color code for the fragment code path
  13003. * @param lodVarName name of the lod variable
  13004. * @param swizzleLookupTexture swizzle to use for the final color variable
  13005. * @returns the shader code
  13006. */
  13007. handleFragmentSideCodeReflectionColor(lodVarName?: string, swizzleLookupTexture?: string): string;
  13008. /**
  13009. * Generates the code corresponding to the connected output points
  13010. * @param state node material build state
  13011. * @param varName name of the variable to output
  13012. * @returns the shader code
  13013. */
  13014. writeOutputs(state: NodeMaterialBuildState, varName: string): string;
  13015. protected _buildBlock(state: NodeMaterialBuildState): this;
  13016. protected _dumpPropertiesCode(): string;
  13017. serialize(): any;
  13018. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  13019. dispose(): void;
  13020. }
  13021. }
  13022. declare module BABYLON {
  13023. /**
  13024. * Defines a connection point to be used for points with a custom object type
  13025. */
  13026. export class NodeMaterialConnectionPointCustomObject<T extends NodeMaterialBlock> extends NodeMaterialConnectionPoint {
  13027. private _blockType;
  13028. private _blockName;
  13029. private _nameForCheking?;
  13030. /**
  13031. * Creates a new connection point
  13032. * @param name defines the connection point name
  13033. * @param ownerBlock defines the block hosting this connection point
  13034. * @param direction defines the direction of the connection point
  13035. */
  13036. constructor(name: string, ownerBlock: NodeMaterialBlock, direction: NodeMaterialConnectionPointDirection, _blockType: new (...args: any[]) => T, _blockName: string, _nameForCheking?: string | undefined);
  13037. /**
  13038. * Gets a number indicating if the current point can be connected to another point
  13039. * @param connectionPoint defines the other connection point
  13040. * @returns a number defining the compatibility state
  13041. */
  13042. checkCompatibilityState(connectionPoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPointCompatibilityStates;
  13043. /**
  13044. * Creates a block suitable to be used as an input for this input point.
  13045. * If null is returned, a block based on the point type will be created.
  13046. * @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
  13047. */
  13048. createCustomInputBlock(): Nullable<[NodeMaterialBlock, string]>;
  13049. }
  13050. }
  13051. declare module BABYLON {
  13052. /**
  13053. * Enum defining the type of properties that can be edited in the property pages in the NME
  13054. */
  13055. export enum PropertyTypeForEdition {
  13056. /** property is a boolean */
  13057. Boolean = 0,
  13058. /** property is a float */
  13059. Float = 1,
  13060. /** property is a Vector2 */
  13061. Vector2 = 2,
  13062. /** property is a list of values */
  13063. List = 3
  13064. }
  13065. /**
  13066. * Interface that defines an option in a variable of type list
  13067. */
  13068. export interface IEditablePropertyListOption {
  13069. /** label of the option */
  13070. "label": string;
  13071. /** value of the option */
  13072. "value": number;
  13073. }
  13074. /**
  13075. * Interface that defines the options available for an editable property
  13076. */
  13077. export interface IEditablePropertyOption {
  13078. /** min value */
  13079. "min"?: number;
  13080. /** max value */
  13081. "max"?: number;
  13082. /** notifiers: indicates which actions to take when the property is changed */
  13083. "notifiers"?: {
  13084. /** the material should be rebuilt */
  13085. "rebuild"?: boolean;
  13086. /** the preview should be updated */
  13087. "update"?: boolean;
  13088. };
  13089. /** list of the options for a variable of type list */
  13090. "options"?: IEditablePropertyListOption[];
  13091. }
  13092. /**
  13093. * Interface that describes an editable property
  13094. */
  13095. export interface IPropertyDescriptionForEdition {
  13096. /** name of the property */
  13097. "propertyName": string;
  13098. /** display name of the property */
  13099. "displayName": string;
  13100. /** type of the property */
  13101. "type": PropertyTypeForEdition;
  13102. /** group of the property - all properties with the same group value will be displayed in a specific section */
  13103. "groupName": string;
  13104. /** options for the property */
  13105. "options": IEditablePropertyOption;
  13106. }
  13107. /**
  13108. * Decorator that flags a property in a node material block as being editable
  13109. */
  13110. export function editableInPropertyPage(displayName: string, propertyType?: PropertyTypeForEdition, groupName?: string, options?: IEditablePropertyOption): (target: any, propertyKey: string) => void;
  13111. }
  13112. declare module BABYLON {
  13113. /**
  13114. * Block used to implement the refraction part of the sub surface module of the PBR material
  13115. */
  13116. export class RefractionBlock extends NodeMaterialBlock {
  13117. /** @hidden */
  13118. _define3DName: string;
  13119. /** @hidden */
  13120. _refractionMatrixName: string;
  13121. /** @hidden */
  13122. _defineLODRefractionAlpha: string;
  13123. /** @hidden */
  13124. _defineLinearSpecularRefraction: string;
  13125. /** @hidden */
  13126. _defineOppositeZ: string;
  13127. /** @hidden */
  13128. _cubeSamplerName: string;
  13129. /** @hidden */
  13130. _2DSamplerName: string;
  13131. /** @hidden */
  13132. _vRefractionMicrosurfaceInfosName: string;
  13133. /** @hidden */
  13134. _vRefractionInfosName: string;
  13135. /** @hidden */
  13136. _vRefractionFilteringInfoName: string;
  13137. private _scene;
  13138. /**
  13139. * The properties below are set by the main PBR block prior to calling methods of this class.
  13140. * This is to avoid having to add them as inputs here whereas they are already inputs of the main block, so already known.
  13141. * It's less burden on the user side in the editor part.
  13142. */
  13143. /** @hidden */
  13144. viewConnectionPoint: NodeMaterialConnectionPoint;
  13145. /** @hidden */
  13146. indexOfRefractionConnectionPoint: NodeMaterialConnectionPoint;
  13147. /**
  13148. * This parameters will make the material used its opacity to control how much it is refracting against not.
  13149. * Materials half opaque for instance using refraction could benefit from this control.
  13150. */
  13151. linkRefractionWithTransparency: boolean;
  13152. /**
  13153. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  13154. */
  13155. invertRefractionY: boolean;
  13156. /**
  13157. * Gets or sets the texture associated with the node
  13158. */
  13159. texture: Nullable<BaseTexture>;
  13160. /**
  13161. * Create a new RefractionBlock
  13162. * @param name defines the block name
  13163. */
  13164. constructor(name: string);
  13165. /**
  13166. * Gets the current class name
  13167. * @returns the class name
  13168. */
  13169. getClassName(): string;
  13170. /**
  13171. * Gets the intensity input component
  13172. */
  13173. get intensity(): NodeMaterialConnectionPoint;
  13174. /**
  13175. * Gets the tint at distance input component
  13176. */
  13177. get tintAtDistance(): NodeMaterialConnectionPoint;
  13178. /**
  13179. * Gets the view input component
  13180. */
  13181. get view(): NodeMaterialConnectionPoint;
  13182. /**
  13183. * Gets the refraction object output component
  13184. */
  13185. get refraction(): NodeMaterialConnectionPoint;
  13186. /**
  13187. * Returns true if the block has a texture
  13188. */
  13189. get hasTexture(): boolean;
  13190. protected _getTexture(): Nullable<BaseTexture>;
  13191. autoConfigure(material: NodeMaterial): void;
  13192. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  13193. isReady(): boolean;
  13194. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh, subMesh?: SubMesh): void;
  13195. /**
  13196. * Gets the main code of the block (fragment side)
  13197. * @param state current state of the node material building
  13198. * @returns the shader code
  13199. */
  13200. getCode(state: NodeMaterialBuildState): string;
  13201. protected _buildBlock(state: NodeMaterialBuildState): this;
  13202. protected _dumpPropertiesCode(): string;
  13203. serialize(): any;
  13204. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  13205. dispose(): void;
  13206. }
  13207. }
  13208. declare module BABYLON {
  13209. /**
  13210. * Base block used as input for post process
  13211. */
  13212. export class CurrentScreenBlock extends NodeMaterialBlock {
  13213. private _samplerName;
  13214. private _linearDefineName;
  13215. private _gammaDefineName;
  13216. private _mainUVName;
  13217. private _tempTextureRead;
  13218. /**
  13219. * Gets or sets the texture associated with the node
  13220. */
  13221. texture: Nullable<BaseTexture>;
  13222. /**
  13223. * Gets or sets a boolean indicating if content needs to be converted to gamma space
  13224. */
  13225. convertToGammaSpace: boolean;
  13226. /**
  13227. * Gets or sets a boolean indicating if content needs to be converted to linear space
  13228. */
  13229. convertToLinearSpace: boolean;
  13230. /**
  13231. * Create a new CurrentScreenBlock
  13232. * @param name defines the block name
  13233. */
  13234. constructor(name: string);
  13235. /**
  13236. * Gets the current class name
  13237. * @returns the class name
  13238. */
  13239. getClassName(): string;
  13240. /**
  13241. * Gets the uv input component
  13242. */
  13243. get uv(): NodeMaterialConnectionPoint;
  13244. /**
  13245. * Gets the rgba output component
  13246. */
  13247. get rgba(): NodeMaterialConnectionPoint;
  13248. /**
  13249. * Gets the rgb output component
  13250. */
  13251. get rgb(): NodeMaterialConnectionPoint;
  13252. /**
  13253. * Gets the r output component
  13254. */
  13255. get r(): NodeMaterialConnectionPoint;
  13256. /**
  13257. * Gets the g output component
  13258. */
  13259. get g(): NodeMaterialConnectionPoint;
  13260. /**
  13261. * Gets the b output component
  13262. */
  13263. get b(): NodeMaterialConnectionPoint;
  13264. /**
  13265. * Gets the a output component
  13266. */
  13267. get a(): NodeMaterialConnectionPoint;
  13268. /**
  13269. * Initialize the block and prepare the context for build
  13270. * @param state defines the state that will be used for the build
  13271. */
  13272. initialize(state: NodeMaterialBuildState): void;
  13273. get target(): NodeMaterialBlockTargets;
  13274. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  13275. isReady(): boolean;
  13276. private _injectVertexCode;
  13277. private _writeTextureRead;
  13278. private _writeOutput;
  13279. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  13280. serialize(): any;
  13281. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  13282. dispose(): void;
  13283. }
  13284. }
  13285. declare module BABYLON {
  13286. /**
  13287. * Base block used for the particle texture
  13288. */
  13289. export class ParticleTextureBlock extends NodeMaterialBlock {
  13290. private _samplerName;
  13291. private _linearDefineName;
  13292. private _gammaDefineName;
  13293. private _tempTextureRead;
  13294. /**
  13295. * Gets or sets the texture associated with the node
  13296. */
  13297. texture: Nullable<BaseTexture>;
  13298. /**
  13299. * Gets or sets a boolean indicating if content needs to be converted to gamma space
  13300. */
  13301. convertToGammaSpace: boolean;
  13302. /**
  13303. * Gets or sets a boolean indicating if content needs to be converted to linear space
  13304. */
  13305. convertToLinearSpace: boolean;
  13306. /**
  13307. * Create a new ParticleTextureBlock
  13308. * @param name defines the block name
  13309. */
  13310. constructor(name: string);
  13311. /**
  13312. * Gets the current class name
  13313. * @returns the class name
  13314. */
  13315. getClassName(): string;
  13316. /**
  13317. * Gets the uv input component
  13318. */
  13319. get uv(): NodeMaterialConnectionPoint;
  13320. /**
  13321. * Gets the rgba output component
  13322. */
  13323. get rgba(): NodeMaterialConnectionPoint;
  13324. /**
  13325. * Gets the rgb output component
  13326. */
  13327. get rgb(): NodeMaterialConnectionPoint;
  13328. /**
  13329. * Gets the r output component
  13330. */
  13331. get r(): NodeMaterialConnectionPoint;
  13332. /**
  13333. * Gets the g output component
  13334. */
  13335. get g(): NodeMaterialConnectionPoint;
  13336. /**
  13337. * Gets the b output component
  13338. */
  13339. get b(): NodeMaterialConnectionPoint;
  13340. /**
  13341. * Gets the a output component
  13342. */
  13343. get a(): NodeMaterialConnectionPoint;
  13344. /**
  13345. * Initialize the block and prepare the context for build
  13346. * @param state defines the state that will be used for the build
  13347. */
  13348. initialize(state: NodeMaterialBuildState): void;
  13349. autoConfigure(material: NodeMaterial): void;
  13350. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  13351. isReady(): boolean;
  13352. private _writeOutput;
  13353. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  13354. serialize(): any;
  13355. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  13356. dispose(): void;
  13357. }
  13358. }
  13359. declare module BABYLON {
  13360. /**
  13361. * Class used to store shared data between 2 NodeMaterialBuildState
  13362. */
  13363. export class NodeMaterialBuildStateSharedData {
  13364. /**
  13365. * Gets the list of emitted varyings
  13366. */
  13367. temps: string[];
  13368. /**
  13369. * Gets the list of emitted varyings
  13370. */
  13371. varyings: string[];
  13372. /**
  13373. * Gets the varying declaration string
  13374. */
  13375. varyingDeclaration: string;
  13376. /**
  13377. * Input blocks
  13378. */
  13379. inputBlocks: InputBlock[];
  13380. /**
  13381. * Input blocks
  13382. */
  13383. textureBlocks: (TextureBlock | ReflectionTextureBaseBlock | RefractionBlock | CurrentScreenBlock | ParticleTextureBlock)[];
  13384. /**
  13385. * Bindable blocks (Blocks that need to set data to the effect)
  13386. */
  13387. bindableBlocks: NodeMaterialBlock[];
  13388. /**
  13389. * List of blocks that can provide a compilation fallback
  13390. */
  13391. blocksWithFallbacks: NodeMaterialBlock[];
  13392. /**
  13393. * List of blocks that can provide a define update
  13394. */
  13395. blocksWithDefines: NodeMaterialBlock[];
  13396. /**
  13397. * List of blocks that can provide a repeatable content
  13398. */
  13399. repeatableContentBlocks: NodeMaterialBlock[];
  13400. /**
  13401. * List of blocks that can provide a dynamic list of uniforms
  13402. */
  13403. dynamicUniformBlocks: NodeMaterialBlock[];
  13404. /**
  13405. * List of blocks that can block the isReady function for the material
  13406. */
  13407. blockingBlocks: NodeMaterialBlock[];
  13408. /**
  13409. * Gets the list of animated inputs
  13410. */
  13411. animatedInputs: InputBlock[];
  13412. /**
  13413. * Build Id used to avoid multiple recompilations
  13414. */
  13415. buildId: number;
  13416. /** List of emitted variables */
  13417. variableNames: {
  13418. [key: string]: number;
  13419. };
  13420. /** List of emitted defines */
  13421. defineNames: {
  13422. [key: string]: number;
  13423. };
  13424. /** Should emit comments? */
  13425. emitComments: boolean;
  13426. /** Emit build activity */
  13427. verbose: boolean;
  13428. /** Gets or sets the hosting scene */
  13429. scene: Scene;
  13430. /**
  13431. * Gets the compilation hints emitted at compilation time
  13432. */
  13433. hints: {
  13434. needWorldViewMatrix: boolean;
  13435. needWorldViewProjectionMatrix: boolean;
  13436. needAlphaBlending: boolean;
  13437. needAlphaTesting: boolean;
  13438. };
  13439. /**
  13440. * List of compilation checks
  13441. */
  13442. checks: {
  13443. emitVertex: boolean;
  13444. emitFragment: boolean;
  13445. notConnectedNonOptionalInputs: NodeMaterialConnectionPoint[];
  13446. };
  13447. /**
  13448. * Is vertex program allowed to be empty?
  13449. */
  13450. allowEmptyVertexProgram: boolean;
  13451. /** Creates a new shared data */
  13452. constructor();
  13453. /**
  13454. * Emits console errors and exceptions if there is a failing check
  13455. */
  13456. emitErrors(): void;
  13457. }
  13458. }
  13459. declare module BABYLON {
  13460. /**
  13461. * Class used to store node based material build state
  13462. */
  13463. export class NodeMaterialBuildState {
  13464. /** Gets or sets a boolean indicating if the current state can emit uniform buffers */
  13465. supportUniformBuffers: boolean;
  13466. /**
  13467. * Gets the list of emitted attributes
  13468. */
  13469. attributes: string[];
  13470. /**
  13471. * Gets the list of emitted uniforms
  13472. */
  13473. uniforms: string[];
  13474. /**
  13475. * Gets the list of emitted constants
  13476. */
  13477. constants: string[];
  13478. /**
  13479. * Gets the list of emitted samplers
  13480. */
  13481. samplers: string[];
  13482. /**
  13483. * Gets the list of emitted functions
  13484. */
  13485. functions: {
  13486. [key: string]: string;
  13487. };
  13488. /**
  13489. * Gets the list of emitted extensions
  13490. */
  13491. extensions: {
  13492. [key: string]: string;
  13493. };
  13494. /**
  13495. * Gets the target of the compilation state
  13496. */
  13497. target: NodeMaterialBlockTargets;
  13498. /**
  13499. * Gets the list of emitted counters
  13500. */
  13501. counters: {
  13502. [key: string]: number;
  13503. };
  13504. /**
  13505. * Shared data between multiple NodeMaterialBuildState instances
  13506. */
  13507. sharedData: NodeMaterialBuildStateSharedData;
  13508. /** @hidden */
  13509. _vertexState: NodeMaterialBuildState;
  13510. /** @hidden */
  13511. _attributeDeclaration: string;
  13512. /** @hidden */
  13513. _uniformDeclaration: string;
  13514. /** @hidden */
  13515. _constantDeclaration: string;
  13516. /** @hidden */
  13517. _samplerDeclaration: string;
  13518. /** @hidden */
  13519. _varyingTransfer: string;
  13520. /** @hidden */
  13521. _injectAtEnd: string;
  13522. private _repeatableContentAnchorIndex;
  13523. /** @hidden */
  13524. _builtCompilationString: string;
  13525. /**
  13526. * Gets the emitted compilation strings
  13527. */
  13528. compilationString: string;
  13529. /**
  13530. * Finalize the compilation strings
  13531. * @param state defines the current compilation state
  13532. */
  13533. finalize(state: NodeMaterialBuildState): void;
  13534. /** @hidden */
  13535. get _repeatableContentAnchor(): string;
  13536. /** @hidden */
  13537. _getFreeVariableName(prefix: string): string;
  13538. /** @hidden */
  13539. _getFreeDefineName(prefix: string): string;
  13540. /** @hidden */
  13541. _excludeVariableName(name: string): void;
  13542. /** @hidden */
  13543. _emit2DSampler(name: string): void;
  13544. /** @hidden */
  13545. _getGLType(type: NodeMaterialBlockConnectionPointTypes): string;
  13546. /** @hidden */
  13547. _emitExtension(name: string, extension: string, define?: string): void;
  13548. /** @hidden */
  13549. _emitFunction(name: string, code: string, comments: string): void;
  13550. /** @hidden */
  13551. _emitCodeFromInclude(includeName: string, comments: string, options?: {
  13552. replaceStrings?: {
  13553. search: RegExp;
  13554. replace: string;
  13555. }[];
  13556. repeatKey?: string;
  13557. }): string;
  13558. /** @hidden */
  13559. _emitFunctionFromInclude(includeName: string, comments: string, options?: {
  13560. repeatKey?: string;
  13561. removeAttributes?: boolean;
  13562. removeUniforms?: boolean;
  13563. removeVaryings?: boolean;
  13564. removeIfDef?: boolean;
  13565. replaceStrings?: {
  13566. search: RegExp;
  13567. replace: string;
  13568. }[];
  13569. }, storeKey?: string): void;
  13570. /** @hidden */
  13571. _registerTempVariable(name: string): boolean;
  13572. /** @hidden */
  13573. _emitVaryingFromString(name: string, type: string, define?: string, notDefine?: boolean): boolean;
  13574. /** @hidden */
  13575. _emitUniformFromString(name: string, type: string, define?: string, notDefine?: boolean): void;
  13576. /** @hidden */
  13577. _emitFloat(value: number): string;
  13578. }
  13579. }
  13580. declare module BABYLON {
  13581. /**
  13582. * Helper class used to generate session unique ID
  13583. */
  13584. export class UniqueIdGenerator {
  13585. private static _UniqueIdCounter;
  13586. /**
  13587. * Gets an unique (relatively to the current scene) Id
  13588. */
  13589. static get UniqueId(): number;
  13590. }
  13591. }
  13592. declare module BABYLON {
  13593. /**
  13594. * EffectFallbacks can be used to add fallbacks (properties to disable) to certain properties when desired to improve performance.
  13595. * (Eg. Start at high quality with reflection and fog, if fps is low, remove reflection, if still low remove fog)
  13596. */
  13597. export class EffectFallbacks implements IEffectFallbacks {
  13598. private _defines;
  13599. private _currentRank;
  13600. private _maxRank;
  13601. private _mesh;
  13602. /**
  13603. * Removes the fallback from the bound mesh.
  13604. */
  13605. unBindMesh(): void;
  13606. /**
  13607. * Adds a fallback on the specified property.
  13608. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  13609. * @param define The name of the define in the shader
  13610. */
  13611. addFallback(rank: number, define: string): void;
  13612. /**
  13613. * Sets the mesh to use CPU skinning when needing to fallback.
  13614. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  13615. * @param mesh The mesh to use the fallbacks.
  13616. */
  13617. addCPUSkinningFallback(rank: number, mesh: AbstractMesh): void;
  13618. /**
  13619. * Checks to see if more fallbacks are still available.
  13620. */
  13621. get hasMoreFallbacks(): boolean;
  13622. /**
  13623. * Removes the defines that should be removed when falling back.
  13624. * @param currentDefines defines the current define statements for the shader.
  13625. * @param effect defines the current effect we try to compile
  13626. * @returns The resulting defines with defines of the current rank removed.
  13627. */
  13628. reduce(currentDefines: string, effect: Effect): string;
  13629. }
  13630. }
  13631. declare module BABYLON {
  13632. /**
  13633. * Defines a block that can be used inside a node based material
  13634. */
  13635. export class NodeMaterialBlock {
  13636. private _buildId;
  13637. private _buildTarget;
  13638. private _target;
  13639. private _isFinalMerger;
  13640. private _isInput;
  13641. private _name;
  13642. protected _isUnique: boolean;
  13643. /** Gets or sets a boolean indicating that only one input can be connected at a time */
  13644. inputsAreExclusive: boolean;
  13645. /** @hidden */
  13646. _codeVariableName: string;
  13647. /** @hidden */
  13648. _inputs: NodeMaterialConnectionPoint[];
  13649. /** @hidden */
  13650. _outputs: NodeMaterialConnectionPoint[];
  13651. /** @hidden */
  13652. _preparationId: number;
  13653. /** @hidden */
  13654. readonly _originalTargetIsNeutral: boolean;
  13655. /**
  13656. * Gets the name of the block
  13657. */
  13658. get name(): string;
  13659. /**
  13660. * Sets the name of the block. Will check if the name is valid.
  13661. */
  13662. set name(newName: string);
  13663. /**
  13664. * Gets or sets the unique id of the node
  13665. */
  13666. uniqueId: number;
  13667. /**
  13668. * Gets or sets the comments associated with this block
  13669. */
  13670. comments: string;
  13671. /**
  13672. * Gets a boolean indicating that this block can only be used once per NodeMaterial
  13673. */
  13674. get isUnique(): boolean;
  13675. /**
  13676. * Gets a boolean indicating that this block is an end block (e.g. it is generating a system value)
  13677. */
  13678. get isFinalMerger(): boolean;
  13679. /**
  13680. * Gets a boolean indicating that this block is an input (e.g. it sends data to the shader)
  13681. */
  13682. get isInput(): boolean;
  13683. /**
  13684. * Gets or sets the build Id
  13685. */
  13686. get buildId(): number;
  13687. set buildId(value: number);
  13688. /**
  13689. * Gets or sets the target of the block
  13690. */
  13691. get target(): NodeMaterialBlockTargets;
  13692. set target(value: NodeMaterialBlockTargets);
  13693. /**
  13694. * Gets the list of input points
  13695. */
  13696. get inputs(): NodeMaterialConnectionPoint[];
  13697. /** Gets the list of output points */
  13698. get outputs(): NodeMaterialConnectionPoint[];
  13699. /**
  13700. * Find an input by its name
  13701. * @param name defines the name of the input to look for
  13702. * @returns the input or null if not found
  13703. */
  13704. getInputByName(name: string): Nullable<NodeMaterialConnectionPoint>;
  13705. /**
  13706. * Find an output by its name
  13707. * @param name defines the name of the output to look for
  13708. * @returns the output or null if not found
  13709. */
  13710. getOutputByName(name: string): Nullable<NodeMaterialConnectionPoint>;
  13711. /** Gets or sets a boolean indicating that this input can be edited in the Inspector (false by default) */
  13712. visibleInInspector: boolean;
  13713. /** Gets or sets a boolean indicating that this input can be edited from a collapsed frame*/
  13714. visibleOnFrame: boolean;
  13715. /**
  13716. * Creates a new NodeMaterialBlock
  13717. * @param name defines the block name
  13718. * @param target defines the target of that block (Vertex by default)
  13719. * @param isFinalMerger defines a boolean indicating that this block is an end block (e.g. it is generating a system value). Default is false
  13720. * @param isInput defines a boolean indicating that this block is an input (e.g. it sends data to the shader). Default is false
  13721. */
  13722. constructor(name: string, target?: NodeMaterialBlockTargets, isFinalMerger?: boolean, isInput?: boolean);
  13723. /**
  13724. * Initialize the block and prepare the context for build
  13725. * @param state defines the state that will be used for the build
  13726. */
  13727. initialize(state: NodeMaterialBuildState): void;
  13728. /**
  13729. * Bind data to effect. Will only be called for blocks with isBindable === true
  13730. * @param effect defines the effect to bind data to
  13731. * @param nodeMaterial defines the hosting NodeMaterial
  13732. * @param mesh defines the mesh that will be rendered
  13733. * @param subMesh defines the submesh that will be rendered
  13734. */
  13735. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh, subMesh?: SubMesh): void;
  13736. protected _declareOutput(output: NodeMaterialConnectionPoint, state: NodeMaterialBuildState): string;
  13737. protected _writeVariable(currentPoint: NodeMaterialConnectionPoint): string;
  13738. protected _writeFloat(value: number): string;
  13739. /**
  13740. * Gets the current class name e.g. "NodeMaterialBlock"
  13741. * @returns the class name
  13742. */
  13743. getClassName(): string;
  13744. /**
  13745. * Register a new input. Must be called inside a block constructor
  13746. * @param name defines the connection point name
  13747. * @param type defines the connection point type
  13748. * @param isOptional defines a boolean indicating that this input can be omitted
  13749. * @param target defines the target to use to limit the connection point (will be VertexAndFragment by default)
  13750. * @param point an already created connection point. If not provided, create a new one
  13751. * @returns the current block
  13752. */
  13753. registerInput(name: string, type: NodeMaterialBlockConnectionPointTypes, isOptional?: boolean, target?: NodeMaterialBlockTargets, point?: NodeMaterialConnectionPoint): this;
  13754. /**
  13755. * Register a new output. Must be called inside a block constructor
  13756. * @param name defines the connection point name
  13757. * @param type defines the connection point type
  13758. * @param target defines the target to use to limit the connection point (will be VertexAndFragment by default)
  13759. * @param point an already created connection point. If not provided, create a new one
  13760. * @returns the current block
  13761. */
  13762. registerOutput(name: string, type: NodeMaterialBlockConnectionPointTypes, target?: NodeMaterialBlockTargets, point?: NodeMaterialConnectionPoint): this;
  13763. /**
  13764. * Will return the first available input e.g. the first one which is not an uniform or an attribute
  13765. * @param forOutput defines an optional connection point to check compatibility with
  13766. * @returns the first available input or null
  13767. */
  13768. getFirstAvailableInput(forOutput?: Nullable<NodeMaterialConnectionPoint>): Nullable<NodeMaterialConnectionPoint>;
  13769. /**
  13770. * Will return the first available output e.g. the first one which is not yet connected and not a varying
  13771. * @param forBlock defines an optional block to check compatibility with
  13772. * @returns the first available input or null
  13773. */
  13774. getFirstAvailableOutput(forBlock?: Nullable<NodeMaterialBlock>): Nullable<NodeMaterialConnectionPoint>;
  13775. /**
  13776. * Gets the sibling of the given output
  13777. * @param current defines the current output
  13778. * @returns the next output in the list or null
  13779. */
  13780. getSiblingOutput(current: NodeMaterialConnectionPoint): Nullable<NodeMaterialConnectionPoint>;
  13781. /**
  13782. * Connect current block with another block
  13783. * @param other defines the block to connect with
  13784. * @param options define the various options to help pick the right connections
  13785. * @returns the current block
  13786. */
  13787. connectTo(other: NodeMaterialBlock, options?: {
  13788. input?: string;
  13789. output?: string;
  13790. outputSwizzle?: string;
  13791. }): this | undefined;
  13792. protected _buildBlock(state: NodeMaterialBuildState): void;
  13793. /**
  13794. * Add uniforms, samplers and uniform buffers at compilation time
  13795. * @param state defines the state to update
  13796. * @param nodeMaterial defines the node material requesting the update
  13797. * @param defines defines the material defines to update
  13798. * @param uniformBuffers defines the list of uniform buffer names
  13799. */
  13800. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, uniformBuffers: string[]): void;
  13801. /**
  13802. * Add potential fallbacks if shader compilation fails
  13803. * @param mesh defines the mesh to be rendered
  13804. * @param fallbacks defines the current prioritized list of fallbacks
  13805. */
  13806. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  13807. /**
  13808. * Initialize defines for shader compilation
  13809. * @param mesh defines the mesh to be rendered
  13810. * @param nodeMaterial defines the node material requesting the update
  13811. * @param defines defines the material defines to update
  13812. * @param useInstances specifies that instances should be used
  13813. */
  13814. initializeDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  13815. /**
  13816. * Update defines for shader compilation
  13817. * @param mesh defines the mesh to be rendered
  13818. * @param nodeMaterial defines the node material requesting the update
  13819. * @param defines defines the material defines to update
  13820. * @param useInstances specifies that instances should be used
  13821. * @param subMesh defines which submesh to render
  13822. */
  13823. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean, subMesh?: SubMesh): void;
  13824. /**
  13825. * Lets the block try to connect some inputs automatically
  13826. * @param material defines the hosting NodeMaterial
  13827. */
  13828. autoConfigure(material: NodeMaterial): void;
  13829. /**
  13830. * Function called when a block is declared as repeatable content generator
  13831. * @param vertexShaderState defines the current compilation state for the vertex shader
  13832. * @param fragmentShaderState defines the current compilation state for the fragment shader
  13833. * @param mesh defines the mesh to be rendered
  13834. * @param defines defines the material defines to update
  13835. */
  13836. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  13837. /**
  13838. * Checks if the block is ready
  13839. * @param mesh defines the mesh to be rendered
  13840. * @param nodeMaterial defines the node material requesting the update
  13841. * @param defines defines the material defines to update
  13842. * @param useInstances specifies that instances should be used
  13843. * @returns true if the block is ready
  13844. */
  13845. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): boolean;
  13846. protected _linkConnectionTypes(inputIndex0: number, inputIndex1: number, looseCoupling?: boolean): void;
  13847. private _processBuild;
  13848. /**
  13849. * Validates the new name for the block node.
  13850. * @param newName the new name to be given to the node.
  13851. * @returns false if the name is a reserve word, else true.
  13852. */
  13853. validateBlockName(newName: string): boolean;
  13854. /**
  13855. * Compile the current node and generate the shader code
  13856. * @param state defines the current compilation state (uniforms, samplers, current string)
  13857. * @param activeBlocks defines the list of active blocks (i.e. blocks to compile)
  13858. * @returns true if already built
  13859. */
  13860. build(state: NodeMaterialBuildState, activeBlocks: NodeMaterialBlock[]): boolean;
  13861. protected _inputRename(name: string): string;
  13862. protected _outputRename(name: string): string;
  13863. protected _dumpPropertiesCode(): string;
  13864. /** @hidden */
  13865. _dumpCode(uniqueNames: string[], alreadyDumped: NodeMaterialBlock[]): string;
  13866. /** @hidden */
  13867. _dumpCodeForOutputConnections(alreadyDumped: NodeMaterialBlock[]): string;
  13868. /**
  13869. * Clone the current block to a new identical block
  13870. * @param scene defines the hosting scene
  13871. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  13872. * @returns a copy of the current block
  13873. */
  13874. clone(scene: Scene, rootUrl?: string): Nullable<NodeMaterialBlock>;
  13875. /**
  13876. * Serializes this block in a JSON representation
  13877. * @returns the serialized block object
  13878. */
  13879. serialize(): any;
  13880. /** @hidden */
  13881. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  13882. private _deserializePortDisplayNamesAndExposedOnFrame;
  13883. /**
  13884. * Release resources
  13885. */
  13886. dispose(): void;
  13887. }
  13888. }
  13889. declare module BABYLON {
  13890. /**
  13891. * Base class of materials working in push mode in babylon JS
  13892. * @hidden
  13893. */
  13894. export class PushMaterial extends Material {
  13895. protected _activeEffect: Effect;
  13896. protected _normalMatrix: Matrix;
  13897. constructor(name: string, scene: Scene);
  13898. getEffect(): Effect;
  13899. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  13900. protected _isReadyForSubMesh(subMesh: SubMesh): boolean;
  13901. /**
  13902. * Binds the given world matrix to the active effect
  13903. *
  13904. * @param world the matrix to bind
  13905. */
  13906. bindOnlyWorldMatrix(world: Matrix): void;
  13907. /**
  13908. * Binds the given normal matrix to the active effect
  13909. *
  13910. * @param normalMatrix the matrix to bind
  13911. */
  13912. bindOnlyNormalMatrix(normalMatrix: Matrix): void;
  13913. bind(world: Matrix, mesh?: Mesh): void;
  13914. protected _afterBind(mesh: Mesh, effect?: Nullable<Effect>): void;
  13915. protected _mustRebind(scene: Scene, effect: Effect, visibility?: number): boolean;
  13916. }
  13917. }
  13918. declare module BABYLON {
  13919. /**
  13920. * Root class for all node material optimizers
  13921. */
  13922. export class NodeMaterialOptimizer {
  13923. /**
  13924. * Function used to optimize a NodeMaterial graph
  13925. * @param vertexOutputNodes defines the list of output nodes for the vertex shader
  13926. * @param fragmentOutputNodes defines the list of output nodes for the fragment shader
  13927. */
  13928. optimize(vertexOutputNodes: NodeMaterialBlock[], fragmentOutputNodes: NodeMaterialBlock[]): void;
  13929. }
  13930. }
  13931. declare module BABYLON {
  13932. /**
  13933. * Block used to transform a vector (2, 3 or 4) with a matrix. It will generate a Vector4
  13934. */
  13935. export class TransformBlock extends NodeMaterialBlock {
  13936. /**
  13937. * Defines the value to use to complement W value to transform it to a Vector4
  13938. */
  13939. complementW: number;
  13940. /**
  13941. * Defines the value to use to complement z value to transform it to a Vector4
  13942. */
  13943. complementZ: number;
  13944. /**
  13945. * Creates a new TransformBlock
  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 vector input
  13956. */
  13957. get vector(): NodeMaterialConnectionPoint;
  13958. /**
  13959. * Gets the output component
  13960. */
  13961. get output(): NodeMaterialConnectionPoint;
  13962. /**
  13963. * Gets the xyz output component
  13964. */
  13965. get xyz(): NodeMaterialConnectionPoint;
  13966. /**
  13967. * Gets the matrix transform input
  13968. */
  13969. get transform(): NodeMaterialConnectionPoint;
  13970. protected _buildBlock(state: NodeMaterialBuildState): this;
  13971. /**
  13972. * Update defines for shader compilation
  13973. * @param mesh defines the mesh to be rendered
  13974. * @param nodeMaterial defines the node material requesting the update
  13975. * @param defines defines the material defines to update
  13976. * @param useInstances specifies that instances should be used
  13977. * @param subMesh defines which submesh to render
  13978. */
  13979. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean, subMesh?: SubMesh): void;
  13980. serialize(): any;
  13981. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  13982. protected _dumpPropertiesCode(): string;
  13983. }
  13984. }
  13985. declare module BABYLON {
  13986. /**
  13987. * Block used to output the vertex position
  13988. */
  13989. export class VertexOutputBlock extends NodeMaterialBlock {
  13990. /**
  13991. * Creates a new VertexOutputBlock
  13992. * @param name defines the block name
  13993. */
  13994. constructor(name: string);
  13995. /**
  13996. * Gets the current class name
  13997. * @returns the class name
  13998. */
  13999. getClassName(): string;
  14000. /**
  14001. * Gets the vector input component
  14002. */
  14003. get vector(): NodeMaterialConnectionPoint;
  14004. protected _buildBlock(state: NodeMaterialBuildState): this;
  14005. }
  14006. }
  14007. declare module BABYLON {
  14008. /**
  14009. * Block used to output the final color
  14010. */
  14011. export class FragmentOutputBlock extends NodeMaterialBlock {
  14012. /**
  14013. * Create a new FragmentOutputBlock
  14014. * @param name defines the block name
  14015. */
  14016. constructor(name: string);
  14017. /**
  14018. * Gets the current class name
  14019. * @returns the class name
  14020. */
  14021. getClassName(): string;
  14022. /**
  14023. * Gets the rgba input component
  14024. */
  14025. get rgba(): NodeMaterialConnectionPoint;
  14026. /**
  14027. * Gets the rgb input component
  14028. */
  14029. get rgb(): NodeMaterialConnectionPoint;
  14030. /**
  14031. * Gets the a input component
  14032. */
  14033. get a(): NodeMaterialConnectionPoint;
  14034. protected _buildBlock(state: NodeMaterialBuildState): this;
  14035. }
  14036. }
  14037. declare module BABYLON {
  14038. /**
  14039. * Block used for the particle ramp gradient section
  14040. */
  14041. export class ParticleRampGradientBlock extends NodeMaterialBlock {
  14042. /**
  14043. * Create a new ParticleRampGradientBlock
  14044. * @param name defines the block name
  14045. */
  14046. constructor(name: string);
  14047. /**
  14048. * Gets the current class name
  14049. * @returns the class name
  14050. */
  14051. getClassName(): string;
  14052. /**
  14053. * Gets the color input component
  14054. */
  14055. get color(): NodeMaterialConnectionPoint;
  14056. /**
  14057. * Gets the rampColor output component
  14058. */
  14059. get rampColor(): NodeMaterialConnectionPoint;
  14060. /**
  14061. * Initialize the block and prepare the context for build
  14062. * @param state defines the state that will be used for the build
  14063. */
  14064. initialize(state: NodeMaterialBuildState): void;
  14065. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  14066. }
  14067. }
  14068. declare module BABYLON {
  14069. /**
  14070. * Block used for the particle blend multiply section
  14071. */
  14072. export class ParticleBlendMultiplyBlock extends NodeMaterialBlock {
  14073. /**
  14074. * Create a new ParticleBlendMultiplyBlock
  14075. * @param name defines the block name
  14076. */
  14077. constructor(name: string);
  14078. /**
  14079. * Gets the current class name
  14080. * @returns the class name
  14081. */
  14082. getClassName(): string;
  14083. /**
  14084. * Gets the color input component
  14085. */
  14086. get color(): NodeMaterialConnectionPoint;
  14087. /**
  14088. * Gets the alphaTexture input component
  14089. */
  14090. get alphaTexture(): NodeMaterialConnectionPoint;
  14091. /**
  14092. * Gets the alphaColor input component
  14093. */
  14094. get alphaColor(): NodeMaterialConnectionPoint;
  14095. /**
  14096. * Gets the blendColor output component
  14097. */
  14098. get blendColor(): NodeMaterialConnectionPoint;
  14099. /**
  14100. * Initialize the block and prepare the context for build
  14101. * @param state defines the state that will be used for the build
  14102. */
  14103. initialize(state: NodeMaterialBuildState): void;
  14104. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  14105. }
  14106. }
  14107. declare module BABYLON {
  14108. /**
  14109. * Block used to create a Vector2/3/4 out of individual inputs (one for each component)
  14110. */
  14111. export class VectorMergerBlock extends NodeMaterialBlock {
  14112. /**
  14113. * Create a new VectorMergerBlock
  14114. * @param name defines the block name
  14115. */
  14116. constructor(name: string);
  14117. /**
  14118. * Gets the current class name
  14119. * @returns the class name
  14120. */
  14121. getClassName(): string;
  14122. /**
  14123. * Gets the xyz component (input)
  14124. */
  14125. get xyzIn(): NodeMaterialConnectionPoint;
  14126. /**
  14127. * Gets the xy component (input)
  14128. */
  14129. get xyIn(): NodeMaterialConnectionPoint;
  14130. /**
  14131. * Gets the x component (input)
  14132. */
  14133. get x(): NodeMaterialConnectionPoint;
  14134. /**
  14135. * Gets the y component (input)
  14136. */
  14137. get y(): NodeMaterialConnectionPoint;
  14138. /**
  14139. * Gets the z component (input)
  14140. */
  14141. get z(): NodeMaterialConnectionPoint;
  14142. /**
  14143. * Gets the w component (input)
  14144. */
  14145. get w(): NodeMaterialConnectionPoint;
  14146. /**
  14147. * Gets the xyzw component (output)
  14148. */
  14149. get xyzw(): NodeMaterialConnectionPoint;
  14150. /**
  14151. * Gets the xyz component (output)
  14152. */
  14153. get xyzOut(): NodeMaterialConnectionPoint;
  14154. /**
  14155. * Gets the xy component (output)
  14156. */
  14157. get xyOut(): NodeMaterialConnectionPoint;
  14158. /**
  14159. * Gets the xy component (output)
  14160. * @deprecated Please use xyOut instead.
  14161. */
  14162. get xy(): NodeMaterialConnectionPoint;
  14163. /**
  14164. * Gets the xyz component (output)
  14165. * @deprecated Please use xyzOut instead.
  14166. */
  14167. get xyz(): NodeMaterialConnectionPoint;
  14168. protected _buildBlock(state: NodeMaterialBuildState): this;
  14169. }
  14170. }
  14171. declare module BABYLON {
  14172. /**
  14173. * Block used to remap a float from a range to a new one
  14174. */
  14175. export class RemapBlock extends NodeMaterialBlock {
  14176. /**
  14177. * Gets or sets the source range
  14178. */
  14179. sourceRange: Vector2;
  14180. /**
  14181. * Gets or sets the target range
  14182. */
  14183. targetRange: Vector2;
  14184. /**
  14185. * Creates a new RemapBlock
  14186. * @param name defines the block name
  14187. */
  14188. constructor(name: string);
  14189. /**
  14190. * Gets the current class name
  14191. * @returns the class name
  14192. */
  14193. getClassName(): string;
  14194. /**
  14195. * Gets the input component
  14196. */
  14197. get input(): NodeMaterialConnectionPoint;
  14198. /**
  14199. * Gets the source min input component
  14200. */
  14201. get sourceMin(): NodeMaterialConnectionPoint;
  14202. /**
  14203. * Gets the source max input component
  14204. */
  14205. get sourceMax(): NodeMaterialConnectionPoint;
  14206. /**
  14207. * Gets the target min input component
  14208. */
  14209. get targetMin(): NodeMaterialConnectionPoint;
  14210. /**
  14211. * Gets the target max input component
  14212. */
  14213. get targetMax(): NodeMaterialConnectionPoint;
  14214. /**
  14215. * Gets the output component
  14216. */
  14217. get output(): NodeMaterialConnectionPoint;
  14218. protected _buildBlock(state: NodeMaterialBuildState): this;
  14219. protected _dumpPropertiesCode(): string;
  14220. serialize(): any;
  14221. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  14222. }
  14223. }
  14224. declare module BABYLON {
  14225. /**
  14226. * Block used to multiply 2 values
  14227. */
  14228. export class MultiplyBlock extends NodeMaterialBlock {
  14229. /**
  14230. * Creates a new MultiplyBlock
  14231. * @param name defines the block name
  14232. */
  14233. constructor(name: string);
  14234. /**
  14235. * Gets the current class name
  14236. * @returns the class name
  14237. */
  14238. getClassName(): string;
  14239. /**
  14240. * Gets the left operand input component
  14241. */
  14242. get left(): NodeMaterialConnectionPoint;
  14243. /**
  14244. * Gets the right operand input component
  14245. */
  14246. get right(): NodeMaterialConnectionPoint;
  14247. /**
  14248. * Gets the output component
  14249. */
  14250. get output(): NodeMaterialConnectionPoint;
  14251. protected _buildBlock(state: NodeMaterialBuildState): this;
  14252. }
  14253. }
  14254. declare module BABYLON {
  14255. /** Interface used by value gradients (color, factor, ...) */
  14256. export interface IValueGradient {
  14257. /**
  14258. * Gets or sets the gradient value (between 0 and 1)
  14259. */
  14260. gradient: number;
  14261. }
  14262. /** Class used to store color4 gradient */
  14263. export class ColorGradient implements IValueGradient {
  14264. /**
  14265. * Gets or sets the gradient value (between 0 and 1)
  14266. */
  14267. gradient: number;
  14268. /**
  14269. * Gets or sets first associated color
  14270. */
  14271. color1: Color4;
  14272. /**
  14273. * Gets or sets second associated color
  14274. */
  14275. color2?: Color4 | undefined;
  14276. /**
  14277. * Creates a new color4 gradient
  14278. * @param gradient gets or sets the gradient value (between 0 and 1)
  14279. * @param color1 gets or sets first associated color
  14280. * @param color2 gets or sets first second color
  14281. */
  14282. constructor(
  14283. /**
  14284. * Gets or sets the gradient value (between 0 and 1)
  14285. */
  14286. gradient: number,
  14287. /**
  14288. * Gets or sets first associated color
  14289. */
  14290. color1: Color4,
  14291. /**
  14292. * Gets or sets second associated color
  14293. */
  14294. color2?: Color4 | undefined);
  14295. /**
  14296. * Will get a color picked randomly between color1 and color2.
  14297. * If color2 is undefined then color1 will be used
  14298. * @param result defines the target Color4 to store the result in
  14299. */
  14300. getColorToRef(result: Color4): void;
  14301. }
  14302. /** Class used to store color 3 gradient */
  14303. export class Color3Gradient implements IValueGradient {
  14304. /**
  14305. * Gets or sets the gradient value (between 0 and 1)
  14306. */
  14307. gradient: number;
  14308. /**
  14309. * Gets or sets the associated color
  14310. */
  14311. color: Color3;
  14312. /**
  14313. * Creates a new color3 gradient
  14314. * @param gradient gets or sets the gradient value (between 0 and 1)
  14315. * @param color gets or sets associated color
  14316. */
  14317. constructor(
  14318. /**
  14319. * Gets or sets the gradient value (between 0 and 1)
  14320. */
  14321. gradient: number,
  14322. /**
  14323. * Gets or sets the associated color
  14324. */
  14325. color: Color3);
  14326. }
  14327. /** Class used to store factor gradient */
  14328. export class FactorGradient implements IValueGradient {
  14329. /**
  14330. * Gets or sets the gradient value (between 0 and 1)
  14331. */
  14332. gradient: number;
  14333. /**
  14334. * Gets or sets first associated factor
  14335. */
  14336. factor1: number;
  14337. /**
  14338. * Gets or sets second associated factor
  14339. */
  14340. factor2?: number | undefined;
  14341. /**
  14342. * Creates a new factor gradient
  14343. * @param gradient gets or sets the gradient value (between 0 and 1)
  14344. * @param factor1 gets or sets first associated factor
  14345. * @param factor2 gets or sets second associated factor
  14346. */
  14347. constructor(
  14348. /**
  14349. * Gets or sets the gradient value (between 0 and 1)
  14350. */
  14351. gradient: number,
  14352. /**
  14353. * Gets or sets first associated factor
  14354. */
  14355. factor1: number,
  14356. /**
  14357. * Gets or sets second associated factor
  14358. */
  14359. factor2?: number | undefined);
  14360. /**
  14361. * Will get a number picked randomly between factor1 and factor2.
  14362. * If factor2 is undefined then factor1 will be used
  14363. * @returns the picked number
  14364. */
  14365. getFactor(): number;
  14366. }
  14367. /**
  14368. * Helper used to simplify some generic gradient tasks
  14369. */
  14370. export class GradientHelper {
  14371. /**
  14372. * Gets the current gradient from an array of IValueGradient
  14373. * @param ratio defines the current ratio to get
  14374. * @param gradients defines the array of IValueGradient
  14375. * @param updateFunc defines the callback function used to get the final value from the selected gradients
  14376. */
  14377. static GetCurrentGradient(ratio: number, gradients: IValueGradient[], updateFunc: (current: IValueGradient, next: IValueGradient, scale: number) => void): void;
  14378. }
  14379. }
  14380. declare module BABYLON {
  14381. interface ThinEngine {
  14382. /**
  14383. * Creates a raw texture
  14384. * @param data defines the data to store in the texture
  14385. * @param width defines the width of the texture
  14386. * @param height defines the height of the texture
  14387. * @param format defines the format of the data
  14388. * @param generateMipMaps defines if the engine should generate the mip levels
  14389. * @param invertY defines if data must be stored with Y axis inverted
  14390. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  14391. * @param compression defines the compression used (null by default)
  14392. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  14393. * @returns the raw texture inside an InternalTexture
  14394. */
  14395. createRawTexture(data: Nullable<ArrayBufferView>, width: number, height: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, type: number): InternalTexture;
  14396. /**
  14397. * Update a raw texture
  14398. * @param texture defines the texture to update
  14399. * @param data defines the data to store in the texture
  14400. * @param format defines the format of the data
  14401. * @param invertY defines if data must be stored with Y axis inverted
  14402. */
  14403. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  14404. /**
  14405. * Update a raw texture
  14406. * @param texture defines the texture to update
  14407. * @param data defines the data to store in the texture
  14408. * @param format defines the format of the data
  14409. * @param invertY defines if data must be stored with Y axis inverted
  14410. * @param compression defines the compression used (null by default)
  14411. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  14412. */
  14413. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, type: number): void;
  14414. /**
  14415. * Creates a new raw cube texture
  14416. * @param data defines the array of data to use to create each face
  14417. * @param size defines the size of the textures
  14418. * @param format defines the format of the data
  14419. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  14420. * @param generateMipMaps defines if the engine should generate the mip levels
  14421. * @param invertY defines if data must be stored with Y axis inverted
  14422. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  14423. * @param compression defines the compression used (null by default)
  14424. * @returns the cube texture as an InternalTexture
  14425. */
  14426. createRawCubeTexture(data: Nullable<ArrayBufferView[]>, size: number, format: number, type: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>): InternalTexture;
  14427. /**
  14428. * Update a raw cube texture
  14429. * @param texture defines the texture to update
  14430. * @param data defines the data to store
  14431. * @param format defines the data format
  14432. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  14433. * @param invertY defines if data must be stored with Y axis inverted
  14434. */
  14435. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean): void;
  14436. /**
  14437. * Update a raw cube texture
  14438. * @param texture defines the texture to update
  14439. * @param data defines the data to store
  14440. * @param format defines the data format
  14441. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  14442. * @param invertY defines if data must be stored with Y axis inverted
  14443. * @param compression defines the compression used (null by default)
  14444. */
  14445. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>): void;
  14446. /**
  14447. * Update a raw cube texture
  14448. * @param texture defines the texture to update
  14449. * @param data defines the data to store
  14450. * @param format defines the data format
  14451. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  14452. * @param invertY defines if data must be stored with Y axis inverted
  14453. * @param compression defines the compression used (null by default)
  14454. * @param level defines which level of the texture to update
  14455. */
  14456. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>, level: number): void;
  14457. /**
  14458. * Creates a new raw cube texture from a specified url
  14459. * @param url defines the url where the data is located
  14460. * @param scene defines the current scene
  14461. * @param size defines the size of the textures
  14462. * @param format defines the format of the data
  14463. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  14464. * @param noMipmap defines if the engine should avoid generating the mip levels
  14465. * @param callback defines a callback used to extract texture data from loaded data
  14466. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  14467. * @param onLoad defines a callback called when texture is loaded
  14468. * @param onError defines a callback called if there is an error
  14469. * @returns the cube texture as an InternalTexture
  14470. */
  14471. 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;
  14472. /**
  14473. * Creates a new raw cube texture from a specified url
  14474. * @param url defines the url where the data is located
  14475. * @param scene defines the current scene
  14476. * @param size defines the size of the textures
  14477. * @param format defines the format of the data
  14478. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  14479. * @param noMipmap defines if the engine should avoid generating the mip levels
  14480. * @param callback defines a callback used to extract texture data from loaded data
  14481. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  14482. * @param onLoad defines a callback called when texture is loaded
  14483. * @param onError defines a callback called if there is an error
  14484. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  14485. * @param invertY defines if data must be stored with Y axis inverted
  14486. * @returns the cube texture as an InternalTexture
  14487. */
  14488. 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;
  14489. /**
  14490. * Creates a new raw 3D texture
  14491. * @param data defines the data used to create the texture
  14492. * @param width defines the width of the texture
  14493. * @param height defines the height of the texture
  14494. * @param depth defines the depth of the texture
  14495. * @param format defines the format of the texture
  14496. * @param generateMipMaps defines if the engine must generate mip levels
  14497. * @param invertY defines if data must be stored with Y axis inverted
  14498. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  14499. * @param compression defines the compressed used (can be null)
  14500. * @param textureType defines the compressed used (can be null)
  14501. * @returns a new raw 3D texture (stored in an InternalTexture)
  14502. */
  14503. createRawTexture3D(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, textureType: number): InternalTexture;
  14504. /**
  14505. * Update a raw 3D texture
  14506. * @param texture defines the texture to update
  14507. * @param data defines the data to store
  14508. * @param format defines the data format
  14509. * @param invertY defines if data must be stored with Y axis inverted
  14510. */
  14511. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  14512. /**
  14513. * Update a raw 3D texture
  14514. * @param texture defines the texture to update
  14515. * @param data defines the data to store
  14516. * @param format defines the data format
  14517. * @param invertY defines if data must be stored with Y axis inverted
  14518. * @param compression defines the used compression (can be null)
  14519. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  14520. */
  14521. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, textureType: number): void;
  14522. /**
  14523. * Creates a new raw 2D array texture
  14524. * @param data defines the data used to create the texture
  14525. * @param width defines the width of the texture
  14526. * @param height defines the height of the texture
  14527. * @param depth defines the number of layers of the texture
  14528. * @param format defines the format of the texture
  14529. * @param generateMipMaps defines if the engine must generate mip levels
  14530. * @param invertY defines if data must be stored with Y axis inverted
  14531. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  14532. * @param compression defines the compressed used (can be null)
  14533. * @param textureType defines the compressed used (can be null)
  14534. * @returns a new raw 2D array texture (stored in an InternalTexture)
  14535. */
  14536. createRawTexture2DArray(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, textureType: number): InternalTexture;
  14537. /**
  14538. * Update a raw 2D array texture
  14539. * @param texture defines the texture to update
  14540. * @param data defines the data to store
  14541. * @param format defines the data format
  14542. * @param invertY defines if data must be stored with Y axis inverted
  14543. */
  14544. updateRawTexture2DArray(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  14545. /**
  14546. * Update a raw 2D array texture
  14547. * @param texture defines the texture to update
  14548. * @param data defines the data to store
  14549. * @param format defines the data format
  14550. * @param invertY defines if data must be stored with Y axis inverted
  14551. * @param compression defines the used compression (can be null)
  14552. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  14553. */
  14554. updateRawTexture2DArray(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, textureType: number): void;
  14555. }
  14556. }
  14557. declare module BABYLON {
  14558. /**
  14559. * Raw texture can help creating a texture directly from an array of data.
  14560. * This can be super useful if you either get the data from an uncompressed source or
  14561. * if you wish to create your texture pixel by pixel.
  14562. */
  14563. export class RawTexture extends Texture {
  14564. /**
  14565. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  14566. */
  14567. format: number;
  14568. /**
  14569. * Instantiates a new RawTexture.
  14570. * Raw texture can help creating a texture directly from an array of data.
  14571. * This can be super useful if you either get the data from an uncompressed source or
  14572. * if you wish to create your texture pixel by pixel.
  14573. * @param data define the array of data to use to create the texture
  14574. * @param width define the width of the texture
  14575. * @param height define the height of the texture
  14576. * @param format define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  14577. * @param sceneOrEngine defines the scene or engine the texture will belong to
  14578. * @param generateMipMaps define whether mip maps should be generated or not
  14579. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  14580. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  14581. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  14582. */
  14583. constructor(data: ArrayBufferView, width: number, height: number,
  14584. /**
  14585. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  14586. */
  14587. format: number, sceneOrEngine: Nullable<Scene | ThinEngine>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number);
  14588. /**
  14589. * Updates the texture underlying data.
  14590. * @param data Define the new data of the texture
  14591. */
  14592. update(data: ArrayBufferView): void;
  14593. /**
  14594. * Creates a luminance texture from some data.
  14595. * @param data Define the texture data
  14596. * @param width Define the width of the texture
  14597. * @param height Define the height of the texture
  14598. * @param sceneOrEngine defines the scene or engine the texture will belong to
  14599. * @param generateMipMaps Define whether or not to create mip maps for the texture
  14600. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  14601. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  14602. * @returns the luminance texture
  14603. */
  14604. static CreateLuminanceTexture(data: ArrayBufferView, width: number, height: number, sceneOrEngine: Nullable<Scene | ThinEngine>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  14605. /**
  14606. * Creates a luminance alpha texture from some data.
  14607. * @param data Define the texture data
  14608. * @param width Define the width of the texture
  14609. * @param height Define the height of the texture
  14610. * @param sceneOrEngine defines the scene or engine the texture will belong to
  14611. * @param generateMipMaps Define whether or not to create mip maps for the texture
  14612. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  14613. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  14614. * @returns the luminance alpha texture
  14615. */
  14616. static CreateLuminanceAlphaTexture(data: ArrayBufferView, width: number, height: number, sceneOrEngine: Nullable<Scene | ThinEngine>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  14617. /**
  14618. * Creates an alpha texture from some data.
  14619. * @param data Define the texture data
  14620. * @param width Define the width of the texture
  14621. * @param height Define the height of the texture
  14622. * @param sceneOrEngine defines the scene or engine the texture will belong to
  14623. * @param generateMipMaps Define whether or not to create mip maps for the texture
  14624. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  14625. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  14626. * @returns the alpha texture
  14627. */
  14628. static CreateAlphaTexture(data: ArrayBufferView, width: number, height: number, sceneOrEngine: Nullable<Scene | ThinEngine>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  14629. /**
  14630. * Creates a RGB texture from some data.
  14631. * @param data Define the texture data
  14632. * @param width Define the width of the texture
  14633. * @param height Define the height of the texture
  14634. * @param sceneOrEngine defines the scene or engine the texture will belong to
  14635. * @param generateMipMaps Define whether or not to create mip maps for the texture
  14636. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  14637. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  14638. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  14639. * @returns the RGB alpha texture
  14640. */
  14641. static CreateRGBTexture(data: ArrayBufferView, width: number, height: number, sceneOrEngine: Nullable<Scene | ThinEngine>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  14642. /**
  14643. * Creates a RGBA texture from some data.
  14644. * @param data Define the texture data
  14645. * @param width Define the width of the texture
  14646. * @param height Define the height of the texture
  14647. * @param sceneOrEngine defines the scene or engine the texture will belong to
  14648. * @param generateMipMaps Define whether or not to create mip maps for the texture
  14649. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  14650. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  14651. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  14652. * @returns the RGBA texture
  14653. */
  14654. static CreateRGBATexture(data: ArrayBufferView, width: number, height: number, sceneOrEngine: Nullable<Scene | ThinEngine>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  14655. /**
  14656. * Creates a R texture from some data.
  14657. * @param data Define the texture data
  14658. * @param width Define the width of the texture
  14659. * @param height Define the height of the texture
  14660. * @param sceneOrEngine defines the scene or engine the texture will belong to
  14661. * @param generateMipMaps Define whether or not to create mip maps for the texture
  14662. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  14663. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  14664. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  14665. * @returns the R texture
  14666. */
  14667. static CreateRTexture(data: ArrayBufferView, width: number, height: number, sceneOrEngine: Nullable<Scene | ThinEngine>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  14668. }
  14669. }
  14670. declare module BABYLON {
  14671. interface ThinEngine {
  14672. /**
  14673. * Update a dynamic index buffer
  14674. * @param indexBuffer defines the target index buffer
  14675. * @param indices defines the data to update
  14676. * @param offset defines the offset in the target index buffer where update should start
  14677. */
  14678. updateDynamicIndexBuffer(indexBuffer: DataBuffer, indices: IndicesArray, offset?: number): void;
  14679. /**
  14680. * Updates a dynamic vertex buffer.
  14681. * @param vertexBuffer the vertex buffer to update
  14682. * @param data the data used to update the vertex buffer
  14683. * @param byteOffset the byte offset of the data
  14684. * @param byteLength the byte length of the data
  14685. */
  14686. updateDynamicVertexBuffer(vertexBuffer: DataBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  14687. }
  14688. }
  14689. declare module BABYLON {
  14690. interface AbstractScene {
  14691. /**
  14692. * The list of procedural textures added to the scene
  14693. * @see https://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  14694. */
  14695. proceduralTextures: Array<ProceduralTexture>;
  14696. }
  14697. /**
  14698. * Defines the Procedural Texture scene component responsible to manage any Procedural Texture
  14699. * in a given scene.
  14700. */
  14701. export class ProceduralTextureSceneComponent implements ISceneComponent {
  14702. /**
  14703. * The component name helpful to identify the component in the list of scene components.
  14704. */
  14705. readonly name: string;
  14706. /**
  14707. * The scene the component belongs to.
  14708. */
  14709. scene: Scene;
  14710. /**
  14711. * Creates a new instance of the component for the given scene
  14712. * @param scene Defines the scene to register the component in
  14713. */
  14714. constructor(scene: Scene);
  14715. /**
  14716. * Registers the component in a given scene
  14717. */
  14718. register(): void;
  14719. /**
  14720. * Rebuilds the elements related to this component in case of
  14721. * context lost for instance.
  14722. */
  14723. rebuild(): void;
  14724. /**
  14725. * Disposes the component and the associated resources.
  14726. */
  14727. dispose(): void;
  14728. private _beforeClear;
  14729. }
  14730. }
  14731. declare module BABYLON {
  14732. interface ThinEngine {
  14733. /**
  14734. * Creates a new render target cube texture
  14735. * @param size defines the size of the texture
  14736. * @param options defines the options used to create the texture
  14737. * @returns a new render target cube texture stored in an InternalTexture
  14738. */
  14739. createRenderTargetCubeTexture(size: number, options?: Partial<RenderTargetCreationOptions>): InternalTexture;
  14740. }
  14741. }
  14742. declare module BABYLON {
  14743. /** @hidden */
  14744. export var proceduralVertexShader: {
  14745. name: string;
  14746. shader: string;
  14747. };
  14748. }
  14749. declare module BABYLON {
  14750. /**
  14751. * 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.
  14752. * This is the base class of any Procedural texture and contains most of the shareable code.
  14753. * @see https://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  14754. */
  14755. export class ProceduralTexture extends Texture {
  14756. /**
  14757. * Define if the texture is enabled or not (disabled texture will not render)
  14758. */
  14759. isEnabled: boolean;
  14760. /**
  14761. * Define if the texture must be cleared before rendering (default is true)
  14762. */
  14763. autoClear: boolean;
  14764. /**
  14765. * Callback called when the texture is generated
  14766. */
  14767. onGenerated: () => void;
  14768. /**
  14769. * Event raised when the texture is generated
  14770. */
  14771. onGeneratedObservable: Observable<ProceduralTexture>;
  14772. /**
  14773. * Event raised before the texture is generated
  14774. */
  14775. onBeforeGenerationObservable: Observable<ProceduralTexture>;
  14776. /**
  14777. * Gets or sets the node material used to create this texture (null if the texture was manually created)
  14778. */
  14779. nodeMaterialSource: Nullable<NodeMaterial>;
  14780. /** @hidden */
  14781. _generateMipMaps: boolean;
  14782. /** @hidden **/
  14783. _effect: Effect;
  14784. /** @hidden */
  14785. _textures: {
  14786. [key: string]: Texture;
  14787. };
  14788. /** @hidden */
  14789. protected _fallbackTexture: Nullable<Texture>;
  14790. private _size;
  14791. private _textureType;
  14792. private _currentRefreshId;
  14793. private _frameId;
  14794. private _refreshRate;
  14795. private _vertexBuffers;
  14796. private _indexBuffer;
  14797. private _uniforms;
  14798. private _samplers;
  14799. private _fragment;
  14800. private _floats;
  14801. private _ints;
  14802. private _floatsArrays;
  14803. private _colors3;
  14804. private _colors4;
  14805. private _vectors2;
  14806. private _vectors3;
  14807. private _matrices;
  14808. private _fallbackTextureUsed;
  14809. private _fullEngine;
  14810. private _cachedDefines;
  14811. private _contentUpdateId;
  14812. private _contentData;
  14813. /**
  14814. * Instantiates a new procedural texture.
  14815. * 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.
  14816. * This is the base class of any Procedural texture and contains most of the shareable code.
  14817. * @see https://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  14818. * @param name Define the name of the texture
  14819. * @param size Define the size of the texture to create
  14820. * @param fragment Define the fragment shader to use to generate the texture or null if it is defined later
  14821. * @param scene Define the scene the texture belongs to
  14822. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  14823. * @param generateMipMaps Define if the texture should creates mip maps or not
  14824. * @param isCube Define if the texture is a cube texture or not (this will render each faces of the cube)
  14825. * @param textureType The FBO internal texture type
  14826. */
  14827. constructor(name: string, size: RenderTargetTextureSize, fragment: any, scene: Nullable<Scene>, fallbackTexture?: Nullable<Texture>, generateMipMaps?: boolean, isCube?: boolean, textureType?: number);
  14828. /**
  14829. * The effect that is created when initializing the post process.
  14830. * @returns The created effect corresponding the the postprocess.
  14831. */
  14832. getEffect(): Effect;
  14833. /**
  14834. * Gets texture content (Use this function wisely as reading from a texture can be slow)
  14835. * @returns an ArrayBufferView promise (Uint8Array or Float32Array)
  14836. */
  14837. getContent(): Nullable<Promise<ArrayBufferView>>;
  14838. private _createIndexBuffer;
  14839. /** @hidden */
  14840. _rebuild(): void;
  14841. /**
  14842. * Resets the texture in order to recreate its associated resources.
  14843. * This can be called in case of context loss
  14844. */
  14845. reset(): void;
  14846. protected _getDefines(): string;
  14847. /**
  14848. * Is the texture ready to be used ? (rendered at least once)
  14849. * @returns true if ready, otherwise, false.
  14850. */
  14851. isReady(): boolean;
  14852. /**
  14853. * Resets the refresh counter of the texture and start bak from scratch.
  14854. * Could be useful to regenerate the texture if it is setup to render only once.
  14855. */
  14856. resetRefreshCounter(): void;
  14857. /**
  14858. * Set the fragment shader to use in order to render the texture.
  14859. * @param fragment This can be set to a path (into the shader store) or to a json object containing a fragmentElement property.
  14860. */
  14861. setFragment(fragment: any): void;
  14862. /**
  14863. * Define the refresh rate of the texture or the rendering frequency.
  14864. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  14865. */
  14866. get refreshRate(): number;
  14867. set refreshRate(value: number);
  14868. /** @hidden */
  14869. _shouldRender(): boolean;
  14870. /**
  14871. * Get the size the texture is rendering at.
  14872. * @returns the size (on cube texture it is always squared)
  14873. */
  14874. getRenderSize(): RenderTargetTextureSize;
  14875. /**
  14876. * Resize the texture to new value.
  14877. * @param size Define the new size the texture should have
  14878. * @param generateMipMaps Define whether the new texture should create mip maps
  14879. */
  14880. resize(size: number, generateMipMaps: boolean): void;
  14881. private _checkUniform;
  14882. /**
  14883. * Set a texture in the shader program used to render.
  14884. * @param name Define the name of the uniform samplers as defined in the shader
  14885. * @param texture Define the texture to bind to this sampler
  14886. * @return the texture itself allowing "fluent" like uniform updates
  14887. */
  14888. setTexture(name: string, texture: Texture): ProceduralTexture;
  14889. /**
  14890. * Set a float in the shader.
  14891. * @param name Define the name of the uniform as defined in the shader
  14892. * @param value Define the value to give to the uniform
  14893. * @return the texture itself allowing "fluent" like uniform updates
  14894. */
  14895. setFloat(name: string, value: number): ProceduralTexture;
  14896. /**
  14897. * Set a int in the shader.
  14898. * @param name Define the name of the uniform as defined in the shader
  14899. * @param value Define the value to give to the uniform
  14900. * @return the texture itself allowing "fluent" like uniform updates
  14901. */
  14902. setInt(name: string, value: number): ProceduralTexture;
  14903. /**
  14904. * Set an array of floats in the shader.
  14905. * @param name Define the name of the uniform as defined in the shader
  14906. * @param value Define the value to give to the uniform
  14907. * @return the texture itself allowing "fluent" like uniform updates
  14908. */
  14909. setFloats(name: string, value: number[]): ProceduralTexture;
  14910. /**
  14911. * Set a vec3 in the shader from a Color3.
  14912. * @param name Define the name of the uniform as defined in the shader
  14913. * @param value Define the value to give to the uniform
  14914. * @return the texture itself allowing "fluent" like uniform updates
  14915. */
  14916. setColor3(name: string, value: Color3): ProceduralTexture;
  14917. /**
  14918. * Set a vec4 in the shader from a Color4.
  14919. * @param name Define the name of the uniform as defined in the shader
  14920. * @param value Define the value to give to the uniform
  14921. * @return the texture itself allowing "fluent" like uniform updates
  14922. */
  14923. setColor4(name: string, value: Color4): ProceduralTexture;
  14924. /**
  14925. * Set a vec2 in the shader from a Vector2.
  14926. * @param name Define the name of the uniform as defined in the shader
  14927. * @param value Define the value to give to the uniform
  14928. * @return the texture itself allowing "fluent" like uniform updates
  14929. */
  14930. setVector2(name: string, value: Vector2): ProceduralTexture;
  14931. /**
  14932. * Set a vec3 in the shader from a Vector3.
  14933. * @param name Define the name of the uniform as defined in the shader
  14934. * @param value Define the value to give to the uniform
  14935. * @return the texture itself allowing "fluent" like uniform updates
  14936. */
  14937. setVector3(name: string, value: Vector3): ProceduralTexture;
  14938. /**
  14939. * Set a mat4 in the shader from a MAtrix.
  14940. * @param name Define the name of the uniform as defined in the shader
  14941. * @param value Define the value to give to the uniform
  14942. * @return the texture itself allowing "fluent" like uniform updates
  14943. */
  14944. setMatrix(name: string, value: Matrix): ProceduralTexture;
  14945. /**
  14946. * Render the texture to its associated render target.
  14947. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  14948. */
  14949. render(useCameraPostProcess?: boolean): void;
  14950. /**
  14951. * Clone the texture.
  14952. * @returns the cloned texture
  14953. */
  14954. clone(): ProceduralTexture;
  14955. /**
  14956. * Dispose the texture and release its associated resources.
  14957. */
  14958. dispose(): void;
  14959. }
  14960. }
  14961. declare module BABYLON {
  14962. /**
  14963. * This represents the base class for particle system in Babylon.
  14964. * 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.
  14965. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  14966. * @example https://doc.babylonjs.com/babylon101/particles
  14967. */
  14968. export class BaseParticleSystem {
  14969. /**
  14970. * Source color is added to the destination color without alpha affecting the result
  14971. */
  14972. static BLENDMODE_ONEONE: number;
  14973. /**
  14974. * Blend current color and particle color using particle’s alpha
  14975. */
  14976. static BLENDMODE_STANDARD: number;
  14977. /**
  14978. * Add current color and particle color multiplied by particle’s alpha
  14979. */
  14980. static BLENDMODE_ADD: number;
  14981. /**
  14982. * Multiply current color with particle color
  14983. */
  14984. static BLENDMODE_MULTIPLY: number;
  14985. /**
  14986. * Multiply current color with particle color then add current color and particle color multiplied by particle’s alpha
  14987. */
  14988. static BLENDMODE_MULTIPLYADD: number;
  14989. /**
  14990. * List of animations used by the particle system.
  14991. */
  14992. animations: Animation[];
  14993. /**
  14994. * Gets or sets the unique id of the particle system
  14995. */
  14996. uniqueId: number;
  14997. /**
  14998. * The id of the Particle system.
  14999. */
  15000. id: string;
  15001. /**
  15002. * The friendly name of the Particle system.
  15003. */
  15004. name: string;
  15005. /**
  15006. * Snippet ID if the particle system was created from the snippet server
  15007. */
  15008. snippetId: string;
  15009. /**
  15010. * The rendering group used by the Particle system to chose when to render.
  15011. */
  15012. renderingGroupId: number;
  15013. /**
  15014. * The emitter represents the Mesh or position we are attaching the particle system to.
  15015. */
  15016. emitter: Nullable<AbstractMesh | Vector3>;
  15017. /**
  15018. * The maximum number of particles to emit per frame
  15019. */
  15020. emitRate: number;
  15021. /**
  15022. * If you want to launch only a few particles at once, that can be done, as well.
  15023. */
  15024. manualEmitCount: number;
  15025. /**
  15026. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  15027. */
  15028. updateSpeed: number;
  15029. /**
  15030. * The amount of time the particle system is running (depends of the overall update speed).
  15031. */
  15032. targetStopDuration: number;
  15033. /**
  15034. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  15035. */
  15036. disposeOnStop: boolean;
  15037. /**
  15038. * Minimum power of emitting particles.
  15039. */
  15040. minEmitPower: number;
  15041. /**
  15042. * Maximum power of emitting particles.
  15043. */
  15044. maxEmitPower: number;
  15045. /**
  15046. * Minimum life time of emitting particles.
  15047. */
  15048. minLifeTime: number;
  15049. /**
  15050. * Maximum life time of emitting particles.
  15051. */
  15052. maxLifeTime: number;
  15053. /**
  15054. * Minimum Size of emitting particles.
  15055. */
  15056. minSize: number;
  15057. /**
  15058. * Maximum Size of emitting particles.
  15059. */
  15060. maxSize: number;
  15061. /**
  15062. * Minimum scale of emitting particles on X axis.
  15063. */
  15064. minScaleX: number;
  15065. /**
  15066. * Maximum scale of emitting particles on X axis.
  15067. */
  15068. maxScaleX: number;
  15069. /**
  15070. * Minimum scale of emitting particles on Y axis.
  15071. */
  15072. minScaleY: number;
  15073. /**
  15074. * Maximum scale of emitting particles on Y axis.
  15075. */
  15076. maxScaleY: number;
  15077. /**
  15078. * Gets or sets the minimal initial rotation in radians.
  15079. */
  15080. minInitialRotation: number;
  15081. /**
  15082. * Gets or sets the maximal initial rotation in radians.
  15083. */
  15084. maxInitialRotation: number;
  15085. /**
  15086. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  15087. */
  15088. minAngularSpeed: number;
  15089. /**
  15090. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  15091. */
  15092. maxAngularSpeed: number;
  15093. /**
  15094. * The texture used to render each particle. (this can be a spritesheet)
  15095. */
  15096. particleTexture: Nullable<BaseTexture>;
  15097. /**
  15098. * The layer mask we are rendering the particles through.
  15099. */
  15100. layerMask: number;
  15101. /**
  15102. * This can help using your own shader to render the particle system.
  15103. * The according effect will be created
  15104. */
  15105. customShader: any;
  15106. /**
  15107. * By default particle system starts as soon as they are created. This prevents the
  15108. * automatic start to happen and let you decide when to start emitting particles.
  15109. */
  15110. preventAutoStart: boolean;
  15111. protected _rootUrl: string;
  15112. private _noiseTexture;
  15113. /**
  15114. * Gets or sets a texture used to add random noise to particle positions
  15115. */
  15116. get noiseTexture(): Nullable<ProceduralTexture>;
  15117. set noiseTexture(value: Nullable<ProceduralTexture>);
  15118. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  15119. noiseStrength: Vector3;
  15120. /**
  15121. * Callback triggered when the particle animation is ending.
  15122. */
  15123. onAnimationEnd: Nullable<() => void>;
  15124. /**
  15125. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE or ParticleSystem.BLENDMODE_STANDARD.
  15126. */
  15127. blendMode: number;
  15128. /**
  15129. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  15130. * to override the particles.
  15131. */
  15132. forceDepthWrite: boolean;
  15133. /** 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 */
  15134. preWarmCycles: number;
  15135. /** Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1) */
  15136. preWarmStepOffset: number;
  15137. /**
  15138. * 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)
  15139. */
  15140. spriteCellChangeSpeed: number;
  15141. /**
  15142. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  15143. */
  15144. startSpriteCellID: number;
  15145. /**
  15146. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  15147. */
  15148. endSpriteCellID: number;
  15149. /**
  15150. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  15151. */
  15152. spriteCellWidth: number;
  15153. /**
  15154. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  15155. */
  15156. spriteCellHeight: number;
  15157. /**
  15158. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  15159. */
  15160. spriteRandomStartCell: boolean;
  15161. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  15162. translationPivot: Vector2;
  15163. /** @hidden */
  15164. protected _isAnimationSheetEnabled: boolean;
  15165. /**
  15166. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  15167. */
  15168. beginAnimationOnStart: boolean;
  15169. /**
  15170. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  15171. */
  15172. beginAnimationFrom: number;
  15173. /**
  15174. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  15175. */
  15176. beginAnimationTo: number;
  15177. /**
  15178. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  15179. */
  15180. beginAnimationLoop: boolean;
  15181. /**
  15182. * Gets or sets a world offset applied to all particles
  15183. */
  15184. worldOffset: Vector3;
  15185. /**
  15186. * Gets or sets whether an animation sprite sheet is enabled or not on the particle system
  15187. */
  15188. get isAnimationSheetEnabled(): boolean;
  15189. set isAnimationSheetEnabled(value: boolean);
  15190. /**
  15191. * Get hosting scene
  15192. * @returns the scene
  15193. */
  15194. getScene(): Nullable<Scene>;
  15195. /**
  15196. * You can use gravity if you want to give an orientation to your particles.
  15197. */
  15198. gravity: Vector3;
  15199. protected _colorGradients: Nullable<Array<ColorGradient>>;
  15200. protected _sizeGradients: Nullable<Array<FactorGradient>>;
  15201. protected _lifeTimeGradients: Nullable<Array<FactorGradient>>;
  15202. protected _angularSpeedGradients: Nullable<Array<FactorGradient>>;
  15203. protected _velocityGradients: Nullable<Array<FactorGradient>>;
  15204. protected _limitVelocityGradients: Nullable<Array<FactorGradient>>;
  15205. protected _dragGradients: Nullable<Array<FactorGradient>>;
  15206. protected _emitRateGradients: Nullable<Array<FactorGradient>>;
  15207. protected _startSizeGradients: Nullable<Array<FactorGradient>>;
  15208. protected _rampGradients: Nullable<Array<Color3Gradient>>;
  15209. protected _colorRemapGradients: Nullable<Array<FactorGradient>>;
  15210. protected _alphaRemapGradients: Nullable<Array<FactorGradient>>;
  15211. protected _hasTargetStopDurationDependantGradient(): boolean | null;
  15212. /**
  15213. * Defines the delay in milliseconds before starting the system (0 by default)
  15214. */
  15215. startDelay: number;
  15216. /**
  15217. * Gets the current list of drag gradients.
  15218. * You must use addDragGradient and removeDragGradient to update this list
  15219. * @returns the list of drag gradients
  15220. */
  15221. getDragGradients(): Nullable<Array<FactorGradient>>;
  15222. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  15223. limitVelocityDamping: number;
  15224. /**
  15225. * Gets the current list of limit velocity gradients.
  15226. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to update this list
  15227. * @returns the list of limit velocity gradients
  15228. */
  15229. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  15230. /**
  15231. * Gets the current list of color gradients.
  15232. * You must use addColorGradient and removeColorGradient to update this list
  15233. * @returns the list of color gradients
  15234. */
  15235. getColorGradients(): Nullable<Array<ColorGradient>>;
  15236. /**
  15237. * Gets the current list of size gradients.
  15238. * You must use addSizeGradient and removeSizeGradient to update this list
  15239. * @returns the list of size gradients
  15240. */
  15241. getSizeGradients(): Nullable<Array<FactorGradient>>;
  15242. /**
  15243. * Gets the current list of color remap gradients.
  15244. * You must use addColorRemapGradient and removeColorRemapGradient to update this list
  15245. * @returns the list of color remap gradients
  15246. */
  15247. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  15248. /**
  15249. * Gets the current list of alpha remap gradients.
  15250. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to update this list
  15251. * @returns the list of alpha remap gradients
  15252. */
  15253. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  15254. /**
  15255. * Gets the current list of life time gradients.
  15256. * You must use addLifeTimeGradient and removeLifeTimeGradient to update this list
  15257. * @returns the list of life time gradients
  15258. */
  15259. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  15260. /**
  15261. * Gets the current list of angular speed gradients.
  15262. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to update this list
  15263. * @returns the list of angular speed gradients
  15264. */
  15265. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  15266. /**
  15267. * Gets the current list of velocity gradients.
  15268. * You must use addVelocityGradient and removeVelocityGradient to update this list
  15269. * @returns the list of velocity gradients
  15270. */
  15271. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  15272. /**
  15273. * Gets the current list of start size gradients.
  15274. * You must use addStartSizeGradient and removeStartSizeGradient to update this list
  15275. * @returns the list of start size gradients
  15276. */
  15277. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  15278. /**
  15279. * Gets the current list of emit rate gradients.
  15280. * You must use addEmitRateGradient and removeEmitRateGradient to update this list
  15281. * @returns the list of emit rate gradients
  15282. */
  15283. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  15284. /**
  15285. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  15286. * This only works when particleEmitterTyps is a BoxParticleEmitter
  15287. */
  15288. get direction1(): Vector3;
  15289. set direction1(value: Vector3);
  15290. /**
  15291. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  15292. * This only works when particleEmitterTyps is a BoxParticleEmitter
  15293. */
  15294. get direction2(): Vector3;
  15295. set direction2(value: Vector3);
  15296. /**
  15297. * 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.
  15298. * This only works when particleEmitterTyps is a BoxParticleEmitter
  15299. */
  15300. get minEmitBox(): Vector3;
  15301. set minEmitBox(value: Vector3);
  15302. /**
  15303. * 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.
  15304. * This only works when particleEmitterTyps is a BoxParticleEmitter
  15305. */
  15306. get maxEmitBox(): Vector3;
  15307. set maxEmitBox(value: Vector3);
  15308. /**
  15309. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  15310. */
  15311. color1: Color4;
  15312. /**
  15313. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  15314. */
  15315. color2: Color4;
  15316. /**
  15317. * Color the particle will have at the end of its lifetime
  15318. */
  15319. colorDead: Color4;
  15320. /**
  15321. * An optional mask to filter some colors out of the texture, or filter a part of the alpha channel
  15322. */
  15323. textureMask: Color4;
  15324. /**
  15325. * The particle emitter type defines the emitter used by the particle system.
  15326. * It can be for example box, sphere, or cone...
  15327. */
  15328. particleEmitterType: IParticleEmitterType;
  15329. /** @hidden */
  15330. _isSubEmitter: boolean;
  15331. /**
  15332. * Gets or sets the billboard mode to use when isBillboardBased = true.
  15333. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  15334. */
  15335. billboardMode: number;
  15336. protected _isBillboardBased: boolean;
  15337. /**
  15338. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  15339. */
  15340. get isBillboardBased(): boolean;
  15341. set isBillboardBased(value: boolean);
  15342. /**
  15343. * The scene the particle system belongs to.
  15344. */
  15345. protected _scene: Nullable<Scene>;
  15346. /**
  15347. * The engine the particle system belongs to.
  15348. */
  15349. protected _engine: ThinEngine;
  15350. /**
  15351. * Local cache of defines for image processing.
  15352. */
  15353. protected _imageProcessingConfigurationDefines: ImageProcessingConfigurationDefines;
  15354. /**
  15355. * Default configuration related to image processing available in the standard Material.
  15356. */
  15357. protected _imageProcessingConfiguration: Nullable<ImageProcessingConfiguration>;
  15358. /**
  15359. * Gets the image processing configuration used either in this material.
  15360. */
  15361. get imageProcessingConfiguration(): Nullable<ImageProcessingConfiguration>;
  15362. /**
  15363. * Sets the Default image processing configuration used either in the this material.
  15364. *
  15365. * If sets to null, the scene one is in use.
  15366. */
  15367. set imageProcessingConfiguration(value: Nullable<ImageProcessingConfiguration>);
  15368. /**
  15369. * Attaches a new image processing configuration to the Standard Material.
  15370. * @param configuration
  15371. */
  15372. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  15373. /** @hidden */
  15374. protected _reset(): void;
  15375. /** @hidden */
  15376. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: Nullable<RawTexture>): BaseParticleSystem;
  15377. /**
  15378. * Instantiates a particle system.
  15379. * 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.
  15380. * @param name The name of the particle system
  15381. */
  15382. constructor(name: string);
  15383. /**
  15384. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  15385. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  15386. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  15387. * @returns the emitter
  15388. */
  15389. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  15390. /**
  15391. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  15392. * @param radius The radius of the hemisphere to emit from
  15393. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  15394. * @returns the emitter
  15395. */
  15396. createHemisphericEmitter(radius?: number, radiusRange?: number): HemisphericParticleEmitter;
  15397. /**
  15398. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  15399. * @param radius The radius of the sphere to emit from
  15400. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  15401. * @returns the emitter
  15402. */
  15403. createSphereEmitter(radius?: number, radiusRange?: number): SphereParticleEmitter;
  15404. /**
  15405. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  15406. * @param radius The radius of the sphere to emit from
  15407. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  15408. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  15409. * @returns the emitter
  15410. */
  15411. createDirectedSphereEmitter(radius?: number, direction1?: Vector3, direction2?: Vector3): SphereDirectedParticleEmitter;
  15412. /**
  15413. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  15414. * @param radius The radius of the emission cylinder
  15415. * @param height The height of the emission cylinder
  15416. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  15417. * @param directionRandomizer How much to randomize the particle direction [0-1]
  15418. * @returns the emitter
  15419. */
  15420. createCylinderEmitter(radius?: number, height?: number, radiusRange?: number, directionRandomizer?: number): CylinderParticleEmitter;
  15421. /**
  15422. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  15423. * @param radius The radius of the cylinder to emit from
  15424. * @param height The height of the emission cylinder
  15425. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  15426. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  15427. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  15428. * @returns the emitter
  15429. */
  15430. createDirectedCylinderEmitter(radius?: number, height?: number, radiusRange?: number, direction1?: Vector3, direction2?: Vector3): CylinderDirectedParticleEmitter;
  15431. /**
  15432. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  15433. * @param radius The radius of the cone to emit from
  15434. * @param angle The base angle of the cone
  15435. * @returns the emitter
  15436. */
  15437. createConeEmitter(radius?: number, angle?: number): ConeParticleEmitter;
  15438. /**
  15439. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  15440. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  15441. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  15442. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  15443. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  15444. * @returns the emitter
  15445. */
  15446. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  15447. }
  15448. }
  15449. declare module BABYLON {
  15450. /**
  15451. * Type of sub emitter
  15452. */
  15453. export enum SubEmitterType {
  15454. /**
  15455. * Attached to the particle over it's lifetime
  15456. */
  15457. ATTACHED = 0,
  15458. /**
  15459. * Created when the particle dies
  15460. */
  15461. END = 1
  15462. }
  15463. /**
  15464. * Sub emitter class used to emit particles from an existing particle
  15465. */
  15466. export class SubEmitter {
  15467. /**
  15468. * the particle system to be used by the sub emitter
  15469. */
  15470. particleSystem: ParticleSystem;
  15471. /**
  15472. * Type of the submitter (Default: END)
  15473. */
  15474. type: SubEmitterType;
  15475. /**
  15476. * 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)
  15477. * Note: This only is supported when using an emitter of type Mesh
  15478. */
  15479. inheritDirection: boolean;
  15480. /**
  15481. * How much of the attached particles speed should be added to the sub emitted particle (default: 0)
  15482. */
  15483. inheritedVelocityAmount: number;
  15484. /**
  15485. * Creates a sub emitter
  15486. * @param particleSystem the particle system to be used by the sub emitter
  15487. */
  15488. constructor(
  15489. /**
  15490. * the particle system to be used by the sub emitter
  15491. */
  15492. particleSystem: ParticleSystem);
  15493. /**
  15494. * Clones the sub emitter
  15495. * @returns the cloned sub emitter
  15496. */
  15497. clone(): SubEmitter;
  15498. /**
  15499. * Serialize current object to a JSON object
  15500. * @returns the serialized object
  15501. */
  15502. serialize(): any;
  15503. /** @hidden */
  15504. static _ParseParticleSystem(system: any, sceneOrEngine: Scene | ThinEngine, rootUrl: string): ParticleSystem;
  15505. /**
  15506. * Creates a new SubEmitter from a serialized JSON version
  15507. * @param serializationObject defines the JSON object to read from
  15508. * @param sceneOrEngine defines the hosting scene or the hosting engine
  15509. * @param rootUrl defines the rootUrl for data loading
  15510. * @returns a new SubEmitter
  15511. */
  15512. static Parse(serializationObject: any, sceneOrEngine: Scene | ThinEngine, rootUrl: string): SubEmitter;
  15513. /** Release associated resources */
  15514. dispose(): void;
  15515. }
  15516. }
  15517. declare module BABYLON {
  15518. /** @hidden */
  15519. export var clipPlaneFragmentDeclaration: {
  15520. name: string;
  15521. shader: string;
  15522. };
  15523. }
  15524. declare module BABYLON {
  15525. /** @hidden */
  15526. export var imageProcessingDeclaration: {
  15527. name: string;
  15528. shader: string;
  15529. };
  15530. }
  15531. declare module BABYLON {
  15532. /** @hidden */
  15533. export var imageProcessingFunctions: {
  15534. name: string;
  15535. shader: string;
  15536. };
  15537. }
  15538. declare module BABYLON {
  15539. /** @hidden */
  15540. export var clipPlaneFragment: {
  15541. name: string;
  15542. shader: string;
  15543. };
  15544. }
  15545. declare module BABYLON {
  15546. /** @hidden */
  15547. export var particlesPixelShader: {
  15548. name: string;
  15549. shader: string;
  15550. };
  15551. }
  15552. declare module BABYLON {
  15553. /** @hidden */
  15554. export var clipPlaneVertexDeclaration: {
  15555. name: string;
  15556. shader: string;
  15557. };
  15558. }
  15559. declare module BABYLON {
  15560. /** @hidden */
  15561. export var clipPlaneVertex: {
  15562. name: string;
  15563. shader: string;
  15564. };
  15565. }
  15566. declare module BABYLON {
  15567. /** @hidden */
  15568. export var particlesVertexShader: {
  15569. name: string;
  15570. shader: string;
  15571. };
  15572. }
  15573. declare module BABYLON {
  15574. /**
  15575. * Interface used to define entities containing multiple clip planes
  15576. */
  15577. export interface IClipPlanesHolder {
  15578. /**
  15579. * Gets or sets the active clipplane 1
  15580. */
  15581. clipPlane: Nullable<Plane>;
  15582. /**
  15583. * Gets or sets the active clipplane 2
  15584. */
  15585. clipPlane2: Nullable<Plane>;
  15586. /**
  15587. * Gets or sets the active clipplane 3
  15588. */
  15589. clipPlane3: Nullable<Plane>;
  15590. /**
  15591. * Gets or sets the active clipplane 4
  15592. */
  15593. clipPlane4: Nullable<Plane>;
  15594. /**
  15595. * Gets or sets the active clipplane 5
  15596. */
  15597. clipPlane5: Nullable<Plane>;
  15598. /**
  15599. * Gets or sets the active clipplane 6
  15600. */
  15601. clipPlane6: Nullable<Plane>;
  15602. }
  15603. }
  15604. declare module BABYLON {
  15605. /**
  15606. * "Static Class" containing a few commonly used helper while dealing with material for rendering purpose.
  15607. *
  15608. * It is complementary with MaterialHelper but provides completely independent functions (for tree shaking sake)
  15609. *
  15610. * This works by convention in BabylonJS but is meant to be use only with shader following the in place naming rules and conventions.
  15611. */
  15612. export class ThinMaterialHelper {
  15613. /**
  15614. * Binds the clip plane information from the holder to the effect.
  15615. * @param effect The effect we are binding the data to
  15616. * @param holder The entity containing the clip plane information
  15617. */
  15618. static BindClipPlane(effect: Effect, holder: IClipPlanesHolder): void;
  15619. }
  15620. }
  15621. declare module BABYLON {
  15622. interface ThinEngine {
  15623. /**
  15624. * Sets alpha constants used by some alpha blending modes
  15625. * @param r defines the red component
  15626. * @param g defines the green component
  15627. * @param b defines the blue component
  15628. * @param a defines the alpha component
  15629. */
  15630. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  15631. /**
  15632. * Sets the current alpha mode
  15633. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  15634. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  15635. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  15636. */
  15637. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  15638. /**
  15639. * Gets the current alpha mode
  15640. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  15641. * @returns the current alpha mode
  15642. */
  15643. getAlphaMode(): number;
  15644. /**
  15645. * Sets the current alpha equation
  15646. * @param equation defines the equation to use (one of the Engine.ALPHA_EQUATION_XXX)
  15647. */
  15648. setAlphaEquation(equation: number): void;
  15649. /**
  15650. * Gets the current alpha equation.
  15651. * @returns the current alpha equation
  15652. */
  15653. getAlphaEquation(): number;
  15654. }
  15655. }
  15656. declare module BABYLON {
  15657. /**
  15658. * This represents a particle system in Babylon.
  15659. * 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.
  15660. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  15661. * @example https://doc.babylonjs.com/babylon101/particles
  15662. */
  15663. export class ParticleSystem extends BaseParticleSystem implements IDisposable, IAnimatable, IParticleSystem {
  15664. /**
  15665. * Billboard mode will only apply to Y axis
  15666. */
  15667. static readonly BILLBOARDMODE_Y: number;
  15668. /**
  15669. * Billboard mode will apply to all axes
  15670. */
  15671. static readonly BILLBOARDMODE_ALL: number;
  15672. /**
  15673. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  15674. */
  15675. static readonly BILLBOARDMODE_STRETCHED: number;
  15676. /**
  15677. * This function can be defined to provide custom update for active particles.
  15678. * This function will be called instead of regular update (age, position, color, etc.).
  15679. * Do not forget that this function will be called on every frame so try to keep it simple and fast :)
  15680. */
  15681. updateFunction: (particles: Particle[]) => void;
  15682. private _emitterWorldMatrix;
  15683. /**
  15684. * This function can be defined to specify initial direction for every new particle.
  15685. * It by default use the emitterType defined function
  15686. */
  15687. startDirectionFunction: (worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean) => void;
  15688. /**
  15689. * This function can be defined to specify initial position for every new particle.
  15690. * It by default use the emitterType defined function
  15691. */
  15692. startPositionFunction: (worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean) => void;
  15693. /**
  15694. * @hidden
  15695. */
  15696. _inheritedVelocityOffset: Vector3;
  15697. /**
  15698. * An event triggered when the system is disposed
  15699. */
  15700. onDisposeObservable: Observable<IParticleSystem>;
  15701. /**
  15702. * An event triggered when the system is stopped
  15703. */
  15704. onStoppedObservable: Observable<IParticleSystem>;
  15705. private _onDisposeObserver;
  15706. /**
  15707. * Sets a callback that will be triggered when the system is disposed
  15708. */
  15709. set onDispose(callback: () => void);
  15710. private _particles;
  15711. private _epsilon;
  15712. private _capacity;
  15713. private _stockParticles;
  15714. private _newPartsExcess;
  15715. private _vertexData;
  15716. private _vertexBuffer;
  15717. private _vertexBuffers;
  15718. private _spriteBuffer;
  15719. private _indexBuffer;
  15720. private _effect;
  15721. private _customEffect;
  15722. private _cachedDefines;
  15723. private _scaledColorStep;
  15724. private _colorDiff;
  15725. private _scaledDirection;
  15726. private _scaledGravity;
  15727. private _currentRenderId;
  15728. private _alive;
  15729. private _useInstancing;
  15730. private _vertexArrayObject;
  15731. private _started;
  15732. private _stopped;
  15733. private _actualFrame;
  15734. private _scaledUpdateSpeed;
  15735. private _vertexBufferSize;
  15736. /** @hidden */
  15737. _currentEmitRateGradient: Nullable<FactorGradient>;
  15738. /** @hidden */
  15739. _currentEmitRate1: number;
  15740. /** @hidden */
  15741. _currentEmitRate2: number;
  15742. /** @hidden */
  15743. _currentStartSizeGradient: Nullable<FactorGradient>;
  15744. /** @hidden */
  15745. _currentStartSize1: number;
  15746. /** @hidden */
  15747. _currentStartSize2: number;
  15748. private readonly _rawTextureWidth;
  15749. private _rampGradientsTexture;
  15750. private _useRampGradients;
  15751. /** Gets or sets a matrix to use to compute projection */
  15752. defaultProjectionMatrix: Matrix;
  15753. /** Gets or sets a matrix to use to compute view */
  15754. defaultViewMatrix: Matrix;
  15755. /** Gets or sets a boolean indicating that ramp gradients must be used
  15756. * @see https://doc.babylonjs.com/babylon101/particles#ramp-gradients
  15757. */
  15758. get useRampGradients(): boolean;
  15759. set useRampGradients(value: boolean);
  15760. /**
  15761. * 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.
  15762. * 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: [])
  15763. */
  15764. subEmitters: Array<ParticleSystem | SubEmitter | Array<SubEmitter>>;
  15765. private _subEmitters;
  15766. /**
  15767. * @hidden
  15768. * If the particle systems emitter should be disposed when the particle system is disposed
  15769. */
  15770. _disposeEmitterOnDispose: boolean;
  15771. /**
  15772. * The current active Sub-systems, this property is used by the root particle system only.
  15773. */
  15774. activeSubSystems: Array<ParticleSystem>;
  15775. /**
  15776. * Specifies if the particles are updated in emitter local space or world space
  15777. */
  15778. isLocal: boolean;
  15779. private _rootParticleSystem;
  15780. /**
  15781. * Gets the current list of active particles
  15782. */
  15783. get particles(): Particle[];
  15784. /**
  15785. * Gets the number of particles active at the same time.
  15786. * @returns The number of active particles.
  15787. */
  15788. getActiveCount(): number;
  15789. /**
  15790. * Returns the string "ParticleSystem"
  15791. * @returns a string containing the class name
  15792. */
  15793. getClassName(): string;
  15794. /**
  15795. * Gets a boolean indicating that the system is stopping
  15796. * @returns true if the system is currently stopping
  15797. */
  15798. isStopping(): boolean;
  15799. /**
  15800. * Gets the custom effect used to render the particles
  15801. * @param blendMode Blend mode for which the effect should be retrieved
  15802. * @returns The effect
  15803. */
  15804. getCustomEffect(blendMode?: number): Nullable<Effect>;
  15805. /**
  15806. * Sets the custom effect used to render the particles
  15807. * @param effect The effect to set
  15808. * @param blendMode Blend mode for which the effect should be set
  15809. */
  15810. setCustomEffect(effect: Nullable<Effect>, blendMode?: number): void;
  15811. /** @hidden */
  15812. private _onBeforeDrawParticlesObservable;
  15813. /**
  15814. * Observable that will be called just before the particles are drawn
  15815. */
  15816. get onBeforeDrawParticlesObservable(): Observable<Nullable<Effect>>;
  15817. /**
  15818. * Gets the name of the particle vertex shader
  15819. */
  15820. get vertexShaderName(): string;
  15821. /**
  15822. * Instantiates a particle system.
  15823. * 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.
  15824. * @param name The name of the particle system
  15825. * @param capacity The max number of particles alive at the same time
  15826. * @param sceneOrEngine The scene the particle system belongs to or the engine to use if no scene
  15827. * @param customEffect a custom effect used to change the way particles are rendered by default
  15828. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  15829. * @param epsilon Offset used to render the particles
  15830. */
  15831. constructor(name: string, capacity: number, sceneOrEngine: Scene | ThinEngine, customEffect?: Nullable<Effect>, isAnimationSheetEnabled?: boolean, epsilon?: number);
  15832. private _addFactorGradient;
  15833. private _removeFactorGradient;
  15834. /**
  15835. * Adds a new life time gradient
  15836. * @param gradient defines the gradient to use (between 0 and 1)
  15837. * @param factor defines the life time factor to affect to the specified gradient
  15838. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  15839. * @returns the current particle system
  15840. */
  15841. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  15842. /**
  15843. * Remove a specific life time gradient
  15844. * @param gradient defines the gradient to remove
  15845. * @returns the current particle system
  15846. */
  15847. removeLifeTimeGradient(gradient: number): IParticleSystem;
  15848. /**
  15849. * Adds a new size gradient
  15850. * @param gradient defines the gradient to use (between 0 and 1)
  15851. * @param factor defines the size factor to affect to the specified gradient
  15852. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  15853. * @returns the current particle system
  15854. */
  15855. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  15856. /**
  15857. * Remove a specific size gradient
  15858. * @param gradient defines the gradient to remove
  15859. * @returns the current particle system
  15860. */
  15861. removeSizeGradient(gradient: number): IParticleSystem;
  15862. /**
  15863. * Adds a new color remap gradient
  15864. * @param gradient defines the gradient to use (between 0 and 1)
  15865. * @param min defines the color remap minimal range
  15866. * @param max defines the color remap maximal range
  15867. * @returns the current particle system
  15868. */
  15869. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  15870. /**
  15871. * Remove a specific color remap gradient
  15872. * @param gradient defines the gradient to remove
  15873. * @returns the current particle system
  15874. */
  15875. removeColorRemapGradient(gradient: number): IParticleSystem;
  15876. /**
  15877. * Adds a new alpha remap gradient
  15878. * @param gradient defines the gradient to use (between 0 and 1)
  15879. * @param min defines the alpha remap minimal range
  15880. * @param max defines the alpha remap maximal range
  15881. * @returns the current particle system
  15882. */
  15883. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  15884. /**
  15885. * Remove a specific alpha remap gradient
  15886. * @param gradient defines the gradient to remove
  15887. * @returns the current particle system
  15888. */
  15889. removeAlphaRemapGradient(gradient: number): IParticleSystem;
  15890. /**
  15891. * Adds a new angular speed gradient
  15892. * @param gradient defines the gradient to use (between 0 and 1)
  15893. * @param factor defines the angular speed to affect to the specified gradient
  15894. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  15895. * @returns the current particle system
  15896. */
  15897. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  15898. /**
  15899. * Remove a specific angular speed gradient
  15900. * @param gradient defines the gradient to remove
  15901. * @returns the current particle system
  15902. */
  15903. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  15904. /**
  15905. * Adds a new velocity gradient
  15906. * @param gradient defines the gradient to use (between 0 and 1)
  15907. * @param factor defines the velocity to affect to the specified gradient
  15908. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  15909. * @returns the current particle system
  15910. */
  15911. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  15912. /**
  15913. * Remove a specific velocity gradient
  15914. * @param gradient defines the gradient to remove
  15915. * @returns the current particle system
  15916. */
  15917. removeVelocityGradient(gradient: number): IParticleSystem;
  15918. /**
  15919. * Adds a new limit velocity gradient
  15920. * @param gradient defines the gradient to use (between 0 and 1)
  15921. * @param factor defines the limit velocity value to affect to the specified gradient
  15922. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  15923. * @returns the current particle system
  15924. */
  15925. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  15926. /**
  15927. * Remove a specific limit velocity gradient
  15928. * @param gradient defines the gradient to remove
  15929. * @returns the current particle system
  15930. */
  15931. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  15932. /**
  15933. * Adds a new drag gradient
  15934. * @param gradient defines the gradient to use (between 0 and 1)
  15935. * @param factor defines the drag value to affect to the specified gradient
  15936. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  15937. * @returns the current particle system
  15938. */
  15939. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  15940. /**
  15941. * Remove a specific drag gradient
  15942. * @param gradient defines the gradient to remove
  15943. * @returns the current particle system
  15944. */
  15945. removeDragGradient(gradient: number): IParticleSystem;
  15946. /**
  15947. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  15948. * @param gradient defines the gradient to use (between 0 and 1)
  15949. * @param factor defines the emit rate value to affect to the specified gradient
  15950. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  15951. * @returns the current particle system
  15952. */
  15953. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  15954. /**
  15955. * Remove a specific emit rate gradient
  15956. * @param gradient defines the gradient to remove
  15957. * @returns the current particle system
  15958. */
  15959. removeEmitRateGradient(gradient: number): IParticleSystem;
  15960. /**
  15961. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  15962. * @param gradient defines the gradient to use (between 0 and 1)
  15963. * @param factor defines the start size value to affect to the specified gradient
  15964. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  15965. * @returns the current particle system
  15966. */
  15967. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  15968. /**
  15969. * Remove a specific start size gradient
  15970. * @param gradient defines the gradient to remove
  15971. * @returns the current particle system
  15972. */
  15973. removeStartSizeGradient(gradient: number): IParticleSystem;
  15974. private _createRampGradientTexture;
  15975. /**
  15976. * Gets the current list of ramp gradients.
  15977. * You must use addRampGradient and removeRampGradient to update this list
  15978. * @returns the list of ramp gradients
  15979. */
  15980. getRampGradients(): Nullable<Array<Color3Gradient>>;
  15981. /** Force the system to rebuild all gradients that need to be resync */
  15982. forceRefreshGradients(): void;
  15983. private _syncRampGradientTexture;
  15984. /**
  15985. * Adds a new ramp gradient used to remap particle colors
  15986. * @param gradient defines the gradient to use (between 0 and 1)
  15987. * @param color defines the color to affect to the specified gradient
  15988. * @returns the current particle system
  15989. */
  15990. addRampGradient(gradient: number, color: Color3): ParticleSystem;
  15991. /**
  15992. * Remove a specific ramp gradient
  15993. * @param gradient defines the gradient to remove
  15994. * @returns the current particle system
  15995. */
  15996. removeRampGradient(gradient: number): ParticleSystem;
  15997. /**
  15998. * Adds a new color gradient
  15999. * @param gradient defines the gradient to use (between 0 and 1)
  16000. * @param color1 defines the color to affect to the specified gradient
  16001. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  16002. * @returns this particle system
  16003. */
  16004. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  16005. /**
  16006. * Remove a specific color gradient
  16007. * @param gradient defines the gradient to remove
  16008. * @returns this particle system
  16009. */
  16010. removeColorGradient(gradient: number): IParticleSystem;
  16011. private _fetchR;
  16012. protected _reset(): void;
  16013. private _resetEffect;
  16014. private _createVertexBuffers;
  16015. private _createIndexBuffer;
  16016. /**
  16017. * Gets the maximum number of particles active at the same time.
  16018. * @returns The max number of active particles.
  16019. */
  16020. getCapacity(): number;
  16021. /**
  16022. * Gets whether there are still active particles in the system.
  16023. * @returns True if it is alive, otherwise false.
  16024. */
  16025. isAlive(): boolean;
  16026. /**
  16027. * Gets if the system has been started. (Note: this will still be true after stop is called)
  16028. * @returns True if it has been started, otherwise false.
  16029. */
  16030. isStarted(): boolean;
  16031. private _prepareSubEmitterInternalArray;
  16032. /**
  16033. * Starts the particle system and begins to emit
  16034. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  16035. */
  16036. start(delay?: number): void;
  16037. /**
  16038. * Stops the particle system.
  16039. * @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.
  16040. */
  16041. stop(stopSubEmitters?: boolean): void;
  16042. /**
  16043. * Remove all active particles
  16044. */
  16045. reset(): void;
  16046. /**
  16047. * @hidden (for internal use only)
  16048. */
  16049. _appendParticleVertex(index: number, particle: Particle, offsetX: number, offsetY: number): void;
  16050. /**
  16051. * "Recycles" one of the particle by copying it back to the "stock" of particles and removing it from the active list.
  16052. * Its lifetime will start back at 0.
  16053. */
  16054. recycleParticle: (particle: Particle) => void;
  16055. private _stopSubEmitters;
  16056. private _createParticle;
  16057. private _removeFromRoot;
  16058. private _emitFromParticle;
  16059. private _update;
  16060. /** @hidden */
  16061. static _GetAttributeNamesOrOptions(isAnimationSheetEnabled?: boolean, isBillboardBased?: boolean, useRampGradients?: boolean): string[];
  16062. /** @hidden */
  16063. static _GetEffectCreationOptions(isAnimationSheetEnabled?: boolean): string[];
  16064. /**
  16065. * Fill the defines array according to the current settings of the particle system
  16066. * @param defines Array to be updated
  16067. * @param blendMode blend mode to take into account when updating the array
  16068. */
  16069. fillDefines(defines: Array<string>, blendMode: number): void;
  16070. /**
  16071. * Fill the uniforms, attributes and samplers arrays according to the current settings of the particle system
  16072. * @param uniforms Uniforms array to fill
  16073. * @param attributes Attributes array to fill
  16074. * @param samplers Samplers array to fill
  16075. */
  16076. fillUniformsAttributesAndSamplerNames(uniforms: Array<string>, attributes: Array<string>, samplers: Array<string>): void;
  16077. /** @hidden */
  16078. private _getEffect;
  16079. /**
  16080. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  16081. * @param preWarmOnly will prevent the system from updating the vertex buffer (default is false)
  16082. */
  16083. animate(preWarmOnly?: boolean): void;
  16084. private _appendParticleVertices;
  16085. /**
  16086. * Rebuilds the particle system.
  16087. */
  16088. rebuild(): void;
  16089. /**
  16090. * Is this system ready to be used/rendered
  16091. * @return true if the system is ready
  16092. */
  16093. isReady(): boolean;
  16094. private _render;
  16095. /**
  16096. * Renders the particle system in its current state.
  16097. * @returns the current number of particles
  16098. */
  16099. render(): number;
  16100. /**
  16101. * Disposes the particle system and free the associated resources
  16102. * @param disposeTexture defines if the particle texture must be disposed as well (true by default)
  16103. */
  16104. dispose(disposeTexture?: boolean): void;
  16105. /**
  16106. * Clones the particle system.
  16107. * @param name The name of the cloned object
  16108. * @param newEmitter The new emitter to use
  16109. * @returns the cloned particle system
  16110. */
  16111. clone(name: string, newEmitter: any): ParticleSystem;
  16112. /**
  16113. * Serializes the particle system to a JSON object
  16114. * @param serializeTexture defines if the texture must be serialized as well
  16115. * @returns the JSON object
  16116. */
  16117. serialize(serializeTexture?: boolean): any;
  16118. /** @hidden */
  16119. static _Serialize(serializationObject: any, particleSystem: IParticleSystem, serializeTexture: boolean): void;
  16120. /** @hidden */
  16121. static _Parse(parsedParticleSystem: any, particleSystem: IParticleSystem, sceneOrEngine: Scene | ThinEngine, rootUrl: string): void;
  16122. /**
  16123. * Parses a JSON object to create a particle system.
  16124. * @param parsedParticleSystem The JSON object to parse
  16125. * @param sceneOrEngine The scene or the engine to create the particle system in
  16126. * @param rootUrl The root url to use to load external dependencies like texture
  16127. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  16128. * @returns the Parsed particle system
  16129. */
  16130. static Parse(parsedParticleSystem: any, sceneOrEngine: Scene | ThinEngine, rootUrl: string, doNotStart?: boolean): ParticleSystem;
  16131. }
  16132. }
  16133. declare module BABYLON {
  16134. /**
  16135. * A particle represents one of the element emitted by a particle system.
  16136. * This is mainly define by its coordinates, direction, velocity and age.
  16137. */
  16138. export class Particle {
  16139. /**
  16140. * The particle system the particle belongs to.
  16141. */
  16142. particleSystem: ParticleSystem;
  16143. private static _Count;
  16144. /**
  16145. * Unique ID of the particle
  16146. */
  16147. id: number;
  16148. /**
  16149. * The world position of the particle in the scene.
  16150. */
  16151. position: Vector3;
  16152. /**
  16153. * The world direction of the particle in the scene.
  16154. */
  16155. direction: Vector3;
  16156. /**
  16157. * The color of the particle.
  16158. */
  16159. color: Color4;
  16160. /**
  16161. * The color change of the particle per step.
  16162. */
  16163. colorStep: Color4;
  16164. /**
  16165. * Defines how long will the life of the particle be.
  16166. */
  16167. lifeTime: number;
  16168. /**
  16169. * The current age of the particle.
  16170. */
  16171. age: number;
  16172. /**
  16173. * The current size of the particle.
  16174. */
  16175. size: number;
  16176. /**
  16177. * The current scale of the particle.
  16178. */
  16179. scale: Vector2;
  16180. /**
  16181. * The current angle of the particle.
  16182. */
  16183. angle: number;
  16184. /**
  16185. * Defines how fast is the angle changing.
  16186. */
  16187. angularSpeed: number;
  16188. /**
  16189. * Defines the cell index used by the particle to be rendered from a sprite.
  16190. */
  16191. cellIndex: number;
  16192. /**
  16193. * The information required to support color remapping
  16194. */
  16195. remapData: Vector4;
  16196. /** @hidden */
  16197. _randomCellOffset?: number;
  16198. /** @hidden */
  16199. _initialDirection: Nullable<Vector3>;
  16200. /** @hidden */
  16201. _attachedSubEmitters: Nullable<Array<SubEmitter>>;
  16202. /** @hidden */
  16203. _initialStartSpriteCellID: number;
  16204. /** @hidden */
  16205. _initialEndSpriteCellID: number;
  16206. /** @hidden */
  16207. _currentColorGradient: Nullable<ColorGradient>;
  16208. /** @hidden */
  16209. _currentColor1: Color4;
  16210. /** @hidden */
  16211. _currentColor2: Color4;
  16212. /** @hidden */
  16213. _currentSizeGradient: Nullable<FactorGradient>;
  16214. /** @hidden */
  16215. _currentSize1: number;
  16216. /** @hidden */
  16217. _currentSize2: number;
  16218. /** @hidden */
  16219. _currentAngularSpeedGradient: Nullable<FactorGradient>;
  16220. /** @hidden */
  16221. _currentAngularSpeed1: number;
  16222. /** @hidden */
  16223. _currentAngularSpeed2: number;
  16224. /** @hidden */
  16225. _currentVelocityGradient: Nullable<FactorGradient>;
  16226. /** @hidden */
  16227. _currentVelocity1: number;
  16228. /** @hidden */
  16229. _currentVelocity2: number;
  16230. /** @hidden */
  16231. _currentLimitVelocityGradient: Nullable<FactorGradient>;
  16232. /** @hidden */
  16233. _currentLimitVelocity1: number;
  16234. /** @hidden */
  16235. _currentLimitVelocity2: number;
  16236. /** @hidden */
  16237. _currentDragGradient: Nullable<FactorGradient>;
  16238. /** @hidden */
  16239. _currentDrag1: number;
  16240. /** @hidden */
  16241. _currentDrag2: number;
  16242. /** @hidden */
  16243. _randomNoiseCoordinates1: Vector3;
  16244. /** @hidden */
  16245. _randomNoiseCoordinates2: Vector3;
  16246. /** @hidden */
  16247. _localPosition?: Vector3;
  16248. /**
  16249. * Creates a new instance Particle
  16250. * @param particleSystem the particle system the particle belongs to
  16251. */
  16252. constructor(
  16253. /**
  16254. * The particle system the particle belongs to.
  16255. */
  16256. particleSystem: ParticleSystem);
  16257. private updateCellInfoFromSystem;
  16258. /**
  16259. * Defines how the sprite cell index is updated for the particle
  16260. */
  16261. updateCellIndex(): void;
  16262. /** @hidden */
  16263. _inheritParticleInfoToSubEmitter(subEmitter: SubEmitter): void;
  16264. /** @hidden */
  16265. _inheritParticleInfoToSubEmitters(): void;
  16266. /** @hidden */
  16267. _reset(): void;
  16268. /**
  16269. * Copy the properties of particle to another one.
  16270. * @param other the particle to copy the information to.
  16271. */
  16272. copyTo(other: Particle): void;
  16273. }
  16274. }
  16275. declare module BABYLON {
  16276. /**
  16277. * Particle emitter represents a volume emitting particles.
  16278. * This is the responsibility of the implementation to define the volume shape like cone/sphere/box.
  16279. */
  16280. export interface IParticleEmitterType {
  16281. /**
  16282. * Called by the particle System when the direction is computed for the created particle.
  16283. * @param worldMatrix is the world matrix of the particle system
  16284. * @param directionToUpdate is the direction vector to update with the result
  16285. * @param particle is the particle we are computed the direction for
  16286. * @param isLocal defines if the direction should be set in local space
  16287. */
  16288. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  16289. /**
  16290. * Called by the particle System when the position is computed for the created particle.
  16291. * @param worldMatrix is the world matrix of the particle system
  16292. * @param positionToUpdate is the position vector to update with the result
  16293. * @param particle is the particle we are computed the position for
  16294. * @param isLocal defines if the position should be set in local space
  16295. */
  16296. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  16297. /**
  16298. * Clones the current emitter and returns a copy of it
  16299. * @returns the new emitter
  16300. */
  16301. clone(): IParticleEmitterType;
  16302. /**
  16303. * Called by the GPUParticleSystem to setup the update shader
  16304. * @param effect defines the update shader
  16305. */
  16306. applyToShader(effect: Effect): void;
  16307. /**
  16308. * Returns a string to use to update the GPU particles update shader
  16309. * @returns the effect defines string
  16310. */
  16311. getEffectDefines(): string;
  16312. /**
  16313. * Returns a string representing the class name
  16314. * @returns a string containing the class name
  16315. */
  16316. getClassName(): string;
  16317. /**
  16318. * Serializes the particle system to a JSON object.
  16319. * @returns the JSON object
  16320. */
  16321. serialize(): any;
  16322. /**
  16323. * Parse properties from a JSON object
  16324. * @param serializationObject defines the JSON object
  16325. * @param scene defines the hosting scene
  16326. */
  16327. parse(serializationObject: any, scene: Nullable<Scene>): void;
  16328. }
  16329. }
  16330. declare module BABYLON {
  16331. /**
  16332. * Particle emitter emitting particles from the inside of a box.
  16333. * It emits the particles randomly between 2 given directions.
  16334. */
  16335. export class BoxParticleEmitter implements IParticleEmitterType {
  16336. /**
  16337. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  16338. */
  16339. direction1: Vector3;
  16340. /**
  16341. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  16342. */
  16343. direction2: Vector3;
  16344. /**
  16345. * 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.
  16346. */
  16347. minEmitBox: Vector3;
  16348. /**
  16349. * 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.
  16350. */
  16351. maxEmitBox: Vector3;
  16352. /**
  16353. * Creates a new instance BoxParticleEmitter
  16354. */
  16355. constructor();
  16356. /**
  16357. * Called by the particle System when the direction is computed for the created particle.
  16358. * @param worldMatrix is the world matrix of the particle system
  16359. * @param directionToUpdate is the direction vector to update with the result
  16360. * @param particle is the particle we are computed the direction for
  16361. * @param isLocal defines if the direction should be set in local space
  16362. */
  16363. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  16364. /**
  16365. * Called by the particle System when the position is computed for the created particle.
  16366. * @param worldMatrix is the world matrix of the particle system
  16367. * @param positionToUpdate is the position vector to update with the result
  16368. * @param particle is the particle we are computed the position for
  16369. * @param isLocal defines if the position should be set in local space
  16370. */
  16371. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  16372. /**
  16373. * Clones the current emitter and returns a copy of it
  16374. * @returns the new emitter
  16375. */
  16376. clone(): BoxParticleEmitter;
  16377. /**
  16378. * Called by the GPUParticleSystem to setup the update shader
  16379. * @param effect defines the update shader
  16380. */
  16381. applyToShader(effect: Effect): void;
  16382. /**
  16383. * Returns a string to use to update the GPU particles update shader
  16384. * @returns a string containing the defines string
  16385. */
  16386. getEffectDefines(): string;
  16387. /**
  16388. * Returns the string "BoxParticleEmitter"
  16389. * @returns a string containing the class name
  16390. */
  16391. getClassName(): string;
  16392. /**
  16393. * Serializes the particle system to a JSON object.
  16394. * @returns the JSON object
  16395. */
  16396. serialize(): any;
  16397. /**
  16398. * Parse properties from a JSON object
  16399. * @param serializationObject defines the JSON object
  16400. */
  16401. parse(serializationObject: any): void;
  16402. }
  16403. }
  16404. declare module BABYLON {
  16405. /**
  16406. * Particle emitter emitting particles from the inside of a cone.
  16407. * It emits the particles alongside the cone volume from the base to the particle.
  16408. * The emission direction might be randomized.
  16409. */
  16410. export class ConeParticleEmitter implements IParticleEmitterType {
  16411. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  16412. directionRandomizer: number;
  16413. private _radius;
  16414. private _angle;
  16415. private _height;
  16416. /**
  16417. * Gets or sets a value indicating where on the radius the start position should be picked (1 = everywhere, 0 = only surface)
  16418. */
  16419. radiusRange: number;
  16420. /**
  16421. * Gets or sets a value indicating where on the height the start position should be picked (1 = everywhere, 0 = only surface)
  16422. */
  16423. heightRange: number;
  16424. /**
  16425. * Gets or sets a value indicating if all the particles should be emitted from the spawn point only (the base of the cone)
  16426. */
  16427. emitFromSpawnPointOnly: boolean;
  16428. /**
  16429. * Gets or sets the radius of the emission cone
  16430. */
  16431. get radius(): number;
  16432. set radius(value: number);
  16433. /**
  16434. * Gets or sets the angle of the emission cone
  16435. */
  16436. get angle(): number;
  16437. set angle(value: number);
  16438. private _buildHeight;
  16439. /**
  16440. * Creates a new instance ConeParticleEmitter
  16441. * @param radius the radius of the emission cone (1 by default)
  16442. * @param angle the cone base angle (PI by default)
  16443. * @param directionRandomizer defines how much to randomize the particle direction [0-1] (default is 0)
  16444. */
  16445. constructor(radius?: number, angle?: number,
  16446. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  16447. directionRandomizer?: number);
  16448. /**
  16449. * Called by the particle System when the direction is computed for the created particle.
  16450. * @param worldMatrix is the world matrix of the particle system
  16451. * @param directionToUpdate is the direction vector to update with the result
  16452. * @param particle is the particle we are computed the direction for
  16453. * @param isLocal defines if the direction should be set in local space
  16454. */
  16455. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  16456. /**
  16457. * Called by the particle System when the position is computed for the created particle.
  16458. * @param worldMatrix is the world matrix of the particle system
  16459. * @param positionToUpdate is the position vector to update with the result
  16460. * @param particle is the particle we are computed the position for
  16461. * @param isLocal defines if the position should be set in local space
  16462. */
  16463. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  16464. /**
  16465. * Clones the current emitter and returns a copy of it
  16466. * @returns the new emitter
  16467. */
  16468. clone(): ConeParticleEmitter;
  16469. /**
  16470. * Called by the GPUParticleSystem to setup the update shader
  16471. * @param effect defines the update shader
  16472. */
  16473. applyToShader(effect: Effect): void;
  16474. /**
  16475. * Returns a string to use to update the GPU particles update shader
  16476. * @returns a string containing the defines string
  16477. */
  16478. getEffectDefines(): string;
  16479. /**
  16480. * Returns the string "ConeParticleEmitter"
  16481. * @returns a string containing the class name
  16482. */
  16483. getClassName(): string;
  16484. /**
  16485. * Serializes the particle system to a JSON object.
  16486. * @returns the JSON object
  16487. */
  16488. serialize(): any;
  16489. /**
  16490. * Parse properties from a JSON object
  16491. * @param serializationObject defines the JSON object
  16492. */
  16493. parse(serializationObject: any): void;
  16494. }
  16495. }
  16496. declare module BABYLON {
  16497. /**
  16498. * Particle emitter emitting particles from the inside of a cylinder.
  16499. * It emits the particles alongside the cylinder radius. The emission direction might be randomized.
  16500. */
  16501. export class CylinderParticleEmitter implements IParticleEmitterType {
  16502. /**
  16503. * The radius of the emission cylinder.
  16504. */
  16505. radius: number;
  16506. /**
  16507. * The height of the emission cylinder.
  16508. */
  16509. height: number;
  16510. /**
  16511. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  16512. */
  16513. radiusRange: number;
  16514. /**
  16515. * How much to randomize the particle direction [0-1].
  16516. */
  16517. directionRandomizer: number;
  16518. /**
  16519. * Creates a new instance CylinderParticleEmitter
  16520. * @param radius the radius of the emission cylinder (1 by default)
  16521. * @param height the height of the emission cylinder (1 by default)
  16522. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  16523. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  16524. */
  16525. constructor(
  16526. /**
  16527. * The radius of the emission cylinder.
  16528. */
  16529. radius?: number,
  16530. /**
  16531. * The height of the emission cylinder.
  16532. */
  16533. height?: number,
  16534. /**
  16535. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  16536. */
  16537. radiusRange?: number,
  16538. /**
  16539. * How much to randomize the particle direction [0-1].
  16540. */
  16541. directionRandomizer?: number);
  16542. /**
  16543. * Called by the particle System when the direction is computed for the created particle.
  16544. * @param worldMatrix is the world matrix of the particle system
  16545. * @param directionToUpdate is the direction vector to update with the result
  16546. * @param particle is the particle we are computed the direction for
  16547. * @param isLocal defines if the direction should be set in local space
  16548. */
  16549. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  16550. /**
  16551. * Called by the particle System when the position is computed for the created particle.
  16552. * @param worldMatrix is the world matrix of the particle system
  16553. * @param positionToUpdate is the position vector to update with the result
  16554. * @param particle is the particle we are computed the position for
  16555. * @param isLocal defines if the position should be set in local space
  16556. */
  16557. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  16558. /**
  16559. * Clones the current emitter and returns a copy of it
  16560. * @returns the new emitter
  16561. */
  16562. clone(): CylinderParticleEmitter;
  16563. /**
  16564. * Called by the GPUParticleSystem to setup the update shader
  16565. * @param effect defines the update shader
  16566. */
  16567. applyToShader(effect: Effect): void;
  16568. /**
  16569. * Returns a string to use to update the GPU particles update shader
  16570. * @returns a string containing the defines string
  16571. */
  16572. getEffectDefines(): string;
  16573. /**
  16574. * Returns the string "CylinderParticleEmitter"
  16575. * @returns a string containing the class name
  16576. */
  16577. getClassName(): string;
  16578. /**
  16579. * Serializes the particle system to a JSON object.
  16580. * @returns the JSON object
  16581. */
  16582. serialize(): any;
  16583. /**
  16584. * Parse properties from a JSON object
  16585. * @param serializationObject defines the JSON object
  16586. */
  16587. parse(serializationObject: any): void;
  16588. }
  16589. /**
  16590. * Particle emitter emitting particles from the inside of a cylinder.
  16591. * It emits the particles randomly between two vectors.
  16592. */
  16593. export class CylinderDirectedParticleEmitter extends CylinderParticleEmitter {
  16594. /**
  16595. * The min limit of the emission direction.
  16596. */
  16597. direction1: Vector3;
  16598. /**
  16599. * The max limit of the emission direction.
  16600. */
  16601. direction2: Vector3;
  16602. /**
  16603. * Creates a new instance CylinderDirectedParticleEmitter
  16604. * @param radius the radius of the emission cylinder (1 by default)
  16605. * @param height the height of the emission cylinder (1 by default)
  16606. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  16607. * @param direction1 the min limit of the emission direction (up vector by default)
  16608. * @param direction2 the max limit of the emission direction (up vector by default)
  16609. */
  16610. constructor(radius?: number, height?: number, radiusRange?: number,
  16611. /**
  16612. * The min limit of the emission direction.
  16613. */
  16614. direction1?: Vector3,
  16615. /**
  16616. * The max limit of the emission direction.
  16617. */
  16618. direction2?: Vector3);
  16619. /**
  16620. * Called by the particle System when the direction is computed for the created particle.
  16621. * @param worldMatrix is the world matrix of the particle system
  16622. * @param directionToUpdate is the direction vector to update with the result
  16623. * @param particle is the particle we are computed the direction for
  16624. */
  16625. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  16626. /**
  16627. * Clones the current emitter and returns a copy of it
  16628. * @returns the new emitter
  16629. */
  16630. clone(): CylinderDirectedParticleEmitter;
  16631. /**
  16632. * Called by the GPUParticleSystem to setup the update shader
  16633. * @param effect defines the update shader
  16634. */
  16635. applyToShader(effect: Effect): void;
  16636. /**
  16637. * Returns a string to use to update the GPU particles update shader
  16638. * @returns a string containing the defines string
  16639. */
  16640. getEffectDefines(): string;
  16641. /**
  16642. * Returns the string "CylinderDirectedParticleEmitter"
  16643. * @returns a string containing the class name
  16644. */
  16645. getClassName(): string;
  16646. /**
  16647. * Serializes the particle system to a JSON object.
  16648. * @returns the JSON object
  16649. */
  16650. serialize(): any;
  16651. /**
  16652. * Parse properties from a JSON object
  16653. * @param serializationObject defines the JSON object
  16654. */
  16655. parse(serializationObject: any): void;
  16656. }
  16657. }
  16658. declare module BABYLON {
  16659. /**
  16660. * Particle emitter emitting particles from the inside of a hemisphere.
  16661. * It emits the particles alongside the hemisphere radius. The emission direction might be randomized.
  16662. */
  16663. export class HemisphericParticleEmitter implements IParticleEmitterType {
  16664. /**
  16665. * The radius of the emission hemisphere.
  16666. */
  16667. radius: number;
  16668. /**
  16669. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  16670. */
  16671. radiusRange: number;
  16672. /**
  16673. * How much to randomize the particle direction [0-1].
  16674. */
  16675. directionRandomizer: number;
  16676. /**
  16677. * Creates a new instance HemisphericParticleEmitter
  16678. * @param radius the radius of the emission hemisphere (1 by default)
  16679. * @param radiusRange the range of the emission hemisphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  16680. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  16681. */
  16682. constructor(
  16683. /**
  16684. * The radius of the emission hemisphere.
  16685. */
  16686. radius?: number,
  16687. /**
  16688. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  16689. */
  16690. radiusRange?: number,
  16691. /**
  16692. * How much to randomize the particle direction [0-1].
  16693. */
  16694. directionRandomizer?: number);
  16695. /**
  16696. * Called by the particle System when the direction is computed for the created particle.
  16697. * @param worldMatrix is the world matrix of the particle system
  16698. * @param directionToUpdate is the direction vector to update with the result
  16699. * @param particle is the particle we are computed the direction for
  16700. * @param isLocal defines if the direction should be set in local space
  16701. */
  16702. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  16703. /**
  16704. * Called by the particle System when the position is computed for the created particle.
  16705. * @param worldMatrix is the world matrix of the particle system
  16706. * @param positionToUpdate is the position vector to update with the result
  16707. * @param particle is the particle we are computed the position for
  16708. * @param isLocal defines if the position should be set in local space
  16709. */
  16710. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  16711. /**
  16712. * Clones the current emitter and returns a copy of it
  16713. * @returns the new emitter
  16714. */
  16715. clone(): HemisphericParticleEmitter;
  16716. /**
  16717. * Called by the GPUParticleSystem to setup the update shader
  16718. * @param effect defines the update shader
  16719. */
  16720. applyToShader(effect: Effect): void;
  16721. /**
  16722. * Returns a string to use to update the GPU particles update shader
  16723. * @returns a string containing the defines string
  16724. */
  16725. getEffectDefines(): string;
  16726. /**
  16727. * Returns the string "HemisphericParticleEmitter"
  16728. * @returns a string containing the class name
  16729. */
  16730. getClassName(): string;
  16731. /**
  16732. * Serializes the particle system to a JSON object.
  16733. * @returns the JSON object
  16734. */
  16735. serialize(): any;
  16736. /**
  16737. * Parse properties from a JSON object
  16738. * @param serializationObject defines the JSON object
  16739. */
  16740. parse(serializationObject: any): void;
  16741. }
  16742. }
  16743. declare module BABYLON {
  16744. /**
  16745. * Particle emitter emitting particles from a point.
  16746. * It emits the particles randomly between 2 given directions.
  16747. */
  16748. export class PointParticleEmitter implements IParticleEmitterType {
  16749. /**
  16750. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  16751. */
  16752. direction1: Vector3;
  16753. /**
  16754. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  16755. */
  16756. direction2: Vector3;
  16757. /**
  16758. * Creates a new instance PointParticleEmitter
  16759. */
  16760. constructor();
  16761. /**
  16762. * Called by the particle System when the direction is computed for the created particle.
  16763. * @param worldMatrix is the world matrix of the particle system
  16764. * @param directionToUpdate is the direction vector to update with the result
  16765. * @param particle is the particle we are computed the direction for
  16766. * @param isLocal defines if the direction should be set in local space
  16767. */
  16768. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  16769. /**
  16770. * Called by the particle System when the position is computed for the created particle.
  16771. * @param worldMatrix is the world matrix of the particle system
  16772. * @param positionToUpdate is the position vector to update with the result
  16773. * @param particle is the particle we are computed the position for
  16774. * @param isLocal defines if the position should be set in local space
  16775. */
  16776. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  16777. /**
  16778. * Clones the current emitter and returns a copy of it
  16779. * @returns the new emitter
  16780. */
  16781. clone(): PointParticleEmitter;
  16782. /**
  16783. * Called by the GPUParticleSystem to setup the update shader
  16784. * @param effect defines the update shader
  16785. */
  16786. applyToShader(effect: Effect): void;
  16787. /**
  16788. * Returns a string to use to update the GPU particles update shader
  16789. * @returns a string containing the defines string
  16790. */
  16791. getEffectDefines(): string;
  16792. /**
  16793. * Returns the string "PointParticleEmitter"
  16794. * @returns a string containing the class name
  16795. */
  16796. getClassName(): string;
  16797. /**
  16798. * Serializes the particle system to a JSON object.
  16799. * @returns the JSON object
  16800. */
  16801. serialize(): any;
  16802. /**
  16803. * Parse properties from a JSON object
  16804. * @param serializationObject defines the JSON object
  16805. */
  16806. parse(serializationObject: any): void;
  16807. }
  16808. }
  16809. declare module BABYLON {
  16810. /**
  16811. * Particle emitter emitting particles from the inside of a sphere.
  16812. * It emits the particles alongside the sphere radius. The emission direction might be randomized.
  16813. */
  16814. export class SphereParticleEmitter implements IParticleEmitterType {
  16815. /**
  16816. * The radius of the emission sphere.
  16817. */
  16818. radius: number;
  16819. /**
  16820. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  16821. */
  16822. radiusRange: number;
  16823. /**
  16824. * How much to randomize the particle direction [0-1].
  16825. */
  16826. directionRandomizer: number;
  16827. /**
  16828. * Creates a new instance SphereParticleEmitter
  16829. * @param radius the radius of the emission sphere (1 by default)
  16830. * @param radiusRange the range of the emission sphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  16831. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  16832. */
  16833. constructor(
  16834. /**
  16835. * The radius of the emission sphere.
  16836. */
  16837. radius?: number,
  16838. /**
  16839. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  16840. */
  16841. radiusRange?: number,
  16842. /**
  16843. * How much to randomize the particle direction [0-1].
  16844. */
  16845. directionRandomizer?: number);
  16846. /**
  16847. * Called by the particle System when the direction is computed for the created particle.
  16848. * @param worldMatrix is the world matrix of the particle system
  16849. * @param directionToUpdate is the direction vector to update with the result
  16850. * @param particle is the particle we are computed the direction for
  16851. * @param isLocal defines if the direction should be set in local space
  16852. */
  16853. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  16854. /**
  16855. * Called by the particle System when the position is computed for the created particle.
  16856. * @param worldMatrix is the world matrix of the particle system
  16857. * @param positionToUpdate is the position vector to update with the result
  16858. * @param particle is the particle we are computed the position for
  16859. * @param isLocal defines if the position should be set in local space
  16860. */
  16861. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  16862. /**
  16863. * Clones the current emitter and returns a copy of it
  16864. * @returns the new emitter
  16865. */
  16866. clone(): SphereParticleEmitter;
  16867. /**
  16868. * Called by the GPUParticleSystem to setup the update shader
  16869. * @param effect defines the update shader
  16870. */
  16871. applyToShader(effect: Effect): void;
  16872. /**
  16873. * Returns a string to use to update the GPU particles update shader
  16874. * @returns a string containing the defines string
  16875. */
  16876. getEffectDefines(): string;
  16877. /**
  16878. * Returns the string "SphereParticleEmitter"
  16879. * @returns a string containing the class name
  16880. */
  16881. getClassName(): string;
  16882. /**
  16883. * Serializes the particle system to a JSON object.
  16884. * @returns the JSON object
  16885. */
  16886. serialize(): any;
  16887. /**
  16888. * Parse properties from a JSON object
  16889. * @param serializationObject defines the JSON object
  16890. */
  16891. parse(serializationObject: any): void;
  16892. }
  16893. /**
  16894. * Particle emitter emitting particles from the inside of a sphere.
  16895. * It emits the particles randomly between two vectors.
  16896. */
  16897. export class SphereDirectedParticleEmitter extends SphereParticleEmitter {
  16898. /**
  16899. * The min limit of the emission direction.
  16900. */
  16901. direction1: Vector3;
  16902. /**
  16903. * The max limit of the emission direction.
  16904. */
  16905. direction2: Vector3;
  16906. /**
  16907. * Creates a new instance SphereDirectedParticleEmitter
  16908. * @param radius the radius of the emission sphere (1 by default)
  16909. * @param direction1 the min limit of the emission direction (up vector by default)
  16910. * @param direction2 the max limit of the emission direction (up vector by default)
  16911. */
  16912. constructor(radius?: number,
  16913. /**
  16914. * The min limit of the emission direction.
  16915. */
  16916. direction1?: Vector3,
  16917. /**
  16918. * The max limit of the emission direction.
  16919. */
  16920. direction2?: Vector3);
  16921. /**
  16922. * Called by the particle System when the direction is computed for the created particle.
  16923. * @param worldMatrix is the world matrix of the particle system
  16924. * @param directionToUpdate is the direction vector to update with the result
  16925. * @param particle is the particle we are computed the direction for
  16926. */
  16927. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  16928. /**
  16929. * Clones the current emitter and returns a copy of it
  16930. * @returns the new emitter
  16931. */
  16932. clone(): SphereDirectedParticleEmitter;
  16933. /**
  16934. * Called by the GPUParticleSystem to setup the update shader
  16935. * @param effect defines the update shader
  16936. */
  16937. applyToShader(effect: Effect): void;
  16938. /**
  16939. * Returns a string to use to update the GPU particles update shader
  16940. * @returns a string containing the defines string
  16941. */
  16942. getEffectDefines(): string;
  16943. /**
  16944. * Returns the string "SphereDirectedParticleEmitter"
  16945. * @returns a string containing the class name
  16946. */
  16947. getClassName(): string;
  16948. /**
  16949. * Serializes the particle system to a JSON object.
  16950. * @returns the JSON object
  16951. */
  16952. serialize(): any;
  16953. /**
  16954. * Parse properties from a JSON object
  16955. * @param serializationObject defines the JSON object
  16956. */
  16957. parse(serializationObject: any): void;
  16958. }
  16959. }
  16960. declare module BABYLON {
  16961. /**
  16962. * Particle emitter emitting particles from a custom list of positions.
  16963. */
  16964. export class CustomParticleEmitter implements IParticleEmitterType {
  16965. /**
  16966. * Gets or sets the position generator that will create the initial position of each particle.
  16967. * Index will be provided when used with GPU particle. Particle will be provided when used with CPU particles
  16968. */
  16969. particlePositionGenerator: (index: number, particle: Nullable<Particle>, outPosition: Vector3) => void;
  16970. /**
  16971. * Gets or sets the destination generator that will create the final destination of each particle.
  16972. * * Index will be provided when used with GPU particle. Particle will be provided when used with CPU particles
  16973. */
  16974. particleDestinationGenerator: (index: number, particle: Nullable<Particle>, outDestination: Vector3) => void;
  16975. /**
  16976. * Creates a new instance CustomParticleEmitter
  16977. */
  16978. constructor();
  16979. /**
  16980. * Called by the particle System when the direction is computed for the created particle.
  16981. * @param worldMatrix is the world matrix of the particle system
  16982. * @param directionToUpdate is the direction vector to update with the result
  16983. * @param particle is the particle we are computed the direction for
  16984. * @param isLocal defines if the direction should be set in local space
  16985. */
  16986. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  16987. /**
  16988. * Called by the particle System when the position is computed for the created particle.
  16989. * @param worldMatrix is the world matrix of the particle system
  16990. * @param positionToUpdate is the position vector to update with the result
  16991. * @param particle is the particle we are computed the position for
  16992. * @param isLocal defines if the position should be set in local space
  16993. */
  16994. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  16995. /**
  16996. * Clones the current emitter and returns a copy of it
  16997. * @returns the new emitter
  16998. */
  16999. clone(): CustomParticleEmitter;
  17000. /**
  17001. * Called by the GPUParticleSystem to setup the update shader
  17002. * @param effect defines the update shader
  17003. */
  17004. applyToShader(effect: Effect): void;
  17005. /**
  17006. * Returns a string to use to update the GPU particles update shader
  17007. * @returns a string containing the defines string
  17008. */
  17009. getEffectDefines(): string;
  17010. /**
  17011. * Returns the string "PointParticleEmitter"
  17012. * @returns a string containing the class name
  17013. */
  17014. getClassName(): string;
  17015. /**
  17016. * Serializes the particle system to a JSON object.
  17017. * @returns the JSON object
  17018. */
  17019. serialize(): any;
  17020. /**
  17021. * Parse properties from a JSON object
  17022. * @param serializationObject defines the JSON object
  17023. */
  17024. parse(serializationObject: any): void;
  17025. }
  17026. }
  17027. declare module BABYLON {
  17028. /**
  17029. * Particle emitter emitting particles from the inside of a box.
  17030. * It emits the particles randomly between 2 given directions.
  17031. */
  17032. export class MeshParticleEmitter implements IParticleEmitterType {
  17033. private _indices;
  17034. private _positions;
  17035. private _normals;
  17036. private _storedNormal;
  17037. private _mesh;
  17038. /**
  17039. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  17040. */
  17041. direction1: Vector3;
  17042. /**
  17043. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  17044. */
  17045. direction2: Vector3;
  17046. /**
  17047. * Gets or sets a boolean indicating that particle directions must be built from mesh face normals
  17048. */
  17049. useMeshNormalsForDirection: boolean;
  17050. /** Defines the mesh to use as source */
  17051. get mesh(): Nullable<AbstractMesh>;
  17052. set mesh(value: Nullable<AbstractMesh>);
  17053. /**
  17054. * Creates a new instance MeshParticleEmitter
  17055. * @param mesh defines the mesh to use as source
  17056. */
  17057. constructor(mesh?: Nullable<AbstractMesh>);
  17058. /**
  17059. * Called by the particle System when the direction is computed for the created particle.
  17060. * @param worldMatrix is the world matrix of the particle system
  17061. * @param directionToUpdate is the direction vector to update with the result
  17062. * @param particle is the particle we are computed the direction for
  17063. * @param isLocal defines if the direction should be set in local space
  17064. */
  17065. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  17066. /**
  17067. * Called by the particle System when the position is computed for the created particle.
  17068. * @param worldMatrix is the world matrix of the particle system
  17069. * @param positionToUpdate is the position vector to update with the result
  17070. * @param particle is the particle we are computed the position for
  17071. * @param isLocal defines if the position should be set in local space
  17072. */
  17073. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  17074. /**
  17075. * Clones the current emitter and returns a copy of it
  17076. * @returns the new emitter
  17077. */
  17078. clone(): MeshParticleEmitter;
  17079. /**
  17080. * Called by the GPUParticleSystem to setup the update shader
  17081. * @param effect defines the update shader
  17082. */
  17083. applyToShader(effect: Effect): void;
  17084. /**
  17085. * Returns a string to use to update the GPU particles update shader
  17086. * @returns a string containing the defines string
  17087. */
  17088. getEffectDefines(): string;
  17089. /**
  17090. * Returns the string "BoxParticleEmitter"
  17091. * @returns a string containing the class name
  17092. */
  17093. getClassName(): string;
  17094. /**
  17095. * Serializes the particle system to a JSON object.
  17096. * @returns the JSON object
  17097. */
  17098. serialize(): any;
  17099. /**
  17100. * Parse properties from a JSON object
  17101. * @param serializationObject defines the JSON object
  17102. * @param scene defines the hosting scene
  17103. */
  17104. parse(serializationObject: any, scene: Nullable<Scene>): void;
  17105. }
  17106. }
  17107. declare module BABYLON {
  17108. /**
  17109. * Interface representing a particle system in Babylon.js.
  17110. * This groups the common functionalities that needs to be implemented in order to create a particle system.
  17111. * A particle system represents a way to manage particles from their emission to their animation and rendering.
  17112. */
  17113. export interface IParticleSystem {
  17114. /**
  17115. * List of animations used by the particle system.
  17116. */
  17117. animations: Animation[];
  17118. /**
  17119. * The id of the Particle system.
  17120. */
  17121. id: string;
  17122. /**
  17123. * The name of the Particle system.
  17124. */
  17125. name: string;
  17126. /**
  17127. * The emitter represents the Mesh or position we are attaching the particle system to.
  17128. */
  17129. emitter: Nullable<AbstractMesh | Vector3>;
  17130. /**
  17131. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  17132. */
  17133. isBillboardBased: boolean;
  17134. /**
  17135. * The rendering group used by the Particle system to chose when to render.
  17136. */
  17137. renderingGroupId: number;
  17138. /**
  17139. * The layer mask we are rendering the particles through.
  17140. */
  17141. layerMask: number;
  17142. /**
  17143. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  17144. */
  17145. updateSpeed: number;
  17146. /**
  17147. * The amount of time the particle system is running (depends of the overall update speed).
  17148. */
  17149. targetStopDuration: number;
  17150. /**
  17151. * The texture used to render each particle. (this can be a spritesheet)
  17152. */
  17153. particleTexture: Nullable<BaseTexture>;
  17154. /**
  17155. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE, ParticleSystem.BLENDMODE_STANDARD or ParticleSystem.BLENDMODE_ADD.
  17156. */
  17157. blendMode: number;
  17158. /**
  17159. * Minimum life time of emitting particles.
  17160. */
  17161. minLifeTime: number;
  17162. /**
  17163. * Maximum life time of emitting particles.
  17164. */
  17165. maxLifeTime: number;
  17166. /**
  17167. * Minimum Size of emitting particles.
  17168. */
  17169. minSize: number;
  17170. /**
  17171. * Maximum Size of emitting particles.
  17172. */
  17173. maxSize: number;
  17174. /**
  17175. * Minimum scale of emitting particles on X axis.
  17176. */
  17177. minScaleX: number;
  17178. /**
  17179. * Maximum scale of emitting particles on X axis.
  17180. */
  17181. maxScaleX: number;
  17182. /**
  17183. * Minimum scale of emitting particles on Y axis.
  17184. */
  17185. minScaleY: number;
  17186. /**
  17187. * Maximum scale of emitting particles on Y axis.
  17188. */
  17189. maxScaleY: number;
  17190. /**
  17191. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  17192. */
  17193. color1: Color4;
  17194. /**
  17195. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  17196. */
  17197. color2: Color4;
  17198. /**
  17199. * Color the particle will have at the end of its lifetime.
  17200. */
  17201. colorDead: Color4;
  17202. /**
  17203. * The maximum number of particles to emit per frame until we reach the activeParticleCount value
  17204. */
  17205. emitRate: number;
  17206. /**
  17207. * You can use gravity if you want to give an orientation to your particles.
  17208. */
  17209. gravity: Vector3;
  17210. /**
  17211. * Minimum power of emitting particles.
  17212. */
  17213. minEmitPower: number;
  17214. /**
  17215. * Maximum power of emitting particles.
  17216. */
  17217. maxEmitPower: number;
  17218. /**
  17219. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  17220. */
  17221. minAngularSpeed: number;
  17222. /**
  17223. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  17224. */
  17225. maxAngularSpeed: number;
  17226. /**
  17227. * Gets or sets the minimal initial rotation in radians.
  17228. */
  17229. minInitialRotation: number;
  17230. /**
  17231. * Gets or sets the maximal initial rotation in radians.
  17232. */
  17233. maxInitialRotation: number;
  17234. /**
  17235. * The particle emitter type defines the emitter used by the particle system.
  17236. * It can be for example box, sphere, or cone...
  17237. */
  17238. particleEmitterType: Nullable<IParticleEmitterType>;
  17239. /**
  17240. * Defines the delay in milliseconds before starting the system (0 by default)
  17241. */
  17242. startDelay: number;
  17243. /**
  17244. * 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
  17245. */
  17246. preWarmCycles: number;
  17247. /**
  17248. * Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1)
  17249. */
  17250. preWarmStepOffset: number;
  17251. /**
  17252. * 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)
  17253. */
  17254. spriteCellChangeSpeed: number;
  17255. /**
  17256. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  17257. */
  17258. startSpriteCellID: number;
  17259. /**
  17260. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  17261. */
  17262. endSpriteCellID: number;
  17263. /**
  17264. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  17265. */
  17266. spriteCellWidth: number;
  17267. /**
  17268. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  17269. */
  17270. spriteCellHeight: number;
  17271. /**
  17272. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  17273. */
  17274. spriteRandomStartCell: boolean;
  17275. /**
  17276. * Gets or sets a boolean indicating if a spritesheet is used to animate the particles texture
  17277. */
  17278. isAnimationSheetEnabled: boolean;
  17279. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  17280. translationPivot: Vector2;
  17281. /**
  17282. * Gets or sets a texture used to add random noise to particle positions
  17283. */
  17284. noiseTexture: Nullable<BaseTexture>;
  17285. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  17286. noiseStrength: Vector3;
  17287. /**
  17288. * Gets or sets the billboard mode to use when isBillboardBased = true.
  17289. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  17290. */
  17291. billboardMode: number;
  17292. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  17293. limitVelocityDamping: number;
  17294. /**
  17295. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  17296. */
  17297. beginAnimationOnStart: boolean;
  17298. /**
  17299. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  17300. */
  17301. beginAnimationFrom: number;
  17302. /**
  17303. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  17304. */
  17305. beginAnimationTo: number;
  17306. /**
  17307. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  17308. */
  17309. beginAnimationLoop: boolean;
  17310. /**
  17311. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  17312. */
  17313. disposeOnStop: boolean;
  17314. /**
  17315. * If you want to launch only a few particles at once, that can be done, as well.
  17316. */
  17317. manualEmitCount: number;
  17318. /**
  17319. * Specifies if the particles are updated in emitter local space or world space
  17320. */
  17321. isLocal: boolean;
  17322. /** Snippet ID if the particle system was created from the snippet server */
  17323. snippetId: string;
  17324. /** Gets or sets a matrix to use to compute projection */
  17325. defaultProjectionMatrix: Matrix;
  17326. /**
  17327. * Gets the maximum number of particles active at the same time.
  17328. * @returns The max number of active particles.
  17329. */
  17330. getCapacity(): number;
  17331. /**
  17332. * Gets the number of particles active at the same time.
  17333. * @returns The number of active particles.
  17334. */
  17335. getActiveCount(): number;
  17336. /**
  17337. * Gets if the system has been started. (Note: this will still be true after stop is called)
  17338. * @returns True if it has been started, otherwise false.
  17339. */
  17340. isStarted(): boolean;
  17341. /**
  17342. * Animates the particle system for this frame.
  17343. */
  17344. animate(): void;
  17345. /**
  17346. * Renders the particle system in its current state.
  17347. * @returns the current number of particles
  17348. */
  17349. render(): number;
  17350. /**
  17351. * Dispose the particle system and frees its associated resources.
  17352. * @param disposeTexture defines if the particle texture must be disposed as well (true by default)
  17353. */
  17354. dispose(disposeTexture?: boolean): void;
  17355. /**
  17356. * An event triggered when the system is disposed
  17357. */
  17358. onDisposeObservable: Observable<IParticleSystem>;
  17359. /**
  17360. * An event triggered when the system is stopped
  17361. */
  17362. onStoppedObservable: Observable<IParticleSystem>;
  17363. /**
  17364. * Clones the particle system.
  17365. * @param name The name of the cloned object
  17366. * @param newEmitter The new emitter to use
  17367. * @returns the cloned particle system
  17368. */
  17369. clone(name: string, newEmitter: any): Nullable<IParticleSystem>;
  17370. /**
  17371. * Serializes the particle system to a JSON object
  17372. * @param serializeTexture defines if the texture must be serialized as well
  17373. * @returns the JSON object
  17374. */
  17375. serialize(serializeTexture: boolean): any;
  17376. /**
  17377. * Rebuild the particle system
  17378. */
  17379. rebuild(): void;
  17380. /** Force the system to rebuild all gradients that need to be resync */
  17381. forceRefreshGradients(): void;
  17382. /**
  17383. * Starts the particle system and begins to emit
  17384. * @param delay defines the delay in milliseconds before starting the system (0 by default)
  17385. */
  17386. start(delay?: number): void;
  17387. /**
  17388. * Stops the particle system.
  17389. */
  17390. stop(): void;
  17391. /**
  17392. * Remove all active particles
  17393. */
  17394. reset(): void;
  17395. /**
  17396. * Gets a boolean indicating that the system is stopping
  17397. * @returns true if the system is currently stopping
  17398. */
  17399. isStopping(): boolean;
  17400. /**
  17401. * Is this system ready to be used/rendered
  17402. * @return true if the system is ready
  17403. */
  17404. isReady(): boolean;
  17405. /**
  17406. * Returns the string "ParticleSystem"
  17407. * @returns a string containing the class name
  17408. */
  17409. getClassName(): string;
  17410. /**
  17411. * Gets the custom effect used to render the particles
  17412. * @param blendMode Blend mode for which the effect should be retrieved
  17413. * @returns The effect
  17414. */
  17415. getCustomEffect(blendMode: number): Nullable<Effect>;
  17416. /**
  17417. * Sets the custom effect used to render the particles
  17418. * @param effect The effect to set
  17419. * @param blendMode Blend mode for which the effect should be set
  17420. */
  17421. setCustomEffect(effect: Nullable<Effect>, blendMode: number): void;
  17422. /**
  17423. * Fill the defines array according to the current settings of the particle system
  17424. * @param defines Array to be updated
  17425. * @param blendMode blend mode to take into account when updating the array
  17426. */
  17427. fillDefines(defines: Array<string>, blendMode: number): void;
  17428. /**
  17429. * Fill the uniforms, attributes and samplers arrays according to the current settings of the particle system
  17430. * @param uniforms Uniforms array to fill
  17431. * @param attributes Attributes array to fill
  17432. * @param samplers Samplers array to fill
  17433. */
  17434. fillUniformsAttributesAndSamplerNames(uniforms: Array<string>, attributes: Array<string>, samplers: Array<string>): void;
  17435. /**
  17436. * Observable that will be called just before the particles are drawn
  17437. */
  17438. onBeforeDrawParticlesObservable: Observable<Nullable<Effect>>;
  17439. /**
  17440. * Gets the name of the particle vertex shader
  17441. */
  17442. vertexShaderName: string;
  17443. /**
  17444. * Adds a new color gradient
  17445. * @param gradient defines the gradient to use (between 0 and 1)
  17446. * @param color1 defines the color to affect to the specified gradient
  17447. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  17448. * @returns the current particle system
  17449. */
  17450. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  17451. /**
  17452. * Remove a specific color gradient
  17453. * @param gradient defines the gradient to remove
  17454. * @returns the current particle system
  17455. */
  17456. removeColorGradient(gradient: number): IParticleSystem;
  17457. /**
  17458. * Adds a new size gradient
  17459. * @param gradient defines the gradient to use (between 0 and 1)
  17460. * @param factor defines the size factor to affect to the specified gradient
  17461. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  17462. * @returns the current particle system
  17463. */
  17464. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  17465. /**
  17466. * Remove a specific size gradient
  17467. * @param gradient defines the gradient to remove
  17468. * @returns the current particle system
  17469. */
  17470. removeSizeGradient(gradient: number): IParticleSystem;
  17471. /**
  17472. * Gets the current list of color gradients.
  17473. * You must use addColorGradient and removeColorGradient to update this list
  17474. * @returns the list of color gradients
  17475. */
  17476. getColorGradients(): Nullable<Array<ColorGradient>>;
  17477. /**
  17478. * Gets the current list of size gradients.
  17479. * You must use addSizeGradient and removeSizeGradient to update this list
  17480. * @returns the list of size gradients
  17481. */
  17482. getSizeGradients(): Nullable<Array<FactorGradient>>;
  17483. /**
  17484. * Gets the current list of angular speed gradients.
  17485. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to update this list
  17486. * @returns the list of angular speed gradients
  17487. */
  17488. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  17489. /**
  17490. * Adds a new angular speed gradient
  17491. * @param gradient defines the gradient to use (between 0 and 1)
  17492. * @param factor defines the angular speed to affect to the specified gradient
  17493. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  17494. * @returns the current particle system
  17495. */
  17496. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  17497. /**
  17498. * Remove a specific angular speed gradient
  17499. * @param gradient defines the gradient to remove
  17500. * @returns the current particle system
  17501. */
  17502. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  17503. /**
  17504. * Gets the current list of velocity gradients.
  17505. * You must use addVelocityGradient and removeVelocityGradient to update this list
  17506. * @returns the list of velocity gradients
  17507. */
  17508. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  17509. /**
  17510. * Adds a new velocity gradient
  17511. * @param gradient defines the gradient to use (between 0 and 1)
  17512. * @param factor defines the velocity to affect to the specified gradient
  17513. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  17514. * @returns the current particle system
  17515. */
  17516. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  17517. /**
  17518. * Remove a specific velocity gradient
  17519. * @param gradient defines the gradient to remove
  17520. * @returns the current particle system
  17521. */
  17522. removeVelocityGradient(gradient: number): IParticleSystem;
  17523. /**
  17524. * Gets the current list of limit velocity gradients.
  17525. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to update this list
  17526. * @returns the list of limit velocity gradients
  17527. */
  17528. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  17529. /**
  17530. * Adds a new limit velocity gradient
  17531. * @param gradient defines the gradient to use (between 0 and 1)
  17532. * @param factor defines the limit velocity to affect to the specified gradient
  17533. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  17534. * @returns the current particle system
  17535. */
  17536. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  17537. /**
  17538. * Remove a specific limit velocity gradient
  17539. * @param gradient defines the gradient to remove
  17540. * @returns the current particle system
  17541. */
  17542. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  17543. /**
  17544. * Adds a new drag gradient
  17545. * @param gradient defines the gradient to use (between 0 and 1)
  17546. * @param factor defines the drag to affect to the specified gradient
  17547. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  17548. * @returns the current particle system
  17549. */
  17550. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  17551. /**
  17552. * Remove a specific drag gradient
  17553. * @param gradient defines the gradient to remove
  17554. * @returns the current particle system
  17555. */
  17556. removeDragGradient(gradient: number): IParticleSystem;
  17557. /**
  17558. * Gets the current list of drag gradients.
  17559. * You must use addDragGradient and removeDragGradient to update this list
  17560. * @returns the list of drag gradients
  17561. */
  17562. getDragGradients(): Nullable<Array<FactorGradient>>;
  17563. /**
  17564. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  17565. * @param gradient defines the gradient to use (between 0 and 1)
  17566. * @param factor defines the emit rate to affect to the specified gradient
  17567. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  17568. * @returns the current particle system
  17569. */
  17570. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  17571. /**
  17572. * Remove a specific emit rate gradient
  17573. * @param gradient defines the gradient to remove
  17574. * @returns the current particle system
  17575. */
  17576. removeEmitRateGradient(gradient: number): IParticleSystem;
  17577. /**
  17578. * Gets the current list of emit rate gradients.
  17579. * You must use addEmitRateGradient and removeEmitRateGradient to update this list
  17580. * @returns the list of emit rate gradients
  17581. */
  17582. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  17583. /**
  17584. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  17585. * @param gradient defines the gradient to use (between 0 and 1)
  17586. * @param factor defines the start size to affect to the specified gradient
  17587. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  17588. * @returns the current particle system
  17589. */
  17590. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  17591. /**
  17592. * Remove a specific start size gradient
  17593. * @param gradient defines the gradient to remove
  17594. * @returns the current particle system
  17595. */
  17596. removeStartSizeGradient(gradient: number): IParticleSystem;
  17597. /**
  17598. * Gets the current list of start size gradients.
  17599. * You must use addStartSizeGradient and removeStartSizeGradient to update this list
  17600. * @returns the list of start size gradients
  17601. */
  17602. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  17603. /**
  17604. * Adds a new life time gradient
  17605. * @param gradient defines the gradient to use (between 0 and 1)
  17606. * @param factor defines the life time factor to affect to the specified gradient
  17607. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  17608. * @returns the current particle system
  17609. */
  17610. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  17611. /**
  17612. * Remove a specific life time gradient
  17613. * @param gradient defines the gradient to remove
  17614. * @returns the current particle system
  17615. */
  17616. removeLifeTimeGradient(gradient: number): IParticleSystem;
  17617. /**
  17618. * Gets the current list of life time gradients.
  17619. * You must use addLifeTimeGradient and removeLifeTimeGradient to update this list
  17620. * @returns the list of life time gradients
  17621. */
  17622. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  17623. /**
  17624. * Gets the current list of color gradients.
  17625. * You must use addColorGradient and removeColorGradient to update this list
  17626. * @returns the list of color gradients
  17627. */
  17628. getColorGradients(): Nullable<Array<ColorGradient>>;
  17629. /**
  17630. * Adds a new ramp gradient used to remap particle colors
  17631. * @param gradient defines the gradient to use (between 0 and 1)
  17632. * @param color defines the color to affect to the specified gradient
  17633. * @returns the current particle system
  17634. */
  17635. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  17636. /**
  17637. * Gets the current list of ramp gradients.
  17638. * You must use addRampGradient and removeRampGradient to update this list
  17639. * @returns the list of ramp gradients
  17640. */
  17641. getRampGradients(): Nullable<Array<Color3Gradient>>;
  17642. /** Gets or sets a boolean indicating that ramp gradients must be used
  17643. * @see https://doc.babylonjs.com/babylon101/particles#ramp-gradients
  17644. */
  17645. useRampGradients: boolean;
  17646. /**
  17647. * Adds a new color remap gradient
  17648. * @param gradient defines the gradient to use (between 0 and 1)
  17649. * @param min defines the color remap minimal range
  17650. * @param max defines the color remap maximal range
  17651. * @returns the current particle system
  17652. */
  17653. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  17654. /**
  17655. * Gets the current list of color remap gradients.
  17656. * You must use addColorRemapGradient and removeColorRemapGradient to update this list
  17657. * @returns the list of color remap gradients
  17658. */
  17659. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  17660. /**
  17661. * Adds a new alpha remap gradient
  17662. * @param gradient defines the gradient to use (between 0 and 1)
  17663. * @param min defines the alpha remap minimal range
  17664. * @param max defines the alpha remap maximal range
  17665. * @returns the current particle system
  17666. */
  17667. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  17668. /**
  17669. * Gets the current list of alpha remap gradients.
  17670. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to update this list
  17671. * @returns the list of alpha remap gradients
  17672. */
  17673. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  17674. /**
  17675. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  17676. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  17677. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  17678. * @returns the emitter
  17679. */
  17680. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  17681. /**
  17682. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  17683. * @param radius The radius of the hemisphere to emit from
  17684. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  17685. * @returns the emitter
  17686. */
  17687. createHemisphericEmitter(radius: number, radiusRange: number): HemisphericParticleEmitter;
  17688. /**
  17689. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  17690. * @param radius The radius of the sphere to emit from
  17691. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  17692. * @returns the emitter
  17693. */
  17694. createSphereEmitter(radius: number, radiusRange: number): SphereParticleEmitter;
  17695. /**
  17696. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  17697. * @param radius The radius of the sphere to emit from
  17698. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  17699. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  17700. * @returns the emitter
  17701. */
  17702. createDirectedSphereEmitter(radius: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  17703. /**
  17704. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  17705. * @param radius The radius of the emission cylinder
  17706. * @param height The height of the emission cylinder
  17707. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  17708. * @param directionRandomizer How much to randomize the particle direction [0-1]
  17709. * @returns the emitter
  17710. */
  17711. createCylinderEmitter(radius: number, height: number, radiusRange: number, directionRandomizer: number): CylinderParticleEmitter;
  17712. /**
  17713. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  17714. * @param radius The radius of the cylinder to emit from
  17715. * @param height The height of the emission cylinder
  17716. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  17717. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  17718. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  17719. * @returns the emitter
  17720. */
  17721. createDirectedCylinderEmitter(radius: number, height: number, radiusRange: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  17722. /**
  17723. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  17724. * @param radius The radius of the cone to emit from
  17725. * @param angle The base angle of the cone
  17726. * @returns the emitter
  17727. */
  17728. createConeEmitter(radius: number, angle: number): ConeParticleEmitter;
  17729. /**
  17730. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  17731. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  17732. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  17733. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  17734. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  17735. * @returns the emitter
  17736. */
  17737. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  17738. /**
  17739. * Get hosting scene
  17740. * @returns the scene
  17741. */
  17742. getScene(): Nullable<Scene>;
  17743. }
  17744. }
  17745. declare module BABYLON {
  17746. /**
  17747. * Block used to expand a Color3/4 into 4 outputs (one for each component)
  17748. */
  17749. export class ColorSplitterBlock extends NodeMaterialBlock {
  17750. /**
  17751. * Create a new ColorSplitterBlock
  17752. * @param name defines the block name
  17753. */
  17754. constructor(name: string);
  17755. /**
  17756. * Gets the current class name
  17757. * @returns the class name
  17758. */
  17759. getClassName(): string;
  17760. /**
  17761. * Gets the rgba component (input)
  17762. */
  17763. get rgba(): NodeMaterialConnectionPoint;
  17764. /**
  17765. * Gets the rgb component (input)
  17766. */
  17767. get rgbIn(): NodeMaterialConnectionPoint;
  17768. /**
  17769. * Gets the rgb component (output)
  17770. */
  17771. get rgbOut(): NodeMaterialConnectionPoint;
  17772. /**
  17773. * Gets the r component (output)
  17774. */
  17775. get r(): NodeMaterialConnectionPoint;
  17776. /**
  17777. * Gets the g component (output)
  17778. */
  17779. get g(): NodeMaterialConnectionPoint;
  17780. /**
  17781. * Gets the b component (output)
  17782. */
  17783. get b(): NodeMaterialConnectionPoint;
  17784. /**
  17785. * Gets the a component (output)
  17786. */
  17787. get a(): NodeMaterialConnectionPoint;
  17788. protected _inputRename(name: string): string;
  17789. protected _outputRename(name: string): string;
  17790. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  17791. }
  17792. }
  17793. declare module BABYLON {
  17794. /**
  17795. * Operations supported by the Trigonometry block
  17796. */
  17797. export enum TrigonometryBlockOperations {
  17798. /** Cos */
  17799. Cos = 0,
  17800. /** Sin */
  17801. Sin = 1,
  17802. /** Abs */
  17803. Abs = 2,
  17804. /** Exp */
  17805. Exp = 3,
  17806. /** Exp2 */
  17807. Exp2 = 4,
  17808. /** Round */
  17809. Round = 5,
  17810. /** Floor */
  17811. Floor = 6,
  17812. /** Ceiling */
  17813. Ceiling = 7,
  17814. /** Square root */
  17815. Sqrt = 8,
  17816. /** Log */
  17817. Log = 9,
  17818. /** Tangent */
  17819. Tan = 10,
  17820. /** Arc tangent */
  17821. ArcTan = 11,
  17822. /** Arc cosinus */
  17823. ArcCos = 12,
  17824. /** Arc sinus */
  17825. ArcSin = 13,
  17826. /** Fraction */
  17827. Fract = 14,
  17828. /** Sign */
  17829. Sign = 15,
  17830. /** To radians (from degrees) */
  17831. Radians = 16,
  17832. /** To degrees (from radians) */
  17833. Degrees = 17
  17834. }
  17835. /**
  17836. * Block used to apply trigonometry operation to floats
  17837. */
  17838. export class TrigonometryBlock extends NodeMaterialBlock {
  17839. /**
  17840. * Gets or sets the operation applied by the block
  17841. */
  17842. operation: TrigonometryBlockOperations;
  17843. /**
  17844. * Creates a new TrigonometryBlock
  17845. * @param name defines the block name
  17846. */
  17847. constructor(name: string);
  17848. /**
  17849. * Gets the current class name
  17850. * @returns the class name
  17851. */
  17852. getClassName(): string;
  17853. /**
  17854. * Gets the input component
  17855. */
  17856. get input(): NodeMaterialConnectionPoint;
  17857. /**
  17858. * Gets the output component
  17859. */
  17860. get output(): NodeMaterialConnectionPoint;
  17861. protected _buildBlock(state: NodeMaterialBuildState): this;
  17862. serialize(): any;
  17863. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  17864. protected _dumpPropertiesCode(): string;
  17865. }
  17866. }
  17867. declare module BABYLON {
  17868. /**
  17869. * Interface used to configure the node material editor
  17870. */
  17871. export interface INodeMaterialEditorOptions {
  17872. /** Define the URl to load node editor script */
  17873. editorURL?: string;
  17874. }
  17875. /** @hidden */
  17876. export class NodeMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  17877. NORMAL: boolean;
  17878. TANGENT: boolean;
  17879. UV1: boolean;
  17880. /** BONES */
  17881. NUM_BONE_INFLUENCERS: number;
  17882. BonesPerMesh: number;
  17883. BONETEXTURE: boolean;
  17884. /** MORPH TARGETS */
  17885. MORPHTARGETS: boolean;
  17886. MORPHTARGETS_NORMAL: boolean;
  17887. MORPHTARGETS_TANGENT: boolean;
  17888. MORPHTARGETS_UV: boolean;
  17889. NUM_MORPH_INFLUENCERS: number;
  17890. /** IMAGE PROCESSING */
  17891. IMAGEPROCESSING: boolean;
  17892. VIGNETTE: boolean;
  17893. VIGNETTEBLENDMODEMULTIPLY: boolean;
  17894. VIGNETTEBLENDMODEOPAQUE: boolean;
  17895. TONEMAPPING: boolean;
  17896. TONEMAPPING_ACES: boolean;
  17897. CONTRAST: boolean;
  17898. EXPOSURE: boolean;
  17899. COLORCURVES: boolean;
  17900. COLORGRADING: boolean;
  17901. COLORGRADING3D: boolean;
  17902. SAMPLER3DGREENDEPTH: boolean;
  17903. SAMPLER3DBGRMAP: boolean;
  17904. IMAGEPROCESSINGPOSTPROCESS: boolean;
  17905. /** MISC. */
  17906. BUMPDIRECTUV: number;
  17907. constructor();
  17908. setValue(name: string, value: any, markAsUnprocessedIfDirty?: boolean): void;
  17909. }
  17910. /**
  17911. * Class used to configure NodeMaterial
  17912. */
  17913. export interface INodeMaterialOptions {
  17914. /**
  17915. * Defines if blocks should emit comments
  17916. */
  17917. emitComments: boolean;
  17918. }
  17919. /**
  17920. * Class used to create a node based material built by assembling shader blocks
  17921. */
  17922. export class NodeMaterial extends PushMaterial {
  17923. private static _BuildIdGenerator;
  17924. private _options;
  17925. private _vertexCompilationState;
  17926. private _fragmentCompilationState;
  17927. private _sharedData;
  17928. private _buildId;
  17929. private _buildWasSuccessful;
  17930. private _cachedWorldViewMatrix;
  17931. private _cachedWorldViewProjectionMatrix;
  17932. private _optimizers;
  17933. private _animationFrame;
  17934. /** Define the Url to load node editor script */
  17935. static EditorURL: string;
  17936. /** Define the Url to load snippets */
  17937. static SnippetUrl: string;
  17938. /** Gets or sets a boolean indicating that node materials should not deserialize textures from json / snippet content */
  17939. static IgnoreTexturesAtLoadTime: boolean;
  17940. private BJSNODEMATERIALEDITOR;
  17941. /** Get the inspector from bundle or global */
  17942. private _getGlobalNodeMaterialEditor;
  17943. /**
  17944. * Snippet ID if the material was created from the snippet server
  17945. */
  17946. snippetId: string;
  17947. /**
  17948. * Gets or sets data used by visual editor
  17949. * @see https://nme.babylonjs.com
  17950. */
  17951. editorData: any;
  17952. /**
  17953. * 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)
  17954. */
  17955. ignoreAlpha: boolean;
  17956. /**
  17957. * Defines the maximum number of lights that can be used in the material
  17958. */
  17959. maxSimultaneousLights: number;
  17960. /**
  17961. * Observable raised when the material is built
  17962. */
  17963. onBuildObservable: Observable<NodeMaterial>;
  17964. /**
  17965. * Gets or sets the root nodes of the material vertex shader
  17966. */
  17967. _vertexOutputNodes: NodeMaterialBlock[];
  17968. /**
  17969. * Gets or sets the root nodes of the material fragment (pixel) shader
  17970. */
  17971. _fragmentOutputNodes: NodeMaterialBlock[];
  17972. /** Gets or sets options to control the node material overall behavior */
  17973. get options(): INodeMaterialOptions;
  17974. set options(options: INodeMaterialOptions);
  17975. /**
  17976. * Default configuration related to image processing available in the standard Material.
  17977. */
  17978. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  17979. /**
  17980. * Gets the image processing configuration used either in this material.
  17981. */
  17982. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  17983. /**
  17984. * Sets the Default image processing configuration used either in the this material.
  17985. *
  17986. * If sets to null, the scene one is in use.
  17987. */
  17988. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  17989. /**
  17990. * Gets an array of blocks that needs to be serialized even if they are not yet connected
  17991. */
  17992. attachedBlocks: NodeMaterialBlock[];
  17993. /**
  17994. * Specifies the mode of the node material
  17995. * @hidden
  17996. */
  17997. _mode: NodeMaterialModes;
  17998. /**
  17999. * Gets the mode property
  18000. */
  18001. get mode(): NodeMaterialModes;
  18002. /**
  18003. * A free comment about the material
  18004. */
  18005. comment: string;
  18006. /**
  18007. * Create a new node based material
  18008. * @param name defines the material name
  18009. * @param scene defines the hosting scene
  18010. * @param options defines creation option
  18011. */
  18012. constructor(name: string, scene?: Scene, options?: Partial<INodeMaterialOptions>);
  18013. /**
  18014. * Gets the current class name of the material e.g. "NodeMaterial"
  18015. * @returns the class name
  18016. */
  18017. getClassName(): string;
  18018. /**
  18019. * Keep track of the image processing observer to allow dispose and replace.
  18020. */
  18021. private _imageProcessingObserver;
  18022. /**
  18023. * Attaches a new image processing configuration to the Standard Material.
  18024. * @param configuration
  18025. */
  18026. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  18027. /**
  18028. * Get a block by its name
  18029. * @param name defines the name of the block to retrieve
  18030. * @returns the required block or null if not found
  18031. */
  18032. getBlockByName(name: string): Nullable<NodeMaterialBlock>;
  18033. /**
  18034. * Get a block by its name
  18035. * @param predicate defines the predicate used to find the good candidate
  18036. * @returns the required block or null if not found
  18037. */
  18038. getBlockByPredicate(predicate: (block: NodeMaterialBlock) => boolean): Nullable<NodeMaterialBlock>;
  18039. /**
  18040. * Get an input block by its name
  18041. * @param predicate defines the predicate used to find the good candidate
  18042. * @returns the required input block or null if not found
  18043. */
  18044. getInputBlockByPredicate(predicate: (block: InputBlock) => boolean): Nullable<InputBlock>;
  18045. /**
  18046. * Gets the list of input blocks attached to this material
  18047. * @returns an array of InputBlocks
  18048. */
  18049. getInputBlocks(): InputBlock[];
  18050. /**
  18051. * Adds a new optimizer to the list of optimizers
  18052. * @param optimizer defines the optimizers to add
  18053. * @returns the current material
  18054. */
  18055. registerOptimizer(optimizer: NodeMaterialOptimizer): this | undefined;
  18056. /**
  18057. * Remove an optimizer from the list of optimizers
  18058. * @param optimizer defines the optimizers to remove
  18059. * @returns the current material
  18060. */
  18061. unregisterOptimizer(optimizer: NodeMaterialOptimizer): this | undefined;
  18062. /**
  18063. * Add a new block to the list of output nodes
  18064. * @param node defines the node to add
  18065. * @returns the current material
  18066. */
  18067. addOutputNode(node: NodeMaterialBlock): this;
  18068. /**
  18069. * Remove a block from the list of root nodes
  18070. * @param node defines the node to remove
  18071. * @returns the current material
  18072. */
  18073. removeOutputNode(node: NodeMaterialBlock): this;
  18074. private _addVertexOutputNode;
  18075. private _removeVertexOutputNode;
  18076. private _addFragmentOutputNode;
  18077. private _removeFragmentOutputNode;
  18078. /**
  18079. * Specifies if the material will require alpha blending
  18080. * @returns a boolean specifying if alpha blending is needed
  18081. */
  18082. needAlphaBlending(): boolean;
  18083. /**
  18084. * Specifies if this material should be rendered in alpha test mode
  18085. * @returns a boolean specifying if an alpha test is needed.
  18086. */
  18087. needAlphaTesting(): boolean;
  18088. private _initializeBlock;
  18089. private _resetDualBlocks;
  18090. /**
  18091. * Remove a block from the current node material
  18092. * @param block defines the block to remove
  18093. */
  18094. removeBlock(block: NodeMaterialBlock): void;
  18095. /**
  18096. * Build the material and generates the inner effect
  18097. * @param verbose defines if the build should log activity
  18098. */
  18099. build(verbose?: boolean): void;
  18100. /**
  18101. * Runs an otpimization phase to try to improve the shader code
  18102. */
  18103. optimize(): void;
  18104. private _prepareDefinesForAttributes;
  18105. /**
  18106. * Create a post process from the material
  18107. * @param camera The camera to apply the render pass to.
  18108. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  18109. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  18110. * @param engine The engine which the post process will be applied. (default: current engine)
  18111. * @param reusable If the post process can be reused on the same frame. (default: false)
  18112. * @param textureType Type of textures used when performing the post process. (default: 0)
  18113. * @param textureFormat Format of textures used when performing the post process. (default: TEXTUREFORMAT_RGBA)
  18114. * @returns the post process created
  18115. */
  18116. createPostProcess(camera: Nullable<Camera>, options?: number | PostProcessOptions, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, textureFormat?: number): Nullable<PostProcess>;
  18117. /**
  18118. * Create the post process effect from the material
  18119. * @param postProcess The post process to create the effect for
  18120. */
  18121. createEffectForPostProcess(postProcess: PostProcess): void;
  18122. private _createEffectForPostProcess;
  18123. /**
  18124. * Create a new procedural texture based on this node material
  18125. * @param size defines the size of the texture
  18126. * @param scene defines the hosting scene
  18127. * @returns the new procedural texture attached to this node material
  18128. */
  18129. createProceduralTexture(size: number | {
  18130. width: number;
  18131. height: number;
  18132. layers?: number;
  18133. }, scene: Scene): Nullable<ProceduralTexture>;
  18134. private _createEffectForParticles;
  18135. private _checkInternals;
  18136. /**
  18137. * Create the effect to be used as the custom effect for a particle system
  18138. * @param particleSystem Particle system to create the effect for
  18139. * @param onCompiled defines a function to call when the effect creation is successful
  18140. * @param onError defines a function to call when the effect creation has failed
  18141. */
  18142. createEffectForParticles(particleSystem: IParticleSystem, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  18143. private _processDefines;
  18144. /**
  18145. * Get if the submesh is ready to be used and all its information available.
  18146. * Child classes can use it to update shaders
  18147. * @param mesh defines the mesh to check
  18148. * @param subMesh defines which submesh to check
  18149. * @param useInstances specifies that instances should be used
  18150. * @returns a boolean indicating that the submesh is ready or not
  18151. */
  18152. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  18153. /**
  18154. * Get a string representing the shaders built by the current node graph
  18155. */
  18156. get compiledShaders(): string;
  18157. /**
  18158. * Binds the world matrix to the material
  18159. * @param world defines the world transformation matrix
  18160. */
  18161. bindOnlyWorldMatrix(world: Matrix): void;
  18162. /**
  18163. * Binds the submesh to this material by preparing the effect and shader to draw
  18164. * @param world defines the world transformation matrix
  18165. * @param mesh defines the mesh containing the submesh
  18166. * @param subMesh defines the submesh to bind the material to
  18167. */
  18168. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  18169. /**
  18170. * Gets the active textures from the material
  18171. * @returns an array of textures
  18172. */
  18173. getActiveTextures(): BaseTexture[];
  18174. /**
  18175. * Gets the list of texture blocks
  18176. * @returns an array of texture blocks
  18177. */
  18178. getTextureBlocks(): (TextureBlock | ReflectionTextureBaseBlock | RefractionBlock | CurrentScreenBlock | ParticleTextureBlock)[];
  18179. /**
  18180. * Specifies if the material uses a texture
  18181. * @param texture defines the texture to check against the material
  18182. * @returns a boolean specifying if the material uses the texture
  18183. */
  18184. hasTexture(texture: BaseTexture): boolean;
  18185. /**
  18186. * Disposes the material
  18187. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  18188. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  18189. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  18190. */
  18191. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  18192. /** Creates the node editor window. */
  18193. private _createNodeEditor;
  18194. /**
  18195. * Launch the node material editor
  18196. * @param config Define the configuration of the editor
  18197. * @return a promise fulfilled when the node editor is visible
  18198. */
  18199. edit(config?: INodeMaterialEditorOptions): Promise<void>;
  18200. /**
  18201. * Clear the current material
  18202. */
  18203. clear(): void;
  18204. /**
  18205. * Clear the current material and set it to a default state
  18206. */
  18207. setToDefault(): void;
  18208. /**
  18209. * Clear the current material and set it to a default state for post process
  18210. */
  18211. setToDefaultPostProcess(): void;
  18212. /**
  18213. * Clear the current material and set it to a default state for procedural texture
  18214. */
  18215. setToDefaultProceduralTexture(): void;
  18216. /**
  18217. * Clear the current material and set it to a default state for particle
  18218. */
  18219. setToDefaultParticle(): void;
  18220. /**
  18221. * Loads the current Node Material from a url pointing to a file save by the Node Material Editor
  18222. * @param url defines the url to load from
  18223. * @returns a promise that will fulfil when the material is fully loaded
  18224. */
  18225. loadAsync(url: string): Promise<void>;
  18226. private _gatherBlocks;
  18227. /**
  18228. * Generate a string containing the code declaration required to create an equivalent of this material
  18229. * @returns a string
  18230. */
  18231. generateCode(): string;
  18232. /**
  18233. * Serializes this material in a JSON representation
  18234. * @returns the serialized material object
  18235. */
  18236. serialize(selectedBlocks?: NodeMaterialBlock[]): any;
  18237. private _restoreConnections;
  18238. /**
  18239. * Clear the current graph and load a new one from a serialization object
  18240. * @param source defines the JSON representation of the material
  18241. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  18242. * @param merge defines whether or not the source must be merged or replace the current content
  18243. */
  18244. loadFromSerialization(source: any, rootUrl?: string, merge?: boolean): void;
  18245. /**
  18246. * Makes a duplicate of the current material.
  18247. * @param name - name to use for the new material.
  18248. */
  18249. clone(name: string): NodeMaterial;
  18250. /**
  18251. * Creates a node material from parsed material data
  18252. * @param source defines the JSON representation of the material
  18253. * @param scene defines the hosting scene
  18254. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  18255. * @returns a new node material
  18256. */
  18257. static Parse(source: any, scene: Scene, rootUrl?: string): NodeMaterial;
  18258. /**
  18259. * Creates a node material from a snippet saved in a remote file
  18260. * @param name defines the name of the material to create
  18261. * @param url defines the url to load from
  18262. * @param scene defines the hosting scene
  18263. * @returns a promise that will resolve to the new node material
  18264. */
  18265. static ParseFromFileAsync(name: string, url: string, scene: Scene): Promise<NodeMaterial>;
  18266. /**
  18267. * Creates a node material from a snippet saved by the node material editor
  18268. * @param snippetId defines the snippet to load
  18269. * @param scene defines the hosting scene
  18270. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  18271. * @param nodeMaterial defines a node material to update (instead of creating a new one)
  18272. * @returns a promise that will resolve to the new node material
  18273. */
  18274. static ParseFromSnippetAsync(snippetId: string, scene: Scene, rootUrl?: string, nodeMaterial?: NodeMaterial): Promise<NodeMaterial>;
  18275. /**
  18276. * Creates a new node material set to default basic configuration
  18277. * @param name defines the name of the material
  18278. * @param scene defines the hosting scene
  18279. * @returns a new NodeMaterial
  18280. */
  18281. static CreateDefault(name: string, scene?: Scene): NodeMaterial;
  18282. }
  18283. }
  18284. declare module BABYLON {
  18285. interface ThinEngine {
  18286. /**
  18287. * Unbind a list of render target textures from the webGL context
  18288. * This is used only when drawBuffer extension or webGL2 are active
  18289. * @param textures defines the render target textures to unbind
  18290. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  18291. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  18292. */
  18293. unBindMultiColorAttachmentFramebuffer(textures: InternalTexture[], disableGenerateMipMaps: boolean, onBeforeUnbind?: () => void): void;
  18294. /**
  18295. * Create a multi render target texture
  18296. * @see https://doc.babylonjs.com/features/webgl2#multiple-render-target
  18297. * @param size defines the size of the texture
  18298. * @param options defines the creation options
  18299. * @param initializeBuffers if set to true, the engine will make an initializing call of drawBuffers
  18300. * @returns the cube texture as an InternalTexture
  18301. */
  18302. createMultipleRenderTarget(size: any, options: IMultiRenderTargetOptions, initializeBuffers?: boolean): InternalTexture[];
  18303. /**
  18304. * Update the sample count for a given multiple render target texture
  18305. * @see https://doc.babylonjs.com/features/webgl2#multisample-render-targets
  18306. * @param textures defines the textures to update
  18307. * @param samples defines the sample count to set
  18308. * @param initializeBuffers if set to true, the engine will make an initializing call of drawBuffers
  18309. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  18310. */
  18311. updateMultipleRenderTargetTextureSampleCount(textures: Nullable<InternalTexture[]>, samples: number, initializeBuffers?: boolean): number;
  18312. /**
  18313. * Select a subsets of attachments to draw to.
  18314. * @param attachments gl attachments
  18315. */
  18316. bindAttachments(attachments: number[]): void;
  18317. /**
  18318. * Creates a layout object to draw/clear on specific textures in a MRT
  18319. * @param textureStatus textureStatus[i] indicates if the i-th is active
  18320. * @returns A layout to be fed to the engine, calling `bindAttachments`.
  18321. */
  18322. buildTextureLayout(textureStatus: boolean[]): number[];
  18323. /**
  18324. * Restores the webgl state to only draw on the main color attachment
  18325. * when the frame buffer associated is the canvas frame buffer
  18326. */
  18327. restoreSingleAttachment(): void;
  18328. /**
  18329. * Restores the webgl state to only draw on the main color attachment
  18330. * when the frame buffer associated is not the canvas frame buffer
  18331. */
  18332. restoreSingleAttachmentForRenderTarget(): void;
  18333. /**
  18334. * Clears a list of attachments
  18335. * @param attachments list of the attachments
  18336. * @param colorMain clear color for the main attachment (the first one)
  18337. * @param colorOthers clear color for the other attachments
  18338. * @param clearDepth true to clear the depth buffer. Used only for the first attachment
  18339. * @param clearStencil true to clear the stencil buffer. Used only for the first attachment
  18340. */
  18341. clearAttachments(attachments: number[], colorMain: Nullable<IColor4Like>, colorOthers: Nullable<IColor4Like>, clearDepth: boolean, clearStencil: boolean): void;
  18342. }
  18343. }
  18344. declare module BABYLON {
  18345. /**
  18346. * Creation options of the multi render target texture.
  18347. */
  18348. export interface IMultiRenderTargetOptions {
  18349. /**
  18350. * Define if the texture needs to create mip maps after render.
  18351. */
  18352. generateMipMaps?: boolean;
  18353. /**
  18354. * Define the types of all the draw buffers we want to create
  18355. */
  18356. types?: number[];
  18357. /**
  18358. * Define the sampling modes of all the draw buffers we want to create
  18359. */
  18360. samplingModes?: number[];
  18361. /**
  18362. * Define if a depth buffer is required
  18363. */
  18364. generateDepthBuffer?: boolean;
  18365. /**
  18366. * Define if a stencil buffer is required
  18367. */
  18368. generateStencilBuffer?: boolean;
  18369. /**
  18370. * Define if a depth texture is required instead of a depth buffer
  18371. */
  18372. generateDepthTexture?: boolean;
  18373. /**
  18374. * Define the number of desired draw buffers
  18375. */
  18376. textureCount?: number;
  18377. /**
  18378. * Define if aspect ratio should be adapted to the texture or stay the scene one
  18379. */
  18380. doNotChangeAspectRatio?: boolean;
  18381. /**
  18382. * Define the default type of the buffers we are creating
  18383. */
  18384. defaultType?: number;
  18385. /**
  18386. * Define the default type of the buffers we are creating
  18387. */
  18388. drawOnlyOnFirstAttachmentByDefault?: boolean;
  18389. }
  18390. /**
  18391. * A multi render target, like a render target provides the ability to render to a texture.
  18392. * Unlike the render target, it can render to several draw buffers in one draw.
  18393. * This is specially interesting in deferred rendering or for any effects requiring more than
  18394. * just one color from a single pass.
  18395. */
  18396. export class MultiRenderTarget extends RenderTargetTexture {
  18397. private _internalTextures;
  18398. private _textures;
  18399. private _multiRenderTargetOptions;
  18400. private _count;
  18401. private _drawOnlyOnFirstAttachmentByDefault;
  18402. /**
  18403. * Get if draw buffers are currently supported by the used hardware and browser.
  18404. */
  18405. get isSupported(): boolean;
  18406. /**
  18407. * Get the list of textures generated by the multi render target.
  18408. */
  18409. get textures(): Texture[];
  18410. /**
  18411. * Gets the number of textures in this MRT. This number can be different from `_textures.length` in case a depth texture is generated.
  18412. */
  18413. get count(): number;
  18414. /**
  18415. * Get the depth texture generated by the multi render target if options.generateDepthTexture has been set
  18416. */
  18417. get depthTexture(): Texture;
  18418. /**
  18419. * Set the wrapping mode on U of all the textures we are rendering to.
  18420. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  18421. */
  18422. set wrapU(wrap: number);
  18423. /**
  18424. * Set the wrapping mode on V of all the textures we are rendering to.
  18425. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  18426. */
  18427. set wrapV(wrap: number);
  18428. /**
  18429. * Instantiate a new multi render target texture.
  18430. * A multi render target, like a render target provides the ability to render to a texture.
  18431. * Unlike the render target, it can render to several draw buffers in one draw.
  18432. * This is specially interesting in deferred rendering or for any effects requiring more than
  18433. * just one color from a single pass.
  18434. * @param name Define the name of the texture
  18435. * @param size Define the size of the buffers to render to
  18436. * @param count Define the number of target we are rendering into
  18437. * @param scene Define the scene the texture belongs to
  18438. * @param options Define the options used to create the multi render target
  18439. */
  18440. constructor(name: string, size: any, count: number, scene: Scene, options?: IMultiRenderTargetOptions);
  18441. private _initTypes;
  18442. /** @hidden */
  18443. _rebuild(forceFullRebuild?: boolean): void;
  18444. private _createInternalTextures;
  18445. private _createTextures;
  18446. /**
  18447. * Replaces a texture within the MRT.
  18448. * @param texture The new texture to insert in the MRT
  18449. * @param index The index of the texture to replace
  18450. */
  18451. replaceTexture(texture: Texture, index: number): void;
  18452. /**
  18453. * Define the number of samples used if MSAA is enabled.
  18454. */
  18455. get samples(): number;
  18456. set samples(value: number);
  18457. /**
  18458. * Resize all the textures in the multi render target.
  18459. * Be careful as it will recreate all the data in the new texture.
  18460. * @param size Define the new size
  18461. */
  18462. resize(size: any): void;
  18463. /**
  18464. * Changes the number of render targets in this MRT
  18465. * Be careful as it will recreate all the data in the new texture.
  18466. * @param count new texture count
  18467. * @param options Specifies texture types and sampling modes for new textures
  18468. */
  18469. updateCount(count: number, options?: IMultiRenderTargetOptions): void;
  18470. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  18471. /**
  18472. * Dispose the render targets and their associated resources
  18473. */
  18474. dispose(): void;
  18475. /**
  18476. * Release all the underlying texture used as draw buffers.
  18477. */
  18478. releaseInternalTextures(): void;
  18479. }
  18480. }
  18481. declare module BABYLON {
  18482. /** @hidden */
  18483. export var imageProcessingPixelShader: {
  18484. name: string;
  18485. shader: string;
  18486. };
  18487. }
  18488. declare module BABYLON {
  18489. /**
  18490. * ImageProcessingPostProcess
  18491. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#imageprocessing
  18492. */
  18493. export class ImageProcessingPostProcess extends PostProcess {
  18494. /**
  18495. * Default configuration related to image processing available in the PBR Material.
  18496. */
  18497. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  18498. /**
  18499. * Gets the image processing configuration used either in this material.
  18500. */
  18501. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  18502. /**
  18503. * Sets the Default image processing configuration used either in the this material.
  18504. *
  18505. * If sets to null, the scene one is in use.
  18506. */
  18507. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  18508. /**
  18509. * Keep track of the image processing observer to allow dispose and replace.
  18510. */
  18511. private _imageProcessingObserver;
  18512. /**
  18513. * Attaches a new image processing configuration to the PBR Material.
  18514. * @param configuration
  18515. */
  18516. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>, doNotBuild?: boolean): void;
  18517. /**
  18518. * If the post process is supported.
  18519. */
  18520. get isSupported(): boolean;
  18521. /**
  18522. * Gets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  18523. */
  18524. get colorCurves(): Nullable<ColorCurves>;
  18525. /**
  18526. * Sets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  18527. */
  18528. set colorCurves(value: Nullable<ColorCurves>);
  18529. /**
  18530. * Gets wether the color curves effect is enabled.
  18531. */
  18532. get colorCurvesEnabled(): boolean;
  18533. /**
  18534. * Sets wether the color curves effect is enabled.
  18535. */
  18536. set colorCurvesEnabled(value: boolean);
  18537. /**
  18538. * Gets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  18539. */
  18540. get colorGradingTexture(): Nullable<BaseTexture>;
  18541. /**
  18542. * Sets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  18543. */
  18544. set colorGradingTexture(value: Nullable<BaseTexture>);
  18545. /**
  18546. * Gets wether the color grading effect is enabled.
  18547. */
  18548. get colorGradingEnabled(): boolean;
  18549. /**
  18550. * Gets wether the color grading effect is enabled.
  18551. */
  18552. set colorGradingEnabled(value: boolean);
  18553. /**
  18554. * Gets exposure used in the effect.
  18555. */
  18556. get exposure(): number;
  18557. /**
  18558. * Sets exposure used in the effect.
  18559. */
  18560. set exposure(value: number);
  18561. /**
  18562. * Gets wether tonemapping is enabled or not.
  18563. */
  18564. get toneMappingEnabled(): boolean;
  18565. /**
  18566. * Sets wether tonemapping is enabled or not
  18567. */
  18568. set toneMappingEnabled(value: boolean);
  18569. /**
  18570. * Gets the type of tone mapping effect.
  18571. */
  18572. get toneMappingType(): number;
  18573. /**
  18574. * Sets the type of tone mapping effect.
  18575. */
  18576. set toneMappingType(value: number);
  18577. /**
  18578. * Gets contrast used in the effect.
  18579. */
  18580. get contrast(): number;
  18581. /**
  18582. * Sets contrast used in the effect.
  18583. */
  18584. set contrast(value: number);
  18585. /**
  18586. * Gets Vignette stretch size.
  18587. */
  18588. get vignetteStretch(): number;
  18589. /**
  18590. * Sets Vignette stretch size.
  18591. */
  18592. set vignetteStretch(value: number);
  18593. /**
  18594. * Gets Vignette centre X Offset.
  18595. */
  18596. get vignetteCentreX(): number;
  18597. /**
  18598. * Sets Vignette centre X Offset.
  18599. */
  18600. set vignetteCentreX(value: number);
  18601. /**
  18602. * Gets Vignette centre Y Offset.
  18603. */
  18604. get vignetteCentreY(): number;
  18605. /**
  18606. * Sets Vignette centre Y Offset.
  18607. */
  18608. set vignetteCentreY(value: number);
  18609. /**
  18610. * Gets Vignette weight or intensity of the vignette effect.
  18611. */
  18612. get vignetteWeight(): number;
  18613. /**
  18614. * Sets Vignette weight or intensity of the vignette effect.
  18615. */
  18616. set vignetteWeight(value: number);
  18617. /**
  18618. * Gets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  18619. * if vignetteEnabled is set to true.
  18620. */
  18621. get vignetteColor(): Color4;
  18622. /**
  18623. * Sets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  18624. * if vignetteEnabled is set to true.
  18625. */
  18626. set vignetteColor(value: Color4);
  18627. /**
  18628. * Gets Camera field of view used by the Vignette effect.
  18629. */
  18630. get vignetteCameraFov(): number;
  18631. /**
  18632. * Sets Camera field of view used by the Vignette effect.
  18633. */
  18634. set vignetteCameraFov(value: number);
  18635. /**
  18636. * Gets the vignette blend mode allowing different kind of effect.
  18637. */
  18638. get vignetteBlendMode(): number;
  18639. /**
  18640. * Sets the vignette blend mode allowing different kind of effect.
  18641. */
  18642. set vignetteBlendMode(value: number);
  18643. /**
  18644. * Gets wether the vignette effect is enabled.
  18645. */
  18646. get vignetteEnabled(): boolean;
  18647. /**
  18648. * Sets wether the vignette effect is enabled.
  18649. */
  18650. set vignetteEnabled(value: boolean);
  18651. private _fromLinearSpace;
  18652. /**
  18653. * Gets wether the input of the processing is in Gamma or Linear Space.
  18654. */
  18655. get fromLinearSpace(): boolean;
  18656. /**
  18657. * Sets wether the input of the processing is in Gamma or Linear Space.
  18658. */
  18659. set fromLinearSpace(value: boolean);
  18660. /**
  18661. * Defines cache preventing GC.
  18662. */
  18663. private _defines;
  18664. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, imageProcessingConfiguration?: ImageProcessingConfiguration);
  18665. /**
  18666. * "ImageProcessingPostProcess"
  18667. * @returns "ImageProcessingPostProcess"
  18668. */
  18669. getClassName(): string;
  18670. /**
  18671. * @hidden
  18672. */
  18673. _updateParameters(): void;
  18674. dispose(camera?: Camera): void;
  18675. }
  18676. }
  18677. declare module BABYLON {
  18678. /**
  18679. * A multi render target designed to render the prepass.
  18680. * Prepass is a scene component used to render information in multiple textures
  18681. * alongside with the scene materials rendering.
  18682. * Note : This is an internal class, and you should NOT need to instanciate this.
  18683. * Only the `PrePassRenderer` should instanciate this class.
  18684. * It is more likely that you need a regular `MultiRenderTarget`
  18685. * @hidden
  18686. */
  18687. export class PrePassRenderTarget extends MultiRenderTarget {
  18688. /**
  18689. * @hidden
  18690. */
  18691. _beforeCompositionPostProcesses: PostProcess[];
  18692. /**
  18693. * Image processing post process for composition
  18694. */
  18695. imageProcessingPostProcess: ImageProcessingPostProcess;
  18696. /**
  18697. * @hidden
  18698. */
  18699. _engine: Engine;
  18700. /**
  18701. * @hidden
  18702. */
  18703. _scene: Scene;
  18704. /**
  18705. * @hidden
  18706. */
  18707. _outputPostProcess: Nullable<PostProcess>;
  18708. /**
  18709. * @hidden
  18710. */
  18711. _internalTextureDirty: boolean;
  18712. /**
  18713. * Is this render target enabled for prepass rendering
  18714. */
  18715. enabled: boolean;
  18716. /**
  18717. * Render target associated with this prePassRenderTarget
  18718. * If this is `null`, it means this prePassRenderTarget is associated with the scene
  18719. */
  18720. renderTargetTexture: Nullable<RenderTargetTexture>;
  18721. constructor(name: string, renderTargetTexture: Nullable<RenderTargetTexture>, size: any, count: number, scene: Scene, options?: IMultiRenderTargetOptions | undefined);
  18722. /**
  18723. * Creates a composition effect for this RT
  18724. * @hidden
  18725. */
  18726. _createCompositionEffect(): void;
  18727. /**
  18728. * Checks that the size of this RT is still adapted to the desired render size.
  18729. * @hidden
  18730. */
  18731. _checkSize(): void;
  18732. /**
  18733. * Changes the number of render targets in this MRT
  18734. * Be careful as it will recreate all the data in the new texture.
  18735. * @param count new texture count
  18736. * @param options Specifies texture types and sampling modes for new textures
  18737. */
  18738. updateCount(count: number, options?: IMultiRenderTargetOptions): void;
  18739. /**
  18740. * Resets the post processes chains applied to this RT.
  18741. * @hidden
  18742. */
  18743. _resetPostProcessChain(): void;
  18744. /**
  18745. * Diposes this render target
  18746. */
  18747. dispose(): void;
  18748. }
  18749. }
  18750. declare module BABYLON {
  18751. /**
  18752. * Interface for defining prepass effects in the prepass post-process pipeline
  18753. */
  18754. export interface PrePassEffectConfiguration {
  18755. /**
  18756. * Name of the effect
  18757. */
  18758. name: string;
  18759. /**
  18760. * Post process to attach for this effect
  18761. */
  18762. postProcess?: PostProcess;
  18763. /**
  18764. * Textures required in the MRT
  18765. */
  18766. texturesRequired: number[];
  18767. /**
  18768. * Is the effect enabled
  18769. */
  18770. enabled: boolean;
  18771. /**
  18772. * Does the output of this prepass need to go through imageprocessing
  18773. */
  18774. needsImageProcessing?: boolean;
  18775. /**
  18776. * Disposes the effect configuration
  18777. */
  18778. dispose?: () => void;
  18779. /**
  18780. * Creates the associated post process
  18781. */
  18782. createPostProcess?: () => PostProcess;
  18783. }
  18784. }
  18785. declare module BABYLON {
  18786. /**
  18787. * Options to be used when creating a FresnelParameters.
  18788. */
  18789. export type IFresnelParametersCreationOptions = {
  18790. /**
  18791. * Define the color used on edges (grazing angle)
  18792. */
  18793. leftColor?: Color3;
  18794. /**
  18795. * Define the color used on center
  18796. */
  18797. rightColor?: Color3;
  18798. /**
  18799. * Define bias applied to computed fresnel term
  18800. */
  18801. bias?: number;
  18802. /**
  18803. * Defined the power exponent applied to fresnel term
  18804. */
  18805. power?: number;
  18806. /**
  18807. * Define if the fresnel effect is enable or not.
  18808. */
  18809. isEnabled?: boolean;
  18810. };
  18811. /**
  18812. * Serialized format for FresnelParameters.
  18813. */
  18814. export type IFresnelParametersSerialized = {
  18815. /**
  18816. * Define the color used on edges (grazing angle) [as an array]
  18817. */
  18818. leftColor: number[];
  18819. /**
  18820. * Define the color used on center [as an array]
  18821. */
  18822. rightColor: number[];
  18823. /**
  18824. * Define bias applied to computed fresnel term
  18825. */
  18826. bias: number;
  18827. /**
  18828. * Defined the power exponent applied to fresnel term
  18829. */
  18830. power?: number;
  18831. /**
  18832. * Define if the fresnel effect is enable or not.
  18833. */
  18834. isEnabled: boolean;
  18835. };
  18836. /**
  18837. * This represents all the required information to add a fresnel effect on a material:
  18838. * @see https://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  18839. */
  18840. export class FresnelParameters {
  18841. private _isEnabled;
  18842. /**
  18843. * Define if the fresnel effect is enable or not.
  18844. */
  18845. get isEnabled(): boolean;
  18846. set isEnabled(value: boolean);
  18847. /**
  18848. * Define the color used on edges (grazing angle)
  18849. */
  18850. leftColor: Color3;
  18851. /**
  18852. * Define the color used on center
  18853. */
  18854. rightColor: Color3;
  18855. /**
  18856. * Define bias applied to computed fresnel term
  18857. */
  18858. bias: number;
  18859. /**
  18860. * Defined the power exponent applied to fresnel term
  18861. */
  18862. power: number;
  18863. /**
  18864. * Creates a new FresnelParameters object.
  18865. *
  18866. * @param options provide your own settings to optionally to override defaults
  18867. */
  18868. constructor(options?: IFresnelParametersCreationOptions);
  18869. /**
  18870. * Clones the current fresnel and its values
  18871. * @returns a clone fresnel configuration
  18872. */
  18873. clone(): FresnelParameters;
  18874. /**
  18875. * Determines equality between FresnelParameters objects
  18876. * @param otherFresnelParameters defines the second operand
  18877. * @returns true if the power, bias, leftColor, rightColor and isEnabled values are equal to the given ones
  18878. */
  18879. equals(otherFresnelParameters: DeepImmutable<FresnelParameters>): boolean;
  18880. /**
  18881. * Serializes the current fresnel parameters to a JSON representation.
  18882. * @return the JSON serialization
  18883. */
  18884. serialize(): IFresnelParametersSerialized;
  18885. /**
  18886. * Parse a JSON object and deserialize it to a new Fresnel parameter object.
  18887. * @param parsedFresnelParameters Define the JSON representation
  18888. * @returns the parsed parameters
  18889. */
  18890. static Parse(parsedFresnelParameters: IFresnelParametersSerialized): FresnelParameters;
  18891. }
  18892. }
  18893. declare module BABYLON {
  18894. /**
  18895. * This groups all the flags used to control the materials channel.
  18896. */
  18897. export class MaterialFlags {
  18898. private static _DiffuseTextureEnabled;
  18899. /**
  18900. * Are diffuse textures enabled in the application.
  18901. */
  18902. static get DiffuseTextureEnabled(): boolean;
  18903. static set DiffuseTextureEnabled(value: boolean);
  18904. private static _DetailTextureEnabled;
  18905. /**
  18906. * Are detail textures enabled in the application.
  18907. */
  18908. static get DetailTextureEnabled(): boolean;
  18909. static set DetailTextureEnabled(value: boolean);
  18910. private static _AmbientTextureEnabled;
  18911. /**
  18912. * Are ambient textures enabled in the application.
  18913. */
  18914. static get AmbientTextureEnabled(): boolean;
  18915. static set AmbientTextureEnabled(value: boolean);
  18916. private static _OpacityTextureEnabled;
  18917. /**
  18918. * Are opacity textures enabled in the application.
  18919. */
  18920. static get OpacityTextureEnabled(): boolean;
  18921. static set OpacityTextureEnabled(value: boolean);
  18922. private static _ReflectionTextureEnabled;
  18923. /**
  18924. * Are reflection textures enabled in the application.
  18925. */
  18926. static get ReflectionTextureEnabled(): boolean;
  18927. static set ReflectionTextureEnabled(value: boolean);
  18928. private static _EmissiveTextureEnabled;
  18929. /**
  18930. * Are emissive textures enabled in the application.
  18931. */
  18932. static get EmissiveTextureEnabled(): boolean;
  18933. static set EmissiveTextureEnabled(value: boolean);
  18934. private static _SpecularTextureEnabled;
  18935. /**
  18936. * Are specular textures enabled in the application.
  18937. */
  18938. static get SpecularTextureEnabled(): boolean;
  18939. static set SpecularTextureEnabled(value: boolean);
  18940. private static _BumpTextureEnabled;
  18941. /**
  18942. * Are bump textures enabled in the application.
  18943. */
  18944. static get BumpTextureEnabled(): boolean;
  18945. static set BumpTextureEnabled(value: boolean);
  18946. private static _LightmapTextureEnabled;
  18947. /**
  18948. * Are lightmap textures enabled in the application.
  18949. */
  18950. static get LightmapTextureEnabled(): boolean;
  18951. static set LightmapTextureEnabled(value: boolean);
  18952. private static _RefractionTextureEnabled;
  18953. /**
  18954. * Are refraction textures enabled in the application.
  18955. */
  18956. static get RefractionTextureEnabled(): boolean;
  18957. static set RefractionTextureEnabled(value: boolean);
  18958. private static _ColorGradingTextureEnabled;
  18959. /**
  18960. * Are color grading textures enabled in the application.
  18961. */
  18962. static get ColorGradingTextureEnabled(): boolean;
  18963. static set ColorGradingTextureEnabled(value: boolean);
  18964. private static _FresnelEnabled;
  18965. /**
  18966. * Are fresnels enabled in the application.
  18967. */
  18968. static get FresnelEnabled(): boolean;
  18969. static set FresnelEnabled(value: boolean);
  18970. private static _ClearCoatTextureEnabled;
  18971. /**
  18972. * Are clear coat textures enabled in the application.
  18973. */
  18974. static get ClearCoatTextureEnabled(): boolean;
  18975. static set ClearCoatTextureEnabled(value: boolean);
  18976. private static _ClearCoatBumpTextureEnabled;
  18977. /**
  18978. * Are clear coat bump textures enabled in the application.
  18979. */
  18980. static get ClearCoatBumpTextureEnabled(): boolean;
  18981. static set ClearCoatBumpTextureEnabled(value: boolean);
  18982. private static _ClearCoatTintTextureEnabled;
  18983. /**
  18984. * Are clear coat tint textures enabled in the application.
  18985. */
  18986. static get ClearCoatTintTextureEnabled(): boolean;
  18987. static set ClearCoatTintTextureEnabled(value: boolean);
  18988. private static _SheenTextureEnabled;
  18989. /**
  18990. * Are sheen textures enabled in the application.
  18991. */
  18992. static get SheenTextureEnabled(): boolean;
  18993. static set SheenTextureEnabled(value: boolean);
  18994. private static _AnisotropicTextureEnabled;
  18995. /**
  18996. * Are anisotropic textures enabled in the application.
  18997. */
  18998. static get AnisotropicTextureEnabled(): boolean;
  18999. static set AnisotropicTextureEnabled(value: boolean);
  19000. private static _ThicknessTextureEnabled;
  19001. /**
  19002. * Are thickness textures enabled in the application.
  19003. */
  19004. static get ThicknessTextureEnabled(): boolean;
  19005. static set ThicknessTextureEnabled(value: boolean);
  19006. }
  19007. }
  19008. declare module BABYLON {
  19009. /** @hidden */
  19010. export var defaultFragmentDeclaration: {
  19011. name: string;
  19012. shader: string;
  19013. };
  19014. }
  19015. declare module BABYLON {
  19016. /** @hidden */
  19017. export var sceneUboDeclaration: {
  19018. name: string;
  19019. shader: string;
  19020. };
  19021. }
  19022. declare module BABYLON {
  19023. /** @hidden */
  19024. export var meshUboDeclaration: {
  19025. name: string;
  19026. shader: string;
  19027. };
  19028. }
  19029. declare module BABYLON {
  19030. /** @hidden */
  19031. export var defaultUboDeclaration: {
  19032. name: string;
  19033. shader: string;
  19034. };
  19035. }
  19036. declare module BABYLON {
  19037. /** @hidden */
  19038. export var prePassDeclaration: {
  19039. name: string;
  19040. shader: string;
  19041. };
  19042. }
  19043. declare module BABYLON {
  19044. /** @hidden */
  19045. export var lightFragmentDeclaration: {
  19046. name: string;
  19047. shader: string;
  19048. };
  19049. }
  19050. declare module BABYLON {
  19051. /** @hidden */
  19052. export var lightUboDeclaration: {
  19053. name: string;
  19054. shader: string;
  19055. };
  19056. }
  19057. declare module BABYLON {
  19058. /** @hidden */
  19059. export var lightsFragmentFunctions: {
  19060. name: string;
  19061. shader: string;
  19062. };
  19063. }
  19064. declare module BABYLON {
  19065. /** @hidden */
  19066. export var shadowsFragmentFunctions: {
  19067. name: string;
  19068. shader: string;
  19069. };
  19070. }
  19071. declare module BABYLON {
  19072. /** @hidden */
  19073. export var fresnelFunction: {
  19074. name: string;
  19075. shader: string;
  19076. };
  19077. }
  19078. declare module BABYLON {
  19079. /** @hidden */
  19080. export var bumpFragmentMainFunctions: {
  19081. name: string;
  19082. shader: string;
  19083. };
  19084. }
  19085. declare module BABYLON {
  19086. /** @hidden */
  19087. export var bumpFragmentFunctions: {
  19088. name: string;
  19089. shader: string;
  19090. };
  19091. }
  19092. declare module BABYLON {
  19093. /** @hidden */
  19094. export var logDepthDeclaration: {
  19095. name: string;
  19096. shader: string;
  19097. };
  19098. }
  19099. declare module BABYLON {
  19100. /** @hidden */
  19101. export var fogFragmentDeclaration: {
  19102. name: string;
  19103. shader: string;
  19104. };
  19105. }
  19106. declare module BABYLON {
  19107. /** @hidden */
  19108. export var bumpFragment: {
  19109. name: string;
  19110. shader: string;
  19111. };
  19112. }
  19113. declare module BABYLON {
  19114. /** @hidden */
  19115. export var depthPrePass: {
  19116. name: string;
  19117. shader: string;
  19118. };
  19119. }
  19120. declare module BABYLON {
  19121. /** @hidden */
  19122. export var lightFragment: {
  19123. name: string;
  19124. shader: string;
  19125. };
  19126. }
  19127. declare module BABYLON {
  19128. /** @hidden */
  19129. export var logDepthFragment: {
  19130. name: string;
  19131. shader: string;
  19132. };
  19133. }
  19134. declare module BABYLON {
  19135. /** @hidden */
  19136. export var fogFragment: {
  19137. name: string;
  19138. shader: string;
  19139. };
  19140. }
  19141. declare module BABYLON {
  19142. /** @hidden */
  19143. export var defaultPixelShader: {
  19144. name: string;
  19145. shader: string;
  19146. };
  19147. }
  19148. declare module BABYLON {
  19149. /** @hidden */
  19150. export var defaultVertexDeclaration: {
  19151. name: string;
  19152. shader: string;
  19153. };
  19154. }
  19155. declare module BABYLON {
  19156. /** @hidden */
  19157. export var bonesDeclaration: {
  19158. name: string;
  19159. shader: string;
  19160. };
  19161. }
  19162. declare module BABYLON {
  19163. /** @hidden */
  19164. export var prePassVertexDeclaration: {
  19165. name: string;
  19166. shader: string;
  19167. };
  19168. }
  19169. declare module BABYLON {
  19170. /** @hidden */
  19171. export var bumpVertexDeclaration: {
  19172. name: string;
  19173. shader: string;
  19174. };
  19175. }
  19176. declare module BABYLON {
  19177. /** @hidden */
  19178. export var fogVertexDeclaration: {
  19179. name: string;
  19180. shader: string;
  19181. };
  19182. }
  19183. declare module BABYLON {
  19184. /** @hidden */
  19185. export var lightVxFragmentDeclaration: {
  19186. name: string;
  19187. shader: string;
  19188. };
  19189. }
  19190. declare module BABYLON {
  19191. /** @hidden */
  19192. export var lightVxUboDeclaration: {
  19193. name: string;
  19194. shader: string;
  19195. };
  19196. }
  19197. declare module BABYLON {
  19198. /** @hidden */
  19199. export var morphTargetsVertexGlobalDeclaration: {
  19200. name: string;
  19201. shader: string;
  19202. };
  19203. }
  19204. declare module BABYLON {
  19205. /** @hidden */
  19206. export var morphTargetsVertexDeclaration: {
  19207. name: string;
  19208. shader: string;
  19209. };
  19210. }
  19211. declare module BABYLON {
  19212. /** @hidden */
  19213. export var morphTargetsVertex: {
  19214. name: string;
  19215. shader: string;
  19216. };
  19217. }
  19218. declare module BABYLON {
  19219. /** @hidden */
  19220. export var instancesVertex: {
  19221. name: string;
  19222. shader: string;
  19223. };
  19224. }
  19225. declare module BABYLON {
  19226. /** @hidden */
  19227. export var bonesVertex: {
  19228. name: string;
  19229. shader: string;
  19230. };
  19231. }
  19232. declare module BABYLON {
  19233. /** @hidden */
  19234. export var prePassVertex: {
  19235. name: string;
  19236. shader: string;
  19237. };
  19238. }
  19239. declare module BABYLON {
  19240. /** @hidden */
  19241. export var bumpVertex: {
  19242. name: string;
  19243. shader: string;
  19244. };
  19245. }
  19246. declare module BABYLON {
  19247. /** @hidden */
  19248. export var fogVertex: {
  19249. name: string;
  19250. shader: string;
  19251. };
  19252. }
  19253. declare module BABYLON {
  19254. /** @hidden */
  19255. export var shadowsVertex: {
  19256. name: string;
  19257. shader: string;
  19258. };
  19259. }
  19260. declare module BABYLON {
  19261. /** @hidden */
  19262. export var pointCloudVertex: {
  19263. name: string;
  19264. shader: string;
  19265. };
  19266. }
  19267. declare module BABYLON {
  19268. /** @hidden */
  19269. export var logDepthVertex: {
  19270. name: string;
  19271. shader: string;
  19272. };
  19273. }
  19274. declare module BABYLON {
  19275. /** @hidden */
  19276. export var defaultVertexShader: {
  19277. name: string;
  19278. shader: string;
  19279. };
  19280. }
  19281. declare module BABYLON {
  19282. /**
  19283. * @hidden
  19284. */
  19285. export interface IMaterialDetailMapDefines {
  19286. DETAIL: boolean;
  19287. DETAILDIRECTUV: number;
  19288. DETAIL_NORMALBLENDMETHOD: number;
  19289. /** @hidden */
  19290. _areTexturesDirty: boolean;
  19291. }
  19292. /**
  19293. * Define the code related to the detail map parameters of a material
  19294. *
  19295. * Inspired from:
  19296. * 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
  19297. * Unreal: https://docs.unrealengine.com/en-US/Engine/Rendering/Materials/HowTo/DetailTexturing/index.html
  19298. * Cryengine: https://docs.cryengine.com/display/SDKDOC2/Detail+Maps
  19299. */
  19300. export class DetailMapConfiguration {
  19301. private _texture;
  19302. /**
  19303. * The detail texture of the material.
  19304. */
  19305. texture: Nullable<BaseTexture>;
  19306. /**
  19307. * Defines how strongly the detail diffuse/albedo channel is blended with the regular diffuse/albedo texture
  19308. * Bigger values mean stronger blending
  19309. */
  19310. diffuseBlendLevel: number;
  19311. /**
  19312. * Defines how strongly the detail roughness channel is blended with the regular roughness value
  19313. * Bigger values mean stronger blending. Only used with PBR materials
  19314. */
  19315. roughnessBlendLevel: number;
  19316. /**
  19317. * Defines how strong the bump effect from the detail map is
  19318. * Bigger values mean stronger effect
  19319. */
  19320. bumpLevel: number;
  19321. private _normalBlendMethod;
  19322. /**
  19323. * The method used to blend the bump and detail normals together
  19324. */
  19325. normalBlendMethod: number;
  19326. private _isEnabled;
  19327. /**
  19328. * Enable or disable the detail map on this material
  19329. */
  19330. isEnabled: boolean;
  19331. /** @hidden */
  19332. private _internalMarkAllSubMeshesAsTexturesDirty;
  19333. /** @hidden */
  19334. _markAllSubMeshesAsTexturesDirty(): void;
  19335. /**
  19336. * Instantiate a new detail map
  19337. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  19338. */
  19339. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  19340. /**
  19341. * Gets whether the submesh is ready to be used or not.
  19342. * @param defines the list of "defines" to update.
  19343. * @param scene defines the scene the material belongs to.
  19344. * @returns - boolean indicating that the submesh is ready or not.
  19345. */
  19346. isReadyForSubMesh(defines: IMaterialDetailMapDefines, scene: Scene): boolean;
  19347. /**
  19348. * Update the defines for detail map usage
  19349. * @param defines the list of "defines" to update.
  19350. * @param scene defines the scene the material belongs to.
  19351. */
  19352. prepareDefines(defines: IMaterialDetailMapDefines, scene: Scene): void;
  19353. /**
  19354. * Binds the material data.
  19355. * @param uniformBuffer defines the Uniform buffer to fill in.
  19356. * @param scene defines the scene the material belongs to.
  19357. * @param isFrozen defines whether the material is frozen or not.
  19358. */
  19359. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  19360. /**
  19361. * Checks to see if a texture is used in the material.
  19362. * @param texture - Base texture to use.
  19363. * @returns - Boolean specifying if a texture is used in the material.
  19364. */
  19365. hasTexture(texture: BaseTexture): boolean;
  19366. /**
  19367. * Returns an array of the actively used textures.
  19368. * @param activeTextures Array of BaseTextures
  19369. */
  19370. getActiveTextures(activeTextures: BaseTexture[]): void;
  19371. /**
  19372. * Returns the animatable textures.
  19373. * @param animatables Array of animatable textures.
  19374. */
  19375. getAnimatables(animatables: IAnimatable[]): void;
  19376. /**
  19377. * Disposes the resources of the material.
  19378. * @param forceDisposeTextures - Forces the disposal of all textures.
  19379. */
  19380. dispose(forceDisposeTextures?: boolean): void;
  19381. /**
  19382. * Get the current class name useful for serialization or dynamic coding.
  19383. * @returns "DetailMap"
  19384. */
  19385. getClassName(): string;
  19386. /**
  19387. * Add the required uniforms to the current list.
  19388. * @param uniforms defines the current uniform list.
  19389. */
  19390. static AddUniforms(uniforms: string[]): void;
  19391. /**
  19392. * Add the required samplers to the current list.
  19393. * @param samplers defines the current sampler list.
  19394. */
  19395. static AddSamplers(samplers: string[]): void;
  19396. /**
  19397. * Add the required uniforms to the current buffer.
  19398. * @param uniformBuffer defines the current uniform buffer.
  19399. */
  19400. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  19401. /**
  19402. * Makes a duplicate of the current instance into another one.
  19403. * @param detailMap define the instance where to copy the info
  19404. */
  19405. copyTo(detailMap: DetailMapConfiguration): void;
  19406. /**
  19407. * Serializes this detail map instance
  19408. * @returns - An object with the serialized instance.
  19409. */
  19410. serialize(): any;
  19411. /**
  19412. * Parses a detail map setting from a serialized object.
  19413. * @param source - Serialized object.
  19414. * @param scene Defines the scene we are parsing for
  19415. * @param rootUrl Defines the rootUrl to load from
  19416. */
  19417. parse(source: any, scene: Scene, rootUrl: string): void;
  19418. }
  19419. }
  19420. declare module BABYLON {
  19421. /** @hidden */
  19422. export class StandardMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines, IMaterialDetailMapDefines {
  19423. MAINUV1: boolean;
  19424. MAINUV2: boolean;
  19425. DIFFUSE: boolean;
  19426. DIFFUSEDIRECTUV: number;
  19427. DETAIL: boolean;
  19428. DETAILDIRECTUV: number;
  19429. DETAIL_NORMALBLENDMETHOD: number;
  19430. AMBIENT: boolean;
  19431. AMBIENTDIRECTUV: number;
  19432. OPACITY: boolean;
  19433. OPACITYDIRECTUV: number;
  19434. OPACITYRGB: boolean;
  19435. REFLECTION: boolean;
  19436. EMISSIVE: boolean;
  19437. EMISSIVEDIRECTUV: number;
  19438. SPECULAR: boolean;
  19439. SPECULARDIRECTUV: number;
  19440. BUMP: boolean;
  19441. BUMPDIRECTUV: number;
  19442. PARALLAX: boolean;
  19443. PARALLAXOCCLUSION: boolean;
  19444. SPECULAROVERALPHA: boolean;
  19445. CLIPPLANE: boolean;
  19446. CLIPPLANE2: boolean;
  19447. CLIPPLANE3: boolean;
  19448. CLIPPLANE4: boolean;
  19449. CLIPPLANE5: boolean;
  19450. CLIPPLANE6: boolean;
  19451. ALPHATEST: boolean;
  19452. DEPTHPREPASS: boolean;
  19453. ALPHAFROMDIFFUSE: boolean;
  19454. POINTSIZE: boolean;
  19455. FOG: boolean;
  19456. SPECULARTERM: boolean;
  19457. DIFFUSEFRESNEL: boolean;
  19458. OPACITYFRESNEL: boolean;
  19459. REFLECTIONFRESNEL: boolean;
  19460. REFRACTIONFRESNEL: boolean;
  19461. EMISSIVEFRESNEL: boolean;
  19462. FRESNEL: boolean;
  19463. NORMAL: boolean;
  19464. UV1: boolean;
  19465. UV2: boolean;
  19466. VERTEXCOLOR: boolean;
  19467. VERTEXALPHA: boolean;
  19468. NUM_BONE_INFLUENCERS: number;
  19469. BonesPerMesh: number;
  19470. BONETEXTURE: boolean;
  19471. BONES_VELOCITY_ENABLED: boolean;
  19472. INSTANCES: boolean;
  19473. THIN_INSTANCES: boolean;
  19474. GLOSSINESS: boolean;
  19475. ROUGHNESS: boolean;
  19476. EMISSIVEASILLUMINATION: boolean;
  19477. LINKEMISSIVEWITHDIFFUSE: boolean;
  19478. REFLECTIONFRESNELFROMSPECULAR: boolean;
  19479. LIGHTMAP: boolean;
  19480. LIGHTMAPDIRECTUV: number;
  19481. OBJECTSPACE_NORMALMAP: boolean;
  19482. USELIGHTMAPASSHADOWMAP: boolean;
  19483. REFLECTIONMAP_3D: boolean;
  19484. REFLECTIONMAP_SPHERICAL: boolean;
  19485. REFLECTIONMAP_PLANAR: boolean;
  19486. REFLECTIONMAP_CUBIC: boolean;
  19487. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  19488. REFLECTIONMAP_PROJECTION: boolean;
  19489. REFLECTIONMAP_SKYBOX: boolean;
  19490. REFLECTIONMAP_EXPLICIT: boolean;
  19491. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  19492. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  19493. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  19494. REFLECTIONMAP_OPPOSITEZ: boolean;
  19495. INVERTCUBICMAP: boolean;
  19496. LOGARITHMICDEPTH: boolean;
  19497. REFRACTION: boolean;
  19498. REFRACTIONMAP_3D: boolean;
  19499. REFLECTIONOVERALPHA: boolean;
  19500. TWOSIDEDLIGHTING: boolean;
  19501. SHADOWFLOAT: boolean;
  19502. MORPHTARGETS: boolean;
  19503. MORPHTARGETS_NORMAL: boolean;
  19504. MORPHTARGETS_TANGENT: boolean;
  19505. MORPHTARGETS_UV: boolean;
  19506. NUM_MORPH_INFLUENCERS: number;
  19507. NONUNIFORMSCALING: boolean;
  19508. PREMULTIPLYALPHA: boolean;
  19509. ALPHATEST_AFTERALLALPHACOMPUTATIONS: boolean;
  19510. ALPHABLEND: boolean;
  19511. PREPASS: boolean;
  19512. PREPASS_IRRADIANCE: boolean;
  19513. PREPASS_IRRADIANCE_INDEX: number;
  19514. PREPASS_ALBEDO: boolean;
  19515. PREPASS_ALBEDO_INDEX: number;
  19516. PREPASS_DEPTH: boolean;
  19517. PREPASS_DEPTH_INDEX: number;
  19518. PREPASS_NORMAL: boolean;
  19519. PREPASS_NORMAL_INDEX: number;
  19520. PREPASS_POSITION: boolean;
  19521. PREPASS_POSITION_INDEX: number;
  19522. PREPASS_VELOCITY: boolean;
  19523. PREPASS_VELOCITY_INDEX: number;
  19524. PREPASS_REFLECTIVITY: boolean;
  19525. PREPASS_REFLECTIVITY_INDEX: number;
  19526. SCENE_MRT_COUNT: number;
  19527. RGBDLIGHTMAP: boolean;
  19528. RGBDREFLECTION: boolean;
  19529. RGBDREFRACTION: boolean;
  19530. IMAGEPROCESSING: boolean;
  19531. VIGNETTE: boolean;
  19532. VIGNETTEBLENDMODEMULTIPLY: boolean;
  19533. VIGNETTEBLENDMODEOPAQUE: boolean;
  19534. TONEMAPPING: boolean;
  19535. TONEMAPPING_ACES: boolean;
  19536. CONTRAST: boolean;
  19537. COLORCURVES: boolean;
  19538. COLORGRADING: boolean;
  19539. COLORGRADING3D: boolean;
  19540. SAMPLER3DGREENDEPTH: boolean;
  19541. SAMPLER3DBGRMAP: boolean;
  19542. IMAGEPROCESSINGPOSTPROCESS: boolean;
  19543. MULTIVIEW: boolean;
  19544. /**
  19545. * If the reflection texture on this material is in linear color space
  19546. * @hidden
  19547. */
  19548. IS_REFLECTION_LINEAR: boolean;
  19549. /**
  19550. * If the refraction texture on this material is in linear color space
  19551. * @hidden
  19552. */
  19553. IS_REFRACTION_LINEAR: boolean;
  19554. EXPOSURE: boolean;
  19555. constructor();
  19556. setReflectionMode(modeToEnable: string): void;
  19557. }
  19558. /**
  19559. * This is the default material used in Babylon. It is the best trade off between quality
  19560. * and performances.
  19561. * @see https://doc.babylonjs.com/babylon101/materials
  19562. */
  19563. export class StandardMaterial extends PushMaterial {
  19564. private _diffuseTexture;
  19565. /**
  19566. * The basic texture of the material as viewed under a light.
  19567. */
  19568. diffuseTexture: Nullable<BaseTexture>;
  19569. private _ambientTexture;
  19570. /**
  19571. * AKA Occlusion Texture in other nomenclature, it helps adding baked shadows into your material.
  19572. */
  19573. ambientTexture: Nullable<BaseTexture>;
  19574. private _opacityTexture;
  19575. /**
  19576. * Define the transparency of the material from a texture.
  19577. * The final alpha value can be read either from the red channel (if texture.getAlphaFromRGB is false)
  19578. * or from the luminance or the current texel (if texture.getAlphaFromRGB is true)
  19579. */
  19580. opacityTexture: Nullable<BaseTexture>;
  19581. private _reflectionTexture;
  19582. /**
  19583. * Define the texture used to display the reflection.
  19584. * @see https://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  19585. */
  19586. reflectionTexture: Nullable<BaseTexture>;
  19587. private _emissiveTexture;
  19588. /**
  19589. * Define texture of the material as if self lit.
  19590. * This will be mixed in the final result even in the absence of light.
  19591. */
  19592. emissiveTexture: Nullable<BaseTexture>;
  19593. private _specularTexture;
  19594. /**
  19595. * Define how the color and intensity of the highlight given by the light in the material.
  19596. */
  19597. specularTexture: Nullable<BaseTexture>;
  19598. private _bumpTexture;
  19599. /**
  19600. * Bump mapping is a technique to simulate bump and dents on a rendered surface.
  19601. * 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.
  19602. * @see https://doc.babylonjs.com/how_to/more_materials#bump-map
  19603. */
  19604. bumpTexture: Nullable<BaseTexture>;
  19605. private _lightmapTexture;
  19606. /**
  19607. * Complex lighting can be computationally expensive to compute at runtime.
  19608. * To save on computation, lightmaps may be used to store calculated lighting in a texture which will be applied to a given mesh.
  19609. * @see https://doc.babylonjs.com/babylon101/lights#lightmaps
  19610. */
  19611. lightmapTexture: Nullable<BaseTexture>;
  19612. private _refractionTexture;
  19613. /**
  19614. * Define the texture used to display the refraction.
  19615. * @see https://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  19616. */
  19617. refractionTexture: Nullable<BaseTexture>;
  19618. /**
  19619. * The color of the material lit by the environmental background lighting.
  19620. * @see https://doc.babylonjs.com/babylon101/materials#ambient-color-example
  19621. */
  19622. ambientColor: Color3;
  19623. /**
  19624. * The basic color of the material as viewed under a light.
  19625. */
  19626. diffuseColor: Color3;
  19627. /**
  19628. * Define how the color and intensity of the highlight given by the light in the material.
  19629. */
  19630. specularColor: Color3;
  19631. /**
  19632. * Define the color of the material as if self lit.
  19633. * This will be mixed in the final result even in the absence of light.
  19634. */
  19635. emissiveColor: Color3;
  19636. /**
  19637. * Defines how sharp are the highlights in the material.
  19638. * The bigger the value the sharper giving a more glossy feeling to the result.
  19639. * Reversely, the smaller the value the blurrier giving a more rough feeling to the result.
  19640. */
  19641. specularPower: number;
  19642. private _useAlphaFromDiffuseTexture;
  19643. /**
  19644. * Does the transparency come from the diffuse texture alpha channel.
  19645. */
  19646. useAlphaFromDiffuseTexture: boolean;
  19647. private _useEmissiveAsIllumination;
  19648. /**
  19649. * If true, the emissive value is added into the end result, otherwise it is multiplied in.
  19650. */
  19651. useEmissiveAsIllumination: boolean;
  19652. private _linkEmissiveWithDiffuse;
  19653. /**
  19654. * If true, some kind of energy conservation will prevent the end result to be more than 1 by reducing
  19655. * the emissive level when the final color is close to one.
  19656. */
  19657. linkEmissiveWithDiffuse: boolean;
  19658. private _useSpecularOverAlpha;
  19659. /**
  19660. * Specifies that the material will keep the specular highlights over a transparent surface (only the most luminous ones).
  19661. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  19662. */
  19663. useSpecularOverAlpha: boolean;
  19664. private _useReflectionOverAlpha;
  19665. /**
  19666. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most luminous ones).
  19667. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  19668. */
  19669. useReflectionOverAlpha: boolean;
  19670. private _disableLighting;
  19671. /**
  19672. * Does lights from the scene impacts this material.
  19673. * It can be a nice trick for performance to disable lighting on a fully emissive material.
  19674. */
  19675. disableLighting: boolean;
  19676. private _useObjectSpaceNormalMap;
  19677. /**
  19678. * Allows using an object space normal map (instead of tangent space).
  19679. */
  19680. useObjectSpaceNormalMap: boolean;
  19681. private _useParallax;
  19682. /**
  19683. * Is parallax enabled or not.
  19684. * @see https://doc.babylonjs.com/how_to/using_parallax_mapping
  19685. */
  19686. useParallax: boolean;
  19687. private _useParallaxOcclusion;
  19688. /**
  19689. * Is parallax occlusion enabled or not.
  19690. * If true, the outcome is way more realistic than traditional Parallax but you can expect a performance hit that worthes consideration.
  19691. * @see https://doc.babylonjs.com/how_to/using_parallax_mapping
  19692. */
  19693. useParallaxOcclusion: boolean;
  19694. /**
  19695. * 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.
  19696. */
  19697. parallaxScaleBias: number;
  19698. private _roughness;
  19699. /**
  19700. * Helps to define how blurry the reflections should appears in the material.
  19701. */
  19702. roughness: number;
  19703. /**
  19704. * In case of refraction, define the value of the index of refraction.
  19705. * @see https://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  19706. */
  19707. indexOfRefraction: number;
  19708. /**
  19709. * Invert the refraction texture alongside the y axis.
  19710. * It can be useful with procedural textures or probe for instance.
  19711. * @see https://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  19712. */
  19713. invertRefractionY: boolean;
  19714. /**
  19715. * Defines the alpha limits in alpha test mode.
  19716. */
  19717. alphaCutOff: number;
  19718. private _useLightmapAsShadowmap;
  19719. /**
  19720. * In case of light mapping, define whether the map contains light or shadow informations.
  19721. */
  19722. useLightmapAsShadowmap: boolean;
  19723. private _diffuseFresnelParameters;
  19724. /**
  19725. * Define the diffuse fresnel parameters of the material.
  19726. * @see https://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  19727. */
  19728. diffuseFresnelParameters: FresnelParameters;
  19729. private _opacityFresnelParameters;
  19730. /**
  19731. * Define the opacity fresnel parameters of the material.
  19732. * @see https://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  19733. */
  19734. opacityFresnelParameters: FresnelParameters;
  19735. private _reflectionFresnelParameters;
  19736. /**
  19737. * Define the reflection fresnel parameters of the material.
  19738. * @see https://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  19739. */
  19740. reflectionFresnelParameters: FresnelParameters;
  19741. private _refractionFresnelParameters;
  19742. /**
  19743. * Define the refraction fresnel parameters of the material.
  19744. * @see https://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  19745. */
  19746. refractionFresnelParameters: FresnelParameters;
  19747. private _emissiveFresnelParameters;
  19748. /**
  19749. * Define the emissive fresnel parameters of the material.
  19750. * @see https://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  19751. */
  19752. emissiveFresnelParameters: FresnelParameters;
  19753. private _useReflectionFresnelFromSpecular;
  19754. /**
  19755. * If true automatically deducts the fresnels values from the material specularity.
  19756. * @see https://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  19757. */
  19758. useReflectionFresnelFromSpecular: boolean;
  19759. private _useGlossinessFromSpecularMapAlpha;
  19760. /**
  19761. * Defines if the glossiness/roughness of the material should be read from the specular map alpha channel
  19762. */
  19763. useGlossinessFromSpecularMapAlpha: boolean;
  19764. private _maxSimultaneousLights;
  19765. /**
  19766. * Defines the maximum number of lights that can be used in the material
  19767. */
  19768. maxSimultaneousLights: number;
  19769. private _invertNormalMapX;
  19770. /**
  19771. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  19772. */
  19773. invertNormalMapX: boolean;
  19774. private _invertNormalMapY;
  19775. /**
  19776. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  19777. */
  19778. invertNormalMapY: boolean;
  19779. private _twoSidedLighting;
  19780. /**
  19781. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  19782. */
  19783. twoSidedLighting: boolean;
  19784. /**
  19785. * Default configuration related to image processing available in the standard Material.
  19786. */
  19787. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  19788. /**
  19789. * Gets the image processing configuration used either in this material.
  19790. */
  19791. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  19792. /**
  19793. * Sets the Default image processing configuration used either in the this material.
  19794. *
  19795. * If sets to null, the scene one is in use.
  19796. */
  19797. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  19798. /**
  19799. * Keep track of the image processing observer to allow dispose and replace.
  19800. */
  19801. private _imageProcessingObserver;
  19802. /**
  19803. * Attaches a new image processing configuration to the Standard Material.
  19804. * @param configuration
  19805. */
  19806. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  19807. /**
  19808. * Defines additional PrePass parameters for the material.
  19809. */
  19810. readonly prePassConfiguration: PrePassConfiguration;
  19811. /**
  19812. * Can this material render to prepass
  19813. */
  19814. get isPrePassCapable(): boolean;
  19815. /**
  19816. * Gets whether the color curves effect is enabled.
  19817. */
  19818. get cameraColorCurvesEnabled(): boolean;
  19819. /**
  19820. * Sets whether the color curves effect is enabled.
  19821. */
  19822. set cameraColorCurvesEnabled(value: boolean);
  19823. /**
  19824. * Gets whether the color grading effect is enabled.
  19825. */
  19826. get cameraColorGradingEnabled(): boolean;
  19827. /**
  19828. * Gets whether the color grading effect is enabled.
  19829. */
  19830. set cameraColorGradingEnabled(value: boolean);
  19831. /**
  19832. * Gets whether tonemapping is enabled or not.
  19833. */
  19834. get cameraToneMappingEnabled(): boolean;
  19835. /**
  19836. * Sets whether tonemapping is enabled or not
  19837. */
  19838. set cameraToneMappingEnabled(value: boolean);
  19839. /**
  19840. * The camera exposure used on this material.
  19841. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  19842. * This corresponds to a photographic exposure.
  19843. */
  19844. get cameraExposure(): number;
  19845. /**
  19846. * The camera exposure used on this material.
  19847. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  19848. * This corresponds to a photographic exposure.
  19849. */
  19850. set cameraExposure(value: number);
  19851. /**
  19852. * Gets The camera contrast used on this material.
  19853. */
  19854. get cameraContrast(): number;
  19855. /**
  19856. * Sets The camera contrast used on this material.
  19857. */
  19858. set cameraContrast(value: number);
  19859. /**
  19860. * Gets the Color Grading 2D Lookup Texture.
  19861. */
  19862. get cameraColorGradingTexture(): Nullable<BaseTexture>;
  19863. /**
  19864. * Sets the Color Grading 2D Lookup Texture.
  19865. */
  19866. set cameraColorGradingTexture(value: Nullable<BaseTexture>);
  19867. /**
  19868. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  19869. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  19870. * 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;
  19871. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  19872. */
  19873. get cameraColorCurves(): Nullable<ColorCurves>;
  19874. /**
  19875. * The color grading curves provide additional color adjustment that is applied after any color grading transform (3D LUT).
  19876. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  19877. * 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;
  19878. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  19879. */
  19880. set cameraColorCurves(value: Nullable<ColorCurves>);
  19881. /**
  19882. * Can this material render to several textures at once
  19883. */
  19884. get canRenderToMRT(): boolean;
  19885. /**
  19886. * Defines the detail map parameters for the material.
  19887. */
  19888. readonly detailMap: DetailMapConfiguration;
  19889. protected _renderTargets: SmartArray<RenderTargetTexture>;
  19890. protected _worldViewProjectionMatrix: Matrix;
  19891. protected _globalAmbientColor: Color3;
  19892. protected _useLogarithmicDepth: boolean;
  19893. protected _rebuildInParallel: boolean;
  19894. /**
  19895. * Instantiates a new standard material.
  19896. * This is the default material used in Babylon. It is the best trade off between quality
  19897. * and performances.
  19898. * @see https://doc.babylonjs.com/babylon101/materials
  19899. * @param name Define the name of the material in the scene
  19900. * @param scene Define the scene the material belong to
  19901. */
  19902. constructor(name: string, scene: Scene);
  19903. /**
  19904. * Gets a boolean indicating that current material needs to register RTT
  19905. */
  19906. get hasRenderTargetTextures(): boolean;
  19907. /**
  19908. * Gets the current class name of the material e.g. "StandardMaterial"
  19909. * Mainly use in serialization.
  19910. * @returns the class name
  19911. */
  19912. getClassName(): string;
  19913. /**
  19914. * In case the depth buffer does not allow enough depth precision for your scene (might be the case in large scenes)
  19915. * You can try switching to logarithmic depth.
  19916. * @see https://doc.babylonjs.com/how_to/using_logarithmic_depth_buffer
  19917. */
  19918. get useLogarithmicDepth(): boolean;
  19919. set useLogarithmicDepth(value: boolean);
  19920. /**
  19921. * Specifies if the material will require alpha blending
  19922. * @returns a boolean specifying if alpha blending is needed
  19923. */
  19924. needAlphaBlending(): boolean;
  19925. /**
  19926. * Specifies if this material should be rendered in alpha test mode
  19927. * @returns a boolean specifying if an alpha test is needed.
  19928. */
  19929. needAlphaTesting(): boolean;
  19930. /**
  19931. * Specifies whether or not the alpha value of the diffuse texture should be used for alpha blending.
  19932. */
  19933. protected _shouldUseAlphaFromDiffuseTexture(): boolean;
  19934. /**
  19935. * Specifies whether or not there is a usable alpha channel for transparency.
  19936. */
  19937. protected _hasAlphaChannel(): boolean;
  19938. /**
  19939. * Get the texture used for alpha test purpose.
  19940. * @returns the diffuse texture in case of the standard material.
  19941. */
  19942. getAlphaTestTexture(): Nullable<BaseTexture>;
  19943. /**
  19944. * Get if the submesh is ready to be used and all its information available.
  19945. * Child classes can use it to update shaders
  19946. * @param mesh defines the mesh to check
  19947. * @param subMesh defines which submesh to check
  19948. * @param useInstances specifies that instances should be used
  19949. * @returns a boolean indicating that the submesh is ready or not
  19950. */
  19951. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  19952. /**
  19953. * Builds the material UBO layouts.
  19954. * Used internally during the effect preparation.
  19955. */
  19956. buildUniformLayout(): void;
  19957. /**
  19958. * Unbinds the material from the mesh
  19959. */
  19960. unbind(): void;
  19961. /**
  19962. * Binds the submesh to this material by preparing the effect and shader to draw
  19963. * @param world defines the world transformation matrix
  19964. * @param mesh defines the mesh containing the submesh
  19965. * @param subMesh defines the submesh to bind the material to
  19966. */
  19967. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  19968. /**
  19969. * Get the list of animatables in the material.
  19970. * @returns the list of animatables object used in the material
  19971. */
  19972. getAnimatables(): IAnimatable[];
  19973. /**
  19974. * Gets the active textures from the material
  19975. * @returns an array of textures
  19976. */
  19977. getActiveTextures(): BaseTexture[];
  19978. /**
  19979. * Specifies if the material uses a texture
  19980. * @param texture defines the texture to check against the material
  19981. * @returns a boolean specifying if the material uses the texture
  19982. */
  19983. hasTexture(texture: BaseTexture): boolean;
  19984. /**
  19985. * Disposes the material
  19986. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  19987. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  19988. */
  19989. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  19990. /**
  19991. * Makes a duplicate of the material, and gives it a new name
  19992. * @param name defines the new name for the duplicated material
  19993. * @returns the cloned material
  19994. */
  19995. clone(name: string): StandardMaterial;
  19996. /**
  19997. * Serializes this material in a JSON representation
  19998. * @returns the serialized material object
  19999. */
  20000. serialize(): any;
  20001. /**
  20002. * Creates a standard material from parsed material data
  20003. * @param source defines the JSON representation of the material
  20004. * @param scene defines the hosting scene
  20005. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  20006. * @returns a new standard material
  20007. */
  20008. static Parse(source: any, scene: Scene, rootUrl: string): StandardMaterial;
  20009. /**
  20010. * Are diffuse textures enabled in the application.
  20011. */
  20012. static get DiffuseTextureEnabled(): boolean;
  20013. static set DiffuseTextureEnabled(value: boolean);
  20014. /**
  20015. * Are detail textures enabled in the application.
  20016. */
  20017. static get DetailTextureEnabled(): boolean;
  20018. static set DetailTextureEnabled(value: boolean);
  20019. /**
  20020. * Are ambient textures enabled in the application.
  20021. */
  20022. static get AmbientTextureEnabled(): boolean;
  20023. static set AmbientTextureEnabled(value: boolean);
  20024. /**
  20025. * Are opacity textures enabled in the application.
  20026. */
  20027. static get OpacityTextureEnabled(): boolean;
  20028. static set OpacityTextureEnabled(value: boolean);
  20029. /**
  20030. * Are reflection textures enabled in the application.
  20031. */
  20032. static get ReflectionTextureEnabled(): boolean;
  20033. static set ReflectionTextureEnabled(value: boolean);
  20034. /**
  20035. * Are emissive textures enabled in the application.
  20036. */
  20037. static get EmissiveTextureEnabled(): boolean;
  20038. static set EmissiveTextureEnabled(value: boolean);
  20039. /**
  20040. * Are specular textures enabled in the application.
  20041. */
  20042. static get SpecularTextureEnabled(): boolean;
  20043. static set SpecularTextureEnabled(value: boolean);
  20044. /**
  20045. * Are bump textures enabled in the application.
  20046. */
  20047. static get BumpTextureEnabled(): boolean;
  20048. static set BumpTextureEnabled(value: boolean);
  20049. /**
  20050. * Are lightmap textures enabled in the application.
  20051. */
  20052. static get LightmapTextureEnabled(): boolean;
  20053. static set LightmapTextureEnabled(value: boolean);
  20054. /**
  20055. * Are refraction textures enabled in the application.
  20056. */
  20057. static get RefractionTextureEnabled(): boolean;
  20058. static set RefractionTextureEnabled(value: boolean);
  20059. /**
  20060. * Are color grading textures enabled in the application.
  20061. */
  20062. static get ColorGradingTextureEnabled(): boolean;
  20063. static set ColorGradingTextureEnabled(value: boolean);
  20064. /**
  20065. * Are fresnels enabled in the application.
  20066. */
  20067. static get FresnelEnabled(): boolean;
  20068. static set FresnelEnabled(value: boolean);
  20069. }
  20070. }
  20071. declare module BABYLON {
  20072. /** @hidden */
  20073. export var rgbdDecodePixelShader: {
  20074. name: string;
  20075. shader: string;
  20076. };
  20077. }
  20078. declare module BABYLON {
  20079. /** @hidden */
  20080. export var passPixelShader: {
  20081. name: string;
  20082. shader: string;
  20083. };
  20084. }
  20085. declare module BABYLON {
  20086. /** @hidden */
  20087. export var passCubePixelShader: {
  20088. name: string;
  20089. shader: string;
  20090. };
  20091. }
  20092. declare module BABYLON {
  20093. /**
  20094. * PassPostProcess which produces an output the same as it's input
  20095. */
  20096. export class PassPostProcess extends PostProcess {
  20097. /**
  20098. * Gets a string identifying the name of the class
  20099. * @returns "PassPostProcess" string
  20100. */
  20101. getClassName(): string;
  20102. /**
  20103. * Creates the PassPostProcess
  20104. * @param name The name of the effect.
  20105. * @param options The required width/height ratio to downsize to before computing the render pass.
  20106. * @param camera The camera to apply the render pass to.
  20107. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  20108. * @param engine The engine which the post process will be applied. (default: current engine)
  20109. * @param reusable If the post process can be reused on the same frame. (default: false)
  20110. * @param textureType The type of texture to be used when performing the post processing.
  20111. * @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)
  20112. */
  20113. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  20114. /** @hidden */
  20115. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): PassPostProcess;
  20116. }
  20117. /**
  20118. * PassCubePostProcess which produces an output the same as it's input (which must be a cube texture)
  20119. */
  20120. export class PassCubePostProcess extends PostProcess {
  20121. private _face;
  20122. /**
  20123. * Gets or sets the cube face to display.
  20124. * * 0 is +X
  20125. * * 1 is -X
  20126. * * 2 is +Y
  20127. * * 3 is -Y
  20128. * * 4 is +Z
  20129. * * 5 is -Z
  20130. */
  20131. get face(): number;
  20132. set face(value: number);
  20133. /**
  20134. * Gets a string identifying the name of the class
  20135. * @returns "PassCubePostProcess" string
  20136. */
  20137. getClassName(): string;
  20138. /**
  20139. * Creates the PassCubePostProcess
  20140. * @param name The name of the effect.
  20141. * @param options The required width/height ratio to downsize to before computing the render pass.
  20142. * @param camera The camera to apply the render pass to.
  20143. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  20144. * @param engine The engine which the post process will be applied. (default: current engine)
  20145. * @param reusable If the post process can be reused on the same frame. (default: false)
  20146. * @param textureType The type of texture to be used when performing the post processing.
  20147. * @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)
  20148. */
  20149. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  20150. /** @hidden */
  20151. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): PassCubePostProcess;
  20152. }
  20153. }
  20154. declare module BABYLON {
  20155. /**
  20156. * Class used to host texture specific utilities
  20157. */
  20158. export class TextureTools {
  20159. /**
  20160. * Uses the GPU to create a copy texture rescaled at a given size
  20161. * @param texture Texture to copy from
  20162. * @param width defines the desired width
  20163. * @param height defines the desired height
  20164. * @param useBilinearMode defines if bilinear mode has to be used
  20165. * @return the generated texture
  20166. */
  20167. static CreateResizedCopy(texture: Texture, width: number, height: number, useBilinearMode?: boolean): Texture;
  20168. /**
  20169. * Apply a post process to a texture
  20170. * @param postProcessName name of the fragment post process
  20171. * @param internalTexture the texture to encode
  20172. * @param scene the scene hosting the texture
  20173. * @param type type of the output texture. If not provided, use the one from internalTexture
  20174. * @param samplingMode sampling mode to use to sample the source texture. If not provided, use the one from internalTexture
  20175. * @param format format of the output texture. If not provided, use the one from internalTexture
  20176. * @return a promise with the internalTexture having its texture replaced by the result of the processing
  20177. */
  20178. static ApplyPostProcess(postProcessName: string, internalTexture: InternalTexture, scene: Scene, type?: number, samplingMode?: number, format?: number): Promise<InternalTexture>;
  20179. }
  20180. }
  20181. declare module BABYLON {
  20182. /**
  20183. * Class used to host RGBD texture specific utilities
  20184. */
  20185. export class RGBDTextureTools {
  20186. /**
  20187. * Expand the RGBD Texture from RGBD to Half Float if possible.
  20188. * @param texture the texture to expand.
  20189. */
  20190. static ExpandRGBDTexture(texture: Texture): void;
  20191. /**
  20192. * Encode the texture to RGBD if possible.
  20193. * @param internalTexture the texture to encode
  20194. * @param scene the scene hosting the texture
  20195. * @param outputTextureType type of the texture in which the encoding is performed
  20196. * @return a promise with the internalTexture having its texture replaced by the result of the processing
  20197. */
  20198. static EncodeTextureToRGBD(internalTexture: InternalTexture, scene: Scene, outputTextureType?: number): Promise<InternalTexture>;
  20199. }
  20200. }
  20201. declare module BABYLON {
  20202. /**
  20203. * Class used to host texture specific utilities
  20204. */
  20205. export class BRDFTextureTools {
  20206. /**
  20207. * Prevents texture cache collision
  20208. */
  20209. private static _instanceNumber;
  20210. /**
  20211. * Gets a default environment BRDF for MS-BRDF Height Correlated BRDF
  20212. * @param scene defines the hosting scene
  20213. * @returns the environment BRDF texture
  20214. */
  20215. static GetEnvironmentBRDFTexture(scene: Scene): BaseTexture;
  20216. private static _environmentBRDFBase64Texture;
  20217. }
  20218. }
  20219. declare module BABYLON {
  20220. /**
  20221. * @hidden
  20222. */
  20223. export interface IMaterialClearCoatDefines {
  20224. CLEARCOAT: boolean;
  20225. CLEARCOAT_DEFAULTIOR: boolean;
  20226. CLEARCOAT_TEXTURE: boolean;
  20227. CLEARCOAT_TEXTURE_ROUGHNESS: boolean;
  20228. CLEARCOAT_TEXTUREDIRECTUV: number;
  20229. CLEARCOAT_TEXTURE_ROUGHNESSDIRECTUV: number;
  20230. CLEARCOAT_BUMP: boolean;
  20231. CLEARCOAT_BUMPDIRECTUV: number;
  20232. CLEARCOAT_USE_ROUGHNESS_FROM_MAINTEXTURE: boolean;
  20233. CLEARCOAT_TEXTURE_ROUGHNESS_IDENTICAL: boolean;
  20234. CLEARCOAT_REMAP_F0: boolean;
  20235. CLEARCOAT_TINT: boolean;
  20236. CLEARCOAT_TINT_TEXTURE: boolean;
  20237. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  20238. /** @hidden */
  20239. _areTexturesDirty: boolean;
  20240. }
  20241. /**
  20242. * Define the code related to the clear coat parameters of the pbr material.
  20243. */
  20244. export class PBRClearCoatConfiguration {
  20245. /**
  20246. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  20247. * The default fits with a polyurethane material.
  20248. * @hidden
  20249. */
  20250. static readonly _DefaultIndexOfRefraction: number;
  20251. private _isEnabled;
  20252. /**
  20253. * Defines if the clear coat is enabled in the material.
  20254. */
  20255. isEnabled: boolean;
  20256. /**
  20257. * Defines the clear coat layer strength (between 0 and 1) it defaults to 1.
  20258. */
  20259. intensity: number;
  20260. /**
  20261. * Defines the clear coat layer roughness.
  20262. */
  20263. roughness: number;
  20264. private _indexOfRefraction;
  20265. /**
  20266. * Defines the index of refraction of the clear coat.
  20267. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  20268. * The default fits with a polyurethane material.
  20269. * Changing the default value is more performance intensive.
  20270. */
  20271. indexOfRefraction: number;
  20272. private _texture;
  20273. /**
  20274. * Stores the clear coat values in a texture (red channel is intensity and green channel is roughness)
  20275. * If useRoughnessFromMainTexture is false, the green channel of texture is not used and the green channel of textureRoughness is used instead
  20276. * if textureRoughness is not empty, else no texture roughness is used
  20277. */
  20278. texture: Nullable<BaseTexture>;
  20279. private _useRoughnessFromMainTexture;
  20280. /**
  20281. * Indicates that the green channel of the texture property will be used for roughness (default: true)
  20282. * If false, the green channel from textureRoughness is used for roughness
  20283. */
  20284. useRoughnessFromMainTexture: boolean;
  20285. private _textureRoughness;
  20286. /**
  20287. * Stores the clear coat roughness in a texture (green channel)
  20288. * Not used if useRoughnessFromMainTexture is true
  20289. */
  20290. textureRoughness: Nullable<BaseTexture>;
  20291. private _remapF0OnInterfaceChange;
  20292. /**
  20293. * Defines if the F0 value should be remapped to account for the interface change in the material.
  20294. */
  20295. remapF0OnInterfaceChange: boolean;
  20296. private _bumpTexture;
  20297. /**
  20298. * Define the clear coat specific bump texture.
  20299. */
  20300. bumpTexture: Nullable<BaseTexture>;
  20301. private _isTintEnabled;
  20302. /**
  20303. * Defines if the clear coat tint is enabled in the material.
  20304. */
  20305. isTintEnabled: boolean;
  20306. /**
  20307. * Defines the clear coat tint of the material.
  20308. * This is only use if tint is enabled
  20309. */
  20310. tintColor: Color3;
  20311. /**
  20312. * Defines the distance at which the tint color should be found in the
  20313. * clear coat media.
  20314. * This is only use if tint is enabled
  20315. */
  20316. tintColorAtDistance: number;
  20317. /**
  20318. * Defines the clear coat layer thickness.
  20319. * This is only use if tint is enabled
  20320. */
  20321. tintThickness: number;
  20322. private _tintTexture;
  20323. /**
  20324. * Stores the clear tint values in a texture.
  20325. * rgb is tint
  20326. * a is a thickness factor
  20327. */
  20328. tintTexture: Nullable<BaseTexture>;
  20329. /** @hidden */
  20330. private _internalMarkAllSubMeshesAsTexturesDirty;
  20331. /** @hidden */
  20332. _markAllSubMeshesAsTexturesDirty(): void;
  20333. /**
  20334. * Instantiate a new instance of clear coat configuration.
  20335. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  20336. */
  20337. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  20338. /**
  20339. * Gets whether the submesh is ready to be used or not.
  20340. * @param defines the list of "defines" to update.
  20341. * @param scene defines the scene the material belongs to.
  20342. * @param engine defines the engine the material belongs to.
  20343. * @param disableBumpMap defines whether the material disables bump or not.
  20344. * @returns - boolean indicating that the submesh is ready or not.
  20345. */
  20346. isReadyForSubMesh(defines: IMaterialClearCoatDefines, scene: Scene, engine: Engine, disableBumpMap: boolean): boolean;
  20347. /**
  20348. * Checks to see if a texture is used in the material.
  20349. * @param defines the list of "defines" to update.
  20350. * @param scene defines the scene to the material belongs to.
  20351. */
  20352. prepareDefines(defines: IMaterialClearCoatDefines, scene: Scene): void;
  20353. /**
  20354. * Binds the material data.
  20355. * @param uniformBuffer defines the Uniform buffer to fill in.
  20356. * @param scene defines the scene the material belongs to.
  20357. * @param engine defines the engine the material belongs to.
  20358. * @param disableBumpMap defines whether the material disables bump or not.
  20359. * @param isFrozen defines whether the material is frozen or not.
  20360. * @param invertNormalMapX If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  20361. * @param invertNormalMapY If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  20362. * @param subMesh the submesh to bind data for
  20363. */
  20364. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, disableBumpMap: boolean, isFrozen: boolean, invertNormalMapX: boolean, invertNormalMapY: boolean, subMesh?: SubMesh): void;
  20365. /**
  20366. * Checks to see if a texture is used in the material.
  20367. * @param texture - Base texture to use.
  20368. * @returns - Boolean specifying if a texture is used in the material.
  20369. */
  20370. hasTexture(texture: BaseTexture): boolean;
  20371. /**
  20372. * Returns an array of the actively used textures.
  20373. * @param activeTextures Array of BaseTextures
  20374. */
  20375. getActiveTextures(activeTextures: BaseTexture[]): void;
  20376. /**
  20377. * Returns the animatable textures.
  20378. * @param animatables Array of animatable textures.
  20379. */
  20380. getAnimatables(animatables: IAnimatable[]): void;
  20381. /**
  20382. * Disposes the resources of the material.
  20383. * @param forceDisposeTextures - Forces the disposal of all textures.
  20384. */
  20385. dispose(forceDisposeTextures?: boolean): void;
  20386. /**
  20387. * Get the current class name of the texture useful for serialization or dynamic coding.
  20388. * @returns "PBRClearCoatConfiguration"
  20389. */
  20390. getClassName(): string;
  20391. /**
  20392. * Add fallbacks to the effect fallbacks list.
  20393. * @param defines defines the Base texture to use.
  20394. * @param fallbacks defines the current fallback list.
  20395. * @param currentRank defines the current fallback rank.
  20396. * @returns the new fallback rank.
  20397. */
  20398. static AddFallbacks(defines: IMaterialClearCoatDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  20399. /**
  20400. * Add the required uniforms to the current list.
  20401. * @param uniforms defines the current uniform list.
  20402. */
  20403. static AddUniforms(uniforms: string[]): void;
  20404. /**
  20405. * Add the required samplers to the current list.
  20406. * @param samplers defines the current sampler list.
  20407. */
  20408. static AddSamplers(samplers: string[]): void;
  20409. /**
  20410. * Add the required uniforms to the current buffer.
  20411. * @param uniformBuffer defines the current uniform buffer.
  20412. */
  20413. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  20414. /**
  20415. * Makes a duplicate of the current configuration into another one.
  20416. * @param clearCoatConfiguration define the config where to copy the info
  20417. */
  20418. copyTo(clearCoatConfiguration: PBRClearCoatConfiguration): void;
  20419. /**
  20420. * Serializes this clear coat configuration.
  20421. * @returns - An object with the serialized config.
  20422. */
  20423. serialize(): any;
  20424. /**
  20425. * Parses a anisotropy Configuration from a serialized object.
  20426. * @param source - Serialized object.
  20427. * @param scene Defines the scene we are parsing for
  20428. * @param rootUrl Defines the rootUrl to load from
  20429. */
  20430. parse(source: any, scene: Scene, rootUrl: string): void;
  20431. }
  20432. }
  20433. declare module BABYLON {
  20434. /**
  20435. * @hidden
  20436. */
  20437. export interface IMaterialAnisotropicDefines {
  20438. ANISOTROPIC: boolean;
  20439. ANISOTROPIC_TEXTURE: boolean;
  20440. ANISOTROPIC_TEXTUREDIRECTUV: number;
  20441. MAINUV1: boolean;
  20442. _areTexturesDirty: boolean;
  20443. _needUVs: boolean;
  20444. }
  20445. /**
  20446. * Define the code related to the anisotropic parameters of the pbr material.
  20447. */
  20448. export class PBRAnisotropicConfiguration {
  20449. private _isEnabled;
  20450. /**
  20451. * Defines if the anisotropy is enabled in the material.
  20452. */
  20453. isEnabled: boolean;
  20454. /**
  20455. * Defines the anisotropy strength (between 0 and 1) it defaults to 1.
  20456. */
  20457. intensity: number;
  20458. /**
  20459. * Defines if the effect is along the tangents, bitangents or in between.
  20460. * By default, the effect is "stretching" the highlights along the tangents.
  20461. */
  20462. direction: Vector2;
  20463. private _texture;
  20464. /**
  20465. * Stores the anisotropy values in a texture.
  20466. * rg is direction (like normal from -1 to 1)
  20467. * b is a intensity
  20468. */
  20469. texture: Nullable<BaseTexture>;
  20470. /** @hidden */
  20471. private _internalMarkAllSubMeshesAsTexturesDirty;
  20472. /** @hidden */
  20473. _markAllSubMeshesAsTexturesDirty(): void;
  20474. /**
  20475. * Instantiate a new instance of anisotropy configuration.
  20476. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  20477. */
  20478. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  20479. /**
  20480. * Specifies that the submesh is ready to be used.
  20481. * @param defines the list of "defines" to update.
  20482. * @param scene defines the scene the material belongs to.
  20483. * @returns - boolean indicating that the submesh is ready or not.
  20484. */
  20485. isReadyForSubMesh(defines: IMaterialAnisotropicDefines, scene: Scene): boolean;
  20486. /**
  20487. * Checks to see if a texture is used in the material.
  20488. * @param defines the list of "defines" to update.
  20489. * @param mesh the mesh we are preparing the defines for.
  20490. * @param scene defines the scene the material belongs to.
  20491. */
  20492. prepareDefines(defines: IMaterialAnisotropicDefines, mesh: AbstractMesh, scene: Scene): void;
  20493. /**
  20494. * Binds the material data.
  20495. * @param uniformBuffer defines the Uniform buffer to fill in.
  20496. * @param scene defines the scene the material belongs to.
  20497. * @param isFrozen defines whether the material is frozen or not.
  20498. */
  20499. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  20500. /**
  20501. * Checks to see if a texture is used in the material.
  20502. * @param texture - Base texture to use.
  20503. * @returns - Boolean specifying if a texture is used in the material.
  20504. */
  20505. hasTexture(texture: BaseTexture): boolean;
  20506. /**
  20507. * Returns an array of the actively used textures.
  20508. * @param activeTextures Array of BaseTextures
  20509. */
  20510. getActiveTextures(activeTextures: BaseTexture[]): void;
  20511. /**
  20512. * Returns the animatable textures.
  20513. * @param animatables Array of animatable textures.
  20514. */
  20515. getAnimatables(animatables: IAnimatable[]): void;
  20516. /**
  20517. * Disposes the resources of the material.
  20518. * @param forceDisposeTextures - Forces the disposal of all textures.
  20519. */
  20520. dispose(forceDisposeTextures?: boolean): void;
  20521. /**
  20522. * Get the current class name of the texture useful for serialization or dynamic coding.
  20523. * @returns "PBRAnisotropicConfiguration"
  20524. */
  20525. getClassName(): string;
  20526. /**
  20527. * Add fallbacks to the effect fallbacks list.
  20528. * @param defines defines the Base texture to use.
  20529. * @param fallbacks defines the current fallback list.
  20530. * @param currentRank defines the current fallback rank.
  20531. * @returns the new fallback rank.
  20532. */
  20533. static AddFallbacks(defines: IMaterialAnisotropicDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  20534. /**
  20535. * Add the required uniforms to the current list.
  20536. * @param uniforms defines the current uniform list.
  20537. */
  20538. static AddUniforms(uniforms: string[]): void;
  20539. /**
  20540. * Add the required uniforms to the current buffer.
  20541. * @param uniformBuffer defines the current uniform buffer.
  20542. */
  20543. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  20544. /**
  20545. * Add the required samplers to the current list.
  20546. * @param samplers defines the current sampler list.
  20547. */
  20548. static AddSamplers(samplers: string[]): void;
  20549. /**
  20550. * Makes a duplicate of the current configuration into another one.
  20551. * @param anisotropicConfiguration define the config where to copy the info
  20552. */
  20553. copyTo(anisotropicConfiguration: PBRAnisotropicConfiguration): void;
  20554. /**
  20555. * Serializes this anisotropy configuration.
  20556. * @returns - An object with the serialized config.
  20557. */
  20558. serialize(): any;
  20559. /**
  20560. * Parses a anisotropy Configuration from a serialized object.
  20561. * @param source - Serialized object.
  20562. * @param scene Defines the scene we are parsing for
  20563. * @param rootUrl Defines the rootUrl to load from
  20564. */
  20565. parse(source: any, scene: Scene, rootUrl: string): void;
  20566. }
  20567. }
  20568. declare module BABYLON {
  20569. /**
  20570. * @hidden
  20571. */
  20572. export interface IMaterialBRDFDefines {
  20573. BRDF_V_HEIGHT_CORRELATED: boolean;
  20574. MS_BRDF_ENERGY_CONSERVATION: boolean;
  20575. SPHERICAL_HARMONICS: boolean;
  20576. SPECULAR_GLOSSINESS_ENERGY_CONSERVATION: boolean;
  20577. /** @hidden */
  20578. _areMiscDirty: boolean;
  20579. }
  20580. /**
  20581. * Define the code related to the BRDF parameters of the pbr material.
  20582. */
  20583. export class PBRBRDFConfiguration {
  20584. /**
  20585. * Default value used for the energy conservation.
  20586. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  20587. */
  20588. static DEFAULT_USE_ENERGY_CONSERVATION: boolean;
  20589. /**
  20590. * Default value used for the Smith Visibility Height Correlated mode.
  20591. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  20592. */
  20593. static DEFAULT_USE_SMITH_VISIBILITY_HEIGHT_CORRELATED: boolean;
  20594. /**
  20595. * Default value used for the IBL diffuse part.
  20596. * This can help switching back to the polynomials mode globally which is a tiny bit
  20597. * less GPU intensive at the drawback of a lower quality.
  20598. */
  20599. static DEFAULT_USE_SPHERICAL_HARMONICS: boolean;
  20600. /**
  20601. * Default value used for activating energy conservation for the specular workflow.
  20602. * If activated, the albedo color is multiplied with (1. - maxChannel(specular color)).
  20603. * If deactivated, a material is only physically plausible, when (albedo color + specular color) < 1.
  20604. */
  20605. static DEFAULT_USE_SPECULAR_GLOSSINESS_INPUT_ENERGY_CONSERVATION: boolean;
  20606. private _useEnergyConservation;
  20607. /**
  20608. * Defines if the material uses energy conservation.
  20609. */
  20610. useEnergyConservation: boolean;
  20611. private _useSmithVisibilityHeightCorrelated;
  20612. /**
  20613. * LEGACY Mode set to false
  20614. * Defines if the material uses height smith correlated visibility term.
  20615. * If you intent to not use our default BRDF, you need to load a separate BRDF Texture for the PBR
  20616. * You can either load https://assets.babylonjs.com/environments/uncorrelatedBRDF.png
  20617. * or https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds to have more precision
  20618. * Not relying on height correlated will also disable energy conservation.
  20619. */
  20620. useSmithVisibilityHeightCorrelated: boolean;
  20621. private _useSphericalHarmonics;
  20622. /**
  20623. * LEGACY Mode set to false
  20624. * Defines if the material uses spherical harmonics vs spherical polynomials for the
  20625. * diffuse part of the IBL.
  20626. * The harmonics despite a tiny bigger cost has been proven to provide closer results
  20627. * to the ground truth.
  20628. */
  20629. useSphericalHarmonics: boolean;
  20630. private _useSpecularGlossinessInputEnergyConservation;
  20631. /**
  20632. * Defines if the material uses energy conservation, when the specular workflow is active.
  20633. * If activated, the albedo color is multiplied with (1. - maxChannel(specular color)).
  20634. * If deactivated, a material is only physically plausible, when (albedo color + specular color) < 1.
  20635. * In the deactivated case, the material author has to ensure energy conservation, for a physically plausible rendering.
  20636. */
  20637. useSpecularGlossinessInputEnergyConservation: boolean;
  20638. /** @hidden */
  20639. private _internalMarkAllSubMeshesAsMiscDirty;
  20640. /** @hidden */
  20641. _markAllSubMeshesAsMiscDirty(): void;
  20642. /**
  20643. * Instantiate a new instance of clear coat configuration.
  20644. * @param markAllSubMeshesAsMiscDirty Callback to flag the material to dirty
  20645. */
  20646. constructor(markAllSubMeshesAsMiscDirty: () => void);
  20647. /**
  20648. * Checks to see if a texture is used in the material.
  20649. * @param defines the list of "defines" to update.
  20650. */
  20651. prepareDefines(defines: IMaterialBRDFDefines): void;
  20652. /**
  20653. * Get the current class name of the texture useful for serialization or dynamic coding.
  20654. * @returns "PBRClearCoatConfiguration"
  20655. */
  20656. getClassName(): string;
  20657. /**
  20658. * Makes a duplicate of the current configuration into another one.
  20659. * @param brdfConfiguration define the config where to copy the info
  20660. */
  20661. copyTo(brdfConfiguration: PBRBRDFConfiguration): void;
  20662. /**
  20663. * Serializes this BRDF configuration.
  20664. * @returns - An object with the serialized config.
  20665. */
  20666. serialize(): any;
  20667. /**
  20668. * Parses a anisotropy Configuration from a serialized object.
  20669. * @param source - Serialized object.
  20670. * @param scene Defines the scene we are parsing for
  20671. * @param rootUrl Defines the rootUrl to load from
  20672. */
  20673. parse(source: any, scene: Scene, rootUrl: string): void;
  20674. }
  20675. }
  20676. declare module BABYLON {
  20677. /**
  20678. * @hidden
  20679. */
  20680. export interface IMaterialSheenDefines {
  20681. SHEEN: boolean;
  20682. SHEEN_TEXTURE: boolean;
  20683. SHEEN_TEXTURE_ROUGHNESS: boolean;
  20684. SHEEN_TEXTUREDIRECTUV: number;
  20685. SHEEN_TEXTURE_ROUGHNESSDIRECTUV: number;
  20686. SHEEN_LINKWITHALBEDO: boolean;
  20687. SHEEN_ROUGHNESS: boolean;
  20688. SHEEN_ALBEDOSCALING: boolean;
  20689. SHEEN_USE_ROUGHNESS_FROM_MAINTEXTURE: boolean;
  20690. SHEEN_TEXTURE_ROUGHNESS_IDENTICAL: boolean;
  20691. /** @hidden */
  20692. _areTexturesDirty: boolean;
  20693. }
  20694. /**
  20695. * Define the code related to the Sheen parameters of the pbr material.
  20696. */
  20697. export class PBRSheenConfiguration {
  20698. private _isEnabled;
  20699. /**
  20700. * Defines if the material uses sheen.
  20701. */
  20702. isEnabled: boolean;
  20703. private _linkSheenWithAlbedo;
  20704. /**
  20705. * Defines if the sheen is linked to the sheen color.
  20706. */
  20707. linkSheenWithAlbedo: boolean;
  20708. /**
  20709. * Defines the sheen intensity.
  20710. */
  20711. intensity: number;
  20712. /**
  20713. * Defines the sheen color.
  20714. */
  20715. color: Color3;
  20716. private _texture;
  20717. /**
  20718. * Stores the sheen tint values in a texture.
  20719. * rgb is tint
  20720. * 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)
  20721. * If the roughness property has been defined and useRoughnessFromTexture is false then the alpha channel is not used to modulate roughness
  20722. */
  20723. texture: Nullable<BaseTexture>;
  20724. private _useRoughnessFromMainTexture;
  20725. /**
  20726. * Indicates that the alpha channel of the texture property will be used for roughness.
  20727. * Has no effect if the roughness (and texture!) property is not defined
  20728. */
  20729. useRoughnessFromMainTexture: boolean;
  20730. private _roughness;
  20731. /**
  20732. * Defines the sheen roughness.
  20733. * It is not taken into account if linkSheenWithAlbedo is true.
  20734. * To stay backward compatible, material roughness is used instead if sheen roughness = null
  20735. */
  20736. roughness: Nullable<number>;
  20737. private _textureRoughness;
  20738. /**
  20739. * Stores the sheen roughness in a texture.
  20740. * alpha channel is the roughness. This texture won't be used if the texture property is not empty and useRoughnessFromTexture is true
  20741. */
  20742. textureRoughness: Nullable<BaseTexture>;
  20743. private _albedoScaling;
  20744. /**
  20745. * If true, the sheen effect is layered above the base BRDF with the albedo-scaling technique.
  20746. * It allows the strength of the sheen effect to not depend on the base color of the material,
  20747. * making it easier to setup and tweak the effect
  20748. */
  20749. albedoScaling: boolean;
  20750. /** @hidden */
  20751. private _internalMarkAllSubMeshesAsTexturesDirty;
  20752. /** @hidden */
  20753. _markAllSubMeshesAsTexturesDirty(): void;
  20754. /**
  20755. * Instantiate a new instance of clear coat configuration.
  20756. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  20757. */
  20758. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  20759. /**
  20760. * Specifies that the submesh is ready to be used.
  20761. * @param defines the list of "defines" to update.
  20762. * @param scene defines the scene the material belongs to.
  20763. * @returns - boolean indicating that the submesh is ready or not.
  20764. */
  20765. isReadyForSubMesh(defines: IMaterialSheenDefines, scene: Scene): boolean;
  20766. /**
  20767. * Checks to see if a texture is used in the material.
  20768. * @param defines the list of "defines" to update.
  20769. * @param scene defines the scene the material belongs to.
  20770. */
  20771. prepareDefines(defines: IMaterialSheenDefines, scene: Scene): void;
  20772. /**
  20773. * Binds the material data.
  20774. * @param uniformBuffer defines the Uniform buffer to fill in.
  20775. * @param scene defines the scene the material belongs to.
  20776. * @param isFrozen defines whether the material is frozen or not.
  20777. * @param subMesh the submesh to bind data for
  20778. */
  20779. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean, subMesh?: SubMesh): void;
  20780. /**
  20781. * Checks to see if a texture is used in the material.
  20782. * @param texture - Base texture to use.
  20783. * @returns - Boolean specifying if a texture is used in the material.
  20784. */
  20785. hasTexture(texture: BaseTexture): boolean;
  20786. /**
  20787. * Returns an array of the actively used textures.
  20788. * @param activeTextures Array of BaseTextures
  20789. */
  20790. getActiveTextures(activeTextures: BaseTexture[]): void;
  20791. /**
  20792. * Returns the animatable textures.
  20793. * @param animatables Array of animatable textures.
  20794. */
  20795. getAnimatables(animatables: IAnimatable[]): void;
  20796. /**
  20797. * Disposes the resources of the material.
  20798. * @param forceDisposeTextures - Forces the disposal of all textures.
  20799. */
  20800. dispose(forceDisposeTextures?: boolean): void;
  20801. /**
  20802. * Get the current class name of the texture useful for serialization or dynamic coding.
  20803. * @returns "PBRSheenConfiguration"
  20804. */
  20805. getClassName(): string;
  20806. /**
  20807. * Add fallbacks to the effect fallbacks list.
  20808. * @param defines defines the Base texture to use.
  20809. * @param fallbacks defines the current fallback list.
  20810. * @param currentRank defines the current fallback rank.
  20811. * @returns the new fallback rank.
  20812. */
  20813. static AddFallbacks(defines: IMaterialSheenDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  20814. /**
  20815. * Add the required uniforms to the current list.
  20816. * @param uniforms defines the current uniform list.
  20817. */
  20818. static AddUniforms(uniforms: string[]): void;
  20819. /**
  20820. * Add the required uniforms to the current buffer.
  20821. * @param uniformBuffer defines the current uniform buffer.
  20822. */
  20823. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  20824. /**
  20825. * Add the required samplers to the current list.
  20826. * @param samplers defines the current sampler list.
  20827. */
  20828. static AddSamplers(samplers: string[]): void;
  20829. /**
  20830. * Makes a duplicate of the current configuration into another one.
  20831. * @param sheenConfiguration define the config where to copy the info
  20832. */
  20833. copyTo(sheenConfiguration: PBRSheenConfiguration): void;
  20834. /**
  20835. * Serializes this BRDF configuration.
  20836. * @returns - An object with the serialized config.
  20837. */
  20838. serialize(): any;
  20839. /**
  20840. * Parses a anisotropy Configuration from a serialized object.
  20841. * @param source - Serialized object.
  20842. * @param scene Defines the scene we are parsing for
  20843. * @param rootUrl Defines the rootUrl to load from
  20844. */
  20845. parse(source: any, scene: Scene, rootUrl: string): void;
  20846. }
  20847. }
  20848. declare module BABYLON {
  20849. /**
  20850. * @hidden
  20851. */
  20852. export interface IMaterialSubSurfaceDefines {
  20853. SUBSURFACE: boolean;
  20854. SS_REFRACTION: boolean;
  20855. SS_TRANSLUCENCY: boolean;
  20856. SS_SCATTERING: boolean;
  20857. SS_THICKNESSANDMASK_TEXTURE: boolean;
  20858. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  20859. SS_REFRACTIONMAP_3D: boolean;
  20860. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  20861. SS_LODINREFRACTIONALPHA: boolean;
  20862. SS_GAMMAREFRACTION: boolean;
  20863. SS_RGBDREFRACTION: boolean;
  20864. SS_LINEARSPECULARREFRACTION: boolean;
  20865. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  20866. SS_ALBEDOFORREFRACTIONTINT: boolean;
  20867. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  20868. SS_MASK_FROM_THICKNESS_TEXTURE_GLTF: boolean;
  20869. /** @hidden */
  20870. _areTexturesDirty: boolean;
  20871. }
  20872. /**
  20873. * Define the code related to the sub surface parameters of the pbr material.
  20874. */
  20875. export class PBRSubSurfaceConfiguration {
  20876. private _isRefractionEnabled;
  20877. /**
  20878. * Defines if the refraction is enabled in the material.
  20879. */
  20880. isRefractionEnabled: boolean;
  20881. private _isTranslucencyEnabled;
  20882. /**
  20883. * Defines if the translucency is enabled in the material.
  20884. */
  20885. isTranslucencyEnabled: boolean;
  20886. private _isScatteringEnabled;
  20887. /**
  20888. * Defines if the sub surface scattering is enabled in the material.
  20889. */
  20890. isScatteringEnabled: boolean;
  20891. private _scatteringDiffusionProfileIndex;
  20892. /**
  20893. * Diffusion profile for subsurface scattering.
  20894. * Useful for better scattering in the skins or foliages.
  20895. */
  20896. get scatteringDiffusionProfile(): Nullable<Color3>;
  20897. set scatteringDiffusionProfile(c: Nullable<Color3>);
  20898. /**
  20899. * Defines the refraction intensity of the material.
  20900. * The refraction when enabled replaces the Diffuse part of the material.
  20901. * The intensity helps transitioning between diffuse and refraction.
  20902. */
  20903. refractionIntensity: number;
  20904. /**
  20905. * Defines the translucency intensity of the material.
  20906. * When translucency has been enabled, this defines how much of the "translucency"
  20907. * is added to the diffuse part of the material.
  20908. */
  20909. translucencyIntensity: number;
  20910. /**
  20911. * When enabled, transparent surfaces will be tinted with the albedo colour (independent of thickness)
  20912. */
  20913. useAlbedoToTintRefraction: boolean;
  20914. private _thicknessTexture;
  20915. /**
  20916. * Stores the average thickness of a mesh in a texture (The texture is holding the values linearly).
  20917. * The red channel of the texture should contain the thickness remapped between 0 and 1.
  20918. * 0 would mean minimumThickness
  20919. * 1 would mean maximumThickness
  20920. * The other channels might be use as a mask to vary the different effects intensity.
  20921. */
  20922. thicknessTexture: Nullable<BaseTexture>;
  20923. private _refractionTexture;
  20924. /**
  20925. * Defines the texture to use for refraction.
  20926. */
  20927. refractionTexture: Nullable<BaseTexture>;
  20928. private _indexOfRefraction;
  20929. /**
  20930. * Index of refraction of the material base layer.
  20931. * https://en.wikipedia.org/wiki/List_of_refractive_indices
  20932. *
  20933. * This does not only impact refraction but also the Base F0 of Dielectric Materials.
  20934. *
  20935. * From dielectric fresnel rules: F0 = square((iorT - iorI) / (iorT + iorI))
  20936. */
  20937. indexOfRefraction: number;
  20938. private _volumeIndexOfRefraction;
  20939. /**
  20940. * Index of refraction of the material's volume.
  20941. * https://en.wikipedia.org/wiki/List_of_refractive_indices
  20942. *
  20943. * This ONLY impacts refraction. If not provided or given a non-valid value,
  20944. * the volume will use the same IOR as the surface.
  20945. */
  20946. get volumeIndexOfRefraction(): number;
  20947. set volumeIndexOfRefraction(value: number);
  20948. private _invertRefractionY;
  20949. /**
  20950. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  20951. */
  20952. invertRefractionY: boolean;
  20953. private _linkRefractionWithTransparency;
  20954. /**
  20955. * This parameters will make the material used its opacity to control how much it is refracting against not.
  20956. * Materials half opaque for instance using refraction could benefit from this control.
  20957. */
  20958. linkRefractionWithTransparency: boolean;
  20959. /**
  20960. * Defines the minimum thickness stored in the thickness map.
  20961. * If no thickness map is defined, this value will be used to simulate thickness.
  20962. */
  20963. minimumThickness: number;
  20964. /**
  20965. * Defines the maximum thickness stored in the thickness map.
  20966. */
  20967. maximumThickness: number;
  20968. /**
  20969. * Defines the volume tint of the material.
  20970. * This is used for both translucency and scattering.
  20971. */
  20972. tintColor: Color3;
  20973. /**
  20974. * Defines the distance at which the tint color should be found in the media.
  20975. * This is used for refraction only.
  20976. */
  20977. tintColorAtDistance: number;
  20978. /**
  20979. * Defines how far each channel transmit through the media.
  20980. * It is defined as a color to simplify it selection.
  20981. */
  20982. diffusionDistance: Color3;
  20983. private _useMaskFromThicknessTexture;
  20984. /**
  20985. * Stores the intensity of the different subsurface effects in the thickness texture.
  20986. * * the green channel is the translucency intensity.
  20987. * * the blue channel is the scattering intensity.
  20988. * * the alpha channel is the refraction intensity.
  20989. */
  20990. useMaskFromThicknessTexture: boolean;
  20991. private _scene;
  20992. private _useMaskFromThicknessTextureGltf;
  20993. /**
  20994. * Stores the intensity of the different subsurface effects in the thickness texture. This variation
  20995. * matches the channel-packing that is used by glTF.
  20996. * * the red channel is the transmission/translucency intensity.
  20997. * * the green channel is the thickness.
  20998. */
  20999. useMaskFromThicknessTextureGltf: boolean;
  21000. /** @hidden */
  21001. private _internalMarkAllSubMeshesAsTexturesDirty;
  21002. private _internalMarkScenePrePassDirty;
  21003. /** @hidden */
  21004. _markAllSubMeshesAsTexturesDirty(): void;
  21005. /** @hidden */
  21006. _markScenePrePassDirty(): void;
  21007. /**
  21008. * Instantiate a new instance of sub surface configuration.
  21009. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  21010. * @param markScenePrePassDirty Callback to flag the scene as prepass dirty
  21011. * @param scene The scene
  21012. */
  21013. constructor(markAllSubMeshesAsTexturesDirty: () => void, markScenePrePassDirty: () => void, scene: Scene);
  21014. /**
  21015. * Gets whether the submesh is ready to be used or not.
  21016. * @param defines the list of "defines" to update.
  21017. * @param scene defines the scene the material belongs to.
  21018. * @returns - boolean indicating that the submesh is ready or not.
  21019. */
  21020. isReadyForSubMesh(defines: IMaterialSubSurfaceDefines, scene: Scene): boolean;
  21021. /**
  21022. * Checks to see if a texture is used in the material.
  21023. * @param defines the list of "defines" to update.
  21024. * @param scene defines the scene to the material belongs to.
  21025. */
  21026. prepareDefines(defines: IMaterialSubSurfaceDefines, scene: Scene): void;
  21027. /**
  21028. * Binds the material data.
  21029. * @param uniformBuffer defines the Uniform buffer to fill in.
  21030. * @param scene defines the scene the material belongs to.
  21031. * @param engine defines the engine the material belongs to.
  21032. * @param isFrozen defines whether the material is frozen or not.
  21033. * @param lodBasedMicrosurface defines whether the material relies on lod based microsurface or not.
  21034. * @param realTimeFiltering defines whether the textures should be filtered on the fly.
  21035. */
  21036. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, isFrozen: boolean, lodBasedMicrosurface: boolean, realTimeFiltering: boolean): void;
  21037. /**
  21038. * Unbinds the material from the mesh.
  21039. * @param activeEffect defines the effect that should be unbound from.
  21040. * @returns true if unbound, otherwise false
  21041. */
  21042. unbind(activeEffect: Effect): boolean;
  21043. /**
  21044. * Returns the texture used for refraction or null if none is used.
  21045. * @param scene defines the scene the material belongs to.
  21046. * @returns - Refraction texture if present. If no refraction texture and refraction
  21047. * is linked with transparency, returns environment texture. Otherwise, returns null.
  21048. */
  21049. private _getRefractionTexture;
  21050. /**
  21051. * Returns true if alpha blending should be disabled.
  21052. */
  21053. get disableAlphaBlending(): boolean;
  21054. /**
  21055. * Fills the list of render target textures.
  21056. * @param renderTargets the list of render targets to update
  21057. */
  21058. fillRenderTargetTextures(renderTargets: SmartArray<RenderTargetTexture>): void;
  21059. /**
  21060. * Checks to see if a texture is used in the material.
  21061. * @param texture - Base texture to use.
  21062. * @returns - Boolean specifying if a texture is used in the material.
  21063. */
  21064. hasTexture(texture: BaseTexture): boolean;
  21065. /**
  21066. * Gets a boolean indicating that current material needs to register RTT
  21067. * @returns true if this uses a render target otherwise false.
  21068. */
  21069. hasRenderTargetTextures(): boolean;
  21070. /**
  21071. * Returns an array of the actively used textures.
  21072. * @param activeTextures Array of BaseTextures
  21073. */
  21074. getActiveTextures(activeTextures: BaseTexture[]): void;
  21075. /**
  21076. * Returns the animatable textures.
  21077. * @param animatables Array of animatable textures.
  21078. */
  21079. getAnimatables(animatables: IAnimatable[]): void;
  21080. /**
  21081. * Disposes the resources of the material.
  21082. * @param forceDisposeTextures - Forces the disposal of all textures.
  21083. */
  21084. dispose(forceDisposeTextures?: boolean): void;
  21085. /**
  21086. * Get the current class name of the texture useful for serialization or dynamic coding.
  21087. * @returns "PBRSubSurfaceConfiguration"
  21088. */
  21089. getClassName(): string;
  21090. /**
  21091. * Add fallbacks to the effect fallbacks list.
  21092. * @param defines defines the Base texture to use.
  21093. * @param fallbacks defines the current fallback list.
  21094. * @param currentRank defines the current fallback rank.
  21095. * @returns the new fallback rank.
  21096. */
  21097. static AddFallbacks(defines: IMaterialSubSurfaceDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  21098. /**
  21099. * Add the required uniforms to the current list.
  21100. * @param uniforms defines the current uniform list.
  21101. */
  21102. static AddUniforms(uniforms: string[]): void;
  21103. /**
  21104. * Add the required samplers to the current list.
  21105. * @param samplers defines the current sampler list.
  21106. */
  21107. static AddSamplers(samplers: string[]): void;
  21108. /**
  21109. * Add the required uniforms to the current buffer.
  21110. * @param uniformBuffer defines the current uniform buffer.
  21111. */
  21112. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  21113. /**
  21114. * Makes a duplicate of the current configuration into another one.
  21115. * @param configuration define the config where to copy the info
  21116. */
  21117. copyTo(configuration: PBRSubSurfaceConfiguration): void;
  21118. /**
  21119. * Serializes this Sub Surface configuration.
  21120. * @returns - An object with the serialized config.
  21121. */
  21122. serialize(): any;
  21123. /**
  21124. * Parses a anisotropy Configuration from a serialized object.
  21125. * @param source - Serialized object.
  21126. * @param scene Defines the scene we are parsing for
  21127. * @param rootUrl Defines the rootUrl to load from
  21128. */
  21129. parse(source: any, scene: Scene, rootUrl: string): void;
  21130. }
  21131. }
  21132. declare module BABYLON {
  21133. /**
  21134. * Class representing spherical harmonics coefficients to the 3rd degree
  21135. */
  21136. export class SphericalHarmonics {
  21137. /**
  21138. * Defines whether or not the harmonics have been prescaled for rendering.
  21139. */
  21140. preScaled: boolean;
  21141. /**
  21142. * The l0,0 coefficients of the spherical harmonics
  21143. */
  21144. l00: Vector3;
  21145. /**
  21146. * The l1,-1 coefficients of the spherical harmonics
  21147. */
  21148. l1_1: Vector3;
  21149. /**
  21150. * The l1,0 coefficients of the spherical harmonics
  21151. */
  21152. l10: Vector3;
  21153. /**
  21154. * The l1,1 coefficients of the spherical harmonics
  21155. */
  21156. l11: Vector3;
  21157. /**
  21158. * The l2,-2 coefficients of the spherical harmonics
  21159. */
  21160. l2_2: Vector3;
  21161. /**
  21162. * The l2,-1 coefficients of the spherical harmonics
  21163. */
  21164. l2_1: Vector3;
  21165. /**
  21166. * The l2,0 coefficients of the spherical harmonics
  21167. */
  21168. l20: Vector3;
  21169. /**
  21170. * The l2,1 coefficients of the spherical harmonics
  21171. */
  21172. l21: Vector3;
  21173. /**
  21174. * The l2,2 coefficients of the spherical harmonics
  21175. */
  21176. l22: Vector3;
  21177. /**
  21178. * Adds a light to the spherical harmonics
  21179. * @param direction the direction of the light
  21180. * @param color the color of the light
  21181. * @param deltaSolidAngle the delta solid angle of the light
  21182. */
  21183. addLight(direction: Vector3, color: Color3, deltaSolidAngle: number): void;
  21184. /**
  21185. * Scales the spherical harmonics by the given amount
  21186. * @param scale the amount to scale
  21187. */
  21188. scaleInPlace(scale: number): void;
  21189. /**
  21190. * Convert from incident radiance (Li) to irradiance (E) by applying convolution with the cosine-weighted hemisphere.
  21191. *
  21192. * ```
  21193. * E_lm = A_l * L_lm
  21194. * ```
  21195. *
  21196. * In spherical harmonics this convolution amounts to scaling factors for each frequency band.
  21197. * This corresponds to equation 5 in "An Efficient Representation for Irradiance Environment Maps", where
  21198. * the scaling factors are given in equation 9.
  21199. */
  21200. convertIncidentRadianceToIrradiance(): void;
  21201. /**
  21202. * Convert from irradiance to outgoing radiance for Lambertian BDRF, suitable for efficient shader evaluation.
  21203. *
  21204. * ```
  21205. * L = (1/pi) * E * rho
  21206. * ```
  21207. *
  21208. * This is done by an additional scale by 1/pi, so is a fairly trivial operation but important conceptually.
  21209. */
  21210. convertIrradianceToLambertianRadiance(): void;
  21211. /**
  21212. * Integrates the reconstruction coefficients directly in to the SH preventing further
  21213. * required operations at run time.
  21214. *
  21215. * This is simply done by scaling back the SH with Ylm constants parameter.
  21216. * The trigonometric part being applied by the shader at run time.
  21217. */
  21218. preScaleForRendering(): void;
  21219. /**
  21220. * Constructs a spherical harmonics from an array.
  21221. * @param data defines the 9x3 coefficients (l00, l1-1, l10, l11, l2-2, l2-1, l20, l21, l22)
  21222. * @returns the spherical harmonics
  21223. */
  21224. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalHarmonics;
  21225. /**
  21226. * Gets the spherical harmonics from polynomial
  21227. * @param polynomial the spherical polynomial
  21228. * @returns the spherical harmonics
  21229. */
  21230. static FromPolynomial(polynomial: SphericalPolynomial): SphericalHarmonics;
  21231. }
  21232. /**
  21233. * Class representing spherical polynomial coefficients to the 3rd degree
  21234. */
  21235. export class SphericalPolynomial {
  21236. private _harmonics;
  21237. /**
  21238. * The spherical harmonics used to create the polynomials.
  21239. */
  21240. get preScaledHarmonics(): SphericalHarmonics;
  21241. /**
  21242. * The x coefficients of the spherical polynomial
  21243. */
  21244. x: Vector3;
  21245. /**
  21246. * The y coefficients of the spherical polynomial
  21247. */
  21248. y: Vector3;
  21249. /**
  21250. * The z coefficients of the spherical polynomial
  21251. */
  21252. z: Vector3;
  21253. /**
  21254. * The xx coefficients of the spherical polynomial
  21255. */
  21256. xx: Vector3;
  21257. /**
  21258. * The yy coefficients of the spherical polynomial
  21259. */
  21260. yy: Vector3;
  21261. /**
  21262. * The zz coefficients of the spherical polynomial
  21263. */
  21264. zz: Vector3;
  21265. /**
  21266. * The xy coefficients of the spherical polynomial
  21267. */
  21268. xy: Vector3;
  21269. /**
  21270. * The yz coefficients of the spherical polynomial
  21271. */
  21272. yz: Vector3;
  21273. /**
  21274. * The zx coefficients of the spherical polynomial
  21275. */
  21276. zx: Vector3;
  21277. /**
  21278. * Adds an ambient color to the spherical polynomial
  21279. * @param color the color to add
  21280. */
  21281. addAmbient(color: Color3): void;
  21282. /**
  21283. * Scales the spherical polynomial by the given amount
  21284. * @param scale the amount to scale
  21285. */
  21286. scaleInPlace(scale: number): void;
  21287. /**
  21288. * Gets the spherical polynomial from harmonics
  21289. * @param harmonics the spherical harmonics
  21290. * @returns the spherical polynomial
  21291. */
  21292. static FromHarmonics(harmonics: SphericalHarmonics): SphericalPolynomial;
  21293. /**
  21294. * Constructs a spherical polynomial from an array.
  21295. * @param data defines the 9x3 coefficients (x, y, z, xx, yy, zz, yz, zx, xy)
  21296. * @returns the spherical polynomial
  21297. */
  21298. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalPolynomial;
  21299. }
  21300. }
  21301. declare module BABYLON {
  21302. /**
  21303. * CubeMap information grouping all the data for each faces as well as the cubemap size.
  21304. */
  21305. export interface CubeMapInfo {
  21306. /**
  21307. * The pixel array for the front face.
  21308. * This is stored in format, left to right, up to down format.
  21309. */
  21310. front: Nullable<ArrayBufferView>;
  21311. /**
  21312. * The pixel array for the back face.
  21313. * This is stored in format, left to right, up to down format.
  21314. */
  21315. back: Nullable<ArrayBufferView>;
  21316. /**
  21317. * The pixel array for the left face.
  21318. * This is stored in format, left to right, up to down format.
  21319. */
  21320. left: Nullable<ArrayBufferView>;
  21321. /**
  21322. * The pixel array for the right face.
  21323. * This is stored in format, left to right, up to down format.
  21324. */
  21325. right: Nullable<ArrayBufferView>;
  21326. /**
  21327. * The pixel array for the up face.
  21328. * This is stored in format, left to right, up to down format.
  21329. */
  21330. up: Nullable<ArrayBufferView>;
  21331. /**
  21332. * The pixel array for the down face.
  21333. * This is stored in format, left to right, up to down format.
  21334. */
  21335. down: Nullable<ArrayBufferView>;
  21336. /**
  21337. * The size of the cubemap stored.
  21338. *
  21339. * Each faces will be size * size pixels.
  21340. */
  21341. size: number;
  21342. /**
  21343. * The format of the texture.
  21344. *
  21345. * RGBA, RGB.
  21346. */
  21347. format: number;
  21348. /**
  21349. * The type of the texture data.
  21350. *
  21351. * UNSIGNED_INT, FLOAT.
  21352. */
  21353. type: number;
  21354. /**
  21355. * Specifies whether the texture is in gamma space.
  21356. */
  21357. gammaSpace: boolean;
  21358. }
  21359. /**
  21360. * Helper class useful to convert panorama picture to their cubemap representation in 6 faces.
  21361. */
  21362. export class PanoramaToCubeMapTools {
  21363. private static FACE_LEFT;
  21364. private static FACE_RIGHT;
  21365. private static FACE_FRONT;
  21366. private static FACE_BACK;
  21367. private static FACE_DOWN;
  21368. private static FACE_UP;
  21369. /**
  21370. * Converts a panorama stored in RGB right to left up to down format into a cubemap (6 faces).
  21371. *
  21372. * @param float32Array The source data.
  21373. * @param inputWidth The width of the input panorama.
  21374. * @param inputHeight The height of the input panorama.
  21375. * @param size The willing size of the generated cubemap (each faces will be size * size pixels)
  21376. * @return The cubemap data
  21377. */
  21378. static ConvertPanoramaToCubemap(float32Array: Float32Array, inputWidth: number, inputHeight: number, size: number): CubeMapInfo;
  21379. private static CreateCubemapTexture;
  21380. private static CalcProjectionSpherical;
  21381. }
  21382. }
  21383. declare module BABYLON {
  21384. /**
  21385. * Helper class dealing with the extraction of spherical polynomial dataArray
  21386. * from a cube map.
  21387. */
  21388. export class CubeMapToSphericalPolynomialTools {
  21389. private static FileFaces;
  21390. /**
  21391. * Converts a texture to the according Spherical Polynomial data.
  21392. * This extracts the first 3 orders only as they are the only one used in the lighting.
  21393. *
  21394. * @param texture The texture to extract the information from.
  21395. * @return The Spherical Polynomial data.
  21396. */
  21397. static ConvertCubeMapTextureToSphericalPolynomial(texture: BaseTexture): Nullable<Promise<SphericalPolynomial>>;
  21398. /**
  21399. * Converts a cubemap to the according Spherical Polynomial data.
  21400. * This extracts the first 3 orders only as they are the only one used in the lighting.
  21401. *
  21402. * @param cubeInfo The Cube map to extract the information from.
  21403. * @return The Spherical Polynomial data.
  21404. */
  21405. static ConvertCubeMapToSphericalPolynomial(cubeInfo: CubeMapInfo): SphericalPolynomial;
  21406. }
  21407. }
  21408. declare module BABYLON {
  21409. interface BaseTexture {
  21410. /**
  21411. * Get the polynomial representation of the texture data.
  21412. * This is mainly use as a fast way to recover IBL Diffuse irradiance data.
  21413. * @see https://learnopengl.com/PBR/IBL/Diffuse-irradiance
  21414. */
  21415. sphericalPolynomial: Nullable<SphericalPolynomial>;
  21416. }
  21417. }
  21418. declare module BABYLON {
  21419. /** @hidden */
  21420. export var pbrFragmentDeclaration: {
  21421. name: string;
  21422. shader: string;
  21423. };
  21424. }
  21425. declare module BABYLON {
  21426. /** @hidden */
  21427. export var pbrUboDeclaration: {
  21428. name: string;
  21429. shader: string;
  21430. };
  21431. }
  21432. declare module BABYLON {
  21433. /** @hidden */
  21434. export var pbrFragmentExtraDeclaration: {
  21435. name: string;
  21436. shader: string;
  21437. };
  21438. }
  21439. declare module BABYLON {
  21440. /** @hidden */
  21441. export var pbrFragmentSamplersDeclaration: {
  21442. name: string;
  21443. shader: string;
  21444. };
  21445. }
  21446. declare module BABYLON {
  21447. /** @hidden */
  21448. export var subSurfaceScatteringFunctions: {
  21449. name: string;
  21450. shader: string;
  21451. };
  21452. }
  21453. declare module BABYLON {
  21454. /** @hidden */
  21455. export var importanceSampling: {
  21456. name: string;
  21457. shader: string;
  21458. };
  21459. }
  21460. declare module BABYLON {
  21461. /** @hidden */
  21462. export var pbrHelperFunctions: {
  21463. name: string;
  21464. shader: string;
  21465. };
  21466. }
  21467. declare module BABYLON {
  21468. /** @hidden */
  21469. export var harmonicsFunctions: {
  21470. name: string;
  21471. shader: string;
  21472. };
  21473. }
  21474. declare module BABYLON {
  21475. /** @hidden */
  21476. export var pbrDirectLightingSetupFunctions: {
  21477. name: string;
  21478. shader: string;
  21479. };
  21480. }
  21481. declare module BABYLON {
  21482. /** @hidden */
  21483. export var pbrDirectLightingFalloffFunctions: {
  21484. name: string;
  21485. shader: string;
  21486. };
  21487. }
  21488. declare module BABYLON {
  21489. /** @hidden */
  21490. export var pbrBRDFFunctions: {
  21491. name: string;
  21492. shader: string;
  21493. };
  21494. }
  21495. declare module BABYLON {
  21496. /** @hidden */
  21497. export var hdrFilteringFunctions: {
  21498. name: string;
  21499. shader: string;
  21500. };
  21501. }
  21502. declare module BABYLON {
  21503. /** @hidden */
  21504. export var pbrDirectLightingFunctions: {
  21505. name: string;
  21506. shader: string;
  21507. };
  21508. }
  21509. declare module BABYLON {
  21510. /** @hidden */
  21511. export var pbrIBLFunctions: {
  21512. name: string;
  21513. shader: string;
  21514. };
  21515. }
  21516. declare module BABYLON {
  21517. /** @hidden */
  21518. export var pbrBlockAlbedoOpacity: {
  21519. name: string;
  21520. shader: string;
  21521. };
  21522. }
  21523. declare module BABYLON {
  21524. /** @hidden */
  21525. export var pbrBlockReflectivity: {
  21526. name: string;
  21527. shader: string;
  21528. };
  21529. }
  21530. declare module BABYLON {
  21531. /** @hidden */
  21532. export var pbrBlockAmbientOcclusion: {
  21533. name: string;
  21534. shader: string;
  21535. };
  21536. }
  21537. declare module BABYLON {
  21538. /** @hidden */
  21539. export var pbrBlockAlphaFresnel: {
  21540. name: string;
  21541. shader: string;
  21542. };
  21543. }
  21544. declare module BABYLON {
  21545. /** @hidden */
  21546. export var pbrBlockAnisotropic: {
  21547. name: string;
  21548. shader: string;
  21549. };
  21550. }
  21551. declare module BABYLON {
  21552. /** @hidden */
  21553. export var pbrBlockReflection: {
  21554. name: string;
  21555. shader: string;
  21556. };
  21557. }
  21558. declare module BABYLON {
  21559. /** @hidden */
  21560. export var pbrBlockSheen: {
  21561. name: string;
  21562. shader: string;
  21563. };
  21564. }
  21565. declare module BABYLON {
  21566. /** @hidden */
  21567. export var pbrBlockClearcoat: {
  21568. name: string;
  21569. shader: string;
  21570. };
  21571. }
  21572. declare module BABYLON {
  21573. /** @hidden */
  21574. export var pbrBlockSubSurface: {
  21575. name: string;
  21576. shader: string;
  21577. };
  21578. }
  21579. declare module BABYLON {
  21580. /** @hidden */
  21581. export var pbrBlockNormalGeometric: {
  21582. name: string;
  21583. shader: string;
  21584. };
  21585. }
  21586. declare module BABYLON {
  21587. /** @hidden */
  21588. export var pbrBlockNormalFinal: {
  21589. name: string;
  21590. shader: string;
  21591. };
  21592. }
  21593. declare module BABYLON {
  21594. /** @hidden */
  21595. export var pbrBlockLightmapInit: {
  21596. name: string;
  21597. shader: string;
  21598. };
  21599. }
  21600. declare module BABYLON {
  21601. /** @hidden */
  21602. export var pbrBlockGeometryInfo: {
  21603. name: string;
  21604. shader: string;
  21605. };
  21606. }
  21607. declare module BABYLON {
  21608. /** @hidden */
  21609. export var pbrBlockReflectance0: {
  21610. name: string;
  21611. shader: string;
  21612. };
  21613. }
  21614. declare module BABYLON {
  21615. /** @hidden */
  21616. export var pbrBlockReflectance: {
  21617. name: string;
  21618. shader: string;
  21619. };
  21620. }
  21621. declare module BABYLON {
  21622. /** @hidden */
  21623. export var pbrBlockDirectLighting: {
  21624. name: string;
  21625. shader: string;
  21626. };
  21627. }
  21628. declare module BABYLON {
  21629. /** @hidden */
  21630. export var pbrBlockFinalLitComponents: {
  21631. name: string;
  21632. shader: string;
  21633. };
  21634. }
  21635. declare module BABYLON {
  21636. /** @hidden */
  21637. export var pbrBlockFinalUnlitComponents: {
  21638. name: string;
  21639. shader: string;
  21640. };
  21641. }
  21642. declare module BABYLON {
  21643. /** @hidden */
  21644. export var pbrBlockFinalColorComposition: {
  21645. name: string;
  21646. shader: string;
  21647. };
  21648. }
  21649. declare module BABYLON {
  21650. /** @hidden */
  21651. export var pbrBlockImageProcessing: {
  21652. name: string;
  21653. shader: string;
  21654. };
  21655. }
  21656. declare module BABYLON {
  21657. /** @hidden */
  21658. export var pbrDebug: {
  21659. name: string;
  21660. shader: string;
  21661. };
  21662. }
  21663. declare module BABYLON {
  21664. /** @hidden */
  21665. export var pbrPixelShader: {
  21666. name: string;
  21667. shader: string;
  21668. };
  21669. }
  21670. declare module BABYLON {
  21671. /** @hidden */
  21672. export var pbrVertexDeclaration: {
  21673. name: string;
  21674. shader: string;
  21675. };
  21676. }
  21677. declare module BABYLON {
  21678. /** @hidden */
  21679. export var pbrVertexShader: {
  21680. name: string;
  21681. shader: string;
  21682. };
  21683. }
  21684. declare module BABYLON {
  21685. /**
  21686. * Manages the defines for the PBR Material.
  21687. * @hidden
  21688. */
  21689. export class PBRMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines, IMaterialClearCoatDefines, IMaterialAnisotropicDefines, IMaterialBRDFDefines, IMaterialSheenDefines, IMaterialSubSurfaceDefines, IMaterialDetailMapDefines {
  21690. PBR: boolean;
  21691. NUM_SAMPLES: string;
  21692. REALTIME_FILTERING: boolean;
  21693. MAINUV1: boolean;
  21694. MAINUV2: boolean;
  21695. UV1: boolean;
  21696. UV2: boolean;
  21697. ALBEDO: boolean;
  21698. GAMMAALBEDO: boolean;
  21699. ALBEDODIRECTUV: number;
  21700. VERTEXCOLOR: boolean;
  21701. DETAIL: boolean;
  21702. DETAILDIRECTUV: number;
  21703. DETAIL_NORMALBLENDMETHOD: number;
  21704. AMBIENT: boolean;
  21705. AMBIENTDIRECTUV: number;
  21706. AMBIENTINGRAYSCALE: boolean;
  21707. OPACITY: boolean;
  21708. VERTEXALPHA: boolean;
  21709. OPACITYDIRECTUV: number;
  21710. OPACITYRGB: boolean;
  21711. ALPHATEST: boolean;
  21712. DEPTHPREPASS: boolean;
  21713. ALPHABLEND: boolean;
  21714. ALPHAFROMALBEDO: boolean;
  21715. ALPHATESTVALUE: string;
  21716. SPECULAROVERALPHA: boolean;
  21717. RADIANCEOVERALPHA: boolean;
  21718. ALPHAFRESNEL: boolean;
  21719. LINEARALPHAFRESNEL: boolean;
  21720. PREMULTIPLYALPHA: boolean;
  21721. EMISSIVE: boolean;
  21722. EMISSIVEDIRECTUV: number;
  21723. REFLECTIVITY: boolean;
  21724. REFLECTIVITYDIRECTUV: number;
  21725. SPECULARTERM: boolean;
  21726. MICROSURFACEFROMREFLECTIVITYMAP: boolean;
  21727. MICROSURFACEAUTOMATIC: boolean;
  21728. LODBASEDMICROSFURACE: boolean;
  21729. MICROSURFACEMAP: boolean;
  21730. MICROSURFACEMAPDIRECTUV: number;
  21731. METALLICWORKFLOW: boolean;
  21732. ROUGHNESSSTOREINMETALMAPALPHA: boolean;
  21733. ROUGHNESSSTOREINMETALMAPGREEN: boolean;
  21734. METALLNESSSTOREINMETALMAPBLUE: boolean;
  21735. AOSTOREINMETALMAPRED: boolean;
  21736. METALLIC_REFLECTANCE: boolean;
  21737. METALLIC_REFLECTANCEDIRECTUV: number;
  21738. ENVIRONMENTBRDF: boolean;
  21739. ENVIRONMENTBRDF_RGBD: boolean;
  21740. NORMAL: boolean;
  21741. TANGENT: boolean;
  21742. BUMP: boolean;
  21743. BUMPDIRECTUV: number;
  21744. OBJECTSPACE_NORMALMAP: boolean;
  21745. PARALLAX: boolean;
  21746. PARALLAXOCCLUSION: boolean;
  21747. NORMALXYSCALE: boolean;
  21748. LIGHTMAP: boolean;
  21749. LIGHTMAPDIRECTUV: number;
  21750. USELIGHTMAPASSHADOWMAP: boolean;
  21751. GAMMALIGHTMAP: boolean;
  21752. RGBDLIGHTMAP: boolean;
  21753. REFLECTION: boolean;
  21754. REFLECTIONMAP_3D: boolean;
  21755. REFLECTIONMAP_SPHERICAL: boolean;
  21756. REFLECTIONMAP_PLANAR: boolean;
  21757. REFLECTIONMAP_CUBIC: boolean;
  21758. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  21759. REFLECTIONMAP_PROJECTION: boolean;
  21760. REFLECTIONMAP_SKYBOX: boolean;
  21761. REFLECTIONMAP_EXPLICIT: boolean;
  21762. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  21763. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  21764. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  21765. INVERTCUBICMAP: boolean;
  21766. USESPHERICALFROMREFLECTIONMAP: boolean;
  21767. USEIRRADIANCEMAP: boolean;
  21768. SPHERICAL_HARMONICS: boolean;
  21769. USESPHERICALINVERTEX: boolean;
  21770. REFLECTIONMAP_OPPOSITEZ: boolean;
  21771. LODINREFLECTIONALPHA: boolean;
  21772. GAMMAREFLECTION: boolean;
  21773. RGBDREFLECTION: boolean;
  21774. LINEARSPECULARREFLECTION: boolean;
  21775. RADIANCEOCCLUSION: boolean;
  21776. HORIZONOCCLUSION: boolean;
  21777. INSTANCES: boolean;
  21778. THIN_INSTANCES: boolean;
  21779. PREPASS: boolean;
  21780. PREPASS_IRRADIANCE: boolean;
  21781. PREPASS_IRRADIANCE_INDEX: number;
  21782. PREPASS_ALBEDO: boolean;
  21783. PREPASS_ALBEDO_INDEX: number;
  21784. PREPASS_DEPTH: boolean;
  21785. PREPASS_DEPTH_INDEX: number;
  21786. PREPASS_NORMAL: boolean;
  21787. PREPASS_NORMAL_INDEX: number;
  21788. PREPASS_POSITION: boolean;
  21789. PREPASS_POSITION_INDEX: number;
  21790. PREPASS_VELOCITY: boolean;
  21791. PREPASS_VELOCITY_INDEX: number;
  21792. PREPASS_REFLECTIVITY: boolean;
  21793. PREPASS_REFLECTIVITY_INDEX: number;
  21794. SCENE_MRT_COUNT: number;
  21795. NUM_BONE_INFLUENCERS: number;
  21796. BonesPerMesh: number;
  21797. BONETEXTURE: boolean;
  21798. BONES_VELOCITY_ENABLED: boolean;
  21799. NONUNIFORMSCALING: boolean;
  21800. MORPHTARGETS: boolean;
  21801. MORPHTARGETS_NORMAL: boolean;
  21802. MORPHTARGETS_TANGENT: boolean;
  21803. MORPHTARGETS_UV: boolean;
  21804. NUM_MORPH_INFLUENCERS: number;
  21805. IMAGEPROCESSING: boolean;
  21806. VIGNETTE: boolean;
  21807. VIGNETTEBLENDMODEMULTIPLY: boolean;
  21808. VIGNETTEBLENDMODEOPAQUE: boolean;
  21809. TONEMAPPING: boolean;
  21810. TONEMAPPING_ACES: boolean;
  21811. CONTRAST: boolean;
  21812. COLORCURVES: boolean;
  21813. COLORGRADING: boolean;
  21814. COLORGRADING3D: boolean;
  21815. SAMPLER3DGREENDEPTH: boolean;
  21816. SAMPLER3DBGRMAP: boolean;
  21817. IMAGEPROCESSINGPOSTPROCESS: boolean;
  21818. EXPOSURE: boolean;
  21819. MULTIVIEW: boolean;
  21820. USEPHYSICALLIGHTFALLOFF: boolean;
  21821. USEGLTFLIGHTFALLOFF: boolean;
  21822. TWOSIDEDLIGHTING: boolean;
  21823. SHADOWFLOAT: boolean;
  21824. CLIPPLANE: boolean;
  21825. CLIPPLANE2: boolean;
  21826. CLIPPLANE3: boolean;
  21827. CLIPPLANE4: boolean;
  21828. CLIPPLANE5: boolean;
  21829. CLIPPLANE6: boolean;
  21830. POINTSIZE: boolean;
  21831. FOG: boolean;
  21832. LOGARITHMICDEPTH: boolean;
  21833. FORCENORMALFORWARD: boolean;
  21834. SPECULARAA: boolean;
  21835. CLEARCOAT: boolean;
  21836. CLEARCOAT_DEFAULTIOR: boolean;
  21837. CLEARCOAT_TEXTURE: boolean;
  21838. CLEARCOAT_TEXTURE_ROUGHNESS: boolean;
  21839. CLEARCOAT_TEXTUREDIRECTUV: number;
  21840. CLEARCOAT_TEXTURE_ROUGHNESSDIRECTUV: number;
  21841. CLEARCOAT_USE_ROUGHNESS_FROM_MAINTEXTURE: boolean;
  21842. CLEARCOAT_TEXTURE_ROUGHNESS_IDENTICAL: boolean;
  21843. CLEARCOAT_BUMP: boolean;
  21844. CLEARCOAT_BUMPDIRECTUV: number;
  21845. CLEARCOAT_REMAP_F0: boolean;
  21846. CLEARCOAT_TINT: boolean;
  21847. CLEARCOAT_TINT_TEXTURE: boolean;
  21848. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  21849. ANISOTROPIC: boolean;
  21850. ANISOTROPIC_TEXTURE: boolean;
  21851. ANISOTROPIC_TEXTUREDIRECTUV: number;
  21852. BRDF_V_HEIGHT_CORRELATED: boolean;
  21853. MS_BRDF_ENERGY_CONSERVATION: boolean;
  21854. SPECULAR_GLOSSINESS_ENERGY_CONSERVATION: boolean;
  21855. SHEEN: boolean;
  21856. SHEEN_TEXTURE: boolean;
  21857. SHEEN_TEXTURE_ROUGHNESS: boolean;
  21858. SHEEN_TEXTUREDIRECTUV: number;
  21859. SHEEN_TEXTURE_ROUGHNESSDIRECTUV: number;
  21860. SHEEN_LINKWITHALBEDO: boolean;
  21861. SHEEN_ROUGHNESS: boolean;
  21862. SHEEN_ALBEDOSCALING: boolean;
  21863. SHEEN_USE_ROUGHNESS_FROM_MAINTEXTURE: boolean;
  21864. SHEEN_TEXTURE_ROUGHNESS_IDENTICAL: boolean;
  21865. SUBSURFACE: boolean;
  21866. SS_REFRACTION: boolean;
  21867. SS_TRANSLUCENCY: boolean;
  21868. SS_SCATTERING: boolean;
  21869. SS_THICKNESSANDMASK_TEXTURE: boolean;
  21870. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  21871. SS_REFRACTIONMAP_3D: boolean;
  21872. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  21873. SS_LODINREFRACTIONALPHA: boolean;
  21874. SS_GAMMAREFRACTION: boolean;
  21875. SS_RGBDREFRACTION: boolean;
  21876. SS_LINEARSPECULARREFRACTION: boolean;
  21877. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  21878. SS_ALBEDOFORREFRACTIONTINT: boolean;
  21879. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  21880. SS_MASK_FROM_THICKNESS_TEXTURE_GLTF: boolean;
  21881. UNLIT: boolean;
  21882. DEBUGMODE: number;
  21883. /**
  21884. * Initializes the PBR Material defines.
  21885. */
  21886. constructor();
  21887. /**
  21888. * Resets the PBR Material defines.
  21889. */
  21890. reset(): void;
  21891. }
  21892. /**
  21893. * The Physically based material base class of BJS.
  21894. *
  21895. * This offers the main features of a standard PBR material.
  21896. * For more information, please refer to the documentation :
  21897. * https://doc.babylonjs.com/how_to/physically_based_rendering
  21898. */
  21899. export abstract class PBRBaseMaterial extends PushMaterial {
  21900. /**
  21901. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  21902. */
  21903. static readonly PBRMATERIAL_OPAQUE: number;
  21904. /**
  21905. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  21906. */
  21907. static readonly PBRMATERIAL_ALPHATEST: number;
  21908. /**
  21909. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  21910. */
  21911. static readonly PBRMATERIAL_ALPHABLEND: number;
  21912. /**
  21913. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  21914. * They are also discarded below the alpha cutoff threshold to improve performances.
  21915. */
  21916. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  21917. /**
  21918. * Defines the default value of how much AO map is occluding the analytical lights
  21919. * (point spot...).
  21920. */
  21921. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  21922. /**
  21923. * PBRMaterialLightFalloff Physical: light is falling off following the inverse squared distance law.
  21924. */
  21925. static readonly LIGHTFALLOFF_PHYSICAL: number;
  21926. /**
  21927. * PBRMaterialLightFalloff gltf: light is falling off as described in the gltf moving to PBR document
  21928. * to enhance interoperability with other engines.
  21929. */
  21930. static readonly LIGHTFALLOFF_GLTF: number;
  21931. /**
  21932. * PBRMaterialLightFalloff Standard: light is falling off like in the standard material
  21933. * to enhance interoperability with other materials.
  21934. */
  21935. static readonly LIGHTFALLOFF_STANDARD: number;
  21936. /**
  21937. * Intensity of the direct lights e.g. the four lights available in your scene.
  21938. * This impacts both the direct diffuse and specular highlights.
  21939. */
  21940. protected _directIntensity: number;
  21941. /**
  21942. * Intensity of the emissive part of the material.
  21943. * This helps controlling the emissive effect without modifying the emissive color.
  21944. */
  21945. protected _emissiveIntensity: number;
  21946. /**
  21947. * Intensity of the environment e.g. how much the environment will light the object
  21948. * either through harmonics for rough material or through the reflection for shiny ones.
  21949. */
  21950. protected _environmentIntensity: number;
  21951. /**
  21952. * This is a special control allowing the reduction of the specular highlights coming from the
  21953. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  21954. */
  21955. protected _specularIntensity: number;
  21956. /**
  21957. * This stores the direct, emissive, environment, and specular light intensities into a Vector4.
  21958. */
  21959. private _lightingInfos;
  21960. /**
  21961. * Debug Control allowing disabling the bump map on this material.
  21962. */
  21963. protected _disableBumpMap: boolean;
  21964. /**
  21965. * AKA Diffuse Texture in standard nomenclature.
  21966. */
  21967. protected _albedoTexture: Nullable<BaseTexture>;
  21968. /**
  21969. * AKA Occlusion Texture in other nomenclature.
  21970. */
  21971. protected _ambientTexture: Nullable<BaseTexture>;
  21972. /**
  21973. * AKA Occlusion Texture Intensity in other nomenclature.
  21974. */
  21975. protected _ambientTextureStrength: number;
  21976. /**
  21977. * Defines how much the AO map is occluding the analytical lights (point spot...).
  21978. * 1 means it completely occludes it
  21979. * 0 mean it has no impact
  21980. */
  21981. protected _ambientTextureImpactOnAnalyticalLights: number;
  21982. /**
  21983. * Stores the alpha values in a texture.
  21984. */
  21985. protected _opacityTexture: Nullable<BaseTexture>;
  21986. /**
  21987. * Stores the reflection values in a texture.
  21988. */
  21989. protected _reflectionTexture: Nullable<BaseTexture>;
  21990. /**
  21991. * Stores the emissive values in a texture.
  21992. */
  21993. protected _emissiveTexture: Nullable<BaseTexture>;
  21994. /**
  21995. * AKA Specular texture in other nomenclature.
  21996. */
  21997. protected _reflectivityTexture: Nullable<BaseTexture>;
  21998. /**
  21999. * Used to switch from specular/glossiness to metallic/roughness workflow.
  22000. */
  22001. protected _metallicTexture: Nullable<BaseTexture>;
  22002. /**
  22003. * Specifies the metallic scalar of the metallic/roughness workflow.
  22004. * Can also be used to scale the metalness values of the metallic texture.
  22005. */
  22006. protected _metallic: Nullable<number>;
  22007. /**
  22008. * Specifies the roughness scalar of the metallic/roughness workflow.
  22009. * Can also be used to scale the roughness values of the metallic texture.
  22010. */
  22011. protected _roughness: Nullable<number>;
  22012. /**
  22013. * In metallic workflow, specifies an F0 factor to help configuring the material F0.
  22014. * By default the indexOfrefraction is used to compute F0;
  22015. *
  22016. * This is used as a factor against the default reflectance at normal incidence to tweak it.
  22017. *
  22018. * F0 = defaultF0 * metallicF0Factor * metallicReflectanceColor;
  22019. * F90 = metallicReflectanceColor;
  22020. */
  22021. protected _metallicF0Factor: number;
  22022. /**
  22023. * In metallic workflow, specifies an F90 color to help configuring the material F90.
  22024. * By default the F90 is always 1;
  22025. *
  22026. * Please note that this factor is also used as a factor against the default reflectance at normal incidence.
  22027. *
  22028. * F0 = defaultF0 * metallicF0Factor * metallicReflectanceColor
  22029. * F90 = metallicReflectanceColor;
  22030. */
  22031. protected _metallicReflectanceColor: Color3;
  22032. /**
  22033. * Defines to store metallicReflectanceColor in RGB and metallicF0Factor in A
  22034. * This is multiply against the scalar values defined in the material.
  22035. */
  22036. protected _metallicReflectanceTexture: Nullable<BaseTexture>;
  22037. /**
  22038. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  22039. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  22040. */
  22041. protected _microSurfaceTexture: Nullable<BaseTexture>;
  22042. /**
  22043. * Stores surface normal data used to displace a mesh in a texture.
  22044. */
  22045. protected _bumpTexture: Nullable<BaseTexture>;
  22046. /**
  22047. * Stores the pre-calculated light information of a mesh in a texture.
  22048. */
  22049. protected _lightmapTexture: Nullable<BaseTexture>;
  22050. /**
  22051. * The color of a material in ambient lighting.
  22052. */
  22053. protected _ambientColor: Color3;
  22054. /**
  22055. * AKA Diffuse Color in other nomenclature.
  22056. */
  22057. protected _albedoColor: Color3;
  22058. /**
  22059. * AKA Specular Color in other nomenclature.
  22060. */
  22061. protected _reflectivityColor: Color3;
  22062. /**
  22063. * The color applied when light is reflected from a material.
  22064. */
  22065. protected _reflectionColor: Color3;
  22066. /**
  22067. * The color applied when light is emitted from a material.
  22068. */
  22069. protected _emissiveColor: Color3;
  22070. /**
  22071. * AKA Glossiness in other nomenclature.
  22072. */
  22073. protected _microSurface: number;
  22074. /**
  22075. * Specifies that the material will use the light map as a show map.
  22076. */
  22077. protected _useLightmapAsShadowmap: boolean;
  22078. /**
  22079. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  22080. * makes the reflect vector face the model (under horizon).
  22081. */
  22082. protected _useHorizonOcclusion: boolean;
  22083. /**
  22084. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  22085. * too much the area relying on ambient texture to define their ambient occlusion.
  22086. */
  22087. protected _useRadianceOcclusion: boolean;
  22088. /**
  22089. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  22090. */
  22091. protected _useAlphaFromAlbedoTexture: boolean;
  22092. /**
  22093. * Specifies that the material will keeps the specular highlights over a transparent surface (only the most luminous ones).
  22094. * A car glass is a good example of that. When sun reflects on it you can not see what is behind.
  22095. */
  22096. protected _useSpecularOverAlpha: boolean;
  22097. /**
  22098. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  22099. */
  22100. protected _useMicroSurfaceFromReflectivityMapAlpha: boolean;
  22101. /**
  22102. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  22103. */
  22104. protected _useRoughnessFromMetallicTextureAlpha: boolean;
  22105. /**
  22106. * Specifies if the metallic texture contains the roughness information in its green channel.
  22107. */
  22108. protected _useRoughnessFromMetallicTextureGreen: boolean;
  22109. /**
  22110. * Specifies if the metallic texture contains the metallness information in its blue channel.
  22111. */
  22112. protected _useMetallnessFromMetallicTextureBlue: boolean;
  22113. /**
  22114. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  22115. */
  22116. protected _useAmbientOcclusionFromMetallicTextureRed: boolean;
  22117. /**
  22118. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  22119. */
  22120. protected _useAmbientInGrayScale: boolean;
  22121. /**
  22122. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  22123. * The material will try to infer what glossiness each pixel should be.
  22124. */
  22125. protected _useAutoMicroSurfaceFromReflectivityMap: boolean;
  22126. /**
  22127. * Defines the falloff type used in this material.
  22128. * It by default is Physical.
  22129. */
  22130. protected _lightFalloff: number;
  22131. /**
  22132. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most luminous ones).
  22133. * A car glass is a good example of that. When the street lights reflects on it you can not see what is behind.
  22134. */
  22135. protected _useRadianceOverAlpha: boolean;
  22136. /**
  22137. * Allows using an object space normal map (instead of tangent space).
  22138. */
  22139. protected _useObjectSpaceNormalMap: boolean;
  22140. /**
  22141. * Allows using the bump map in parallax mode.
  22142. */
  22143. protected _useParallax: boolean;
  22144. /**
  22145. * Allows using the bump map in parallax occlusion mode.
  22146. */
  22147. protected _useParallaxOcclusion: boolean;
  22148. /**
  22149. * Controls the scale bias of the parallax mode.
  22150. */
  22151. protected _parallaxScaleBias: number;
  22152. /**
  22153. * If sets to true, disables all the lights affecting the material.
  22154. */
  22155. protected _disableLighting: boolean;
  22156. /**
  22157. * Number of Simultaneous lights allowed on the material.
  22158. */
  22159. protected _maxSimultaneousLights: number;
  22160. /**
  22161. * If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  22162. */
  22163. protected _invertNormalMapX: boolean;
  22164. /**
  22165. * If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  22166. */
  22167. protected _invertNormalMapY: boolean;
  22168. /**
  22169. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  22170. */
  22171. protected _twoSidedLighting: boolean;
  22172. /**
  22173. * Defines the alpha limits in alpha test mode.
  22174. */
  22175. protected _alphaCutOff: number;
  22176. /**
  22177. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  22178. */
  22179. protected _forceAlphaTest: boolean;
  22180. /**
  22181. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  22182. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  22183. */
  22184. protected _useAlphaFresnel: boolean;
  22185. /**
  22186. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  22187. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  22188. */
  22189. protected _useLinearAlphaFresnel: boolean;
  22190. /**
  22191. * Specifies the environment BRDF texture used to compute the scale and offset roughness values
  22192. * from cos theta and roughness:
  22193. * http://blog.selfshadow.com/publications/s2013-shading-course/karis/s2013_pbs_epic_notes_v2.pdf
  22194. */
  22195. protected _environmentBRDFTexture: Nullable<BaseTexture>;
  22196. /**
  22197. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  22198. */
  22199. protected _forceIrradianceInFragment: boolean;
  22200. private _realTimeFiltering;
  22201. /**
  22202. * Enables realtime filtering on the texture.
  22203. */
  22204. get realTimeFiltering(): boolean;
  22205. set realTimeFiltering(b: boolean);
  22206. private _realTimeFilteringQuality;
  22207. /**
  22208. * Quality switch for realtime filtering
  22209. */
  22210. get realTimeFilteringQuality(): number;
  22211. set realTimeFilteringQuality(n: number);
  22212. /**
  22213. * Can this material render to several textures at once
  22214. */
  22215. get canRenderToMRT(): boolean;
  22216. /**
  22217. * Force normal to face away from face.
  22218. */
  22219. protected _forceNormalForward: boolean;
  22220. /**
  22221. * Enables specular anti aliasing in the PBR shader.
  22222. * It will both interacts on the Geometry for analytical and IBL lighting.
  22223. * It also prefilter the roughness map based on the bump values.
  22224. */
  22225. protected _enableSpecularAntiAliasing: boolean;
  22226. /**
  22227. * Default configuration related to image processing available in the PBR Material.
  22228. */
  22229. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  22230. /**
  22231. * Keep track of the image processing observer to allow dispose and replace.
  22232. */
  22233. private _imageProcessingObserver;
  22234. /**
  22235. * Attaches a new image processing configuration to the PBR Material.
  22236. * @param configuration
  22237. */
  22238. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  22239. /**
  22240. * Stores the available render targets.
  22241. */
  22242. private _renderTargets;
  22243. /**
  22244. * Sets the global ambient color for the material used in lighting calculations.
  22245. */
  22246. private _globalAmbientColor;
  22247. /**
  22248. * Enables the use of logarithmic depth buffers, which is good for wide depth buffers.
  22249. */
  22250. private _useLogarithmicDepth;
  22251. /**
  22252. * If set to true, no lighting calculations will be applied.
  22253. */
  22254. private _unlit;
  22255. private _debugMode;
  22256. /**
  22257. * @hidden
  22258. * This is reserved for the inspector.
  22259. * Defines the material debug mode.
  22260. * It helps seeing only some components of the material while troubleshooting.
  22261. */
  22262. debugMode: number;
  22263. /**
  22264. * @hidden
  22265. * This is reserved for the inspector.
  22266. * Specify from where on screen the debug mode should start.
  22267. * The value goes from -1 (full screen) to 1 (not visible)
  22268. * It helps with side by side comparison against the final render
  22269. * This defaults to -1
  22270. */
  22271. private debugLimit;
  22272. /**
  22273. * @hidden
  22274. * This is reserved for the inspector.
  22275. * As the default viewing range might not be enough (if the ambient is really small for instance)
  22276. * You can use the factor to better multiply the final value.
  22277. */
  22278. private debugFactor;
  22279. /**
  22280. * Defines the clear coat layer parameters for the material.
  22281. */
  22282. readonly clearCoat: PBRClearCoatConfiguration;
  22283. /**
  22284. * Defines the anisotropic parameters for the material.
  22285. */
  22286. readonly anisotropy: PBRAnisotropicConfiguration;
  22287. /**
  22288. * Defines the BRDF parameters for the material.
  22289. */
  22290. readonly brdf: PBRBRDFConfiguration;
  22291. /**
  22292. * Defines the Sheen parameters for the material.
  22293. */
  22294. readonly sheen: PBRSheenConfiguration;
  22295. /**
  22296. * Defines the SubSurface parameters for the material.
  22297. */
  22298. readonly subSurface: PBRSubSurfaceConfiguration;
  22299. /**
  22300. * Defines additional PrePass parameters for the material.
  22301. */
  22302. readonly prePassConfiguration: PrePassConfiguration;
  22303. /**
  22304. * Defines the detail map parameters for the material.
  22305. */
  22306. readonly detailMap: DetailMapConfiguration;
  22307. protected _rebuildInParallel: boolean;
  22308. /**
  22309. * Instantiates a new PBRMaterial instance.
  22310. *
  22311. * @param name The material name
  22312. * @param scene The scene the material will be use in.
  22313. */
  22314. constructor(name: string, scene: Scene);
  22315. /**
  22316. * Gets a boolean indicating that current material needs to register RTT
  22317. */
  22318. get hasRenderTargetTextures(): boolean;
  22319. /**
  22320. * Can this material render to prepass
  22321. */
  22322. get isPrePassCapable(): boolean;
  22323. /**
  22324. * Gets the name of the material class.
  22325. */
  22326. getClassName(): string;
  22327. /**
  22328. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  22329. */
  22330. get useLogarithmicDepth(): boolean;
  22331. /**
  22332. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  22333. */
  22334. set useLogarithmicDepth(value: boolean);
  22335. /**
  22336. * Returns true if alpha blending should be disabled.
  22337. */
  22338. protected get _disableAlphaBlending(): boolean;
  22339. /**
  22340. * Specifies whether or not this material should be rendered in alpha blend mode.
  22341. */
  22342. needAlphaBlending(): boolean;
  22343. /**
  22344. * Specifies whether or not this material should be rendered in alpha test mode.
  22345. */
  22346. needAlphaTesting(): boolean;
  22347. /**
  22348. * Specifies whether or not the alpha value of the albedo texture should be used for alpha blending.
  22349. */
  22350. protected _shouldUseAlphaFromAlbedoTexture(): boolean;
  22351. /**
  22352. * Specifies whether or not there is a usable alpha channel for transparency.
  22353. */
  22354. protected _hasAlphaChannel(): boolean;
  22355. /**
  22356. * Gets the texture used for the alpha test.
  22357. */
  22358. getAlphaTestTexture(): Nullable<BaseTexture>;
  22359. /**
  22360. * Specifies that the submesh is ready to be used.
  22361. * @param mesh - BJS mesh.
  22362. * @param subMesh - A submesh of the BJS mesh. Used to check if it is ready.
  22363. * @param useInstances - Specifies that instances should be used.
  22364. * @returns - boolean indicating that the submesh is ready or not.
  22365. */
  22366. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  22367. /**
  22368. * Specifies if the material uses metallic roughness workflow.
  22369. * @returns boolean specifying if the material uses metallic roughness workflow.
  22370. */
  22371. isMetallicWorkflow(): boolean;
  22372. private _prepareEffect;
  22373. private _prepareDefines;
  22374. /**
  22375. * Force shader compilation
  22376. */
  22377. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<IMaterialCompilationOptions>): void;
  22378. /**
  22379. * Initializes the uniform buffer layout for the shader.
  22380. */
  22381. buildUniformLayout(): void;
  22382. /**
  22383. * Unbinds the material from the mesh
  22384. */
  22385. unbind(): void;
  22386. /**
  22387. * Binds the submesh data.
  22388. * @param world - The world matrix.
  22389. * @param mesh - The BJS mesh.
  22390. * @param subMesh - A submesh of the BJS mesh.
  22391. */
  22392. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  22393. /**
  22394. * Returns the animatable textures.
  22395. * @returns - Array of animatable textures.
  22396. */
  22397. getAnimatables(): IAnimatable[];
  22398. /**
  22399. * Returns the texture used for reflections.
  22400. * @returns - Reflection texture if present. Otherwise, returns the environment texture.
  22401. */
  22402. private _getReflectionTexture;
  22403. /**
  22404. * Returns an array of the actively used textures.
  22405. * @returns - Array of BaseTextures
  22406. */
  22407. getActiveTextures(): BaseTexture[];
  22408. /**
  22409. * Checks to see if a texture is used in the material.
  22410. * @param texture - Base texture to use.
  22411. * @returns - Boolean specifying if a texture is used in the material.
  22412. */
  22413. hasTexture(texture: BaseTexture): boolean;
  22414. /**
  22415. * Sets the required values to the prepass renderer.
  22416. * @param prePassRenderer defines the prepass renderer to setup
  22417. */
  22418. setPrePassRenderer(prePassRenderer: PrePassRenderer): boolean;
  22419. /**
  22420. * Disposes the resources of the material.
  22421. * @param forceDisposeEffect - Forces the disposal of effects.
  22422. * @param forceDisposeTextures - Forces the disposal of all textures.
  22423. */
  22424. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  22425. }
  22426. }
  22427. declare module BABYLON {
  22428. /**
  22429. * The Physically based material of BJS.
  22430. *
  22431. * This offers the main features of a standard PBR material.
  22432. * For more information, please refer to the documentation :
  22433. * https://doc.babylonjs.com/how_to/physically_based_rendering
  22434. */
  22435. export class PBRMaterial extends PBRBaseMaterial {
  22436. /**
  22437. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  22438. */
  22439. static readonly PBRMATERIAL_OPAQUE: number;
  22440. /**
  22441. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  22442. */
  22443. static readonly PBRMATERIAL_ALPHATEST: number;
  22444. /**
  22445. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  22446. */
  22447. static readonly PBRMATERIAL_ALPHABLEND: number;
  22448. /**
  22449. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  22450. * They are also discarded below the alpha cutoff threshold to improve performances.
  22451. */
  22452. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  22453. /**
  22454. * Defines the default value of how much AO map is occluding the analytical lights
  22455. * (point spot...).
  22456. */
  22457. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  22458. /**
  22459. * Intensity of the direct lights e.g. the four lights available in your scene.
  22460. * This impacts both the direct diffuse and specular highlights.
  22461. */
  22462. directIntensity: number;
  22463. /**
  22464. * Intensity of the emissive part of the material.
  22465. * This helps controlling the emissive effect without modifying the emissive color.
  22466. */
  22467. emissiveIntensity: number;
  22468. /**
  22469. * Intensity of the environment e.g. how much the environment will light the object
  22470. * either through harmonics for rough material or through the reflection for shiny ones.
  22471. */
  22472. environmentIntensity: number;
  22473. /**
  22474. * This is a special control allowing the reduction of the specular highlights coming from the
  22475. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  22476. */
  22477. specularIntensity: number;
  22478. /**
  22479. * Debug Control allowing disabling the bump map on this material.
  22480. */
  22481. disableBumpMap: boolean;
  22482. /**
  22483. * AKA Diffuse Texture in standard nomenclature.
  22484. */
  22485. albedoTexture: BaseTexture;
  22486. /**
  22487. * AKA Occlusion Texture in other nomenclature.
  22488. */
  22489. ambientTexture: BaseTexture;
  22490. /**
  22491. * AKA Occlusion Texture Intensity in other nomenclature.
  22492. */
  22493. ambientTextureStrength: number;
  22494. /**
  22495. * Defines how much the AO map is occluding the analytical lights (point spot...).
  22496. * 1 means it completely occludes it
  22497. * 0 mean it has no impact
  22498. */
  22499. ambientTextureImpactOnAnalyticalLights: number;
  22500. /**
  22501. * Stores the alpha values in a texture. Use luminance if texture.getAlphaFromRGB is true.
  22502. */
  22503. opacityTexture: BaseTexture;
  22504. /**
  22505. * Stores the reflection values in a texture.
  22506. */
  22507. reflectionTexture: Nullable<BaseTexture>;
  22508. /**
  22509. * Stores the emissive values in a texture.
  22510. */
  22511. emissiveTexture: BaseTexture;
  22512. /**
  22513. * AKA Specular texture in other nomenclature.
  22514. */
  22515. reflectivityTexture: BaseTexture;
  22516. /**
  22517. * Used to switch from specular/glossiness to metallic/roughness workflow.
  22518. */
  22519. metallicTexture: BaseTexture;
  22520. /**
  22521. * Specifies the metallic scalar of the metallic/roughness workflow.
  22522. * Can also be used to scale the metalness values of the metallic texture.
  22523. */
  22524. metallic: Nullable<number>;
  22525. /**
  22526. * Specifies the roughness scalar of the metallic/roughness workflow.
  22527. * Can also be used to scale the roughness values of the metallic texture.
  22528. */
  22529. roughness: Nullable<number>;
  22530. /**
  22531. * In metallic workflow, specifies an F0 factor to help configuring the material F0.
  22532. * By default the indexOfrefraction is used to compute F0;
  22533. *
  22534. * This is used as a factor against the default reflectance at normal incidence to tweak it.
  22535. *
  22536. * F0 = defaultF0 * metallicF0Factor * metallicReflectanceColor;
  22537. * F90 = metallicReflectanceColor;
  22538. */
  22539. metallicF0Factor: number;
  22540. /**
  22541. * In metallic workflow, specifies an F90 color to help configuring the material F90.
  22542. * By default the F90 is always 1;
  22543. *
  22544. * Please note that this factor is also used as a factor against the default reflectance at normal incidence.
  22545. *
  22546. * F0 = defaultF0 * metallicF0Factor * metallicReflectanceColor
  22547. * F90 = metallicReflectanceColor;
  22548. */
  22549. metallicReflectanceColor: Color3;
  22550. /**
  22551. * Defines to store metallicReflectanceColor in RGB and metallicF0Factor in A
  22552. * This is multiply against the scalar values defined in the material.
  22553. */
  22554. metallicReflectanceTexture: Nullable<BaseTexture>;
  22555. /**
  22556. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  22557. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  22558. */
  22559. microSurfaceTexture: BaseTexture;
  22560. /**
  22561. * Stores surface normal data used to displace a mesh in a texture.
  22562. */
  22563. bumpTexture: BaseTexture;
  22564. /**
  22565. * Stores the pre-calculated light information of a mesh in a texture.
  22566. */
  22567. lightmapTexture: BaseTexture;
  22568. /**
  22569. * Stores the refracted light information in a texture.
  22570. */
  22571. get refractionTexture(): Nullable<BaseTexture>;
  22572. set refractionTexture(value: Nullable<BaseTexture>);
  22573. /**
  22574. * The color of a material in ambient lighting.
  22575. */
  22576. ambientColor: Color3;
  22577. /**
  22578. * AKA Diffuse Color in other nomenclature.
  22579. */
  22580. albedoColor: Color3;
  22581. /**
  22582. * AKA Specular Color in other nomenclature.
  22583. */
  22584. reflectivityColor: Color3;
  22585. /**
  22586. * The color reflected from the material.
  22587. */
  22588. reflectionColor: Color3;
  22589. /**
  22590. * The color emitted from the material.
  22591. */
  22592. emissiveColor: Color3;
  22593. /**
  22594. * AKA Glossiness in other nomenclature.
  22595. */
  22596. microSurface: number;
  22597. /**
  22598. * Index of refraction of the material base layer.
  22599. * https://en.wikipedia.org/wiki/List_of_refractive_indices
  22600. *
  22601. * This does not only impact refraction but also the Base F0 of Dielectric Materials.
  22602. *
  22603. * From dielectric fresnel rules: F0 = square((iorT - iorI) / (iorT + iorI))
  22604. */
  22605. get indexOfRefraction(): number;
  22606. set indexOfRefraction(value: number);
  22607. /**
  22608. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  22609. */
  22610. get invertRefractionY(): boolean;
  22611. set invertRefractionY(value: boolean);
  22612. /**
  22613. * This parameters will make the material used its opacity to control how much it is refracting against not.
  22614. * Materials half opaque for instance using refraction could benefit from this control.
  22615. */
  22616. get linkRefractionWithTransparency(): boolean;
  22617. set linkRefractionWithTransparency(value: boolean);
  22618. /**
  22619. * If true, the light map contains occlusion information instead of lighting info.
  22620. */
  22621. useLightmapAsShadowmap: boolean;
  22622. /**
  22623. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  22624. */
  22625. useAlphaFromAlbedoTexture: boolean;
  22626. /**
  22627. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  22628. */
  22629. forceAlphaTest: boolean;
  22630. /**
  22631. * Defines the alpha limits in alpha test mode.
  22632. */
  22633. alphaCutOff: number;
  22634. /**
  22635. * Specifies that the material will keep the specular highlights over a transparent surface (only the most luminous ones).
  22636. * A car glass is a good example of that. When sun reflects on it you can not see what is behind.
  22637. */
  22638. useSpecularOverAlpha: boolean;
  22639. /**
  22640. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  22641. */
  22642. useMicroSurfaceFromReflectivityMapAlpha: boolean;
  22643. /**
  22644. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  22645. */
  22646. useRoughnessFromMetallicTextureAlpha: boolean;
  22647. /**
  22648. * Specifies if the metallic texture contains the roughness information in its green channel.
  22649. */
  22650. useRoughnessFromMetallicTextureGreen: boolean;
  22651. /**
  22652. * Specifies if the metallic texture contains the metallness information in its blue channel.
  22653. */
  22654. useMetallnessFromMetallicTextureBlue: boolean;
  22655. /**
  22656. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  22657. */
  22658. useAmbientOcclusionFromMetallicTextureRed: boolean;
  22659. /**
  22660. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  22661. */
  22662. useAmbientInGrayScale: boolean;
  22663. /**
  22664. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  22665. * The material will try to infer what glossiness each pixel should be.
  22666. */
  22667. useAutoMicroSurfaceFromReflectivityMap: boolean;
  22668. /**
  22669. * BJS is using an hardcoded light falloff based on a manually sets up range.
  22670. * In PBR, one way to represents the falloff is to use the inverse squared root algorithm.
  22671. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  22672. */
  22673. get usePhysicalLightFalloff(): boolean;
  22674. /**
  22675. * BJS is using an hardcoded light falloff based on a manually sets up range.
  22676. * In PBR, one way to represents the falloff is to use the inverse squared root algorithm.
  22677. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  22678. */
  22679. set usePhysicalLightFalloff(value: boolean);
  22680. /**
  22681. * In order to support the falloff compatibility with gltf, a special mode has been added
  22682. * to reproduce the gltf light falloff.
  22683. */
  22684. get useGLTFLightFalloff(): boolean;
  22685. /**
  22686. * In order to support the falloff compatibility with gltf, a special mode has been added
  22687. * to reproduce the gltf light falloff.
  22688. */
  22689. set useGLTFLightFalloff(value: boolean);
  22690. /**
  22691. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most luminous ones).
  22692. * A car glass is a good example of that. When the street lights reflects on it you can not see what is behind.
  22693. */
  22694. useRadianceOverAlpha: boolean;
  22695. /**
  22696. * Allows using an object space normal map (instead of tangent space).
  22697. */
  22698. useObjectSpaceNormalMap: boolean;
  22699. /**
  22700. * Allows using the bump map in parallax mode.
  22701. */
  22702. useParallax: boolean;
  22703. /**
  22704. * Allows using the bump map in parallax occlusion mode.
  22705. */
  22706. useParallaxOcclusion: boolean;
  22707. /**
  22708. * Controls the scale bias of the parallax mode.
  22709. */
  22710. parallaxScaleBias: number;
  22711. /**
  22712. * If sets to true, disables all the lights affecting the material.
  22713. */
  22714. disableLighting: boolean;
  22715. /**
  22716. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  22717. */
  22718. forceIrradianceInFragment: boolean;
  22719. /**
  22720. * Number of Simultaneous lights allowed on the material.
  22721. */
  22722. maxSimultaneousLights: number;
  22723. /**
  22724. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  22725. */
  22726. invertNormalMapX: boolean;
  22727. /**
  22728. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  22729. */
  22730. invertNormalMapY: boolean;
  22731. /**
  22732. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  22733. */
  22734. twoSidedLighting: boolean;
  22735. /**
  22736. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  22737. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  22738. */
  22739. useAlphaFresnel: boolean;
  22740. /**
  22741. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  22742. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  22743. */
  22744. useLinearAlphaFresnel: boolean;
  22745. /**
  22746. * Let user defines the brdf lookup texture used for IBL.
  22747. * A default 8bit version is embedded but you could point at :
  22748. * * Default texture: https://assets.babylonjs.com/environments/correlatedMSBRDF_RGBD.png
  22749. * * Default 16bit pixel depth texture: https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  22750. * * LEGACY Default None correlated https://assets.babylonjs.com/environments/uncorrelatedBRDF_RGBD.png
  22751. * * LEGACY Default None correlated 16bit pixel depth https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  22752. */
  22753. environmentBRDFTexture: Nullable<BaseTexture>;
  22754. /**
  22755. * Force normal to face away from face.
  22756. */
  22757. forceNormalForward: boolean;
  22758. /**
  22759. * Enables specular anti aliasing in the PBR shader.
  22760. * It will both interacts on the Geometry for analytical and IBL lighting.
  22761. * It also prefilter the roughness map based on the bump values.
  22762. */
  22763. enableSpecularAntiAliasing: boolean;
  22764. /**
  22765. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  22766. * makes the reflect vector face the model (under horizon).
  22767. */
  22768. useHorizonOcclusion: boolean;
  22769. /**
  22770. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  22771. * too much the area relying on ambient texture to define their ambient occlusion.
  22772. */
  22773. useRadianceOcclusion: boolean;
  22774. /**
  22775. * If set to true, no lighting calculations will be applied.
  22776. */
  22777. unlit: boolean;
  22778. /**
  22779. * Gets the image processing configuration used either in this material.
  22780. */
  22781. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  22782. /**
  22783. * Sets the Default image processing configuration used either in the this material.
  22784. *
  22785. * If sets to null, the scene one is in use.
  22786. */
  22787. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  22788. /**
  22789. * Gets whether the color curves effect is enabled.
  22790. */
  22791. get cameraColorCurvesEnabled(): boolean;
  22792. /**
  22793. * Sets whether the color curves effect is enabled.
  22794. */
  22795. set cameraColorCurvesEnabled(value: boolean);
  22796. /**
  22797. * Gets whether the color grading effect is enabled.
  22798. */
  22799. get cameraColorGradingEnabled(): boolean;
  22800. /**
  22801. * Gets whether the color grading effect is enabled.
  22802. */
  22803. set cameraColorGradingEnabled(value: boolean);
  22804. /**
  22805. * Gets whether tonemapping is enabled or not.
  22806. */
  22807. get cameraToneMappingEnabled(): boolean;
  22808. /**
  22809. * Sets whether tonemapping is enabled or not
  22810. */
  22811. set cameraToneMappingEnabled(value: boolean);
  22812. /**
  22813. * The camera exposure used on this material.
  22814. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  22815. * This corresponds to a photographic exposure.
  22816. */
  22817. get cameraExposure(): number;
  22818. /**
  22819. * The camera exposure used on this material.
  22820. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  22821. * This corresponds to a photographic exposure.
  22822. */
  22823. set cameraExposure(value: number);
  22824. /**
  22825. * Gets The camera contrast used on this material.
  22826. */
  22827. get cameraContrast(): number;
  22828. /**
  22829. * Sets The camera contrast used on this material.
  22830. */
  22831. set cameraContrast(value: number);
  22832. /**
  22833. * Gets the Color Grading 2D Lookup Texture.
  22834. */
  22835. get cameraColorGradingTexture(): Nullable<BaseTexture>;
  22836. /**
  22837. * Sets the Color Grading 2D Lookup Texture.
  22838. */
  22839. set cameraColorGradingTexture(value: Nullable<BaseTexture>);
  22840. /**
  22841. * The color grading curves provide additional color adjustment that is applied after any color grading transform (3D LUT).
  22842. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  22843. * 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;
  22844. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  22845. */
  22846. get cameraColorCurves(): Nullable<ColorCurves>;
  22847. /**
  22848. * The color grading curves provide additional color adjustment that is applied after any color grading transform (3D LUT).
  22849. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  22850. * 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;
  22851. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  22852. */
  22853. set cameraColorCurves(value: Nullable<ColorCurves>);
  22854. /**
  22855. * Instantiates a new PBRMaterial instance.
  22856. *
  22857. * @param name The material name
  22858. * @param scene The scene the material will be use in.
  22859. */
  22860. constructor(name: string, scene: Scene);
  22861. /**
  22862. * Returns the name of this material class.
  22863. */
  22864. getClassName(): string;
  22865. /**
  22866. * Makes a duplicate of the current material.
  22867. * @param name - name to use for the new material.
  22868. */
  22869. clone(name: string): PBRMaterial;
  22870. /**
  22871. * Serializes this PBR Material.
  22872. * @returns - An object with the serialized material.
  22873. */
  22874. serialize(): any;
  22875. /**
  22876. * Parses a PBR Material from a serialized object.
  22877. * @param source - Serialized object.
  22878. * @param scene - BJS scene instance.
  22879. * @param rootUrl - url for the scene object
  22880. * @returns - PBRMaterial
  22881. */
  22882. static Parse(source: any, scene: Scene, rootUrl: string): PBRMaterial;
  22883. }
  22884. }
  22885. declare module BABYLON {
  22886. /** @hidden */
  22887. export var mrtFragmentDeclaration: {
  22888. name: string;
  22889. shader: string;
  22890. };
  22891. }
  22892. declare module BABYLON {
  22893. /** @hidden */
  22894. export var geometryPixelShader: {
  22895. name: string;
  22896. shader: string;
  22897. };
  22898. }
  22899. declare module BABYLON {
  22900. /** @hidden */
  22901. export var instancesDeclaration: {
  22902. name: string;
  22903. shader: string;
  22904. };
  22905. }
  22906. declare module BABYLON {
  22907. /** @hidden */
  22908. export var geometryVertexDeclaration: {
  22909. name: string;
  22910. shader: string;
  22911. };
  22912. }
  22913. declare module BABYLON {
  22914. /** @hidden */
  22915. export var geometryUboDeclaration: {
  22916. name: string;
  22917. shader: string;
  22918. };
  22919. }
  22920. declare module BABYLON {
  22921. /** @hidden */
  22922. export var geometryVertexShader: {
  22923. name: string;
  22924. shader: string;
  22925. };
  22926. }
  22927. declare module BABYLON {
  22928. /** @hidden */
  22929. interface ISavedTransformationMatrix {
  22930. world: Matrix;
  22931. viewProjection: Matrix;
  22932. }
  22933. /**
  22934. * This renderer is helpfull to fill one of the render target with a geometry buffer.
  22935. */
  22936. export class GeometryBufferRenderer {
  22937. /**
  22938. * Constant used to retrieve the depth texture index in the G-Buffer textures array
  22939. * using getIndex(GeometryBufferRenderer.DEPTH_TEXTURE_INDEX)
  22940. */
  22941. static readonly DEPTH_TEXTURE_TYPE: number;
  22942. /**
  22943. * Constant used to retrieve the normal texture index in the G-Buffer textures array
  22944. * using getIndex(GeometryBufferRenderer.NORMAL_TEXTURE_INDEX)
  22945. */
  22946. static readonly NORMAL_TEXTURE_TYPE: number;
  22947. /**
  22948. * Constant used to retrieve the position texture index in the G-Buffer textures array
  22949. * using getIndex(GeometryBufferRenderer.POSITION_TEXTURE_INDEX)
  22950. */
  22951. static readonly POSITION_TEXTURE_TYPE: number;
  22952. /**
  22953. * Constant used to retrieve the velocity texture index in the G-Buffer textures array
  22954. * using getIndex(GeometryBufferRenderer.VELOCITY_TEXTURE_INDEX)
  22955. */
  22956. static readonly VELOCITY_TEXTURE_TYPE: number;
  22957. /**
  22958. * Constant used to retrieve the reflectivity texture index in the G-Buffer textures array
  22959. * using the getIndex(GeometryBufferRenderer.REFLECTIVITY_TEXTURE_TYPE)
  22960. */
  22961. static readonly REFLECTIVITY_TEXTURE_TYPE: number;
  22962. /**
  22963. * Dictionary used to store the previous transformation matrices of each rendered mesh
  22964. * in order to compute objects velocities when enableVelocity is set to "true"
  22965. * @hidden
  22966. */
  22967. _previousTransformationMatrices: {
  22968. [index: number]: ISavedTransformationMatrix;
  22969. };
  22970. /**
  22971. * Dictionary used to store the previous bones transformation matrices of each rendered mesh
  22972. * in order to compute objects velocities when enableVelocity is set to "true"
  22973. * @hidden
  22974. */
  22975. _previousBonesTransformationMatrices: {
  22976. [index: number]: Float32Array;
  22977. };
  22978. /**
  22979. * Array used to store the ignored skinned meshes while computing velocity map (typically used by the motion blur post-process).
  22980. * Avoids computing bones velocities and computes only mesh's velocity itself (position, rotation, scaling).
  22981. */
  22982. excludedSkinnedMeshesFromVelocity: AbstractMesh[];
  22983. /** Gets or sets a boolean indicating if transparent meshes should be rendered */
  22984. renderTransparentMeshes: boolean;
  22985. private _scene;
  22986. private _resizeObserver;
  22987. private _multiRenderTarget;
  22988. private _ratio;
  22989. private _enablePosition;
  22990. private _enableVelocity;
  22991. private _enableReflectivity;
  22992. private _positionIndex;
  22993. private _velocityIndex;
  22994. private _reflectivityIndex;
  22995. private _depthIndex;
  22996. private _normalIndex;
  22997. private _linkedWithPrePass;
  22998. private _prePassRenderer;
  22999. private _attachments;
  23000. private _useUbo;
  23001. protected _effect: Effect;
  23002. protected _cachedDefines: string;
  23003. /**
  23004. * @hidden
  23005. * Sets up internal structures to share outputs with PrePassRenderer
  23006. * This method should only be called by the PrePassRenderer itself
  23007. */
  23008. _linkPrePassRenderer(prePassRenderer: PrePassRenderer): void;
  23009. /**
  23010. * @hidden
  23011. * Separates internal structures from PrePassRenderer so the geometry buffer can now operate by itself.
  23012. * This method should only be called by the PrePassRenderer itself
  23013. */
  23014. _unlinkPrePassRenderer(): void;
  23015. /**
  23016. * @hidden
  23017. * Resets the geometry buffer layout
  23018. */
  23019. _resetLayout(): void;
  23020. /**
  23021. * @hidden
  23022. * Replaces a texture in the geometry buffer renderer
  23023. * Useful when linking textures of the prepass renderer
  23024. */
  23025. _forceTextureType(geometryBufferType: number, index: number): void;
  23026. /**
  23027. * @hidden
  23028. * Sets texture attachments
  23029. * Useful when linking textures of the prepass renderer
  23030. */
  23031. _setAttachments(attachments: number[]): void;
  23032. /**
  23033. * @hidden
  23034. * Replaces the first texture which is hard coded as a depth texture in the geometry buffer
  23035. * Useful when linking textures of the prepass renderer
  23036. */
  23037. _linkInternalTexture(internalTexture: InternalTexture): void;
  23038. /**
  23039. * Gets the render list (meshes to be rendered) used in the G buffer.
  23040. */
  23041. get renderList(): Nullable<AbstractMesh[]>;
  23042. /**
  23043. * Set the render list (meshes to be rendered) used in the G buffer.
  23044. */
  23045. set renderList(meshes: Nullable<AbstractMesh[]>);
  23046. /**
  23047. * Gets wether or not G buffer are supported by the running hardware.
  23048. * This requires draw buffer supports
  23049. */
  23050. get isSupported(): boolean;
  23051. /**
  23052. * Returns the index of the given texture type in the G-Buffer textures array
  23053. * @param textureType The texture type constant. For example GeometryBufferRenderer.POSITION_TEXTURE_INDEX
  23054. * @returns the index of the given texture type in the G-Buffer textures array
  23055. */
  23056. getTextureIndex(textureType: number): number;
  23057. /**
  23058. * Gets a boolean indicating if objects positions are enabled for the G buffer.
  23059. */
  23060. get enablePosition(): boolean;
  23061. /**
  23062. * Sets whether or not objects positions are enabled for the G buffer.
  23063. */
  23064. set enablePosition(enable: boolean);
  23065. /**
  23066. * Gets a boolean indicating if objects velocities are enabled for the G buffer.
  23067. */
  23068. get enableVelocity(): boolean;
  23069. /**
  23070. * Sets wether or not objects velocities are enabled for the G buffer.
  23071. */
  23072. set enableVelocity(enable: boolean);
  23073. /**
  23074. * Gets a boolean indicating if objects roughness are enabled in the G buffer.
  23075. */
  23076. get enableReflectivity(): boolean;
  23077. /**
  23078. * Sets wether or not objects roughness are enabled for the G buffer.
  23079. */
  23080. set enableReflectivity(enable: boolean);
  23081. /**
  23082. * Gets the scene associated with the buffer.
  23083. */
  23084. get scene(): Scene;
  23085. /**
  23086. * Gets the ratio used by the buffer during its creation.
  23087. * How big is the buffer related to the main canvas.
  23088. */
  23089. get ratio(): number;
  23090. /** @hidden */
  23091. static _SceneComponentInitialization: (scene: Scene) => void;
  23092. /**
  23093. * Creates a new G Buffer for the scene
  23094. * @param scene The scene the buffer belongs to
  23095. * @param ratio How big is the buffer related to the main canvas.
  23096. */
  23097. constructor(scene: Scene, ratio?: number);
  23098. /**
  23099. * Checks wether everything is ready to render a submesh to the G buffer.
  23100. * @param subMesh the submesh to check readiness for
  23101. * @param useInstances is the mesh drawn using instance or not
  23102. * @returns true if ready otherwise false
  23103. */
  23104. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  23105. /**
  23106. * Gets the current underlying G Buffer.
  23107. * @returns the buffer
  23108. */
  23109. getGBuffer(): MultiRenderTarget;
  23110. /**
  23111. * Gets the number of samples used to render the buffer (anti aliasing).
  23112. */
  23113. get samples(): number;
  23114. /**
  23115. * Sets the number of samples used to render the buffer (anti aliasing).
  23116. */
  23117. set samples(value: number);
  23118. /**
  23119. * Disposes the renderer and frees up associated resources.
  23120. */
  23121. dispose(): void;
  23122. private _assignRenderTargetIndices;
  23123. protected _createRenderTargets(): void;
  23124. private _copyBonesTransformationMatrices;
  23125. }
  23126. }
  23127. declare module BABYLON {
  23128. /**
  23129. * Renders a pre pass of the scene
  23130. * This means every mesh in the scene will be rendered to a render target texture
  23131. * And then this texture will be composited to the rendering canvas with post processes
  23132. * It is necessary for effects like subsurface scattering or deferred shading
  23133. */
  23134. export class PrePassRenderer {
  23135. /** @hidden */
  23136. static _SceneComponentInitialization: (scene: Scene) => void;
  23137. /**
  23138. * To save performance, we can excluded skinned meshes from the prepass
  23139. */
  23140. excludedSkinnedMesh: AbstractMesh[];
  23141. /**
  23142. * Force material to be excluded from the prepass
  23143. * Can be useful when `useGeometryBufferFallback` is set to `true`
  23144. * and you don't want a material to show in the effect.
  23145. */
  23146. excludedMaterials: Material[];
  23147. private _scene;
  23148. private _engine;
  23149. /**
  23150. * Number of textures in the multi render target texture where the scene is directly rendered
  23151. */
  23152. mrtCount: number;
  23153. private _mrtFormats;
  23154. private _mrtLayout;
  23155. private _textureIndices;
  23156. private _multiRenderAttachments;
  23157. private _defaultAttachments;
  23158. private _clearAttachments;
  23159. /**
  23160. * Returns the index of a texture in the multi render target texture array.
  23161. * @param type Texture type
  23162. * @return The index
  23163. */
  23164. getIndex(type: number): number;
  23165. /**
  23166. * How many samples are used for MSAA of the scene render target
  23167. */
  23168. get samples(): number;
  23169. set samples(n: number);
  23170. private static _textureFormats;
  23171. private _isDirty;
  23172. /**
  23173. * The render target where the scene is directly rendered
  23174. */
  23175. defaultRT: PrePassRenderTarget;
  23176. /**
  23177. * Configuration for prepass effects
  23178. */
  23179. private _effectConfigurations;
  23180. /**
  23181. * @return the prepass render target for the rendering pass.
  23182. * If we are currently rendering a render target, it returns the PrePassRenderTarget
  23183. * associated with that render target. Otherwise, it returns the scene default PrePassRenderTarget
  23184. */
  23185. getRenderTarget(): PrePassRenderTarget;
  23186. /**
  23187. * @hidden
  23188. * Managed by the scene component
  23189. * @param prePassRenderTarget
  23190. */
  23191. _setRenderTarget(prePassRenderTarget: Nullable<PrePassRenderTarget>): void;
  23192. /**
  23193. * Returns true if the currently rendered prePassRenderTarget is the one
  23194. * associated with the scene.
  23195. */
  23196. get currentRTisSceneRT(): boolean;
  23197. private _geometryBuffer;
  23198. /**
  23199. * Prevents the PrePassRenderer from using the GeometryBufferRenderer as a fallback
  23200. */
  23201. doNotUseGeometryRendererFallback: boolean;
  23202. private _refreshGeometryBufferRendererLink;
  23203. private _currentTarget;
  23204. /**
  23205. * All the render targets generated by prepass
  23206. */
  23207. renderTargets: PrePassRenderTarget[];
  23208. private readonly _clearColor;
  23209. private _enabled;
  23210. private _needsCompositionForThisPass;
  23211. private _postProcessesSourceForThisPass;
  23212. /**
  23213. * Indicates if the prepass is enabled
  23214. */
  23215. get enabled(): boolean;
  23216. /**
  23217. * Set to true to disable gamma transform in PrePass.
  23218. * Can be useful in case you already proceed to gamma transform on a material level
  23219. * and your post processes don't need to be in linear color space.
  23220. */
  23221. disableGammaTransform: boolean;
  23222. /**
  23223. * Instanciates a prepass renderer
  23224. * @param scene The scene
  23225. */
  23226. constructor(scene: Scene);
  23227. /**
  23228. * Creates a new PrePassRenderTarget
  23229. * This should be the only way to instanciate a `PrePassRenderTarget`
  23230. * @param name Name of the `PrePassRenderTarget`
  23231. * @param renderTargetTexture RenderTarget the `PrePassRenderTarget` will be attached to.
  23232. * Can be `null` if the created `PrePassRenderTarget` is attached to the scene (default framebuffer).
  23233. * @hidden
  23234. */
  23235. _createRenderTarget(name: string, renderTargetTexture: Nullable<RenderTargetTexture>): PrePassRenderTarget;
  23236. /**
  23237. * Indicates if rendering a prepass is supported
  23238. */
  23239. get isSupported(): boolean;
  23240. /**
  23241. * Sets the proper output textures to draw in the engine.
  23242. * @param effect The effect that is drawn. It can be or not be compatible with drawing to several output textures.
  23243. * @param subMesh Submesh on which the effect is applied
  23244. */
  23245. bindAttachmentsForEffect(effect: Effect, subMesh: SubMesh): void;
  23246. private _reinitializeAttachments;
  23247. private _resetLayout;
  23248. private _updateGeometryBufferLayout;
  23249. /**
  23250. * Restores attachments for single texture draw.
  23251. */
  23252. restoreAttachments(): void;
  23253. /**
  23254. * @hidden
  23255. */
  23256. _beforeDraw(camera?: Camera, faceIndex?: number, layer?: number): void;
  23257. private _prepareFrame;
  23258. private _renderPostProcesses;
  23259. /**
  23260. * @hidden
  23261. */
  23262. _afterDraw(faceIndex?: number, layer?: number): void;
  23263. /**
  23264. * Clears the current prepass render target (in the sense of settings pixels to the scene clear color value)
  23265. * @hidden
  23266. */
  23267. _clear(): void;
  23268. private _bindFrameBuffer;
  23269. private _setEnabled;
  23270. private _setRenderTargetEnabled;
  23271. /**
  23272. * Adds an effect configuration to the prepass render target.
  23273. * If an effect has already been added, it won't add it twice and will return the configuration
  23274. * already present.
  23275. * @param cfg the effect configuration
  23276. * @return the effect configuration now used by the prepass
  23277. */
  23278. addEffectConfiguration(cfg: PrePassEffectConfiguration): PrePassEffectConfiguration;
  23279. private _enable;
  23280. private _disable;
  23281. private _getPostProcessesSource;
  23282. private _setupOutputForThisPass;
  23283. private _linkInternalTexture;
  23284. private _needsImageProcessing;
  23285. private _hasImageProcessing;
  23286. /**
  23287. * Internal, gets the first post proces.
  23288. * @returns the first post process to be run on this camera.
  23289. */
  23290. private _getFirstPostProcess;
  23291. /**
  23292. * Marks the prepass renderer as dirty, triggering a check if the prepass is necessary for the next rendering.
  23293. */
  23294. markAsDirty(): void;
  23295. /**
  23296. * Enables a texture on the MultiRenderTarget for prepass
  23297. */
  23298. private _enableTextures;
  23299. private _update;
  23300. private _markAllMaterialsAsPrePassDirty;
  23301. /**
  23302. * Disposes the prepass renderer.
  23303. */
  23304. dispose(): void;
  23305. }
  23306. }
  23307. declare module BABYLON {
  23308. /**
  23309. * Size options for a post process
  23310. */
  23311. export type PostProcessOptions = {
  23312. width: number;
  23313. height: number;
  23314. };
  23315. /**
  23316. * PostProcess can be used to apply a shader to a texture after it has been rendered
  23317. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  23318. */
  23319. export class PostProcess {
  23320. /**
  23321. * Gets or sets the unique id of the post process
  23322. */
  23323. uniqueId: number;
  23324. /** Name of the PostProcess. */
  23325. name: string;
  23326. /**
  23327. * Width of the texture to apply the post process on
  23328. */
  23329. width: number;
  23330. /**
  23331. * Height of the texture to apply the post process on
  23332. */
  23333. height: number;
  23334. /**
  23335. * Gets the node material used to create this postprocess (null if the postprocess was manually created)
  23336. */
  23337. nodeMaterialSource: Nullable<NodeMaterial>;
  23338. /**
  23339. * Internal, reference to the location where this postprocess was output to. (Typically the texture on the next postprocess in the chain)
  23340. * @hidden
  23341. */
  23342. _outputTexture: Nullable<InternalTexture>;
  23343. /**
  23344. * Sampling mode used by the shader
  23345. * See https://doc.babylonjs.com/classes/3.1/texture
  23346. */
  23347. renderTargetSamplingMode: number;
  23348. /**
  23349. * Clear color to use when screen clearing
  23350. */
  23351. clearColor: Color4;
  23352. /**
  23353. * If the buffer needs to be cleared before applying the post process. (default: true)
  23354. * Should be set to false if shader will overwrite all previous pixels.
  23355. */
  23356. autoClear: boolean;
  23357. /**
  23358. * Type of alpha mode to use when performing the post process (default: Engine.ALPHA_DISABLE)
  23359. */
  23360. alphaMode: number;
  23361. /**
  23362. * Sets the setAlphaBlendConstants of the babylon engine
  23363. */
  23364. alphaConstants: Color4;
  23365. /**
  23366. * Animations to be used for the post processing
  23367. */
  23368. animations: Animation[];
  23369. /**
  23370. * Enable Pixel Perfect mode where texture is not scaled to be power of 2.
  23371. * Can only be used on a single postprocess or on the last one of a chain. (default: false)
  23372. */
  23373. enablePixelPerfectMode: boolean;
  23374. /**
  23375. * Force the postprocess to be applied without taking in account viewport
  23376. */
  23377. forceFullscreenViewport: boolean;
  23378. /**
  23379. * List of inspectable custom properties (used by the Inspector)
  23380. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  23381. */
  23382. inspectableCustomProperties: IInspectable[];
  23383. /**
  23384. * Scale mode for the post process (default: Engine.SCALEMODE_FLOOR)
  23385. *
  23386. * | Value | Type | Description |
  23387. * | ----- | ----------------------------------- | ----------- |
  23388. * | 1 | SCALEMODE_FLOOR | [engine.scalemode_floor](https://doc.babylonjs.com/api/classes/babylon.engine#scalemode_floor) |
  23389. * | 2 | SCALEMODE_NEAREST | [engine.scalemode_nearest](https://doc.babylonjs.com/api/classes/babylon.engine#scalemode_nearest) |
  23390. * | 3 | SCALEMODE_CEILING | [engine.scalemode_ceiling](https://doc.babylonjs.com/api/classes/babylon.engine#scalemode_ceiling) |
  23391. *
  23392. */
  23393. scaleMode: number;
  23394. /**
  23395. * Force textures to be a power of two (default: false)
  23396. */
  23397. alwaysForcePOT: boolean;
  23398. private _samples;
  23399. /**
  23400. * Number of sample textures (default: 1)
  23401. */
  23402. get samples(): number;
  23403. set samples(n: number);
  23404. /**
  23405. * Modify the scale of the post process to be the same as the viewport (default: false)
  23406. */
  23407. adaptScaleToCurrentViewport: boolean;
  23408. private _camera;
  23409. protected _scene: Scene;
  23410. private _engine;
  23411. private _options;
  23412. private _reusable;
  23413. private _renderId;
  23414. private _textureType;
  23415. private _textureFormat;
  23416. /**
  23417. * Smart array of input and output textures for the post process.
  23418. * @hidden
  23419. */
  23420. _textures: SmartArray<InternalTexture>;
  23421. /**
  23422. * Smart array of input and output textures for the post process.
  23423. * @hidden
  23424. */
  23425. private _textureCache;
  23426. /**
  23427. * The index in _textures that corresponds to the output texture.
  23428. * @hidden
  23429. */
  23430. _currentRenderTextureInd: number;
  23431. private _effect;
  23432. private _samplers;
  23433. private _fragmentUrl;
  23434. private _vertexUrl;
  23435. private _parameters;
  23436. protected _postProcessDefines: Nullable<string>;
  23437. private _scaleRatio;
  23438. protected _indexParameters: any;
  23439. private _shareOutputWithPostProcess;
  23440. private _texelSize;
  23441. /** @hidden */
  23442. _forcedOutputTexture: Nullable<InternalTexture>;
  23443. /**
  23444. * Prepass configuration in case this post process needs a texture from prepass
  23445. * @hidden
  23446. */
  23447. _prePassEffectConfiguration: PrePassEffectConfiguration;
  23448. /**
  23449. * Returns the fragment url or shader name used in the post process.
  23450. * @returns the fragment url or name in the shader store.
  23451. */
  23452. getEffectName(): string;
  23453. /**
  23454. * An event triggered when the postprocess is activated.
  23455. */
  23456. onActivateObservable: Observable<Camera>;
  23457. private _onActivateObserver;
  23458. /**
  23459. * A function that is added to the onActivateObservable
  23460. */
  23461. set onActivate(callback: Nullable<(camera: Camera) => void>);
  23462. /**
  23463. * An event triggered when the postprocess changes its size.
  23464. */
  23465. onSizeChangedObservable: Observable<PostProcess>;
  23466. private _onSizeChangedObserver;
  23467. /**
  23468. * A function that is added to the onSizeChangedObservable
  23469. */
  23470. set onSizeChanged(callback: (postProcess: PostProcess) => void);
  23471. /**
  23472. * An event triggered when the postprocess applies its effect.
  23473. */
  23474. onApplyObservable: Observable<Effect>;
  23475. private _onApplyObserver;
  23476. /**
  23477. * A function that is added to the onApplyObservable
  23478. */
  23479. set onApply(callback: (effect: Effect) => void);
  23480. /**
  23481. * An event triggered before rendering the postprocess
  23482. */
  23483. onBeforeRenderObservable: Observable<Effect>;
  23484. private _onBeforeRenderObserver;
  23485. /**
  23486. * A function that is added to the onBeforeRenderObservable
  23487. */
  23488. set onBeforeRender(callback: (effect: Effect) => void);
  23489. /**
  23490. * An event triggered after rendering the postprocess
  23491. */
  23492. onAfterRenderObservable: Observable<Effect>;
  23493. private _onAfterRenderObserver;
  23494. /**
  23495. * A function that is added to the onAfterRenderObservable
  23496. */
  23497. set onAfterRender(callback: (efect: Effect) => void);
  23498. /**
  23499. * 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
  23500. * render it's output into this texture and this texture will be used as textureSampler in the fragment shader of this post process.
  23501. */
  23502. get inputTexture(): InternalTexture;
  23503. set inputTexture(value: InternalTexture);
  23504. /**
  23505. * Since inputTexture should always be defined, if we previously manually set `inputTexture`,
  23506. * the only way to unset it is to use this function to restore its internal state
  23507. */
  23508. restoreDefaultInputTexture(): void;
  23509. /**
  23510. * Gets the camera which post process is applied to.
  23511. * @returns The camera the post process is applied to.
  23512. */
  23513. getCamera(): Camera;
  23514. /**
  23515. * Gets the texel size of the postprocess.
  23516. * See https://en.wikipedia.org/wiki/Texel_(graphics)
  23517. */
  23518. get texelSize(): Vector2;
  23519. /**
  23520. * Creates a new instance PostProcess
  23521. * @param name The name of the PostProcess.
  23522. * @param fragmentUrl The url of the fragment shader to be used.
  23523. * @param parameters Array of the names of uniform non-sampler2D variables that will be passed to the shader.
  23524. * @param samplers Array of the names of uniform sampler2D variables that will be passed to the shader.
  23525. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  23526. * @param camera The camera to apply the render pass to.
  23527. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  23528. * @param engine The engine which the post process will be applied. (default: current engine)
  23529. * @param reusable If the post process can be reused on the same frame. (default: false)
  23530. * @param defines String of defines that will be set when running the fragment shader. (default: null)
  23531. * @param textureType Type of textures used when performing the post process. (default: 0)
  23532. * @param vertexUrl The url of the vertex shader to be used. (default: "postprocess")
  23533. * @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
  23534. * @param blockCompilation If the shader should not be compiled immediatly. (default: false)
  23535. * @param textureFormat Format of textures used when performing the post process. (default: TEXTUREFORMAT_RGBA)
  23536. */
  23537. 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);
  23538. /**
  23539. * Gets a string identifying the name of the class
  23540. * @returns "PostProcess" string
  23541. */
  23542. getClassName(): string;
  23543. /**
  23544. * Gets the engine which this post process belongs to.
  23545. * @returns The engine the post process was enabled with.
  23546. */
  23547. getEngine(): Engine;
  23548. /**
  23549. * The effect that is created when initializing the post process.
  23550. * @returns The created effect corresponding the the postprocess.
  23551. */
  23552. getEffect(): Effect;
  23553. /**
  23554. * To avoid multiple redundant textures for multiple post process, the output the output texture for this post process can be shared with another.
  23555. * @param postProcess The post process to share the output with.
  23556. * @returns This post process.
  23557. */
  23558. shareOutputWith(postProcess: PostProcess): PostProcess;
  23559. /**
  23560. * Reverses the effect of calling shareOutputWith and returns the post process back to its original state.
  23561. * This should be called if the post process that shares output with this post process is disabled/disposed.
  23562. */
  23563. useOwnOutput(): void;
  23564. /**
  23565. * Updates the effect with the current post process compile time values and recompiles the shader.
  23566. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  23567. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  23568. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  23569. * @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
  23570. * @param onCompiled Called when the shader has been compiled.
  23571. * @param onError Called if there is an error when compiling a shader.
  23572. * @param vertexUrl The url of the vertex shader to be used (default: the one given at construction time)
  23573. * @param fragmentUrl The url of the fragment shader to be used (default: the one given at construction time)
  23574. */
  23575. 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;
  23576. /**
  23577. * The post process is reusable if it can be used multiple times within one frame.
  23578. * @returns If the post process is reusable
  23579. */
  23580. isReusable(): boolean;
  23581. /** invalidate frameBuffer to hint the postprocess to create a depth buffer */
  23582. markTextureDirty(): void;
  23583. private _createRenderTargetTexture;
  23584. private _flushTextureCache;
  23585. private _resize;
  23586. /**
  23587. * Activates the post process by intializing the textures to be used when executed. Notifies onActivateObservable.
  23588. * 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.
  23589. * @param camera The camera that will be used in the post process. This camera will be used when calling onActivateObservable.
  23590. * @param sourceTexture The source texture to be inspected to get the width and height if not specified in the post process constructor. (default: null)
  23591. * @param forceDepthStencil If true, a depth and stencil buffer will be generated. (default: false)
  23592. * @returns The target texture that was bound to be written to.
  23593. */
  23594. activate(camera: Nullable<Camera>, sourceTexture?: Nullable<InternalTexture>, forceDepthStencil?: boolean): InternalTexture;
  23595. /**
  23596. * If the post process is supported.
  23597. */
  23598. get isSupported(): boolean;
  23599. /**
  23600. * The aspect ratio of the output texture.
  23601. */
  23602. get aspectRatio(): number;
  23603. /**
  23604. * Get a value indicating if the post-process is ready to be used
  23605. * @returns true if the post-process is ready (shader is compiled)
  23606. */
  23607. isReady(): boolean;
  23608. /**
  23609. * Binds all textures and uniforms to the shader, this will be run on every pass.
  23610. * @returns the effect corresponding to this post process. Null if not compiled or not ready.
  23611. */
  23612. apply(): Nullable<Effect>;
  23613. private _disposeTextures;
  23614. private _disposeTextureCache;
  23615. /**
  23616. * Sets the required values to the prepass renderer.
  23617. * @param prePassRenderer defines the prepass renderer to setup.
  23618. * @returns true if the pre pass is needed.
  23619. */
  23620. setPrePassRenderer(prePassRenderer: PrePassRenderer): boolean;
  23621. /**
  23622. * Disposes the post process.
  23623. * @param camera The camera to dispose the post process on.
  23624. */
  23625. dispose(camera?: Camera): void;
  23626. /**
  23627. * Serializes the particle system to a JSON object
  23628. * @returns the JSON object
  23629. */
  23630. serialize(): any;
  23631. /**
  23632. * Clones this post process
  23633. * @returns a new post process similar to this one
  23634. */
  23635. clone(): Nullable<PostProcess>;
  23636. /**
  23637. * Creates a material from parsed material data
  23638. * @param parsedPostProcess defines parsed post process data
  23639. * @param scene defines the hosting scene
  23640. * @param rootUrl defines the root URL to use to load textures
  23641. * @returns a new post process
  23642. */
  23643. static Parse(parsedPostProcess: any, scene: Scene, rootUrl: string): Nullable<PostProcess>;
  23644. /** @hidden */
  23645. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): Nullable<PostProcess>;
  23646. }
  23647. }
  23648. declare module BABYLON {
  23649. /** @hidden */
  23650. export var kernelBlurVaryingDeclaration: {
  23651. name: string;
  23652. shader: string;
  23653. };
  23654. }
  23655. declare module BABYLON {
  23656. /** @hidden */
  23657. export var packingFunctions: {
  23658. name: string;
  23659. shader: string;
  23660. };
  23661. }
  23662. declare module BABYLON {
  23663. /** @hidden */
  23664. export var kernelBlurFragment: {
  23665. name: string;
  23666. shader: string;
  23667. };
  23668. }
  23669. declare module BABYLON {
  23670. /** @hidden */
  23671. export var kernelBlurFragment2: {
  23672. name: string;
  23673. shader: string;
  23674. };
  23675. }
  23676. declare module BABYLON {
  23677. /** @hidden */
  23678. export var kernelBlurPixelShader: {
  23679. name: string;
  23680. shader: string;
  23681. };
  23682. }
  23683. declare module BABYLON {
  23684. /** @hidden */
  23685. export var kernelBlurVertex: {
  23686. name: string;
  23687. shader: string;
  23688. };
  23689. }
  23690. declare module BABYLON {
  23691. /** @hidden */
  23692. export var kernelBlurVertexShader: {
  23693. name: string;
  23694. shader: string;
  23695. };
  23696. }
  23697. declare module BABYLON {
  23698. /**
  23699. * The Blur Post Process which blurs an image based on a kernel and direction.
  23700. * Can be used twice in x and y directions to perform a guassian blur in two passes.
  23701. */
  23702. export class BlurPostProcess extends PostProcess {
  23703. private blockCompilation;
  23704. protected _kernel: number;
  23705. protected _idealKernel: number;
  23706. protected _packedFloat: boolean;
  23707. private _staticDefines;
  23708. /** The direction in which to blur the image. */
  23709. direction: Vector2;
  23710. /**
  23711. * Sets the length in pixels of the blur sample region
  23712. */
  23713. set kernel(v: number);
  23714. /**
  23715. * Gets the length in pixels of the blur sample region
  23716. */
  23717. get kernel(): number;
  23718. /**
  23719. * Sets wether or not the blur needs to unpack/repack floats
  23720. */
  23721. set packedFloat(v: boolean);
  23722. /**
  23723. * Gets wether or not the blur is unpacking/repacking floats
  23724. */
  23725. get packedFloat(): boolean;
  23726. /**
  23727. * Gets a string identifying the name of the class
  23728. * @returns "BlurPostProcess" string
  23729. */
  23730. getClassName(): string;
  23731. /**
  23732. * Creates a new instance BlurPostProcess
  23733. * @param name The name of the effect.
  23734. * @param direction The direction in which to blur the image.
  23735. * @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.
  23736. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  23737. * @param camera The camera to apply the render pass to.
  23738. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  23739. * @param engine The engine which the post process will be applied. (default: current engine)
  23740. * @param reusable If the post process can be reused on the same frame. (default: false)
  23741. * @param textureType Type of textures used when performing the post process. (default: 0)
  23742. * @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)
  23743. */
  23744. 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);
  23745. /**
  23746. * Updates the effect with the current post process compile time values and recompiles the shader.
  23747. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  23748. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  23749. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  23750. * @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
  23751. * @param onCompiled Called when the shader has been compiled.
  23752. * @param onError Called if there is an error when compiling a shader.
  23753. */
  23754. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  23755. protected _updateParameters(onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  23756. /**
  23757. * Best kernels are odd numbers that when divided by 2, their integer part is even, so 5, 9 or 13.
  23758. * Other odd kernels optimize correctly but require proportionally more samples, even kernels are
  23759. * possible but will produce minor visual artifacts. Since each new kernel requires a new shader we
  23760. * want to minimize kernel changes, having gaps between physical kernels is helpful in that regard.
  23761. * The gaps between physical kernels are compensated for in the weighting of the samples
  23762. * @param idealKernel Ideal blur kernel.
  23763. * @return Nearest best kernel.
  23764. */
  23765. protected _nearestBestKernel(idealKernel: number): number;
  23766. /**
  23767. * Calculates the value of a Gaussian distribution with sigma 3 at a given point.
  23768. * @param x The point on the Gaussian distribution to sample.
  23769. * @return the value of the Gaussian function at x.
  23770. */
  23771. protected _gaussianWeight(x: number): number;
  23772. /**
  23773. * Generates a string that can be used as a floating point number in GLSL.
  23774. * @param x Value to print.
  23775. * @param decimalFigures Number of decimal places to print the number to (excluding trailing 0s).
  23776. * @return GLSL float string.
  23777. */
  23778. protected _glslFloat(x: number, decimalFigures?: number): string;
  23779. /** @hidden */
  23780. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): Nullable<BlurPostProcess>;
  23781. }
  23782. }
  23783. declare module BABYLON {
  23784. /**
  23785. * Mirror texture can be used to simulate the view from a mirror in a scene.
  23786. * It will dynamically be rendered every frame to adapt to the camera point of view.
  23787. * You can then easily use it as a reflectionTexture on a flat surface.
  23788. * In case the surface is not a plane, please consider relying on reflection probes.
  23789. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  23790. */
  23791. export class MirrorTexture extends RenderTargetTexture {
  23792. private scene;
  23793. /**
  23794. * Define the reflection plane we want to use. The mirrorPlane is usually set to the constructed reflector.
  23795. * 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.
  23796. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  23797. */
  23798. mirrorPlane: Plane;
  23799. /**
  23800. * Define the blur ratio used to blur the reflection if needed.
  23801. */
  23802. set blurRatio(value: number);
  23803. get blurRatio(): number;
  23804. /**
  23805. * Define the adaptive blur kernel used to blur the reflection if needed.
  23806. * This will autocompute the closest best match for the `blurKernel`
  23807. */
  23808. set adaptiveBlurKernel(value: number);
  23809. /**
  23810. * Define the blur kernel used to blur the reflection if needed.
  23811. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  23812. */
  23813. set blurKernel(value: number);
  23814. /**
  23815. * Define the blur kernel on the X Axis used to blur the reflection if needed.
  23816. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  23817. */
  23818. set blurKernelX(value: number);
  23819. get blurKernelX(): number;
  23820. /**
  23821. * Define the blur kernel on the Y Axis used to blur the reflection if needed.
  23822. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  23823. */
  23824. set blurKernelY(value: number);
  23825. get blurKernelY(): number;
  23826. private _autoComputeBlurKernel;
  23827. protected _onRatioRescale(): void;
  23828. private _updateGammaSpace;
  23829. private _imageProcessingConfigChangeObserver;
  23830. private _transformMatrix;
  23831. private _mirrorMatrix;
  23832. private _blurX;
  23833. private _blurY;
  23834. private _adaptiveBlurKernel;
  23835. private _blurKernelX;
  23836. private _blurKernelY;
  23837. private _blurRatio;
  23838. /**
  23839. * Instantiates a Mirror Texture.
  23840. * Mirror texture can be used to simulate the view from a mirror in a scene.
  23841. * It will dynamically be rendered every frame to adapt to the camera point of view.
  23842. * You can then easily use it as a reflectionTexture on a flat surface.
  23843. * In case the surface is not a plane, please consider relying on reflection probes.
  23844. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  23845. * @param name
  23846. * @param size
  23847. * @param scene
  23848. * @param generateMipMaps
  23849. * @param type
  23850. * @param samplingMode
  23851. * @param generateDepthBuffer
  23852. */
  23853. constructor(name: string, size: number | {
  23854. width: number;
  23855. height: number;
  23856. } | {
  23857. ratio: number;
  23858. }, scene: Scene, generateMipMaps?: boolean, type?: number, samplingMode?: number, generateDepthBuffer?: boolean);
  23859. private _preparePostProcesses;
  23860. /**
  23861. * Clone the mirror texture.
  23862. * @returns the cloned texture
  23863. */
  23864. clone(): MirrorTexture;
  23865. /**
  23866. * Serialize the texture to a JSON representation you could use in Parse later on
  23867. * @returns the serialized JSON representation
  23868. */
  23869. serialize(): any;
  23870. /**
  23871. * Dispose the texture and release its associated resources.
  23872. */
  23873. dispose(): void;
  23874. }
  23875. }
  23876. declare module BABYLON {
  23877. /**
  23878. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  23879. * @see https://doc.babylonjs.com/babylon101/materials#texture
  23880. */
  23881. export class Texture extends BaseTexture {
  23882. /**
  23883. * Gets or sets a general boolean used to indicate that textures containing direct data (buffers) must be saved as part of the serialization process
  23884. */
  23885. static SerializeBuffers: boolean;
  23886. /**
  23887. * Gets or sets a general boolean used to indicate that texture buffers must be saved as part of the serialization process.
  23888. * If no buffer exists, one will be created as base64 string from the internal webgl data.
  23889. */
  23890. static ForceSerializeBuffers: boolean;
  23891. /** @hidden */
  23892. static _CubeTextureParser: (jsonTexture: any, scene: Scene, rootUrl: string) => CubeTexture;
  23893. /** @hidden */
  23894. static _CreateMirror: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => MirrorTexture;
  23895. /** @hidden */
  23896. static _CreateRenderTargetTexture: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => RenderTargetTexture;
  23897. /** nearest is mag = nearest and min = nearest and mip = linear */
  23898. static readonly NEAREST_SAMPLINGMODE: number;
  23899. /** nearest is mag = nearest and min = nearest and mip = linear */
  23900. static readonly NEAREST_NEAREST_MIPLINEAR: number;
  23901. /** Bilinear is mag = linear and min = linear and mip = nearest */
  23902. static readonly BILINEAR_SAMPLINGMODE: number;
  23903. /** Bilinear is mag = linear and min = linear and mip = nearest */
  23904. static readonly LINEAR_LINEAR_MIPNEAREST: number;
  23905. /** Trilinear is mag = linear and min = linear and mip = linear */
  23906. static readonly TRILINEAR_SAMPLINGMODE: number;
  23907. /** Trilinear is mag = linear and min = linear and mip = linear */
  23908. static readonly LINEAR_LINEAR_MIPLINEAR: number;
  23909. /** mag = nearest and min = nearest and mip = nearest */
  23910. static readonly NEAREST_NEAREST_MIPNEAREST: number;
  23911. /** mag = nearest and min = linear and mip = nearest */
  23912. static readonly NEAREST_LINEAR_MIPNEAREST: number;
  23913. /** mag = nearest and min = linear and mip = linear */
  23914. static readonly NEAREST_LINEAR_MIPLINEAR: number;
  23915. /** mag = nearest and min = linear and mip = none */
  23916. static readonly NEAREST_LINEAR: number;
  23917. /** mag = nearest and min = nearest and mip = none */
  23918. static readonly NEAREST_NEAREST: number;
  23919. /** mag = linear and min = nearest and mip = nearest */
  23920. static readonly LINEAR_NEAREST_MIPNEAREST: number;
  23921. /** mag = linear and min = nearest and mip = linear */
  23922. static readonly LINEAR_NEAREST_MIPLINEAR: number;
  23923. /** mag = linear and min = linear and mip = none */
  23924. static readonly LINEAR_LINEAR: number;
  23925. /** mag = linear and min = nearest and mip = none */
  23926. static readonly LINEAR_NEAREST: number;
  23927. /** Explicit coordinates mode */
  23928. static readonly EXPLICIT_MODE: number;
  23929. /** Spherical coordinates mode */
  23930. static readonly SPHERICAL_MODE: number;
  23931. /** Planar coordinates mode */
  23932. static readonly PLANAR_MODE: number;
  23933. /** Cubic coordinates mode */
  23934. static readonly CUBIC_MODE: number;
  23935. /** Projection coordinates mode */
  23936. static readonly PROJECTION_MODE: number;
  23937. /** Inverse Cubic coordinates mode */
  23938. static readonly SKYBOX_MODE: number;
  23939. /** Inverse Cubic coordinates mode */
  23940. static readonly INVCUBIC_MODE: number;
  23941. /** Equirectangular coordinates mode */
  23942. static readonly EQUIRECTANGULAR_MODE: number;
  23943. /** Equirectangular Fixed coordinates mode */
  23944. static readonly FIXED_EQUIRECTANGULAR_MODE: number;
  23945. /** Equirectangular Fixed Mirrored coordinates mode */
  23946. static readonly FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  23947. /** Texture is not repeating outside of 0..1 UVs */
  23948. static readonly CLAMP_ADDRESSMODE: number;
  23949. /** Texture is repeating outside of 0..1 UVs */
  23950. static readonly WRAP_ADDRESSMODE: number;
  23951. /** Texture is repeating and mirrored */
  23952. static readonly MIRROR_ADDRESSMODE: number;
  23953. /**
  23954. * 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
  23955. */
  23956. static UseSerializedUrlIfAny: boolean;
  23957. /**
  23958. * Define the url of the texture.
  23959. */
  23960. url: Nullable<string>;
  23961. /**
  23962. * Define an offset on the texture to offset the u coordinates of the UVs
  23963. * @see https://doc.babylonjs.com/how_to/more_materials#offsetting
  23964. */
  23965. uOffset: number;
  23966. /**
  23967. * Define an offset on the texture to offset the v coordinates of the UVs
  23968. * @see https://doc.babylonjs.com/how_to/more_materials#offsetting
  23969. */
  23970. vOffset: number;
  23971. /**
  23972. * Define an offset on the texture to scale the u coordinates of the UVs
  23973. * @see https://doc.babylonjs.com/how_to/more_materials#tiling
  23974. */
  23975. uScale: number;
  23976. /**
  23977. * Define an offset on the texture to scale the v coordinates of the UVs
  23978. * @see https://doc.babylonjs.com/how_to/more_materials#tiling
  23979. */
  23980. vScale: number;
  23981. /**
  23982. * Define an offset on the texture to rotate around the u coordinates of the UVs
  23983. * @see https://doc.babylonjs.com/how_to/more_materials
  23984. */
  23985. uAng: number;
  23986. /**
  23987. * Define an offset on the texture to rotate around the v coordinates of the UVs
  23988. * @see https://doc.babylonjs.com/how_to/more_materials
  23989. */
  23990. vAng: number;
  23991. /**
  23992. * Define an offset on the texture to rotate around the w coordinates of the UVs (in case of 3d texture)
  23993. * @see https://doc.babylonjs.com/how_to/more_materials
  23994. */
  23995. wAng: number;
  23996. /**
  23997. * Defines the center of rotation (U)
  23998. */
  23999. uRotationCenter: number;
  24000. /**
  24001. * Defines the center of rotation (V)
  24002. */
  24003. vRotationCenter: number;
  24004. /**
  24005. * Defines the center of rotation (W)
  24006. */
  24007. wRotationCenter: number;
  24008. /**
  24009. * Sets this property to true to avoid deformations when rotating the texture with non-uniform scaling
  24010. */
  24011. homogeneousRotationInUVTransform: boolean;
  24012. /**
  24013. * Are mip maps generated for this texture or not.
  24014. */
  24015. get noMipmap(): boolean;
  24016. /**
  24017. * List of inspectable custom properties (used by the Inspector)
  24018. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  24019. */
  24020. inspectableCustomProperties: Nullable<IInspectable[]>;
  24021. private _noMipmap;
  24022. /** @hidden */
  24023. _invertY: boolean;
  24024. private _rowGenerationMatrix;
  24025. private _cachedTextureMatrix;
  24026. private _projectionModeMatrix;
  24027. private _t0;
  24028. private _t1;
  24029. private _t2;
  24030. private _cachedUOffset;
  24031. private _cachedVOffset;
  24032. private _cachedUScale;
  24033. private _cachedVScale;
  24034. private _cachedUAng;
  24035. private _cachedVAng;
  24036. private _cachedWAng;
  24037. private _cachedProjectionMatrixId;
  24038. private _cachedURotationCenter;
  24039. private _cachedVRotationCenter;
  24040. private _cachedWRotationCenter;
  24041. private _cachedHomogeneousRotationInUVTransform;
  24042. private _cachedCoordinatesMode;
  24043. /** @hidden */
  24044. protected _initialSamplingMode: number;
  24045. /** @hidden */
  24046. _buffer: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob | ImageBitmap>;
  24047. private _deleteBuffer;
  24048. protected _format: Nullable<number>;
  24049. private _delayedOnLoad;
  24050. private _delayedOnError;
  24051. private _mimeType?;
  24052. private _loaderOptions?;
  24053. /** Returns the texture mime type if it was defined by a loader (undefined else) */
  24054. get mimeType(): string | undefined;
  24055. /**
  24056. * Observable triggered once the texture has been loaded.
  24057. */
  24058. onLoadObservable: Observable<Texture>;
  24059. protected _isBlocking: boolean;
  24060. /**
  24061. * Is the texture preventing material to render while loading.
  24062. * If false, a default texture will be used instead of the loading one during the preparation step.
  24063. */
  24064. set isBlocking(value: boolean);
  24065. get isBlocking(): boolean;
  24066. /**
  24067. * Get the current sampling mode associated with the texture.
  24068. */
  24069. get samplingMode(): number;
  24070. /**
  24071. * Gets a boolean indicating if the texture needs to be inverted on the y axis during loading
  24072. */
  24073. get invertY(): boolean;
  24074. /**
  24075. * Instantiates a new texture.
  24076. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  24077. * @see https://doc.babylonjs.com/babylon101/materials#texture
  24078. * @param url defines the url of the picture to load as a texture
  24079. * @param sceneOrEngine defines the scene or engine the texture will belong to
  24080. * @param noMipmap defines if the texture will require mip maps or not
  24081. * @param invertY defines if the texture needs to be inverted on the y axis during loading
  24082. * @param samplingMode defines the sampling mode we want for the texture while fetching from it (Texture.NEAREST_SAMPLINGMODE...)
  24083. * @param onLoad defines a callback triggered when the texture has been loaded
  24084. * @param onError defines a callback triggered when an error occurred during the loading session
  24085. * @param buffer defines the buffer to load the texture from in case the texture is loaded from a buffer representation
  24086. * @param deleteBuffer defines if the buffer we are loading the texture from should be deleted after load
  24087. * @param format defines the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  24088. * @param mimeType defines an optional mime type information
  24089. * @param loaderOptions options to be passed to the loader
  24090. */
  24091. 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);
  24092. /**
  24093. * Update the url (and optional buffer) of this texture if url was null during construction.
  24094. * @param url the url of the texture
  24095. * @param buffer the buffer of the texture (defaults to null)
  24096. * @param onLoad callback called when the texture is loaded (defaults to null)
  24097. */
  24098. updateURL(url: string, buffer?: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob>, onLoad?: () => void): void;
  24099. /**
  24100. * Finish the loading sequence of a texture flagged as delayed load.
  24101. * @hidden
  24102. */
  24103. delayLoad(): void;
  24104. private _prepareRowForTextureGeneration;
  24105. /**
  24106. * Checks if the texture has the same transform matrix than another texture
  24107. * @param texture texture to check against
  24108. * @returns true if the transforms are the same, else false
  24109. */
  24110. checkTransformsAreIdentical(texture: Nullable<Texture>): boolean;
  24111. /**
  24112. * Get the current texture matrix which includes the requested offsetting, tiling and rotation components.
  24113. * @returns the transform matrix of the texture.
  24114. */
  24115. getTextureMatrix(uBase?: number): Matrix;
  24116. /**
  24117. * Get the current matrix used to apply reflection. This is useful to rotate an environment texture for instance.
  24118. * @returns The reflection texture transform
  24119. */
  24120. getReflectionTextureMatrix(): Matrix;
  24121. /**
  24122. * Clones the texture.
  24123. * @returns the cloned texture
  24124. */
  24125. clone(): Texture;
  24126. /**
  24127. * Serialize the texture to a JSON representation we can easily use in the respective Parse function.
  24128. * @returns The JSON representation of the texture
  24129. */
  24130. serialize(): any;
  24131. /**
  24132. * Get the current class name of the texture useful for serialization or dynamic coding.
  24133. * @returns "Texture"
  24134. */
  24135. getClassName(): string;
  24136. /**
  24137. * Dispose the texture and release its associated resources.
  24138. */
  24139. dispose(): void;
  24140. /**
  24141. * Parse the JSON representation of a texture in order to recreate the texture in the given scene.
  24142. * @param parsedTexture Define the JSON representation of the texture
  24143. * @param scene Define the scene the parsed texture should be instantiated in
  24144. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  24145. * @returns The parsed texture if successful
  24146. */
  24147. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<BaseTexture>;
  24148. /**
  24149. * Creates a texture from its base 64 representation.
  24150. * @param data Define the base64 payload without the data: prefix
  24151. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  24152. * @param scene Define the scene the texture should belong to
  24153. * @param noMipmap Forces the texture to not create mip map information if true
  24154. * @param invertY define if the texture needs to be inverted on the y axis during loading
  24155. * @param samplingMode define the sampling mode we want for the texture while fetching from it (Texture.NEAREST_SAMPLINGMODE...)
  24156. * @param onLoad define a callback triggered when the texture has been loaded
  24157. * @param onError define a callback triggered when an error occurred during the loading session
  24158. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  24159. * @returns the created texture
  24160. */
  24161. static CreateFromBase64String(data: string, name: string, scene: Scene, noMipmap?: boolean, invertY?: boolean, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<() => void>, format?: number): Texture;
  24162. /**
  24163. * Creates a texture from its data: representation. (data: will be added in case only the payload has been passed in)
  24164. * @param data Define the base64 payload without the data: prefix
  24165. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  24166. * @param buffer define the buffer to load the texture from in case the texture is loaded from a buffer representation
  24167. * @param scene Define the scene the texture should belong to
  24168. * @param deleteBuffer define if the buffer we are loading the texture from should be deleted after load
  24169. * @param noMipmap Forces the texture to not create mip map information if true
  24170. * @param invertY define if the texture needs to be inverted on the y axis during loading
  24171. * @param samplingMode define the sampling mode we want for the texture while fetching from it (Texture.NEAREST_SAMPLINGMODE...)
  24172. * @param onLoad define a callback triggered when the texture has been loaded
  24173. * @param onError define a callback triggered when an error occurred during the loading session
  24174. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  24175. * @returns the created texture
  24176. */
  24177. 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;
  24178. }
  24179. }
  24180. declare module BABYLON {
  24181. /**
  24182. * ThinSprite Class used to represent a thin sprite
  24183. * This is the base class for sprites but can also directly be used with ThinEngine
  24184. * @see https://doc.babylonjs.com/babylon101/sprites
  24185. */
  24186. export class ThinSprite {
  24187. /** Gets or sets the cell index in the sprite sheet */
  24188. cellIndex: number;
  24189. /** Gets or sets the cell reference in the sprite sheet, uses sprite's filename when added to sprite sheet */
  24190. cellRef: string;
  24191. /** Gets or sets the current world position */
  24192. position: IVector3Like;
  24193. /** Gets or sets the main color */
  24194. color: IColor4Like;
  24195. /** Gets or sets the width */
  24196. width: number;
  24197. /** Gets or sets the height */
  24198. height: number;
  24199. /** Gets or sets rotation angle */
  24200. angle: number;
  24201. /** Gets or sets a boolean indicating if UV coordinates should be inverted in U axis */
  24202. invertU: boolean;
  24203. /** Gets or sets a boolean indicating if UV coordinates should be inverted in B axis */
  24204. invertV: boolean;
  24205. /** Gets or sets a boolean indicating if the sprite is visible (renderable). Default is true */
  24206. isVisible: boolean;
  24207. /**
  24208. * Returns a boolean indicating if the animation is started
  24209. */
  24210. get animationStarted(): boolean;
  24211. /** Gets the initial key for the animation (setting it will restart the animation) */
  24212. get fromIndex(): number;
  24213. /** Gets or sets the end key for the animation (setting it will restart the animation) */
  24214. get toIndex(): number;
  24215. /** Gets or sets a boolean indicating if the animation is looping (setting it will restart the animation) */
  24216. get loopAnimation(): boolean;
  24217. /** Gets or sets the delay between cell changes (setting it will restart the animation) */
  24218. get delay(): number;
  24219. /** @hidden */
  24220. _xOffset: number;
  24221. /** @hidden */
  24222. _yOffset: number;
  24223. /** @hidden */
  24224. _xSize: number;
  24225. /** @hidden */
  24226. _ySize: number;
  24227. private _animationStarted;
  24228. protected _loopAnimation: boolean;
  24229. protected _fromIndex: number;
  24230. protected _toIndex: number;
  24231. protected _delay: number;
  24232. private _direction;
  24233. private _time;
  24234. private _onBaseAnimationEnd;
  24235. /**
  24236. * Creates a new Thin Sprite
  24237. */
  24238. constructor();
  24239. /**
  24240. * Starts an animation
  24241. * @param from defines the initial key
  24242. * @param to defines the end key
  24243. * @param loop defines if the animation must loop
  24244. * @param delay defines the start delay (in ms)
  24245. * @param onAnimationEnd defines a callback for when the animation ends
  24246. */
  24247. playAnimation(from: number, to: number, loop: boolean, delay: number, onAnimationEnd: Nullable<() => void>): void;
  24248. /** Stops current animation (if any) */
  24249. stopAnimation(): void;
  24250. /** @hidden */
  24251. _animate(deltaTime: number): void;
  24252. }
  24253. }
  24254. declare module BABYLON {
  24255. /** @hidden */
  24256. export var imageProcessingCompatibility: {
  24257. name: string;
  24258. shader: string;
  24259. };
  24260. }
  24261. declare module BABYLON {
  24262. /** @hidden */
  24263. export var spritesPixelShader: {
  24264. name: string;
  24265. shader: string;
  24266. };
  24267. }
  24268. declare module BABYLON {
  24269. /** @hidden */
  24270. export var spritesVertexShader: {
  24271. name: string;
  24272. shader: string;
  24273. };
  24274. }
  24275. declare module BABYLON {
  24276. /**
  24277. * Class used to render sprites.
  24278. *
  24279. * It can be used either to render Sprites or ThinSriptes with ThinEngine only.
  24280. */
  24281. export class SpriteRenderer {
  24282. /**
  24283. * Defines the texture of the spritesheet
  24284. */
  24285. texture: Nullable<ThinTexture>;
  24286. /**
  24287. * Defines the default width of a cell in the spritesheet
  24288. */
  24289. cellWidth: number;
  24290. /**
  24291. * Defines the default height of a cell in the spritesheet
  24292. */
  24293. cellHeight: number;
  24294. /**
  24295. * Blend mode use to render the particle, it can be any of
  24296. * the static Constants.ALPHA_x properties provided in this class.
  24297. * Default value is Constants.ALPHA_COMBINE
  24298. */
  24299. blendMode: number;
  24300. /**
  24301. * Gets or sets a boolean indicating if alpha mode is automatically
  24302. * reset.
  24303. */
  24304. autoResetAlpha: boolean;
  24305. /**
  24306. * Disables writing to the depth buffer when rendering the sprites.
  24307. * It can be handy to disable depth writing when using textures without alpha channel
  24308. * and setting some specific blend modes.
  24309. */
  24310. disableDepthWrite: boolean;
  24311. /**
  24312. * Gets or sets a boolean indicating if the manager must consider scene fog when rendering
  24313. */
  24314. fogEnabled: boolean;
  24315. /**
  24316. * Gets the capacity of the manager
  24317. */
  24318. get capacity(): number;
  24319. private readonly _engine;
  24320. private readonly _useVAO;
  24321. private readonly _useInstancing;
  24322. private readonly _scene;
  24323. private readonly _capacity;
  24324. private readonly _epsilon;
  24325. private _vertexBufferSize;
  24326. private _vertexData;
  24327. private _buffer;
  24328. private _vertexBuffers;
  24329. private _spriteBuffer;
  24330. private _indexBuffer;
  24331. private _effectBase;
  24332. private _effectFog;
  24333. private _vertexArrayObject;
  24334. /**
  24335. * Creates a new sprite Renderer
  24336. * @param engine defines the engine the renderer works with
  24337. * @param capacity defines the maximum allowed number of sprites
  24338. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  24339. * @param scene defines the hosting scene
  24340. */
  24341. constructor(engine: ThinEngine, capacity: number, epsilon?: number, scene?: Nullable<Scene>);
  24342. /**
  24343. * Render all child sprites
  24344. * @param sprites defines the list of sprites to render
  24345. * @param deltaTime defines the time since last frame
  24346. * @param viewMatrix defines the viewMatrix to use to render the sprites
  24347. * @param projectionMatrix defines the projectionMatrix to use to render the sprites
  24348. * @param customSpriteUpdate defines a custom function to update the sprites data before they render
  24349. */
  24350. render(sprites: ThinSprite[], deltaTime: number, viewMatrix: IMatrixLike, projectionMatrix: IMatrixLike, customSpriteUpdate?: Nullable<(sprite: ThinSprite, baseSize: ISize) => void>): void;
  24351. private _appendSpriteVertex;
  24352. /**
  24353. * Release associated resources
  24354. */
  24355. dispose(): void;
  24356. }
  24357. }
  24358. declare module BABYLON {
  24359. /**
  24360. * Defines the minimum interface to fullfil in order to be a sprite manager.
  24361. */
  24362. export interface ISpriteManager extends IDisposable {
  24363. /**
  24364. * Gets manager's name
  24365. */
  24366. name: string;
  24367. /**
  24368. * Restricts the camera to viewing objects with the same layerMask.
  24369. * A camera with a layerMask of 1 will render spriteManager.layerMask & camera.layerMask!== 0
  24370. */
  24371. layerMask: number;
  24372. /**
  24373. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  24374. */
  24375. isPickable: boolean;
  24376. /**
  24377. * Gets the hosting scene
  24378. */
  24379. scene: Scene;
  24380. /**
  24381. * Specifies the rendering group id for this mesh (0 by default)
  24382. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  24383. */
  24384. renderingGroupId: number;
  24385. /**
  24386. * Defines the list of sprites managed by the manager.
  24387. */
  24388. sprites: Array<Sprite>;
  24389. /**
  24390. * Gets or sets the spritesheet texture
  24391. */
  24392. texture: Texture;
  24393. /** Defines the default width of a cell in the spritesheet */
  24394. cellWidth: number;
  24395. /** Defines the default height of a cell in the spritesheet */
  24396. cellHeight: number;
  24397. /**
  24398. * Tests the intersection of a sprite with a specific ray.
  24399. * @param ray The ray we are sending to test the collision
  24400. * @param camera The camera space we are sending rays in
  24401. * @param predicate A predicate allowing excluding sprites from the list of object to test
  24402. * @param fastCheck defines if the first intersection will be used (and not the closest)
  24403. * @returns picking info or null.
  24404. */
  24405. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  24406. /**
  24407. * Intersects the sprites with a ray
  24408. * @param ray defines the ray to intersect with
  24409. * @param camera defines the current active camera
  24410. * @param predicate defines a predicate used to select candidate sprites
  24411. * @returns null if no hit or a PickingInfo array
  24412. */
  24413. multiIntersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean): Nullable<PickingInfo[]>;
  24414. /**
  24415. * Renders the list of sprites on screen.
  24416. */
  24417. render(): void;
  24418. }
  24419. /**
  24420. * Class used to manage multiple sprites on the same spritesheet
  24421. * @see https://doc.babylonjs.com/babylon101/sprites
  24422. */
  24423. export class SpriteManager implements ISpriteManager {
  24424. /** defines the manager's name */
  24425. name: string;
  24426. /** Define the Url to load snippets */
  24427. static SnippetUrl: string;
  24428. /** Snippet ID if the manager was created from the snippet server */
  24429. snippetId: string;
  24430. /** Gets the list of sprites */
  24431. sprites: Sprite[];
  24432. /** Gets or sets the rendering group id (0 by default) */
  24433. renderingGroupId: number;
  24434. /** Gets or sets camera layer mask */
  24435. layerMask: number;
  24436. /** Gets or sets a boolean indicating if the sprites are pickable */
  24437. isPickable: boolean;
  24438. /**
  24439. * An event triggered when the manager is disposed.
  24440. */
  24441. onDisposeObservable: Observable<SpriteManager>;
  24442. /**
  24443. * Callback called when the manager is disposed
  24444. */
  24445. set onDispose(callback: () => void);
  24446. /**
  24447. * Gets or sets the unique id of the sprite
  24448. */
  24449. uniqueId: number;
  24450. /**
  24451. * Gets the array of sprites
  24452. */
  24453. get children(): Sprite[];
  24454. /**
  24455. * Gets the hosting scene
  24456. */
  24457. get scene(): Scene;
  24458. /**
  24459. * Gets the capacity of the manager
  24460. */
  24461. get capacity(): number;
  24462. /**
  24463. * Gets or sets the spritesheet texture
  24464. */
  24465. get texture(): Texture;
  24466. set texture(value: Texture);
  24467. /** Defines the default width of a cell in the spritesheet */
  24468. get cellWidth(): number;
  24469. set cellWidth(value: number);
  24470. /** Defines the default height of a cell in the spritesheet */
  24471. get cellHeight(): number;
  24472. set cellHeight(value: number);
  24473. /** Gets or sets a boolean indicating if the manager must consider scene fog when rendering */
  24474. get fogEnabled(): boolean;
  24475. set fogEnabled(value: boolean);
  24476. /**
  24477. * Blend mode use to render the particle, it can be any of
  24478. * the static Constants.ALPHA_x properties provided in this class.
  24479. * Default value is Constants.ALPHA_COMBINE
  24480. */
  24481. get blendMode(): number;
  24482. set blendMode(blendMode: number);
  24483. /** Disables writing to the depth buffer when rendering the sprites.
  24484. * It can be handy to disable depth writing when using textures without alpha channel
  24485. * and setting some specific blend modes.
  24486. */
  24487. disableDepthWrite: boolean;
  24488. private _spriteRenderer;
  24489. /** Associative array from JSON sprite data file */
  24490. private _cellData;
  24491. /** Array of sprite names from JSON sprite data file */
  24492. private _spriteMap;
  24493. /** True when packed cell data from JSON file is ready*/
  24494. private _packedAndReady;
  24495. private _textureContent;
  24496. private _onDisposeObserver;
  24497. private _fromPacked;
  24498. private _scene;
  24499. /**
  24500. * Creates a new sprite manager
  24501. * @param name defines the manager's name
  24502. * @param imgUrl defines the sprite sheet url
  24503. * @param capacity defines the maximum allowed number of sprites
  24504. * @param cellSize defines the size of a sprite cell
  24505. * @param scene defines the hosting scene
  24506. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  24507. * @param samplingMode defines the smapling mode to use with spritesheet
  24508. * @param fromPacked set to false; do not alter
  24509. * @param spriteJSON null otherwise a JSON object defining sprite sheet data; do not alter
  24510. */
  24511. constructor(
  24512. /** defines the manager's name */
  24513. name: string, imgUrl: string, capacity: number, cellSize: any, scene: Scene, epsilon?: number, samplingMode?: number, fromPacked?: boolean, spriteJSON?: any | null);
  24514. /**
  24515. * Returns the string "SpriteManager"
  24516. * @returns "SpriteManager"
  24517. */
  24518. getClassName(): string;
  24519. private _makePacked;
  24520. private _checkTextureAlpha;
  24521. /**
  24522. * Intersects the sprites with a ray
  24523. * @param ray defines the ray to intersect with
  24524. * @param camera defines the current active camera
  24525. * @param predicate defines a predicate used to select candidate sprites
  24526. * @param fastCheck defines if a fast check only must be done (the first potential sprite is will be used and not the closer)
  24527. * @returns null if no hit or a PickingInfo
  24528. */
  24529. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  24530. /**
  24531. * Intersects the sprites with a ray
  24532. * @param ray defines the ray to intersect with
  24533. * @param camera defines the current active camera
  24534. * @param predicate defines a predicate used to select candidate sprites
  24535. * @returns null if no hit or a PickingInfo array
  24536. */
  24537. multiIntersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean): Nullable<PickingInfo[]>;
  24538. /**
  24539. * Render all child sprites
  24540. */
  24541. render(): void;
  24542. private _customUpdate;
  24543. /**
  24544. * Release associated resources
  24545. */
  24546. dispose(): void;
  24547. /**
  24548. * Serializes the sprite manager to a JSON object
  24549. * @param serializeTexture defines if the texture must be serialized as well
  24550. * @returns the JSON object
  24551. */
  24552. serialize(serializeTexture?: boolean): any;
  24553. /**
  24554. * Parses a JSON object to create a new sprite manager.
  24555. * @param parsedManager The JSON object to parse
  24556. * @param scene The scene to create the sprite managerin
  24557. * @param rootUrl The root url to use to load external dependencies like texture
  24558. * @returns the new sprite manager
  24559. */
  24560. static Parse(parsedManager: any, scene: Scene, rootUrl: string): SpriteManager;
  24561. /**
  24562. * Creates a sprite manager from a snippet saved in a remote file
  24563. * @param name defines the name of the sprite manager to create (can be null or empty to use the one from the json data)
  24564. * @param url defines the url to load from
  24565. * @param scene defines the hosting scene
  24566. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  24567. * @returns a promise that will resolve to the new sprite manager
  24568. */
  24569. static ParseFromFileAsync(name: Nullable<string>, url: string, scene: Scene, rootUrl?: string): Promise<SpriteManager>;
  24570. /**
  24571. * Creates a sprite manager from a snippet saved by the sprite editor
  24572. * @param snippetId defines the snippet to load (can be set to _BLANK to create a default one)
  24573. * @param scene defines the hosting scene
  24574. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  24575. * @returns a promise that will resolve to the new sprite manager
  24576. */
  24577. static CreateFromSnippetAsync(snippetId: string, scene: Scene, rootUrl?: string): Promise<SpriteManager>;
  24578. }
  24579. }
  24580. declare module BABYLON {
  24581. /**
  24582. * Class used to represent a sprite
  24583. * @see https://doc.babylonjs.com/babylon101/sprites
  24584. */
  24585. export class Sprite extends ThinSprite implements IAnimatable {
  24586. /** defines the name */
  24587. name: string;
  24588. /** Gets or sets the current world position */
  24589. position: Vector3;
  24590. /** Gets or sets the main color */
  24591. color: Color4;
  24592. /** Gets or sets a boolean indicating that this sprite should be disposed after animation ends */
  24593. disposeWhenFinishedAnimating: boolean;
  24594. /** Gets the list of attached animations */
  24595. animations: Nullable<Array<Animation>>;
  24596. /** Gets or sets a boolean indicating if the sprite can be picked */
  24597. isPickable: boolean;
  24598. /** Gets or sets a boolean indicating that sprite texture alpha will be used for precise picking (false by default) */
  24599. useAlphaForPicking: boolean;
  24600. /**
  24601. * Gets or sets the associated action manager
  24602. */
  24603. actionManager: Nullable<ActionManager>;
  24604. /**
  24605. * An event triggered when the control has been disposed
  24606. */
  24607. onDisposeObservable: Observable<Sprite>;
  24608. private _manager;
  24609. private _onAnimationEnd;
  24610. /**
  24611. * Gets or sets the sprite size
  24612. */
  24613. get size(): number;
  24614. set size(value: number);
  24615. /**
  24616. * Gets or sets the unique id of the sprite
  24617. */
  24618. uniqueId: number;
  24619. /**
  24620. * Gets the manager of this sprite
  24621. */
  24622. get manager(): ISpriteManager;
  24623. /**
  24624. * Creates a new Sprite
  24625. * @param name defines the name
  24626. * @param manager defines the manager
  24627. */
  24628. constructor(
  24629. /** defines the name */
  24630. name: string, manager: ISpriteManager);
  24631. /**
  24632. * Returns the string "Sprite"
  24633. * @returns "Sprite"
  24634. */
  24635. getClassName(): string;
  24636. /** Gets or sets the initial key for the animation (setting it will restart the animation) */
  24637. get fromIndex(): number;
  24638. set fromIndex(value: number);
  24639. /** Gets or sets the end key for the animation (setting it will restart the animation) */
  24640. get toIndex(): number;
  24641. set toIndex(value: number);
  24642. /** Gets or sets a boolean indicating if the animation is looping (setting it will restart the animation) */
  24643. get loopAnimation(): boolean;
  24644. set loopAnimation(value: boolean);
  24645. /** Gets or sets the delay between cell changes (setting it will restart the animation) */
  24646. get delay(): number;
  24647. set delay(value: number);
  24648. /**
  24649. * Starts an animation
  24650. * @param from defines the initial key
  24651. * @param to defines the end key
  24652. * @param loop defines if the animation must loop
  24653. * @param delay defines the start delay (in ms)
  24654. * @param onAnimationEnd defines a callback to call when animation ends
  24655. */
  24656. playAnimation(from: number, to: number, loop: boolean, delay: number, onAnimationEnd?: Nullable<() => void>): void;
  24657. private _endAnimation;
  24658. /** Release associated resources */
  24659. dispose(): void;
  24660. /**
  24661. * Serializes the sprite to a JSON object
  24662. * @returns the JSON object
  24663. */
  24664. serialize(): any;
  24665. /**
  24666. * Parses a JSON object to create a new sprite
  24667. * @param parsedSprite The JSON object to parse
  24668. * @param manager defines the hosting manager
  24669. * @returns the new sprite
  24670. */
  24671. static Parse(parsedSprite: any, manager: SpriteManager): Sprite;
  24672. }
  24673. }
  24674. declare module BABYLON {
  24675. /**
  24676. * Information about the result of picking within a scene
  24677. * @see https://doc.babylonjs.com/babylon101/picking_collisions
  24678. */
  24679. export class PickingInfo {
  24680. /** @hidden */
  24681. _pickingUnavailable: boolean;
  24682. /**
  24683. * If the pick collided with an object
  24684. */
  24685. hit: boolean;
  24686. /**
  24687. * Distance away where the pick collided
  24688. */
  24689. distance: number;
  24690. /**
  24691. * The location of pick collision
  24692. */
  24693. pickedPoint: Nullable<Vector3>;
  24694. /**
  24695. * The mesh corresponding the the pick collision
  24696. */
  24697. pickedMesh: Nullable<AbstractMesh>;
  24698. /** (See getTextureCoordinates) The barycentric U coordinate that is used when calculating the texture coordinates of the collision.*/
  24699. bu: number;
  24700. /** (See getTextureCoordinates) The barycentric V coordinate that is used when calculating the texture coordinates of the collision.*/
  24701. bv: number;
  24702. /** The index of the face on the mesh that was picked, or the index of the Line if the picked Mesh is a LinesMesh */
  24703. faceId: number;
  24704. /** The index of the face on the subMesh that was picked, or the index of the Line if the picked Mesh is a LinesMesh */
  24705. subMeshFaceId: number;
  24706. /** Id of the the submesh that was picked */
  24707. subMeshId: number;
  24708. /** If a sprite was picked, this will be the sprite the pick collided with */
  24709. pickedSprite: Nullable<Sprite>;
  24710. /** If we are picking a mesh with thin instance, this will give you the picked thin instance */
  24711. thinInstanceIndex: number;
  24712. /**
  24713. * If a mesh was used to do the picking (eg. 6dof controller) this will be populated.
  24714. */
  24715. originMesh: Nullable<AbstractMesh>;
  24716. /**
  24717. * The ray that was used to perform the picking.
  24718. */
  24719. ray: Nullable<Ray>;
  24720. /**
  24721. * Gets the normal corresponding to the face the pick collided with
  24722. * @param useWorldCoordinates If the resulting normal should be relative to the world (default: false)
  24723. * @param useVerticesNormals If the vertices normals should be used to calculate the normal instead of the normal map
  24724. * @returns The normal corresponding to the face the pick collided with
  24725. */
  24726. getNormal(useWorldCoordinates?: boolean, useVerticesNormals?: boolean): Nullable<Vector3>;
  24727. /**
  24728. * Gets the texture coordinates of where the pick occurred
  24729. * @returns the vector containing the coordinates of the texture
  24730. */
  24731. getTextureCoordinates(): Nullable<Vector2>;
  24732. }
  24733. }
  24734. declare module BABYLON {
  24735. /**
  24736. * Gather the list of pointer event types as constants.
  24737. */
  24738. export class PointerEventTypes {
  24739. /**
  24740. * 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.
  24741. */
  24742. static readonly POINTERDOWN: number;
  24743. /**
  24744. * The pointerup event is fired when a pointer is no longer active.
  24745. */
  24746. static readonly POINTERUP: number;
  24747. /**
  24748. * The pointermove event is fired when a pointer changes coordinates.
  24749. */
  24750. static readonly POINTERMOVE: number;
  24751. /**
  24752. * The pointerwheel event is fired when a mouse wheel has been rotated.
  24753. */
  24754. static readonly POINTERWHEEL: number;
  24755. /**
  24756. * The pointerpick event is fired when a mesh or sprite has been picked by the pointer.
  24757. */
  24758. static readonly POINTERPICK: number;
  24759. /**
  24760. * The pointertap event is fired when a the object has been touched and released without drag.
  24761. */
  24762. static readonly POINTERTAP: number;
  24763. /**
  24764. * The pointerdoubletap event is fired when a the object has been touched and released twice without drag.
  24765. */
  24766. static readonly POINTERDOUBLETAP: number;
  24767. }
  24768. /**
  24769. * Base class of pointer info types.
  24770. */
  24771. export class PointerInfoBase {
  24772. /**
  24773. * Defines the type of event (PointerEventTypes)
  24774. */
  24775. type: number;
  24776. /**
  24777. * Defines the related dom event
  24778. */
  24779. event: PointerEvent | MouseWheelEvent;
  24780. /**
  24781. * Instantiates the base class of pointers info.
  24782. * @param type Defines the type of event (PointerEventTypes)
  24783. * @param event Defines the related dom event
  24784. */
  24785. constructor(
  24786. /**
  24787. * Defines the type of event (PointerEventTypes)
  24788. */
  24789. type: number,
  24790. /**
  24791. * Defines the related dom event
  24792. */
  24793. event: PointerEvent | MouseWheelEvent);
  24794. }
  24795. /**
  24796. * This class is used to store pointer related info for the onPrePointerObservable event.
  24797. * Set the skipOnPointerObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onPointerObservable
  24798. */
  24799. export class PointerInfoPre extends PointerInfoBase {
  24800. /**
  24801. * Ray from a pointer if availible (eg. 6dof controller)
  24802. */
  24803. ray: Nullable<Ray>;
  24804. /**
  24805. * Defines the local position of the pointer on the canvas.
  24806. */
  24807. localPosition: Vector2;
  24808. /**
  24809. * Defines whether the engine should skip the next OnPointerObservable associated to this pre.
  24810. */
  24811. skipOnPointerObservable: boolean;
  24812. /**
  24813. * Instantiates a PointerInfoPre to store pointer related info to the onPrePointerObservable event.
  24814. * @param type Defines the type of event (PointerEventTypes)
  24815. * @param event Defines the related dom event
  24816. * @param localX Defines the local x coordinates of the pointer when the event occured
  24817. * @param localY Defines the local y coordinates of the pointer when the event occured
  24818. */
  24819. constructor(type: number, event: PointerEvent | MouseWheelEvent, localX: number, localY: number);
  24820. }
  24821. /**
  24822. * This type contains all the data related to a pointer event in Babylon.js.
  24823. * 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.
  24824. */
  24825. export class PointerInfo extends PointerInfoBase {
  24826. /**
  24827. * Defines the picking info associated to the info (if any)\
  24828. */
  24829. pickInfo: Nullable<PickingInfo>;
  24830. /**
  24831. * Instantiates a PointerInfo to store pointer related info to the onPointerObservable event.
  24832. * @param type Defines the type of event (PointerEventTypes)
  24833. * @param event Defines the related dom event
  24834. * @param pickInfo Defines the picking info associated to the info (if any)\
  24835. */
  24836. constructor(type: number, event: PointerEvent | MouseWheelEvent,
  24837. /**
  24838. * Defines the picking info associated to the info (if any)\
  24839. */
  24840. pickInfo: Nullable<PickingInfo>);
  24841. }
  24842. /**
  24843. * Data relating to a touch event on the screen.
  24844. */
  24845. export interface PointerTouch {
  24846. /**
  24847. * X coordinate of touch.
  24848. */
  24849. x: number;
  24850. /**
  24851. * Y coordinate of touch.
  24852. */
  24853. y: number;
  24854. /**
  24855. * Id of touch. Unique for each finger.
  24856. */
  24857. pointerId: number;
  24858. /**
  24859. * Event type passed from DOM.
  24860. */
  24861. type: any;
  24862. }
  24863. }
  24864. declare module BABYLON {
  24865. /**
  24866. * Manage the mouse inputs to control the movement of a free camera.
  24867. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  24868. */
  24869. export class FreeCameraMouseInput implements ICameraInput<FreeCamera> {
  24870. /**
  24871. * Define if touch is enabled in the mouse input
  24872. */
  24873. touchEnabled: boolean;
  24874. /**
  24875. * Defines the camera the input is attached to.
  24876. */
  24877. camera: FreeCamera;
  24878. /**
  24879. * Defines the buttons associated with the input to handle camera move.
  24880. */
  24881. buttons: number[];
  24882. /**
  24883. * Defines the pointer angular sensibility along the X and Y axis or how fast is the camera rotating.
  24884. */
  24885. angularSensibility: number;
  24886. private _pointerInput;
  24887. private _onMouseMove;
  24888. private _observer;
  24889. private previousPosition;
  24890. /**
  24891. * Observable for when a pointer move event occurs containing the move offset
  24892. */
  24893. onPointerMovedObservable: Observable<{
  24894. offsetX: number;
  24895. offsetY: number;
  24896. }>;
  24897. /**
  24898. * @hidden
  24899. * If the camera should be rotated automatically based on pointer movement
  24900. */
  24901. _allowCameraRotation: boolean;
  24902. /**
  24903. * Manage the mouse inputs to control the movement of a free camera.
  24904. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  24905. * @param touchEnabled Defines if touch is enabled or not
  24906. */
  24907. constructor(
  24908. /**
  24909. * Define if touch is enabled in the mouse input
  24910. */
  24911. touchEnabled?: boolean);
  24912. /**
  24913. * Attach the input controls to a specific dom element to get the input from.
  24914. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  24915. */
  24916. attachControl(noPreventDefault?: boolean): void;
  24917. /**
  24918. * Called on JS contextmenu event.
  24919. * Override this method to provide functionality.
  24920. */
  24921. protected onContextMenu(evt: PointerEvent): void;
  24922. /**
  24923. * Detach the current controls from the specified dom element.
  24924. */
  24925. detachControl(): void;
  24926. /**
  24927. * Gets the class name of the current input.
  24928. * @returns the class name
  24929. */
  24930. getClassName(): string;
  24931. /**
  24932. * Get the friendly name associated with the input class.
  24933. * @returns the input friendly name
  24934. */
  24935. getSimpleName(): string;
  24936. }
  24937. }
  24938. declare module BABYLON {
  24939. /**
  24940. * Base class for mouse wheel input..
  24941. * See FollowCameraMouseWheelInput in src/Cameras/Inputs/freeCameraMouseWheelInput.ts
  24942. * for example usage.
  24943. */
  24944. export abstract class BaseCameraMouseWheelInput implements ICameraInput<Camera> {
  24945. /**
  24946. * Defines the camera the input is attached to.
  24947. */
  24948. abstract camera: Camera;
  24949. /**
  24950. * How fast is the camera moves in relation to X axis mouseWheel events.
  24951. * Use negative value to reverse direction.
  24952. */
  24953. wheelPrecisionX: number;
  24954. /**
  24955. * How fast is the camera moves in relation to Y axis mouseWheel events.
  24956. * Use negative value to reverse direction.
  24957. */
  24958. wheelPrecisionY: number;
  24959. /**
  24960. * How fast is the camera moves in relation to Z axis mouseWheel events.
  24961. * Use negative value to reverse direction.
  24962. */
  24963. wheelPrecisionZ: number;
  24964. /**
  24965. * Observable for when a mouse wheel move event occurs.
  24966. */
  24967. onChangedObservable: Observable<{
  24968. wheelDeltaX: number;
  24969. wheelDeltaY: number;
  24970. wheelDeltaZ: number;
  24971. }>;
  24972. private _wheel;
  24973. private _observer;
  24974. /**
  24975. * Attach the input controls to a specific dom element to get the input from.
  24976. * @param noPreventDefault Defines whether event caught by the controls
  24977. * should call preventdefault().
  24978. * (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  24979. */
  24980. attachControl(noPreventDefault?: boolean): void;
  24981. /**
  24982. * Detach the current controls from the specified dom element.
  24983. */
  24984. detachControl(): void;
  24985. /**
  24986. * Called for each rendered frame.
  24987. */
  24988. checkInputs(): void;
  24989. /**
  24990. * Gets the class name of the current input.
  24991. * @returns the class name
  24992. */
  24993. getClassName(): string;
  24994. /**
  24995. * Get the friendly name associated with the input class.
  24996. * @returns the input friendly name
  24997. */
  24998. getSimpleName(): string;
  24999. /**
  25000. * Incremental value of multiple mouse wheel movements of the X axis.
  25001. * Should be zero-ed when read.
  25002. */
  25003. protected _wheelDeltaX: number;
  25004. /**
  25005. * Incremental value of multiple mouse wheel movements of the Y axis.
  25006. * Should be zero-ed when read.
  25007. */
  25008. protected _wheelDeltaY: number;
  25009. /**
  25010. * Incremental value of multiple mouse wheel movements of the Z axis.
  25011. * Should be zero-ed when read.
  25012. */
  25013. protected _wheelDeltaZ: number;
  25014. /**
  25015. * Firefox uses a different scheme to report scroll distances to other
  25016. * browsers. Rather than use complicated methods to calculate the exact
  25017. * multiple we need to apply, let's just cheat and use a constant.
  25018. * https://developer.mozilla.org/en-US/docs/Web/API/WheelEvent/deltaMode
  25019. * https://stackoverflow.com/questions/20110224/what-is-the-height-of-a-line-in-a-wheel-event-deltamode-dom-delta-line
  25020. */
  25021. private readonly _ffMultiplier;
  25022. /**
  25023. * Different event attributes for wheel data fall into a few set ranges.
  25024. * Some relevant but dated date here:
  25025. * https://stackoverflow.com/questions/5527601/normalizing-mousewheel-speed-across-browsers
  25026. */
  25027. private readonly _normalize;
  25028. }
  25029. }
  25030. declare module BABYLON {
  25031. /**
  25032. * Manage the mouse wheel inputs to control a free camera.
  25033. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  25034. */
  25035. export class FreeCameraMouseWheelInput extends BaseCameraMouseWheelInput {
  25036. /**
  25037. * Defines the camera the input is attached to.
  25038. */
  25039. camera: FreeCamera;
  25040. /**
  25041. * Gets the class name of the current input.
  25042. * @returns the class name
  25043. */
  25044. getClassName(): string;
  25045. /**
  25046. * Set which movement axis (relative to camera's orientation) the mouse
  25047. * wheel's X axis controls.
  25048. * @param axis The axis to be moved. Set null to clear.
  25049. */
  25050. set wheelXMoveRelative(axis: Nullable<Coordinate>);
  25051. /**
  25052. * Get the configured movement axis (relative to camera's orientation) the
  25053. * mouse wheel's X axis controls.
  25054. * @returns The configured axis or null if none.
  25055. */
  25056. get wheelXMoveRelative(): Nullable<Coordinate>;
  25057. /**
  25058. * Set which movement axis (relative to camera's orientation) the mouse
  25059. * wheel's Y axis controls.
  25060. * @param axis The axis to be moved. Set null to clear.
  25061. */
  25062. set wheelYMoveRelative(axis: Nullable<Coordinate>);
  25063. /**
  25064. * Get the configured movement axis (relative to camera's orientation) the
  25065. * mouse wheel's Y axis controls.
  25066. * @returns The configured axis or null if none.
  25067. */
  25068. get wheelYMoveRelative(): Nullable<Coordinate>;
  25069. /**
  25070. * Set which movement axis (relative to camera's orientation) the mouse
  25071. * wheel's Z axis controls.
  25072. * @param axis The axis to be moved. Set null to clear.
  25073. */
  25074. set wheelZMoveRelative(axis: Nullable<Coordinate>);
  25075. /**
  25076. * Get the configured movement axis (relative to camera's orientation) the
  25077. * mouse wheel's Z axis controls.
  25078. * @returns The configured axis or null if none.
  25079. */
  25080. get wheelZMoveRelative(): Nullable<Coordinate>;
  25081. /**
  25082. * Set which rotation axis (relative to camera's orientation) the mouse
  25083. * wheel's X axis controls.
  25084. * @param axis The axis to be moved. Set null to clear.
  25085. */
  25086. set wheelXRotateRelative(axis: Nullable<Coordinate>);
  25087. /**
  25088. * Get the configured rotation axis (relative to camera's orientation) the
  25089. * mouse wheel's X axis controls.
  25090. * @returns The configured axis or null if none.
  25091. */
  25092. get wheelXRotateRelative(): Nullable<Coordinate>;
  25093. /**
  25094. * Set which rotation axis (relative to camera's orientation) the mouse
  25095. * wheel's Y axis controls.
  25096. * @param axis The axis to be moved. Set null to clear.
  25097. */
  25098. set wheelYRotateRelative(axis: Nullable<Coordinate>);
  25099. /**
  25100. * Get the configured rotation axis (relative to camera's orientation) the
  25101. * mouse wheel's Y axis controls.
  25102. * @returns The configured axis or null if none.
  25103. */
  25104. get wheelYRotateRelative(): Nullable<Coordinate>;
  25105. /**
  25106. * Set which rotation axis (relative to camera's orientation) the mouse
  25107. * wheel's Z axis controls.
  25108. * @param axis The axis to be moved. Set null to clear.
  25109. */
  25110. set wheelZRotateRelative(axis: Nullable<Coordinate>);
  25111. /**
  25112. * Get the configured rotation axis (relative to camera's orientation) the
  25113. * mouse wheel's Z axis controls.
  25114. * @returns The configured axis or null if none.
  25115. */
  25116. get wheelZRotateRelative(): Nullable<Coordinate>;
  25117. /**
  25118. * Set which movement axis (relative to the scene) the mouse wheel's X axis
  25119. * controls.
  25120. * @param axis The axis to be moved. Set null to clear.
  25121. */
  25122. set wheelXMoveScene(axis: Nullable<Coordinate>);
  25123. /**
  25124. * Get the configured movement axis (relative to the scene) the mouse wheel's
  25125. * X axis controls.
  25126. * @returns The configured axis or null if none.
  25127. */
  25128. get wheelXMoveScene(): Nullable<Coordinate>;
  25129. /**
  25130. * Set which movement axis (relative to the scene) the mouse wheel's Y axis
  25131. * controls.
  25132. * @param axis The axis to be moved. Set null to clear.
  25133. */
  25134. set wheelYMoveScene(axis: Nullable<Coordinate>);
  25135. /**
  25136. * Get the configured movement axis (relative to the scene) the mouse wheel's
  25137. * Y axis controls.
  25138. * @returns The configured axis or null if none.
  25139. */
  25140. get wheelYMoveScene(): Nullable<Coordinate>;
  25141. /**
  25142. * Set which movement axis (relative to the scene) the mouse wheel's Z axis
  25143. * controls.
  25144. * @param axis The axis to be moved. Set null to clear.
  25145. */
  25146. set wheelZMoveScene(axis: Nullable<Coordinate>);
  25147. /**
  25148. * Get the configured movement axis (relative to the scene) the mouse wheel's
  25149. * Z axis controls.
  25150. * @returns The configured axis or null if none.
  25151. */
  25152. get wheelZMoveScene(): Nullable<Coordinate>;
  25153. /**
  25154. * Called for each rendered frame.
  25155. */
  25156. checkInputs(): void;
  25157. private _moveRelative;
  25158. private _rotateRelative;
  25159. private _moveScene;
  25160. /**
  25161. * These are set to the desired default behaviour.
  25162. */
  25163. private _wheelXAction;
  25164. private _wheelXActionCoordinate;
  25165. private _wheelYAction;
  25166. private _wheelYActionCoordinate;
  25167. private _wheelZAction;
  25168. private _wheelZActionCoordinate;
  25169. /**
  25170. * Update the camera according to any configured properties for the 3
  25171. * mouse-wheel axis.
  25172. */
  25173. private _updateCamera;
  25174. /**
  25175. * Update one property of the camera.
  25176. */
  25177. private _updateCameraProperty;
  25178. }
  25179. }
  25180. declare module BABYLON {
  25181. /**
  25182. * Manage the touch inputs to control the movement of a free camera.
  25183. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  25184. */
  25185. export class FreeCameraTouchInput implements ICameraInput<FreeCamera> {
  25186. /**
  25187. * Define if mouse events can be treated as touch events
  25188. */
  25189. allowMouse: boolean;
  25190. /**
  25191. * Defines the camera the input is attached to.
  25192. */
  25193. camera: FreeCamera;
  25194. /**
  25195. * Defines the touch sensibility for rotation.
  25196. * The higher the faster.
  25197. */
  25198. touchAngularSensibility: number;
  25199. /**
  25200. * Defines the touch sensibility for move.
  25201. * The higher the faster.
  25202. */
  25203. touchMoveSensibility: number;
  25204. private _offsetX;
  25205. private _offsetY;
  25206. private _pointerPressed;
  25207. private _pointerInput?;
  25208. private _observer;
  25209. private _onLostFocus;
  25210. /**
  25211. * Manage the touch inputs to control the movement of a free camera.
  25212. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  25213. * @param allowMouse Defines if mouse events can be treated as touch events
  25214. */
  25215. constructor(
  25216. /**
  25217. * Define if mouse events can be treated as touch events
  25218. */
  25219. allowMouse?: boolean);
  25220. /**
  25221. * Attach the input controls to a specific dom element to get the input from.
  25222. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  25223. */
  25224. attachControl(noPreventDefault?: boolean): void;
  25225. /**
  25226. * Detach the current controls from the specified dom element.
  25227. */
  25228. detachControl(): void;
  25229. /**
  25230. * Update the current camera state depending on the inputs that have been used this frame.
  25231. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  25232. */
  25233. checkInputs(): void;
  25234. /**
  25235. * Gets the class name of the current input.
  25236. * @returns the class name
  25237. */
  25238. getClassName(): string;
  25239. /**
  25240. * Get the friendly name associated with the input class.
  25241. * @returns the input friendly name
  25242. */
  25243. getSimpleName(): string;
  25244. }
  25245. }
  25246. declare module BABYLON {
  25247. /**
  25248. * Default Inputs manager for the FreeCamera.
  25249. * It groups all the default supported inputs for ease of use.
  25250. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  25251. */
  25252. export class FreeCameraInputsManager extends CameraInputsManager<FreeCamera> {
  25253. /**
  25254. * @hidden
  25255. */
  25256. _mouseInput: Nullable<FreeCameraMouseInput>;
  25257. /**
  25258. * @hidden
  25259. */
  25260. _mouseWheelInput: Nullable<FreeCameraMouseWheelInput>;
  25261. /**
  25262. * Instantiates a new FreeCameraInputsManager.
  25263. * @param camera Defines the camera the inputs belong to
  25264. */
  25265. constructor(camera: FreeCamera);
  25266. /**
  25267. * Add keyboard input support to the input manager.
  25268. * @returns the current input manager
  25269. */
  25270. addKeyboard(): FreeCameraInputsManager;
  25271. /**
  25272. * Add mouse input support to the input manager.
  25273. * @param touchEnabled if the FreeCameraMouseInput should support touch (default: true)
  25274. * @returns the current input manager
  25275. */
  25276. addMouse(touchEnabled?: boolean): FreeCameraInputsManager;
  25277. /**
  25278. * Removes the mouse input support from the manager
  25279. * @returns the current input manager
  25280. */
  25281. removeMouse(): FreeCameraInputsManager;
  25282. /**
  25283. * Add mouse wheel input support to the input manager.
  25284. * @returns the current input manager
  25285. */
  25286. addMouseWheel(): FreeCameraInputsManager;
  25287. /**
  25288. * Removes the mouse wheel input support from the manager
  25289. * @returns the current input manager
  25290. */
  25291. removeMouseWheel(): FreeCameraInputsManager;
  25292. /**
  25293. * Add touch input support to the input manager.
  25294. * @returns the current input manager
  25295. */
  25296. addTouch(): FreeCameraInputsManager;
  25297. /**
  25298. * Remove all attached input methods from a camera
  25299. */
  25300. clear(): void;
  25301. }
  25302. }
  25303. declare module BABYLON {
  25304. /**
  25305. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  25306. * Please consider using the new UniversalCamera instead as it adds more functionality like the gamepad.
  25307. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  25308. */
  25309. export class FreeCamera extends TargetCamera {
  25310. /**
  25311. * Define the collision ellipsoid of the camera.
  25312. * This is helpful to simulate a camera body like the player body around the camera
  25313. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  25314. */
  25315. ellipsoid: Vector3;
  25316. /**
  25317. * Define an offset for the position of the ellipsoid around the camera.
  25318. * This can be helpful to determine the center of the body near the gravity center of the body
  25319. * instead of its head.
  25320. */
  25321. ellipsoidOffset: Vector3;
  25322. /**
  25323. * Enable or disable collisions of the camera with the rest of the scene objects.
  25324. */
  25325. checkCollisions: boolean;
  25326. /**
  25327. * Enable or disable gravity on the camera.
  25328. */
  25329. applyGravity: boolean;
  25330. /**
  25331. * Define the input manager associated to the camera.
  25332. */
  25333. inputs: FreeCameraInputsManager;
  25334. /**
  25335. * Gets the input sensibility for a mouse input. (default is 2000.0)
  25336. * Higher values reduce sensitivity.
  25337. */
  25338. get angularSensibility(): number;
  25339. /**
  25340. * Sets the input sensibility for a mouse input. (default is 2000.0)
  25341. * Higher values reduce sensitivity.
  25342. */
  25343. set angularSensibility(value: number);
  25344. /**
  25345. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  25346. */
  25347. get keysUp(): number[];
  25348. set keysUp(value: number[]);
  25349. /**
  25350. * Gets or Set the list of keyboard keys used to control the upward move of the camera.
  25351. */
  25352. get keysUpward(): number[];
  25353. set keysUpward(value: number[]);
  25354. /**
  25355. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  25356. */
  25357. get keysDown(): number[];
  25358. set keysDown(value: number[]);
  25359. /**
  25360. * Gets or Set the list of keyboard keys used to control the downward move of the camera.
  25361. */
  25362. get keysDownward(): number[];
  25363. set keysDownward(value: number[]);
  25364. /**
  25365. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  25366. */
  25367. get keysLeft(): number[];
  25368. set keysLeft(value: number[]);
  25369. /**
  25370. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  25371. */
  25372. get keysRight(): number[];
  25373. set keysRight(value: number[]);
  25374. /**
  25375. * Event raised when the camera collide with a mesh in the scene.
  25376. */
  25377. onCollide: (collidedMesh: AbstractMesh) => void;
  25378. private _collider;
  25379. private _needMoveForGravity;
  25380. private _oldPosition;
  25381. private _diffPosition;
  25382. private _newPosition;
  25383. /** @hidden */
  25384. _localDirection: Vector3;
  25385. /** @hidden */
  25386. _transformedDirection: Vector3;
  25387. /**
  25388. * Instantiates a Free Camera.
  25389. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  25390. * Please consider using the new UniversalCamera instead as it adds more functionality like touch to this camera.
  25391. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  25392. * @param name Define the name of the camera in the scene
  25393. * @param position Define the start position of the camera in the scene
  25394. * @param scene Define the scene the camera belongs to
  25395. * @param setActiveOnSceneIfNoneActive Defines whether the camera should be marked as active if not other active cameras have been defined
  25396. */
  25397. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  25398. /**
  25399. * Attach the input controls to a specific dom element to get the input from.
  25400. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  25401. */
  25402. attachControl(noPreventDefault?: boolean): void;
  25403. /**
  25404. * Attach the input controls to a specific dom element to get the input from.
  25405. * @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
  25406. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  25407. * BACK COMPAT SIGNATURE ONLY.
  25408. */
  25409. attachControl(ignored: any, noPreventDefault?: boolean): void;
  25410. /**
  25411. * Detach the current controls from the specified dom element.
  25412. */
  25413. detachControl(): void;
  25414. /**
  25415. * Detach the current controls from the specified dom element.
  25416. * @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
  25417. */
  25418. detachControl(ignored: any): void;
  25419. private _collisionMask;
  25420. /**
  25421. * Define a collision mask to limit the list of object the camera can collide with
  25422. */
  25423. get collisionMask(): number;
  25424. set collisionMask(mask: number);
  25425. /** @hidden */
  25426. _collideWithWorld(displacement: Vector3): void;
  25427. private _onCollisionPositionChange;
  25428. /** @hidden */
  25429. _checkInputs(): void;
  25430. /** @hidden */
  25431. _decideIfNeedsToMove(): boolean;
  25432. /** @hidden */
  25433. _updatePosition(): void;
  25434. /**
  25435. * Destroy the camera and release the current resources hold by it.
  25436. */
  25437. dispose(): void;
  25438. /**
  25439. * Gets the current object class name.
  25440. * @return the class name
  25441. */
  25442. getClassName(): string;
  25443. }
  25444. }
  25445. declare module BABYLON {
  25446. /**
  25447. * Represents a gamepad control stick position
  25448. */
  25449. export class StickValues {
  25450. /**
  25451. * The x component of the control stick
  25452. */
  25453. x: number;
  25454. /**
  25455. * The y component of the control stick
  25456. */
  25457. y: number;
  25458. /**
  25459. * Initializes the gamepad x and y control stick values
  25460. * @param x The x component of the gamepad control stick value
  25461. * @param y The y component of the gamepad control stick value
  25462. */
  25463. constructor(
  25464. /**
  25465. * The x component of the control stick
  25466. */
  25467. x: number,
  25468. /**
  25469. * The y component of the control stick
  25470. */
  25471. y: number);
  25472. }
  25473. /**
  25474. * An interface which manages callbacks for gamepad button changes
  25475. */
  25476. export interface GamepadButtonChanges {
  25477. /**
  25478. * Called when a gamepad has been changed
  25479. */
  25480. changed: boolean;
  25481. /**
  25482. * Called when a gamepad press event has been triggered
  25483. */
  25484. pressChanged: boolean;
  25485. /**
  25486. * Called when a touch event has been triggered
  25487. */
  25488. touchChanged: boolean;
  25489. /**
  25490. * Called when a value has changed
  25491. */
  25492. valueChanged: boolean;
  25493. }
  25494. /**
  25495. * Represents a gamepad
  25496. */
  25497. export class Gamepad {
  25498. /**
  25499. * The id of the gamepad
  25500. */
  25501. id: string;
  25502. /**
  25503. * The index of the gamepad
  25504. */
  25505. index: number;
  25506. /**
  25507. * The browser gamepad
  25508. */
  25509. browserGamepad: any;
  25510. /**
  25511. * Specifies what type of gamepad this represents
  25512. */
  25513. type: number;
  25514. private _leftStick;
  25515. private _rightStick;
  25516. /** @hidden */
  25517. _isConnected: boolean;
  25518. private _leftStickAxisX;
  25519. private _leftStickAxisY;
  25520. private _rightStickAxisX;
  25521. private _rightStickAxisY;
  25522. /**
  25523. * Triggered when the left control stick has been changed
  25524. */
  25525. private _onleftstickchanged;
  25526. /**
  25527. * Triggered when the right control stick has been changed
  25528. */
  25529. private _onrightstickchanged;
  25530. /**
  25531. * Represents a gamepad controller
  25532. */
  25533. static GAMEPAD: number;
  25534. /**
  25535. * Represents a generic controller
  25536. */
  25537. static GENERIC: number;
  25538. /**
  25539. * Represents an XBox controller
  25540. */
  25541. static XBOX: number;
  25542. /**
  25543. * Represents a pose-enabled controller
  25544. */
  25545. static POSE_ENABLED: number;
  25546. /**
  25547. * Represents an Dual Shock controller
  25548. */
  25549. static DUALSHOCK: number;
  25550. /**
  25551. * Specifies whether the left control stick should be Y-inverted
  25552. */
  25553. protected _invertLeftStickY: boolean;
  25554. /**
  25555. * Specifies if the gamepad has been connected
  25556. */
  25557. get isConnected(): boolean;
  25558. /**
  25559. * Initializes the gamepad
  25560. * @param id The id of the gamepad
  25561. * @param index The index of the gamepad
  25562. * @param browserGamepad The browser gamepad
  25563. * @param leftStickX The x component of the left joystick
  25564. * @param leftStickY The y component of the left joystick
  25565. * @param rightStickX The x component of the right joystick
  25566. * @param rightStickY The y component of the right joystick
  25567. */
  25568. constructor(
  25569. /**
  25570. * The id of the gamepad
  25571. */
  25572. id: string,
  25573. /**
  25574. * The index of the gamepad
  25575. */
  25576. index: number,
  25577. /**
  25578. * The browser gamepad
  25579. */
  25580. browserGamepad: any, leftStickX?: number, leftStickY?: number, rightStickX?: number, rightStickY?: number);
  25581. /**
  25582. * Callback triggered when the left joystick has changed
  25583. * @param callback
  25584. */
  25585. onleftstickchanged(callback: (values: StickValues) => void): void;
  25586. /**
  25587. * Callback triggered when the right joystick has changed
  25588. * @param callback
  25589. */
  25590. onrightstickchanged(callback: (values: StickValues) => void): void;
  25591. /**
  25592. * Gets the left joystick
  25593. */
  25594. get leftStick(): StickValues;
  25595. /**
  25596. * Sets the left joystick values
  25597. */
  25598. set leftStick(newValues: StickValues);
  25599. /**
  25600. * Gets the right joystick
  25601. */
  25602. get rightStick(): StickValues;
  25603. /**
  25604. * Sets the right joystick value
  25605. */
  25606. set rightStick(newValues: StickValues);
  25607. /**
  25608. * Updates the gamepad joystick positions
  25609. */
  25610. update(): void;
  25611. /**
  25612. * Disposes the gamepad
  25613. */
  25614. dispose(): void;
  25615. }
  25616. /**
  25617. * Represents a generic gamepad
  25618. */
  25619. export class GenericPad extends Gamepad {
  25620. private _buttons;
  25621. private _onbuttondown;
  25622. private _onbuttonup;
  25623. /**
  25624. * Observable triggered when a button has been pressed
  25625. */
  25626. onButtonDownObservable: Observable<number>;
  25627. /**
  25628. * Observable triggered when a button has been released
  25629. */
  25630. onButtonUpObservable: Observable<number>;
  25631. /**
  25632. * Callback triggered when a button has been pressed
  25633. * @param callback Called when a button has been pressed
  25634. */
  25635. onbuttondown(callback: (buttonPressed: number) => void): void;
  25636. /**
  25637. * Callback triggered when a button has been released
  25638. * @param callback Called when a button has been released
  25639. */
  25640. onbuttonup(callback: (buttonReleased: number) => void): void;
  25641. /**
  25642. * Initializes the generic gamepad
  25643. * @param id The id of the generic gamepad
  25644. * @param index The index of the generic gamepad
  25645. * @param browserGamepad The browser gamepad
  25646. */
  25647. constructor(id: string, index: number, browserGamepad: any);
  25648. private _setButtonValue;
  25649. /**
  25650. * Updates the generic gamepad
  25651. */
  25652. update(): void;
  25653. /**
  25654. * Disposes the generic gamepad
  25655. */
  25656. dispose(): void;
  25657. }
  25658. }
  25659. declare module BABYLON {
  25660. /**
  25661. * Defines a runtime animation
  25662. */
  25663. export class RuntimeAnimation {
  25664. private _events;
  25665. /**
  25666. * The current frame of the runtime animation
  25667. */
  25668. private _currentFrame;
  25669. /**
  25670. * The animation used by the runtime animation
  25671. */
  25672. private _animation;
  25673. /**
  25674. * The target of the runtime animation
  25675. */
  25676. private _target;
  25677. /**
  25678. * The initiating animatable
  25679. */
  25680. private _host;
  25681. /**
  25682. * The original value of the runtime animation
  25683. */
  25684. private _originalValue;
  25685. /**
  25686. * The original blend value of the runtime animation
  25687. */
  25688. private _originalBlendValue;
  25689. /**
  25690. * The offsets cache of the runtime animation
  25691. */
  25692. private _offsetsCache;
  25693. /**
  25694. * The high limits cache of the runtime animation
  25695. */
  25696. private _highLimitsCache;
  25697. /**
  25698. * Specifies if the runtime animation has been stopped
  25699. */
  25700. private _stopped;
  25701. /**
  25702. * The blending factor of the runtime animation
  25703. */
  25704. private _blendingFactor;
  25705. /**
  25706. * The BabylonJS scene
  25707. */
  25708. private _scene;
  25709. /**
  25710. * The current value of the runtime animation
  25711. */
  25712. private _currentValue;
  25713. /** @hidden */
  25714. _animationState: _IAnimationState;
  25715. /**
  25716. * The active target of the runtime animation
  25717. */
  25718. private _activeTargets;
  25719. private _currentActiveTarget;
  25720. private _directTarget;
  25721. /**
  25722. * The target path of the runtime animation
  25723. */
  25724. private _targetPath;
  25725. /**
  25726. * The weight of the runtime animation
  25727. */
  25728. private _weight;
  25729. /**
  25730. * The ratio offset of the runtime animation
  25731. */
  25732. private _ratioOffset;
  25733. /**
  25734. * The previous delay of the runtime animation
  25735. */
  25736. private _previousDelay;
  25737. /**
  25738. * The previous ratio of the runtime animation
  25739. */
  25740. private _previousRatio;
  25741. private _enableBlending;
  25742. private _keys;
  25743. private _minFrame;
  25744. private _maxFrame;
  25745. private _minValue;
  25746. private _maxValue;
  25747. private _targetIsArray;
  25748. /**
  25749. * Gets the current frame of the runtime animation
  25750. */
  25751. get currentFrame(): number;
  25752. /**
  25753. * Gets the weight of the runtime animation
  25754. */
  25755. get weight(): number;
  25756. /**
  25757. * Gets the current value of the runtime animation
  25758. */
  25759. get currentValue(): any;
  25760. /**
  25761. * Gets the target path of the runtime animation
  25762. */
  25763. get targetPath(): string;
  25764. /**
  25765. * Gets the actual target of the runtime animation
  25766. */
  25767. get target(): any;
  25768. /**
  25769. * Gets the additive state of the runtime animation
  25770. */
  25771. get isAdditive(): boolean;
  25772. /** @hidden */
  25773. _onLoop: () => void;
  25774. /**
  25775. * Create a new RuntimeAnimation object
  25776. * @param target defines the target of the animation
  25777. * @param animation defines the source animation object
  25778. * @param scene defines the hosting scene
  25779. * @param host defines the initiating Animatable
  25780. */
  25781. constructor(target: any, animation: Animation, scene: Scene, host: Animatable);
  25782. private _preparePath;
  25783. /**
  25784. * Gets the animation from the runtime animation
  25785. */
  25786. get animation(): Animation;
  25787. /**
  25788. * Resets the runtime animation to the beginning
  25789. * @param restoreOriginal defines whether to restore the target property to the original value
  25790. */
  25791. reset(restoreOriginal?: boolean): void;
  25792. /**
  25793. * Specifies if the runtime animation is stopped
  25794. * @returns Boolean specifying if the runtime animation is stopped
  25795. */
  25796. isStopped(): boolean;
  25797. /**
  25798. * Disposes of the runtime animation
  25799. */
  25800. dispose(): void;
  25801. /**
  25802. * Apply the interpolated value to the target
  25803. * @param currentValue defines the value computed by the animation
  25804. * @param weight defines the weight to apply to this value (Defaults to 1.0)
  25805. */
  25806. setValue(currentValue: any, weight: number): void;
  25807. private _getOriginalValues;
  25808. private _setValue;
  25809. /**
  25810. * Gets the loop pmode of the runtime animation
  25811. * @returns Loop Mode
  25812. */
  25813. private _getCorrectLoopMode;
  25814. /**
  25815. * Move the current animation to a given frame
  25816. * @param frame defines the frame to move to
  25817. */
  25818. goToFrame(frame: number): void;
  25819. /**
  25820. * @hidden Internal use only
  25821. */
  25822. _prepareForSpeedRatioChange(newSpeedRatio: number): void;
  25823. /**
  25824. * Execute the current animation
  25825. * @param delay defines the delay to add to the current frame
  25826. * @param from defines the lower bound of the animation range
  25827. * @param to defines the upper bound of the animation range
  25828. * @param loop defines if the current animation must loop
  25829. * @param speedRatio defines the current speed ratio
  25830. * @param weight defines the weight of the animation (default is -1 so no weight)
  25831. * @param onLoop optional callback called when animation loops
  25832. * @returns a boolean indicating if the animation is running
  25833. */
  25834. animate(delay: number, from: number, to: number, loop: boolean, speedRatio: number, weight?: number): boolean;
  25835. }
  25836. }
  25837. declare module BABYLON {
  25838. /**
  25839. * Class used to store an actual running animation
  25840. */
  25841. export class Animatable {
  25842. /** defines the target object */
  25843. target: any;
  25844. /** defines the starting frame number (default is 0) */
  25845. fromFrame: number;
  25846. /** defines the ending frame number (default is 100) */
  25847. toFrame: number;
  25848. /** defines if the animation must loop (default is false) */
  25849. loopAnimation: boolean;
  25850. /** defines a callback to call when animation ends if it is not looping */
  25851. onAnimationEnd?: (() => void) | null | undefined;
  25852. /** defines a callback to call when animation loops */
  25853. onAnimationLoop?: (() => void) | null | undefined;
  25854. /** defines whether the animation should be evaluated additively */
  25855. isAdditive: boolean;
  25856. private _localDelayOffset;
  25857. private _pausedDelay;
  25858. private _runtimeAnimations;
  25859. private _paused;
  25860. private _scene;
  25861. private _speedRatio;
  25862. private _weight;
  25863. private _syncRoot;
  25864. /**
  25865. * Gets or sets a boolean indicating if the animatable must be disposed and removed at the end of the animation.
  25866. * This will only apply for non looping animation (default is true)
  25867. */
  25868. disposeOnEnd: boolean;
  25869. /**
  25870. * Gets a boolean indicating if the animation has started
  25871. */
  25872. animationStarted: boolean;
  25873. /**
  25874. * Observer raised when the animation ends
  25875. */
  25876. onAnimationEndObservable: Observable<Animatable>;
  25877. /**
  25878. * Observer raised when the animation loops
  25879. */
  25880. onAnimationLoopObservable: Observable<Animatable>;
  25881. /**
  25882. * Gets the root Animatable used to synchronize and normalize animations
  25883. */
  25884. get syncRoot(): Nullable<Animatable>;
  25885. /**
  25886. * Gets the current frame of the first RuntimeAnimation
  25887. * Used to synchronize Animatables
  25888. */
  25889. get masterFrame(): number;
  25890. /**
  25891. * Gets or sets the animatable weight (-1.0 by default meaning not weighted)
  25892. */
  25893. get weight(): number;
  25894. set weight(value: number);
  25895. /**
  25896. * Gets or sets the speed ratio to apply to the animatable (1.0 by default)
  25897. */
  25898. get speedRatio(): number;
  25899. set speedRatio(value: number);
  25900. /**
  25901. * Creates a new Animatable
  25902. * @param scene defines the hosting scene
  25903. * @param target defines the target object
  25904. * @param fromFrame defines the starting frame number (default is 0)
  25905. * @param toFrame defines the ending frame number (default is 100)
  25906. * @param loopAnimation defines if the animation must loop (default is false)
  25907. * @param speedRatio defines the factor to apply to animation speed (default is 1)
  25908. * @param onAnimationEnd defines a callback to call when animation ends if it is not looping
  25909. * @param animations defines a group of animation to add to the new Animatable
  25910. * @param onAnimationLoop defines a callback to call when animation loops
  25911. * @param isAdditive defines whether the animation should be evaluated additively
  25912. */
  25913. constructor(scene: Scene,
  25914. /** defines the target object */
  25915. target: any,
  25916. /** defines the starting frame number (default is 0) */
  25917. fromFrame?: number,
  25918. /** defines the ending frame number (default is 100) */
  25919. toFrame?: number,
  25920. /** defines if the animation must loop (default is false) */
  25921. loopAnimation?: boolean, speedRatio?: number,
  25922. /** defines a callback to call when animation ends if it is not looping */
  25923. onAnimationEnd?: (() => void) | null | undefined, animations?: Animation[],
  25924. /** defines a callback to call when animation loops */
  25925. onAnimationLoop?: (() => void) | null | undefined,
  25926. /** defines whether the animation should be evaluated additively */
  25927. isAdditive?: boolean);
  25928. /**
  25929. * Synchronize and normalize current Animatable with a source Animatable
  25930. * This is useful when using animation weights and when animations are not of the same length
  25931. * @param root defines the root Animatable to synchronize with
  25932. * @returns the current Animatable
  25933. */
  25934. syncWith(root: Animatable): Animatable;
  25935. /**
  25936. * Gets the list of runtime animations
  25937. * @returns an array of RuntimeAnimation
  25938. */
  25939. getAnimations(): RuntimeAnimation[];
  25940. /**
  25941. * Adds more animations to the current animatable
  25942. * @param target defines the target of the animations
  25943. * @param animations defines the new animations to add
  25944. */
  25945. appendAnimations(target: any, animations: Animation[]): void;
  25946. /**
  25947. * Gets the source animation for a specific property
  25948. * @param property defines the property to look for
  25949. * @returns null or the source animation for the given property
  25950. */
  25951. getAnimationByTargetProperty(property: string): Nullable<Animation>;
  25952. /**
  25953. * Gets the runtime animation for a specific property
  25954. * @param property defines the property to look for
  25955. * @returns null or the runtime animation for the given property
  25956. */
  25957. getRuntimeAnimationByTargetProperty(property: string): Nullable<RuntimeAnimation>;
  25958. /**
  25959. * Resets the animatable to its original state
  25960. */
  25961. reset(): void;
  25962. /**
  25963. * Allows the animatable to blend with current running animations
  25964. * @see https://doc.babylonjs.com/babylon101/animations#animation-blending
  25965. * @param blendingSpeed defines the blending speed to use
  25966. */
  25967. enableBlending(blendingSpeed: number): void;
  25968. /**
  25969. * Disable animation blending
  25970. * @see https://doc.babylonjs.com/babylon101/animations#animation-blending
  25971. */
  25972. disableBlending(): void;
  25973. /**
  25974. * Jump directly to a given frame
  25975. * @param frame defines the frame to jump to
  25976. */
  25977. goToFrame(frame: number): void;
  25978. /**
  25979. * Pause the animation
  25980. */
  25981. pause(): void;
  25982. /**
  25983. * Restart the animation
  25984. */
  25985. restart(): void;
  25986. private _raiseOnAnimationEnd;
  25987. /**
  25988. * Stop and delete the current animation
  25989. * @param animationName defines a string used to only stop some of the runtime animations instead of all
  25990. * @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)
  25991. */
  25992. stop(animationName?: string, targetMask?: (target: any) => boolean): void;
  25993. /**
  25994. * Wait asynchronously for the animation to end
  25995. * @returns a promise which will be fulfilled when the animation ends
  25996. */
  25997. waitAsync(): Promise<Animatable>;
  25998. /** @hidden */
  25999. _animate(delay: number): boolean;
  26000. }
  26001. interface Scene {
  26002. /** @hidden */
  26003. _registerTargetForLateAnimationBinding(runtimeAnimation: RuntimeAnimation, originalValue: any): void;
  26004. /** @hidden */
  26005. _processLateAnimationBindingsForMatrices(holder: {
  26006. totalWeight: number;
  26007. totalAdditiveWeight: number;
  26008. animations: RuntimeAnimation[];
  26009. additiveAnimations: RuntimeAnimation[];
  26010. originalValue: Matrix;
  26011. }): any;
  26012. /** @hidden */
  26013. _processLateAnimationBindingsForQuaternions(holder: {
  26014. totalWeight: number;
  26015. totalAdditiveWeight: number;
  26016. animations: RuntimeAnimation[];
  26017. additiveAnimations: RuntimeAnimation[];
  26018. originalValue: Quaternion;
  26019. }, refQuaternion: Quaternion): Quaternion;
  26020. /** @hidden */
  26021. _processLateAnimationBindings(): void;
  26022. /**
  26023. * Will start the animation sequence of a given target
  26024. * @param target defines the target
  26025. * @param from defines from which frame should animation start
  26026. * @param to defines until which frame should animation run.
  26027. * @param weight defines the weight to apply to the animation (1.0 by default)
  26028. * @param loop defines if the animation loops
  26029. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  26030. * @param onAnimationEnd defines the function to be executed when the animation ends
  26031. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  26032. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  26033. * @param onAnimationLoop defines the callback to call when an animation loops
  26034. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  26035. * @returns the animatable object created for this animation
  26036. */
  26037. 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;
  26038. /**
  26039. * Will start the animation sequence of a given target
  26040. * @param target defines the target
  26041. * @param from defines from which frame should animation start
  26042. * @param to defines until which frame should animation run.
  26043. * @param loop defines if the animation loops
  26044. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  26045. * @param onAnimationEnd defines the function to be executed when the animation ends
  26046. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  26047. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  26048. * @param targetMask defines if the target should be animate if animations are present (this is called recursively on descendant animatables regardless of return value)
  26049. * @param onAnimationLoop defines the callback to call when an animation loops
  26050. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  26051. * @returns the animatable object created for this animation
  26052. */
  26053. 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;
  26054. /**
  26055. * Will start the animation sequence of a given target and its hierarchy
  26056. * @param target defines the target
  26057. * @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.
  26058. * @param from defines from which frame should animation start
  26059. * @param to defines until which frame should animation run.
  26060. * @param loop defines if the animation loops
  26061. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  26062. * @param onAnimationEnd defines the function to be executed when the animation ends
  26063. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  26064. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  26065. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  26066. * @param onAnimationLoop defines the callback to call when an animation loops
  26067. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  26068. * @returns the list of created animatables
  26069. */
  26070. 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[];
  26071. /**
  26072. * Begin a new animation on a given node
  26073. * @param target defines the target where the animation will take place
  26074. * @param animations defines the list of animations to start
  26075. * @param from defines the initial value
  26076. * @param to defines the final value
  26077. * @param loop defines if you want animation to loop (off by default)
  26078. * @param speedRatio defines the speed ratio to apply to all animations
  26079. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  26080. * @param onAnimationLoop defines the callback to call when an animation loops
  26081. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  26082. * @returns the list of created animatables
  26083. */
  26084. beginDirectAnimation(target: any, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void, isAdditive?: boolean): Animatable;
  26085. /**
  26086. * Begin a new animation on a given node and its hierarchy
  26087. * @param target defines the root node where the animation will take place
  26088. * @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.
  26089. * @param animations defines the list of animations to start
  26090. * @param from defines the initial value
  26091. * @param to defines the final value
  26092. * @param loop defines if you want animation to loop (off by default)
  26093. * @param speedRatio defines the speed ratio to apply to all animations
  26094. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  26095. * @param onAnimationLoop defines the callback to call when an animation loops
  26096. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  26097. * @returns the list of animatables created for all nodes
  26098. */
  26099. beginDirectHierarchyAnimation(target: Node, directDescendantsOnly: boolean, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void, isAdditive?: boolean): Animatable[];
  26100. /**
  26101. * Gets the animatable associated with a specific target
  26102. * @param target defines the target of the animatable
  26103. * @returns the required animatable if found
  26104. */
  26105. getAnimatableByTarget(target: any): Nullable<Animatable>;
  26106. /**
  26107. * Gets all animatables associated with a given target
  26108. * @param target defines the target to look animatables for
  26109. * @returns an array of Animatables
  26110. */
  26111. getAllAnimatablesByTarget(target: any): Array<Animatable>;
  26112. /**
  26113. * Stops and removes all animations that have been applied to the scene
  26114. */
  26115. stopAllAnimations(): void;
  26116. /**
  26117. * Gets the current delta time used by animation engine
  26118. */
  26119. deltaTime: number;
  26120. }
  26121. interface Bone {
  26122. /**
  26123. * Copy an animation range from another bone
  26124. * @param source defines the source bone
  26125. * @param rangeName defines the range name to copy
  26126. * @param frameOffset defines the frame offset
  26127. * @param rescaleAsRequired defines if rescaling must be applied if required
  26128. * @param skelDimensionsRatio defines the scaling ratio
  26129. * @returns true if operation was successful
  26130. */
  26131. copyAnimationRange(source: Bone, rangeName: string, frameOffset: number, rescaleAsRequired: boolean, skelDimensionsRatio: Nullable<Vector3>): boolean;
  26132. }
  26133. }
  26134. declare module BABYLON {
  26135. /**
  26136. * Class used to override all child animations of a given target
  26137. */
  26138. export class AnimationPropertiesOverride {
  26139. /**
  26140. * Gets or sets a value indicating if animation blending must be used
  26141. */
  26142. enableBlending: boolean;
  26143. /**
  26144. * Gets or sets the blending speed to use when enableBlending is true
  26145. */
  26146. blendingSpeed: number;
  26147. /**
  26148. * Gets or sets the default loop mode to use
  26149. */
  26150. loopMode: number;
  26151. }
  26152. }
  26153. declare module BABYLON {
  26154. /**
  26155. * Class used to handle skinning animations
  26156. * @see https://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  26157. */
  26158. export class Skeleton implements IAnimatable {
  26159. /** defines the skeleton name */
  26160. name: string;
  26161. /** defines the skeleton Id */
  26162. id: string;
  26163. /**
  26164. * Defines the list of child bones
  26165. */
  26166. bones: Bone[];
  26167. /**
  26168. * Defines an estimate of the dimension of the skeleton at rest
  26169. */
  26170. dimensionsAtRest: Vector3;
  26171. /**
  26172. * Defines a boolean indicating if the root matrix is provided by meshes or by the current skeleton (this is the default value)
  26173. */
  26174. needInitialSkinMatrix: boolean;
  26175. /**
  26176. * Defines a mesh that override the matrix used to get the world matrix (null by default).
  26177. */
  26178. overrideMesh: Nullable<AbstractMesh>;
  26179. /**
  26180. * Gets the list of animations attached to this skeleton
  26181. */
  26182. animations: Array<Animation>;
  26183. private _scene;
  26184. private _isDirty;
  26185. private _transformMatrices;
  26186. private _transformMatrixTexture;
  26187. private _meshesWithPoseMatrix;
  26188. private _animatables;
  26189. private _identity;
  26190. private _synchronizedWithMesh;
  26191. private _ranges;
  26192. private _lastAbsoluteTransformsUpdateId;
  26193. private _canUseTextureForBones;
  26194. private _uniqueId;
  26195. /** @hidden */
  26196. _numBonesWithLinkedTransformNode: number;
  26197. /** @hidden */
  26198. _hasWaitingData: Nullable<boolean>;
  26199. /** @hidden */
  26200. _waitingOverrideMeshId: Nullable<string>;
  26201. /**
  26202. * Specifies if the skeleton should be serialized
  26203. */
  26204. doNotSerialize: boolean;
  26205. private _useTextureToStoreBoneMatrices;
  26206. /**
  26207. * Gets or sets a boolean indicating that bone matrices should be stored as a texture instead of using shader uniforms (default is true).
  26208. * Please note that this option is not available if the hardware does not support it
  26209. */
  26210. get useTextureToStoreBoneMatrices(): boolean;
  26211. set useTextureToStoreBoneMatrices(value: boolean);
  26212. private _animationPropertiesOverride;
  26213. /**
  26214. * Gets or sets the animation properties override
  26215. */
  26216. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  26217. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  26218. /**
  26219. * List of inspectable custom properties (used by the Inspector)
  26220. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  26221. */
  26222. inspectableCustomProperties: IInspectable[];
  26223. /**
  26224. * An observable triggered before computing the skeleton's matrices
  26225. */
  26226. onBeforeComputeObservable: Observable<Skeleton>;
  26227. /**
  26228. * Gets a boolean indicating that the skeleton effectively stores matrices into a texture
  26229. */
  26230. get isUsingTextureForMatrices(): boolean;
  26231. /**
  26232. * Gets the unique ID of this skeleton
  26233. */
  26234. get uniqueId(): number;
  26235. /**
  26236. * Creates a new skeleton
  26237. * @param name defines the skeleton name
  26238. * @param id defines the skeleton Id
  26239. * @param scene defines the hosting scene
  26240. */
  26241. constructor(
  26242. /** defines the skeleton name */
  26243. name: string,
  26244. /** defines the skeleton Id */
  26245. id: string, scene: Scene);
  26246. /**
  26247. * Gets the current object class name.
  26248. * @return the class name
  26249. */
  26250. getClassName(): string;
  26251. /**
  26252. * Returns an array containing the root bones
  26253. * @returns an array containing the root bones
  26254. */
  26255. getChildren(): Array<Bone>;
  26256. /**
  26257. * Gets the list of transform matrices to send to shaders (one matrix per bone)
  26258. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  26259. * @returns a Float32Array containing matrices data
  26260. */
  26261. getTransformMatrices(mesh: AbstractMesh): Float32Array;
  26262. /**
  26263. * Gets the list of transform matrices to send to shaders inside a texture (one matrix per bone)
  26264. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  26265. * @returns a raw texture containing the data
  26266. */
  26267. getTransformMatrixTexture(mesh: AbstractMesh): Nullable<RawTexture>;
  26268. /**
  26269. * Gets the current hosting scene
  26270. * @returns a scene object
  26271. */
  26272. getScene(): Scene;
  26273. /**
  26274. * Gets a string representing the current skeleton data
  26275. * @param fullDetails defines a boolean indicating if we want a verbose version
  26276. * @returns a string representing the current skeleton data
  26277. */
  26278. toString(fullDetails?: boolean): string;
  26279. /**
  26280. * Get bone's index searching by name
  26281. * @param name defines bone's name to search for
  26282. * @return the indice of the bone. Returns -1 if not found
  26283. */
  26284. getBoneIndexByName(name: string): number;
  26285. /**
  26286. * Create a new animation range
  26287. * @param name defines the name of the range
  26288. * @param from defines the start key
  26289. * @param to defines the end key
  26290. */
  26291. createAnimationRange(name: string, from: number, to: number): void;
  26292. /**
  26293. * Delete a specific animation range
  26294. * @param name defines the name of the range
  26295. * @param deleteFrames defines if frames must be removed as well
  26296. */
  26297. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  26298. /**
  26299. * Gets a specific animation range
  26300. * @param name defines the name of the range to look for
  26301. * @returns the requested animation range or null if not found
  26302. */
  26303. getAnimationRange(name: string): Nullable<AnimationRange>;
  26304. /**
  26305. * Gets the list of all animation ranges defined on this skeleton
  26306. * @returns an array
  26307. */
  26308. getAnimationRanges(): Nullable<AnimationRange>[];
  26309. /**
  26310. * Copy animation range from a source skeleton.
  26311. * This is not for a complete retargeting, only between very similar skeleton's with only possible bone length differences
  26312. * @param source defines the source skeleton
  26313. * @param name defines the name of the range to copy
  26314. * @param rescaleAsRequired defines if rescaling must be applied if required
  26315. * @returns true if operation was successful
  26316. */
  26317. copyAnimationRange(source: Skeleton, name: string, rescaleAsRequired?: boolean): boolean;
  26318. /**
  26319. * Forces the skeleton to go to rest pose
  26320. */
  26321. returnToRest(): void;
  26322. private _getHighestAnimationFrame;
  26323. /**
  26324. * Begin a specific animation range
  26325. * @param name defines the name of the range to start
  26326. * @param loop defines if looping must be turned on (false by default)
  26327. * @param speedRatio defines the speed ratio to apply (1 by default)
  26328. * @param onAnimationEnd defines a callback which will be called when animation will end
  26329. * @returns a new animatable
  26330. */
  26331. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  26332. /**
  26333. * Convert the keyframes for a range of animation on a skeleton to be relative to a given reference frame.
  26334. * @param skeleton defines the Skeleton containing the animation range to convert
  26335. * @param referenceFrame defines the frame that keyframes in the range will be relative to
  26336. * @param range defines the name of the AnimationRange belonging to the Skeleton to convert
  26337. * @returns the original skeleton
  26338. */
  26339. static MakeAnimationAdditive(skeleton: Skeleton, referenceFrame: number | undefined, range: string): Nullable<Skeleton>;
  26340. /** @hidden */
  26341. _markAsDirty(): void;
  26342. /** @hidden */
  26343. _registerMeshWithPoseMatrix(mesh: AbstractMesh): void;
  26344. /** @hidden */
  26345. _unregisterMeshWithPoseMatrix(mesh: AbstractMesh): void;
  26346. private _computeTransformMatrices;
  26347. /**
  26348. * Build all resources required to render a skeleton
  26349. */
  26350. prepare(): void;
  26351. /**
  26352. * Gets the list of animatables currently running for this skeleton
  26353. * @returns an array of animatables
  26354. */
  26355. getAnimatables(): IAnimatable[];
  26356. /**
  26357. * Clone the current skeleton
  26358. * @param name defines the name of the new skeleton
  26359. * @param id defines the id of the new skeleton
  26360. * @returns the new skeleton
  26361. */
  26362. clone(name: string, id?: string): Skeleton;
  26363. /**
  26364. * Enable animation blending for this skeleton
  26365. * @param blendingSpeed defines the blending speed to apply
  26366. * @see https://doc.babylonjs.com/babylon101/animations#animation-blending
  26367. */
  26368. enableBlending(blendingSpeed?: number): void;
  26369. /**
  26370. * Releases all resources associated with the current skeleton
  26371. */
  26372. dispose(): void;
  26373. /**
  26374. * Serialize the skeleton in a JSON object
  26375. * @returns a JSON object
  26376. */
  26377. serialize(): any;
  26378. /**
  26379. * Creates a new skeleton from serialized data
  26380. * @param parsedSkeleton defines the serialized data
  26381. * @param scene defines the hosting scene
  26382. * @returns a new skeleton
  26383. */
  26384. static Parse(parsedSkeleton: any, scene: Scene): Skeleton;
  26385. /**
  26386. * Compute all node absolute transforms
  26387. * @param forceUpdate defines if computation must be done even if cache is up to date
  26388. */
  26389. computeAbsoluteTransforms(forceUpdate?: boolean): void;
  26390. /**
  26391. * Gets the root pose matrix
  26392. * @returns a matrix
  26393. */
  26394. getPoseMatrix(): Nullable<Matrix>;
  26395. /**
  26396. * Sorts bones per internal index
  26397. */
  26398. sortBones(): void;
  26399. private _sortBones;
  26400. /**
  26401. * Set the current local matrix as the restPose for all bones in the skeleton.
  26402. */
  26403. setCurrentPoseAsRest(): void;
  26404. }
  26405. }
  26406. declare module BABYLON {
  26407. /**
  26408. * Class used to store bone information
  26409. * @see https://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  26410. */
  26411. export class Bone extends Node {
  26412. /**
  26413. * defines the bone name
  26414. */
  26415. name: string;
  26416. private static _tmpVecs;
  26417. private static _tmpQuat;
  26418. private static _tmpMats;
  26419. /**
  26420. * Gets the list of child bones
  26421. */
  26422. children: Bone[];
  26423. /** Gets the animations associated with this bone */
  26424. animations: Animation[];
  26425. /**
  26426. * Gets or sets bone length
  26427. */
  26428. length: number;
  26429. /**
  26430. * @hidden Internal only
  26431. * Set this value to map this bone to a different index in the transform matrices
  26432. * Set this value to -1 to exclude the bone from the transform matrices
  26433. */
  26434. _index: Nullable<number>;
  26435. private _skeleton;
  26436. private _localMatrix;
  26437. private _restPose;
  26438. private _bindPose;
  26439. private _baseMatrix;
  26440. private _absoluteTransform;
  26441. private _invertedAbsoluteTransform;
  26442. private _parent;
  26443. private _scalingDeterminant;
  26444. private _worldTransform;
  26445. private _localScaling;
  26446. private _localRotation;
  26447. private _localPosition;
  26448. private _needToDecompose;
  26449. private _needToCompose;
  26450. /** @hidden */
  26451. _linkedTransformNode: Nullable<TransformNode>;
  26452. /** @hidden */
  26453. _waitingTransformNodeId: Nullable<string>;
  26454. /** @hidden */
  26455. get _matrix(): Matrix;
  26456. /** @hidden */
  26457. set _matrix(value: Matrix);
  26458. /**
  26459. * Create a new bone
  26460. * @param name defines the bone name
  26461. * @param skeleton defines the parent skeleton
  26462. * @param parentBone defines the parent (can be null if the bone is the root)
  26463. * @param localMatrix defines the local matrix
  26464. * @param restPose defines the rest pose matrix
  26465. * @param baseMatrix defines the base matrix
  26466. * @param index defines index of the bone in the hierarchy
  26467. */
  26468. constructor(
  26469. /**
  26470. * defines the bone name
  26471. */
  26472. name: string, skeleton: Skeleton, parentBone?: Nullable<Bone>, localMatrix?: Nullable<Matrix>, restPose?: Nullable<Matrix>, baseMatrix?: Nullable<Matrix>, index?: Nullable<number>);
  26473. /**
  26474. * Gets the current object class name.
  26475. * @return the class name
  26476. */
  26477. getClassName(): string;
  26478. /**
  26479. * Gets the parent skeleton
  26480. * @returns a skeleton
  26481. */
  26482. getSkeleton(): Skeleton;
  26483. /**
  26484. * Gets parent bone
  26485. * @returns a bone or null if the bone is the root of the bone hierarchy
  26486. */
  26487. getParent(): Nullable<Bone>;
  26488. /**
  26489. * Returns an array containing the root bones
  26490. * @returns an array containing the root bones
  26491. */
  26492. getChildren(): Array<Bone>;
  26493. /**
  26494. * Gets the node index in matrix array generated for rendering
  26495. * @returns the node index
  26496. */
  26497. getIndex(): number;
  26498. /**
  26499. * Sets the parent bone
  26500. * @param parent defines the parent (can be null if the bone is the root)
  26501. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  26502. */
  26503. setParent(parent: Nullable<Bone>, updateDifferenceMatrix?: boolean): void;
  26504. /**
  26505. * Gets the local matrix
  26506. * @returns a matrix
  26507. */
  26508. getLocalMatrix(): Matrix;
  26509. /**
  26510. * Gets the base matrix (initial matrix which remains unchanged)
  26511. * @returns a matrix
  26512. */
  26513. getBaseMatrix(): Matrix;
  26514. /**
  26515. * Gets the rest pose matrix
  26516. * @returns a matrix
  26517. */
  26518. getRestPose(): Matrix;
  26519. /**
  26520. * Sets the rest pose matrix
  26521. * @param matrix the local-space rest pose to set for this bone
  26522. */
  26523. setRestPose(matrix: Matrix): void;
  26524. /**
  26525. * Gets the bind pose matrix
  26526. * @returns the bind pose matrix
  26527. */
  26528. getBindPose(): Matrix;
  26529. /**
  26530. * Sets the bind pose matrix
  26531. * @param matrix the local-space bind pose to set for this bone
  26532. */
  26533. setBindPose(matrix: Matrix): void;
  26534. /**
  26535. * Gets a matrix used to store world matrix (ie. the matrix sent to shaders)
  26536. */
  26537. getWorldMatrix(): Matrix;
  26538. /**
  26539. * Sets the local matrix to rest pose matrix
  26540. */
  26541. returnToRest(): void;
  26542. /**
  26543. * Gets the inverse of the absolute transform matrix.
  26544. * This matrix will be multiplied by local matrix to get the difference matrix (ie. the difference between original state and current state)
  26545. * @returns a matrix
  26546. */
  26547. getInvertedAbsoluteTransform(): Matrix;
  26548. /**
  26549. * Gets the absolute transform matrix (ie base matrix * parent world matrix)
  26550. * @returns a matrix
  26551. */
  26552. getAbsoluteTransform(): Matrix;
  26553. /**
  26554. * Links with the given transform node.
  26555. * The local matrix of this bone is copied from the transform node every frame.
  26556. * @param transformNode defines the transform node to link to
  26557. */
  26558. linkTransformNode(transformNode: Nullable<TransformNode>): void;
  26559. /**
  26560. * Gets the node used to drive the bone's transformation
  26561. * @returns a transform node or null
  26562. */
  26563. getTransformNode(): Nullable<TransformNode>;
  26564. /** Gets or sets current position (in local space) */
  26565. get position(): Vector3;
  26566. set position(newPosition: Vector3);
  26567. /** Gets or sets current rotation (in local space) */
  26568. get rotation(): Vector3;
  26569. set rotation(newRotation: Vector3);
  26570. /** Gets or sets current rotation quaternion (in local space) */
  26571. get rotationQuaternion(): Quaternion;
  26572. set rotationQuaternion(newRotation: Quaternion);
  26573. /** Gets or sets current scaling (in local space) */
  26574. get scaling(): Vector3;
  26575. set scaling(newScaling: Vector3);
  26576. /**
  26577. * Gets the animation properties override
  26578. */
  26579. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  26580. private _decompose;
  26581. private _compose;
  26582. /**
  26583. * Update the base and local matrices
  26584. * @param matrix defines the new base or local matrix
  26585. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  26586. * @param updateLocalMatrix defines if the local matrix should be updated
  26587. */
  26588. updateMatrix(matrix: Matrix, updateDifferenceMatrix?: boolean, updateLocalMatrix?: boolean): void;
  26589. /** @hidden */
  26590. _updateDifferenceMatrix(rootMatrix?: Matrix, updateChildren?: boolean): void;
  26591. /**
  26592. * Flag the bone as dirty (Forcing it to update everything)
  26593. */
  26594. markAsDirty(): void;
  26595. /** @hidden */
  26596. _markAsDirtyAndCompose(): void;
  26597. private _markAsDirtyAndDecompose;
  26598. /**
  26599. * Translate the bone in local or world space
  26600. * @param vec The amount to translate the bone
  26601. * @param space The space that the translation is in
  26602. * @param mesh The mesh that this bone is attached to. This is only used in world space
  26603. */
  26604. translate(vec: Vector3, space?: Space, mesh?: AbstractMesh): void;
  26605. /**
  26606. * Set the position of the bone in local or world space
  26607. * @param position The position to set the bone
  26608. * @param space The space that the position is in
  26609. * @param mesh The mesh that this bone is attached to. This is only used in world space
  26610. */
  26611. setPosition(position: Vector3, space?: Space, mesh?: AbstractMesh): void;
  26612. /**
  26613. * Set the absolute position of the bone (world space)
  26614. * @param position The position to set the bone
  26615. * @param mesh The mesh that this bone is attached to
  26616. */
  26617. setAbsolutePosition(position: Vector3, mesh?: AbstractMesh): void;
  26618. /**
  26619. * Scale the bone on the x, y and z axes (in local space)
  26620. * @param x The amount to scale the bone on the x axis
  26621. * @param y The amount to scale the bone on the y axis
  26622. * @param z The amount to scale the bone on the z axis
  26623. * @param scaleChildren sets this to true if children of the bone should be scaled as well (false by default)
  26624. */
  26625. scale(x: number, y: number, z: number, scaleChildren?: boolean): void;
  26626. /**
  26627. * Set the bone scaling in local space
  26628. * @param scale defines the scaling vector
  26629. */
  26630. setScale(scale: Vector3): void;
  26631. /**
  26632. * Gets the current scaling in local space
  26633. * @returns the current scaling vector
  26634. */
  26635. getScale(): Vector3;
  26636. /**
  26637. * Gets the current scaling in local space and stores it in a target vector
  26638. * @param result defines the target vector
  26639. */
  26640. getScaleToRef(result: Vector3): void;
  26641. /**
  26642. * Set the yaw, pitch, and roll of the bone in local or world space
  26643. * @param yaw The rotation of the bone on the y axis
  26644. * @param pitch The rotation of the bone on the x axis
  26645. * @param roll The rotation of the bone on the z axis
  26646. * @param space The space that the axes of rotation are in
  26647. * @param mesh The mesh that this bone is attached to. This is only used in world space
  26648. */
  26649. setYawPitchRoll(yaw: number, pitch: number, roll: number, space?: Space, mesh?: AbstractMesh): void;
  26650. /**
  26651. * Add a rotation to the bone on an axis in local or world space
  26652. * @param axis The axis to rotate the bone on
  26653. * @param amount The amount to rotate the bone
  26654. * @param space The space that the axis is in
  26655. * @param mesh The mesh that this bone is attached to. This is only used in world space
  26656. */
  26657. rotate(axis: Vector3, amount: number, space?: Space, mesh?: AbstractMesh): void;
  26658. /**
  26659. * Set the rotation of the bone to a particular axis angle in local or world space
  26660. * @param axis The axis to rotate the bone on
  26661. * @param angle The angle that the bone should be rotated to
  26662. * @param space The space that the axis is in
  26663. * @param mesh The mesh that this bone is attached to. This is only used in world space
  26664. */
  26665. setAxisAngle(axis: Vector3, angle: number, space?: Space, mesh?: AbstractMesh): void;
  26666. /**
  26667. * Set the euler rotation of the bone in local or world space
  26668. * @param rotation The euler rotation that the bone should be set to
  26669. * @param space The space that the rotation is in
  26670. * @param mesh The mesh that this bone is attached to. This is only used in world space
  26671. */
  26672. setRotation(rotation: Vector3, space?: Space, mesh?: AbstractMesh): void;
  26673. /**
  26674. * Set the quaternion rotation of the bone in local or world space
  26675. * @param quat The quaternion rotation that the bone should be set to
  26676. * @param space The space that the rotation is in
  26677. * @param mesh The mesh that this bone is attached to. This is only used in world space
  26678. */
  26679. setRotationQuaternion(quat: Quaternion, space?: Space, mesh?: AbstractMesh): void;
  26680. /**
  26681. * Set the rotation matrix of the bone in local or world space
  26682. * @param rotMat The rotation matrix that the bone should be set to
  26683. * @param space The space that the rotation is in
  26684. * @param mesh The mesh that this bone is attached to. This is only used in world space
  26685. */
  26686. setRotationMatrix(rotMat: Matrix, space?: Space, mesh?: AbstractMesh): void;
  26687. private _rotateWithMatrix;
  26688. private _getNegativeRotationToRef;
  26689. /**
  26690. * Get the position of the bone in local or world space
  26691. * @param space The space that the returned position is in
  26692. * @param mesh The mesh that this bone is attached to. This is only used in world space
  26693. * @returns The position of the bone
  26694. */
  26695. getPosition(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  26696. /**
  26697. * Copy the position of the bone to a vector3 in local or world space
  26698. * @param space The space that the returned position is in
  26699. * @param mesh The mesh that this bone is attached to. This is only used in world space
  26700. * @param result The vector3 to copy the position to
  26701. */
  26702. getPositionToRef(space: Space | undefined, mesh: Nullable<AbstractMesh>, result: Vector3): void;
  26703. /**
  26704. * Get the absolute position of the bone (world space)
  26705. * @param mesh The mesh that this bone is attached to
  26706. * @returns The absolute position of the bone
  26707. */
  26708. getAbsolutePosition(mesh?: Nullable<AbstractMesh>): Vector3;
  26709. /**
  26710. * Copy the absolute position of the bone (world space) to the result param
  26711. * @param mesh The mesh that this bone is attached to
  26712. * @param result The vector3 to copy the absolute position to
  26713. */
  26714. getAbsolutePositionToRef(mesh: AbstractMesh, result: Vector3): void;
  26715. /**
  26716. * Compute the absolute transforms of this bone and its children
  26717. */
  26718. computeAbsoluteTransforms(): void;
  26719. /**
  26720. * Get the world direction from an axis that is in the local space of the bone
  26721. * @param localAxis The local direction that is used to compute the world direction
  26722. * @param mesh The mesh that this bone is attached to
  26723. * @returns The world direction
  26724. */
  26725. getDirection(localAxis: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  26726. /**
  26727. * Copy the world direction to a vector3 from an axis that is in the local space of the bone
  26728. * @param localAxis The local direction that is used to compute the world direction
  26729. * @param mesh The mesh that this bone is attached to
  26730. * @param result The vector3 that the world direction will be copied to
  26731. */
  26732. getDirectionToRef(localAxis: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  26733. /**
  26734. * Get the euler rotation of the bone in local or world space
  26735. * @param space The space that the rotation should be in
  26736. * @param mesh The mesh that this bone is attached to. This is only used in world space
  26737. * @returns The euler rotation
  26738. */
  26739. getRotation(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  26740. /**
  26741. * Copy the euler rotation of the bone to a vector3. The rotation can be in either local or world space
  26742. * @param space The space that the rotation should be in
  26743. * @param mesh The mesh that this bone is attached to. This is only used in world space
  26744. * @param result The vector3 that the rotation should be copied to
  26745. */
  26746. getRotationToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  26747. /**
  26748. * Get the quaternion rotation of the bone in either local or world space
  26749. * @param space The space that the rotation should be in
  26750. * @param mesh The mesh that this bone is attached to. This is only used in world space
  26751. * @returns The quaternion rotation
  26752. */
  26753. getRotationQuaternion(space?: Space, mesh?: Nullable<AbstractMesh>): Quaternion;
  26754. /**
  26755. * Copy the quaternion rotation of the bone to a quaternion. The rotation can be in either local or world space
  26756. * @param space The space that the rotation should be in
  26757. * @param mesh The mesh that this bone is attached to. This is only used in world space
  26758. * @param result The quaternion that the rotation should be copied to
  26759. */
  26760. getRotationQuaternionToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Quaternion): void;
  26761. /**
  26762. * Get the rotation matrix of the bone in local or world space
  26763. * @param space The space that the rotation should be in
  26764. * @param mesh The mesh that this bone is attached to. This is only used in world space
  26765. * @returns The rotation matrix
  26766. */
  26767. getRotationMatrix(space: Space | undefined, mesh: AbstractMesh): Matrix;
  26768. /**
  26769. * Copy the rotation matrix of the bone to a matrix. The rotation can be in either local or world space
  26770. * @param space The space that the rotation should be in
  26771. * @param mesh The mesh that this bone is attached to. This is only used in world space
  26772. * @param result The quaternion that the rotation should be copied to
  26773. */
  26774. getRotationMatrixToRef(space: Space | undefined, mesh: AbstractMesh, result: Matrix): void;
  26775. /**
  26776. * Get the world position of a point that is in the local space of the bone
  26777. * @param position The local position
  26778. * @param mesh The mesh that this bone is attached to
  26779. * @returns The world position
  26780. */
  26781. getAbsolutePositionFromLocal(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  26782. /**
  26783. * Get the world position of a point that is in the local space of the bone and copy it to the result param
  26784. * @param position The local position
  26785. * @param mesh The mesh that this bone is attached to
  26786. * @param result The vector3 that the world position should be copied to
  26787. */
  26788. getAbsolutePositionFromLocalToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  26789. /**
  26790. * Get the local position of a point that is in world space
  26791. * @param position The world position
  26792. * @param mesh The mesh that this bone is attached to
  26793. * @returns The local position
  26794. */
  26795. getLocalPositionFromAbsolute(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  26796. /**
  26797. * Get the local position of a point that is in world space and copy it to the result param
  26798. * @param position The world position
  26799. * @param mesh The mesh that this bone is attached to
  26800. * @param result The vector3 that the local position should be copied to
  26801. */
  26802. getLocalPositionFromAbsoluteToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  26803. /**
  26804. * Set the current local matrix as the restPose for this bone.
  26805. */
  26806. setCurrentPoseAsRest(): void;
  26807. }
  26808. }
  26809. declare module BABYLON {
  26810. /**
  26811. * 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.
  26812. * @see https://doc.babylonjs.com/how_to/transformnode
  26813. */
  26814. export class TransformNode extends Node {
  26815. /**
  26816. * Object will not rotate to face the camera
  26817. */
  26818. static BILLBOARDMODE_NONE: number;
  26819. /**
  26820. * Object will rotate to face the camera but only on the x axis
  26821. */
  26822. static BILLBOARDMODE_X: number;
  26823. /**
  26824. * Object will rotate to face the camera but only on the y axis
  26825. */
  26826. static BILLBOARDMODE_Y: number;
  26827. /**
  26828. * Object will rotate to face the camera but only on the z axis
  26829. */
  26830. static BILLBOARDMODE_Z: number;
  26831. /**
  26832. * Object will rotate to face the camera
  26833. */
  26834. static BILLBOARDMODE_ALL: number;
  26835. /**
  26836. * Object will rotate to face the camera's position instead of orientation
  26837. */
  26838. static BILLBOARDMODE_USE_POSITION: number;
  26839. private static _TmpRotation;
  26840. private static _TmpScaling;
  26841. private static _TmpTranslation;
  26842. private _forward;
  26843. private _forwardInverted;
  26844. private _up;
  26845. private _right;
  26846. private _rightInverted;
  26847. private _position;
  26848. private _rotation;
  26849. private _rotationQuaternion;
  26850. protected _scaling: Vector3;
  26851. protected _isDirty: boolean;
  26852. private _transformToBoneReferal;
  26853. private _isAbsoluteSynced;
  26854. private _billboardMode;
  26855. /**
  26856. * Gets or sets the billboard mode. Default is 0.
  26857. *
  26858. * | Value | Type | Description |
  26859. * | --- | --- | --- |
  26860. * | 0 | BILLBOARDMODE_NONE | |
  26861. * | 1 | BILLBOARDMODE_X | |
  26862. * | 2 | BILLBOARDMODE_Y | |
  26863. * | 4 | BILLBOARDMODE_Z | |
  26864. * | 7 | BILLBOARDMODE_ALL | |
  26865. *
  26866. */
  26867. get billboardMode(): number;
  26868. set billboardMode(value: number);
  26869. private _preserveParentRotationForBillboard;
  26870. /**
  26871. * Gets or sets a boolean indicating that parent rotation should be preserved when using billboards.
  26872. * This could be useful for glTF objects where parent rotation helps converting from right handed to left handed
  26873. */
  26874. get preserveParentRotationForBillboard(): boolean;
  26875. set preserveParentRotationForBillboard(value: boolean);
  26876. /**
  26877. * 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
  26878. */
  26879. scalingDeterminant: number;
  26880. private _infiniteDistance;
  26881. /**
  26882. * Gets or sets the distance of the object to max, often used by skybox
  26883. */
  26884. get infiniteDistance(): boolean;
  26885. set infiniteDistance(value: boolean);
  26886. /**
  26887. * Gets or sets a boolean indicating that non uniform scaling (when at least one component is different from others) should be ignored.
  26888. * By default the system will update normals to compensate
  26889. */
  26890. ignoreNonUniformScaling: boolean;
  26891. /**
  26892. * 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
  26893. */
  26894. reIntegrateRotationIntoRotationQuaternion: boolean;
  26895. /** @hidden */
  26896. _poseMatrix: Nullable<Matrix>;
  26897. /** @hidden */
  26898. _localMatrix: Matrix;
  26899. private _usePivotMatrix;
  26900. private _absolutePosition;
  26901. private _absoluteScaling;
  26902. private _absoluteRotationQuaternion;
  26903. private _pivotMatrix;
  26904. private _pivotMatrixInverse;
  26905. /** @hidden */
  26906. _postMultiplyPivotMatrix: boolean;
  26907. protected _isWorldMatrixFrozen: boolean;
  26908. /** @hidden */
  26909. _indexInSceneTransformNodesArray: number;
  26910. /**
  26911. * An event triggered after the world matrix is updated
  26912. */
  26913. onAfterWorldMatrixUpdateObservable: Observable<TransformNode>;
  26914. constructor(name: string, scene?: Nullable<Scene>, isPure?: boolean);
  26915. /**
  26916. * Gets a string identifying the name of the class
  26917. * @returns "TransformNode" string
  26918. */
  26919. getClassName(): string;
  26920. /**
  26921. * Gets or set the node position (default is (0.0, 0.0, 0.0))
  26922. */
  26923. get position(): Vector3;
  26924. set position(newPosition: Vector3);
  26925. /**
  26926. * 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)).
  26927. * If rotation quaternion is set, this Vector3 will be ignored and copy from the quaternion
  26928. */
  26929. get rotation(): Vector3;
  26930. set rotation(newRotation: Vector3);
  26931. /**
  26932. * 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)).
  26933. */
  26934. get scaling(): Vector3;
  26935. set scaling(newScaling: Vector3);
  26936. /**
  26937. * 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).
  26938. * If set, only the rotationQuaternion is then used to compute the node rotation (ie. node.rotation will be ignored)
  26939. */
  26940. get rotationQuaternion(): Nullable<Quaternion>;
  26941. set rotationQuaternion(quaternion: Nullable<Quaternion>);
  26942. /**
  26943. * The forward direction of that transform in world space.
  26944. */
  26945. get forward(): Vector3;
  26946. /**
  26947. * The up direction of that transform in world space.
  26948. */
  26949. get up(): Vector3;
  26950. /**
  26951. * The right direction of that transform in world space.
  26952. */
  26953. get right(): Vector3;
  26954. /**
  26955. * Copies the parameter passed Matrix into the mesh Pose matrix.
  26956. * @param matrix the matrix to copy the pose from
  26957. * @returns this TransformNode.
  26958. */
  26959. updatePoseMatrix(matrix: Matrix): TransformNode;
  26960. /**
  26961. * Returns the mesh Pose matrix.
  26962. * @returns the pose matrix
  26963. */
  26964. getPoseMatrix(): Matrix;
  26965. /** @hidden */
  26966. _isSynchronized(): boolean;
  26967. /** @hidden */
  26968. _initCache(): void;
  26969. /**
  26970. * Flag the transform node as dirty (Forcing it to update everything)
  26971. * @param property if set to "rotation" the objects rotationQuaternion will be set to null
  26972. * @returns this transform node
  26973. */
  26974. markAsDirty(property: string): TransformNode;
  26975. /**
  26976. * Returns the current mesh absolute position.
  26977. * Returns a Vector3.
  26978. */
  26979. get absolutePosition(): Vector3;
  26980. /**
  26981. * Returns the current mesh absolute scaling.
  26982. * Returns a Vector3.
  26983. */
  26984. get absoluteScaling(): Vector3;
  26985. /**
  26986. * Returns the current mesh absolute rotation.
  26987. * Returns a Quaternion.
  26988. */
  26989. get absoluteRotationQuaternion(): Quaternion;
  26990. /**
  26991. * Sets a new matrix to apply before all other transformation
  26992. * @param matrix defines the transform matrix
  26993. * @returns the current TransformNode
  26994. */
  26995. setPreTransformMatrix(matrix: Matrix): TransformNode;
  26996. /**
  26997. * Sets a new pivot matrix to the current node
  26998. * @param matrix defines the new pivot matrix to use
  26999. * @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
  27000. * @returns the current TransformNode
  27001. */
  27002. setPivotMatrix(matrix: DeepImmutable<Matrix>, postMultiplyPivotMatrix?: boolean): TransformNode;
  27003. /**
  27004. * Returns the mesh pivot matrix.
  27005. * Default : Identity.
  27006. * @returns the matrix
  27007. */
  27008. getPivotMatrix(): Matrix;
  27009. /**
  27010. * Instantiate (when possible) or clone that node with its hierarchy
  27011. * @param newParent defines the new parent to use for the instance (or clone)
  27012. * @param options defines options to configure how copy is done
  27013. * @param onNewNodeCreated defines an option callback to call when a clone or an instance is created
  27014. * @returns an instance (or a clone) of the current node with its hiearchy
  27015. */
  27016. instantiateHierarchy(newParent?: Nullable<TransformNode>, options?: {
  27017. doNotInstantiate: boolean;
  27018. }, onNewNodeCreated?: (source: TransformNode, clone: TransformNode) => void): Nullable<TransformNode>;
  27019. /**
  27020. * Prevents the World matrix to be computed any longer
  27021. * @param newWorldMatrix defines an optional matrix to use as world matrix
  27022. * @returns the TransformNode.
  27023. */
  27024. freezeWorldMatrix(newWorldMatrix?: Nullable<Matrix>): TransformNode;
  27025. /**
  27026. * Allows back the World matrix computation.
  27027. * @returns the TransformNode.
  27028. */
  27029. unfreezeWorldMatrix(): this;
  27030. /**
  27031. * True if the World matrix has been frozen.
  27032. */
  27033. get isWorldMatrixFrozen(): boolean;
  27034. /**
  27035. * Returns the mesh absolute position in the World.
  27036. * @returns a Vector3.
  27037. */
  27038. getAbsolutePosition(): Vector3;
  27039. /**
  27040. * Sets the mesh absolute position in the World from a Vector3 or an Array(3).
  27041. * @param absolutePosition the absolute position to set
  27042. * @returns the TransformNode.
  27043. */
  27044. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  27045. /**
  27046. * Sets the mesh position in its local space.
  27047. * @param vector3 the position to set in localspace
  27048. * @returns the TransformNode.
  27049. */
  27050. setPositionWithLocalVector(vector3: Vector3): TransformNode;
  27051. /**
  27052. * Returns the mesh position in the local space from the current World matrix values.
  27053. * @returns a new Vector3.
  27054. */
  27055. getPositionExpressedInLocalSpace(): Vector3;
  27056. /**
  27057. * Translates the mesh along the passed Vector3 in its local space.
  27058. * @param vector3 the distance to translate in localspace
  27059. * @returns the TransformNode.
  27060. */
  27061. locallyTranslate(vector3: Vector3): TransformNode;
  27062. private static _lookAtVectorCache;
  27063. /**
  27064. * Orients a mesh towards a target point. Mesh must be drawn facing user.
  27065. * @param targetPoint the position (must be in same space as current mesh) to look at
  27066. * @param yawCor optional yaw (y-axis) correction in radians
  27067. * @param pitchCor optional pitch (x-axis) correction in radians
  27068. * @param rollCor optional roll (z-axis) correction in radians
  27069. * @param space the chosen space of the target
  27070. * @returns the TransformNode.
  27071. */
  27072. lookAt(targetPoint: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number, space?: Space): TransformNode;
  27073. /**
  27074. * Returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  27075. * This Vector3 is expressed in the World space.
  27076. * @param localAxis axis to rotate
  27077. * @returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  27078. */
  27079. getDirection(localAxis: Vector3): Vector3;
  27080. /**
  27081. * Sets the Vector3 "result" as the rotated Vector3 "localAxis" in the same rotation than the mesh.
  27082. * localAxis is expressed in the mesh local space.
  27083. * result is computed in the Wordl space from the mesh World matrix.
  27084. * @param localAxis axis to rotate
  27085. * @param result the resulting transformnode
  27086. * @returns this TransformNode.
  27087. */
  27088. getDirectionToRef(localAxis: Vector3, result: Vector3): TransformNode;
  27089. /**
  27090. * Sets this transform node rotation to the given local axis.
  27091. * @param localAxis the axis in local space
  27092. * @param yawCor optional yaw (y-axis) correction in radians
  27093. * @param pitchCor optional pitch (x-axis) correction in radians
  27094. * @param rollCor optional roll (z-axis) correction in radians
  27095. * @returns this TransformNode
  27096. */
  27097. setDirection(localAxis: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number): TransformNode;
  27098. /**
  27099. * Sets a new pivot point to the current node
  27100. * @param point defines the new pivot point to use
  27101. * @param space defines if the point is in world or local space (local by default)
  27102. * @returns the current TransformNode
  27103. */
  27104. setPivotPoint(point: Vector3, space?: Space): TransformNode;
  27105. /**
  27106. * Returns a new Vector3 set with the mesh pivot point coordinates in the local space.
  27107. * @returns the pivot point
  27108. */
  27109. getPivotPoint(): Vector3;
  27110. /**
  27111. * Sets the passed Vector3 "result" with the coordinates of the mesh pivot point in the local space.
  27112. * @param result the vector3 to store the result
  27113. * @returns this TransformNode.
  27114. */
  27115. getPivotPointToRef(result: Vector3): TransformNode;
  27116. /**
  27117. * Returns a new Vector3 set with the mesh pivot point World coordinates.
  27118. * @returns a new Vector3 set with the mesh pivot point World coordinates.
  27119. */
  27120. getAbsolutePivotPoint(): Vector3;
  27121. /**
  27122. * Sets the Vector3 "result" coordinates with the mesh pivot point World coordinates.
  27123. * @param result vector3 to store the result
  27124. * @returns this TransformNode.
  27125. */
  27126. getAbsolutePivotPointToRef(result: Vector3): TransformNode;
  27127. /**
  27128. * Defines the passed node as the parent of the current node.
  27129. * The node will remain exactly where it is and its position / rotation will be updated accordingly
  27130. * @see https://doc.babylonjs.com/how_to/parenting
  27131. * @param node the node ot set as the parent
  27132. * @returns this TransformNode.
  27133. */
  27134. setParent(node: Nullable<Node>): TransformNode;
  27135. private _nonUniformScaling;
  27136. /**
  27137. * True if the scaling property of this object is non uniform eg. (1,2,1)
  27138. */
  27139. get nonUniformScaling(): boolean;
  27140. /** @hidden */
  27141. _updateNonUniformScalingState(value: boolean): boolean;
  27142. /**
  27143. * Attach the current TransformNode to another TransformNode associated with a bone
  27144. * @param bone Bone affecting the TransformNode
  27145. * @param affectedTransformNode TransformNode associated with the bone
  27146. * @returns this object
  27147. */
  27148. attachToBone(bone: Bone, affectedTransformNode: TransformNode): TransformNode;
  27149. /**
  27150. * Detach the transform node if its associated with a bone
  27151. * @returns this object
  27152. */
  27153. detachFromBone(): TransformNode;
  27154. private static _rotationAxisCache;
  27155. /**
  27156. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in the given space.
  27157. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  27158. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  27159. * The passed axis is also normalized.
  27160. * @param axis the axis to rotate around
  27161. * @param amount the amount to rotate in radians
  27162. * @param space Space to rotate in (Default: local)
  27163. * @returns the TransformNode.
  27164. */
  27165. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  27166. /**
  27167. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in world space.
  27168. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  27169. * The passed axis is also normalized. .
  27170. * Method is based on http://www.euclideanspace.com/maths/geometry/affine/aroundPoint/index.htm
  27171. * @param point the point to rotate around
  27172. * @param axis the axis to rotate around
  27173. * @param amount the amount to rotate in radians
  27174. * @returns the TransformNode
  27175. */
  27176. rotateAround(point: Vector3, axis: Vector3, amount: number): TransformNode;
  27177. /**
  27178. * Translates the mesh along the axis vector for the passed distance in the given space.
  27179. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  27180. * @param axis the axis to translate in
  27181. * @param distance the distance to translate
  27182. * @param space Space to rotate in (Default: local)
  27183. * @returns the TransformNode.
  27184. */
  27185. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  27186. /**
  27187. * Adds a rotation step to the mesh current rotation.
  27188. * x, y, z are Euler angles expressed in radians.
  27189. * This methods updates the current mesh rotation, either mesh.rotation, either mesh.rotationQuaternion if it's set.
  27190. * This means this rotation is made in the mesh local space only.
  27191. * It's useful to set a custom rotation order different from the BJS standard one YXZ.
  27192. * Example : this rotates the mesh first around its local X axis, then around its local Z axis, finally around its local Y axis.
  27193. * ```javascript
  27194. * mesh.addRotation(x1, 0, 0).addRotation(0, 0, z2).addRotation(0, 0, y3);
  27195. * ```
  27196. * Note that `addRotation()` accumulates the passed rotation values to the current ones and computes the .rotation or .rotationQuaternion updated values.
  27197. * 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.
  27198. * @param x Rotation to add
  27199. * @param y Rotation to add
  27200. * @param z Rotation to add
  27201. * @returns the TransformNode.
  27202. */
  27203. addRotation(x: number, y: number, z: number): TransformNode;
  27204. /**
  27205. * @hidden
  27206. */
  27207. protected _getEffectiveParent(): Nullable<Node>;
  27208. /**
  27209. * Computes the world matrix of the node
  27210. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  27211. * @returns the world matrix
  27212. */
  27213. computeWorldMatrix(force?: boolean): Matrix;
  27214. /**
  27215. * Resets this nodeTransform's local matrix to Matrix.Identity().
  27216. * @param independentOfChildren indicates if all child nodeTransform's world-space transform should be preserved.
  27217. */
  27218. resetLocalMatrix(independentOfChildren?: boolean): void;
  27219. protected _afterComputeWorldMatrix(): void;
  27220. /**
  27221. * If you'd like to be called back after the mesh position, rotation or scaling has been updated.
  27222. * @param func callback function to add
  27223. *
  27224. * @returns the TransformNode.
  27225. */
  27226. registerAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  27227. /**
  27228. * Removes a registered callback function.
  27229. * @param func callback function to remove
  27230. * @returns the TransformNode.
  27231. */
  27232. unregisterAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  27233. /**
  27234. * Gets the position of the current mesh in camera space
  27235. * @param camera defines the camera to use
  27236. * @returns a position
  27237. */
  27238. getPositionInCameraSpace(camera?: Nullable<Camera>): Vector3;
  27239. /**
  27240. * Returns the distance from the mesh to the active camera
  27241. * @param camera defines the camera to use
  27242. * @returns the distance
  27243. */
  27244. getDistanceToCamera(camera?: Nullable<Camera>): number;
  27245. /**
  27246. * Clone the current transform node
  27247. * @param name Name of the new clone
  27248. * @param newParent New parent for the clone
  27249. * @param doNotCloneChildren Do not clone children hierarchy
  27250. * @returns the new transform node
  27251. */
  27252. clone(name: string, newParent: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<TransformNode>;
  27253. /**
  27254. * Serializes the objects information.
  27255. * @param currentSerializationObject defines the object to serialize in
  27256. * @returns the serialized object
  27257. */
  27258. serialize(currentSerializationObject?: any): any;
  27259. /**
  27260. * Returns a new TransformNode object parsed from the source provided.
  27261. * @param parsedTransformNode is the source.
  27262. * @param scene the scene the object belongs to
  27263. * @param rootUrl is a string, it's the root URL to prefix the `delayLoadingFile` property with
  27264. * @returns a new TransformNode object parsed from the source provided.
  27265. */
  27266. static Parse(parsedTransformNode: any, scene: Scene, rootUrl: string): TransformNode;
  27267. /**
  27268. * Get all child-transformNodes of this node
  27269. * @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
  27270. * @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
  27271. * @returns an array of TransformNode
  27272. */
  27273. getChildTransformNodes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): TransformNode[];
  27274. /**
  27275. * Releases resources associated with this transform node.
  27276. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  27277. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  27278. */
  27279. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  27280. /**
  27281. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  27282. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  27283. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  27284. * @param predicate predicate that is passed in to getHierarchyBoundingVectors when selecting which object should be included when scaling
  27285. * @returns the current mesh
  27286. */
  27287. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean, predicate?: Nullable<(node: AbstractMesh) => boolean>): TransformNode;
  27288. private _syncAbsoluteScalingAndRotation;
  27289. }
  27290. }
  27291. declare module BABYLON {
  27292. /**
  27293. * Defines the types of pose enabled controllers that are supported
  27294. */
  27295. export enum PoseEnabledControllerType {
  27296. /**
  27297. * HTC Vive
  27298. */
  27299. VIVE = 0,
  27300. /**
  27301. * Oculus Rift
  27302. */
  27303. OCULUS = 1,
  27304. /**
  27305. * Windows mixed reality
  27306. */
  27307. WINDOWS = 2,
  27308. /**
  27309. * Samsung gear VR
  27310. */
  27311. GEAR_VR = 3,
  27312. /**
  27313. * Google Daydream
  27314. */
  27315. DAYDREAM = 4,
  27316. /**
  27317. * Generic
  27318. */
  27319. GENERIC = 5
  27320. }
  27321. /**
  27322. * Defines the MutableGamepadButton interface for the state of a gamepad button
  27323. */
  27324. export interface MutableGamepadButton {
  27325. /**
  27326. * Value of the button/trigger
  27327. */
  27328. value: number;
  27329. /**
  27330. * If the button/trigger is currently touched
  27331. */
  27332. touched: boolean;
  27333. /**
  27334. * If the button/trigger is currently pressed
  27335. */
  27336. pressed: boolean;
  27337. }
  27338. /**
  27339. * Defines the ExtendedGamepadButton interface for a gamepad button which includes state provided by a pose controller
  27340. * @hidden
  27341. */
  27342. export interface ExtendedGamepadButton extends GamepadButton {
  27343. /**
  27344. * If the button/trigger is currently pressed
  27345. */
  27346. readonly pressed: boolean;
  27347. /**
  27348. * If the button/trigger is currently touched
  27349. */
  27350. readonly touched: boolean;
  27351. /**
  27352. * Value of the button/trigger
  27353. */
  27354. readonly value: number;
  27355. }
  27356. /** @hidden */
  27357. export interface _GamePadFactory {
  27358. /**
  27359. * Returns whether or not the current gamepad can be created for this type of controller.
  27360. * @param gamepadInfo Defines the gamepad info as received from the controller APIs.
  27361. * @returns true if it can be created, otherwise false
  27362. */
  27363. canCreate(gamepadInfo: any): boolean;
  27364. /**
  27365. * Creates a new instance of the Gamepad.
  27366. * @param gamepadInfo Defines the gamepad info as received from the controller APIs.
  27367. * @returns the new gamepad instance
  27368. */
  27369. create(gamepadInfo: any): Gamepad;
  27370. }
  27371. /**
  27372. * Defines the PoseEnabledControllerHelper object that is used initialize a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  27373. */
  27374. export class PoseEnabledControllerHelper {
  27375. /** @hidden */
  27376. static _ControllerFactories: _GamePadFactory[];
  27377. /** @hidden */
  27378. static _DefaultControllerFactory: Nullable<(gamepadInfo: any) => Gamepad>;
  27379. /**
  27380. * Initializes a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  27381. * @param vrGamepad the gamepad to initialized
  27382. * @returns a vr controller of the type the gamepad identified as
  27383. */
  27384. static InitiateController(vrGamepad: any): Gamepad;
  27385. }
  27386. /**
  27387. * Defines the PoseEnabledController object that contains state of a vr capable controller
  27388. */
  27389. export class PoseEnabledController extends Gamepad implements PoseControlled {
  27390. /**
  27391. * If the controller is used in a webXR session
  27392. */
  27393. isXR: boolean;
  27394. private _deviceRoomPosition;
  27395. private _deviceRoomRotationQuaternion;
  27396. /**
  27397. * The device position in babylon space
  27398. */
  27399. devicePosition: Vector3;
  27400. /**
  27401. * The device rotation in babylon space
  27402. */
  27403. deviceRotationQuaternion: Quaternion;
  27404. /**
  27405. * The scale factor of the device in babylon space
  27406. */
  27407. deviceScaleFactor: number;
  27408. /**
  27409. * (Likely devicePosition should be used instead) The device position in its room space
  27410. */
  27411. position: Vector3;
  27412. /**
  27413. * (Likely deviceRotationQuaternion should be used instead) The device rotation in its room space
  27414. */
  27415. rotationQuaternion: Quaternion;
  27416. /**
  27417. * The type of controller (Eg. Windows mixed reality)
  27418. */
  27419. controllerType: PoseEnabledControllerType;
  27420. protected _calculatedPosition: Vector3;
  27421. private _calculatedRotation;
  27422. /**
  27423. * The raw pose from the device
  27424. */
  27425. rawPose: DevicePose;
  27426. private _trackPosition;
  27427. private _maxRotationDistFromHeadset;
  27428. private _draggedRoomRotation;
  27429. /**
  27430. * @hidden
  27431. */
  27432. _disableTrackPosition(fixedPosition: Vector3): void;
  27433. /**
  27434. * Internal, the mesh attached to the controller
  27435. * @hidden
  27436. */
  27437. _mesh: Nullable<AbstractMesh>;
  27438. private _poseControlledCamera;
  27439. private _leftHandSystemQuaternion;
  27440. /**
  27441. * Internal, matrix used to convert room space to babylon space
  27442. * @hidden
  27443. */
  27444. _deviceToWorld: Matrix;
  27445. /**
  27446. * Node to be used when casting a ray from the controller
  27447. * @hidden
  27448. */
  27449. _pointingPoseNode: Nullable<TransformNode>;
  27450. /**
  27451. * Name of the child mesh that can be used to cast a ray from the controller
  27452. */
  27453. static readonly POINTING_POSE: string;
  27454. /**
  27455. * Creates a new PoseEnabledController from a gamepad
  27456. * @param browserGamepad the gamepad that the PoseEnabledController should be created from
  27457. */
  27458. constructor(browserGamepad: any);
  27459. private _workingMatrix;
  27460. /**
  27461. * Updates the state of the pose enbaled controller and mesh based on the current position and rotation of the controller
  27462. */
  27463. update(): void;
  27464. /**
  27465. * Updates only the pose device and mesh without doing any button event checking
  27466. */
  27467. protected _updatePoseAndMesh(): void;
  27468. /**
  27469. * Updates the state of the pose enbaled controller based on the raw pose data from the device
  27470. * @param poseData raw pose fromthe device
  27471. */
  27472. updateFromDevice(poseData: DevicePose): void;
  27473. /**
  27474. * @hidden
  27475. */
  27476. _meshAttachedObservable: Observable<AbstractMesh>;
  27477. /**
  27478. * Attaches a mesh to the controller
  27479. * @param mesh the mesh to be attached
  27480. */
  27481. attachToMesh(mesh: AbstractMesh): void;
  27482. /**
  27483. * Attaches the controllers mesh to a camera
  27484. * @param camera the camera the mesh should be attached to
  27485. */
  27486. attachToPoseControlledCamera(camera: TargetCamera): void;
  27487. /**
  27488. * Disposes of the controller
  27489. */
  27490. dispose(): void;
  27491. /**
  27492. * The mesh that is attached to the controller
  27493. */
  27494. get mesh(): Nullable<AbstractMesh>;
  27495. /**
  27496. * Gets the ray of the controller in the direction the controller is pointing
  27497. * @param length the length the resulting ray should be
  27498. * @returns a ray in the direction the controller is pointing
  27499. */
  27500. getForwardRay(length?: number): Ray;
  27501. }
  27502. }
  27503. declare module BABYLON {
  27504. /**
  27505. * Defines the WebVRController object that represents controllers tracked in 3D space
  27506. */
  27507. export abstract class WebVRController extends PoseEnabledController {
  27508. /**
  27509. * Internal, the default controller model for the controller
  27510. */
  27511. protected _defaultModel: Nullable<AbstractMesh>;
  27512. /**
  27513. * Fired when the trigger state has changed
  27514. */
  27515. onTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  27516. /**
  27517. * Fired when the main button state has changed
  27518. */
  27519. onMainButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  27520. /**
  27521. * Fired when the secondary button state has changed
  27522. */
  27523. onSecondaryButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  27524. /**
  27525. * Fired when the pad state has changed
  27526. */
  27527. onPadStateChangedObservable: Observable<ExtendedGamepadButton>;
  27528. /**
  27529. * Fired when controllers stick values have changed
  27530. */
  27531. onPadValuesChangedObservable: Observable<StickValues>;
  27532. /**
  27533. * Array of button availible on the controller
  27534. */
  27535. protected _buttons: Array<MutableGamepadButton>;
  27536. private _onButtonStateChange;
  27537. /**
  27538. * Fired when a controller button's state has changed
  27539. * @param callback the callback containing the button that was modified
  27540. */
  27541. onButtonStateChange(callback: (controlledIndex: number, buttonIndex: number, state: ExtendedGamepadButton) => void): void;
  27542. /**
  27543. * X and Y axis corresponding to the controllers joystick
  27544. */
  27545. pad: StickValues;
  27546. /**
  27547. * 'left' or 'right', see https://w3c.github.io/gamepad/extensions.html#gamepadhand-enum
  27548. */
  27549. hand: string;
  27550. /**
  27551. * The default controller model for the controller
  27552. */
  27553. get defaultModel(): Nullable<AbstractMesh>;
  27554. /**
  27555. * Creates a new WebVRController from a gamepad
  27556. * @param vrGamepad the gamepad that the WebVRController should be created from
  27557. */
  27558. constructor(vrGamepad: any);
  27559. /**
  27560. * Updates the state of the controller and mesh based on the current position and rotation of the controller
  27561. */
  27562. update(): void;
  27563. /**
  27564. * Function to be called when a button is modified
  27565. */
  27566. protected abstract _handleButtonChange(buttonIdx: number, value: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  27567. /**
  27568. * Loads a mesh and attaches it to the controller
  27569. * @param scene the scene the mesh should be added to
  27570. * @param meshLoaded callback for when the mesh has been loaded
  27571. */
  27572. abstract initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  27573. private _setButtonValue;
  27574. private _changes;
  27575. private _checkChanges;
  27576. /**
  27577. * Disposes of th webVRCOntroller
  27578. */
  27579. dispose(): void;
  27580. }
  27581. }
  27582. declare module BABYLON {
  27583. /**
  27584. * The HemisphericLight simulates the ambient environment light,
  27585. * so the passed direction is the light reflection direction, not the incoming direction.
  27586. */
  27587. export class HemisphericLight extends Light {
  27588. /**
  27589. * The groundColor is the light in the opposite direction to the one specified during creation.
  27590. * 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.
  27591. */
  27592. groundColor: Color3;
  27593. /**
  27594. * The light reflection direction, not the incoming direction.
  27595. */
  27596. direction: Vector3;
  27597. /**
  27598. * Creates a HemisphericLight object in the scene according to the passed direction (Vector3).
  27599. * The HemisphericLight simulates the ambient environment light, so the passed direction is the light reflection direction, not the incoming direction.
  27600. * The HemisphericLight can't cast shadows.
  27601. * Documentation : https://doc.babylonjs.com/babylon101/lights
  27602. * @param name The friendly name of the light
  27603. * @param direction The direction of the light reflection
  27604. * @param scene The scene the light belongs to
  27605. */
  27606. constructor(name: string, direction: Vector3, scene: Scene);
  27607. protected _buildUniformLayout(): void;
  27608. /**
  27609. * Returns the string "HemisphericLight".
  27610. * @return The class name
  27611. */
  27612. getClassName(): string;
  27613. /**
  27614. * Sets the HemisphericLight direction towards the passed target (Vector3).
  27615. * Returns the updated direction.
  27616. * @param target The target the direction should point to
  27617. * @return The computed direction
  27618. */
  27619. setDirectionToTarget(target: Vector3): Vector3;
  27620. /**
  27621. * Returns the shadow generator associated to the light.
  27622. * @returns Always null for hemispheric lights because it does not support shadows.
  27623. */
  27624. getShadowGenerator(): Nullable<IShadowGenerator>;
  27625. /**
  27626. * Sets the passed Effect object with the HemisphericLight normalized direction and color and the passed name (string).
  27627. * @param effect The effect to update
  27628. * @param lightIndex The index of the light in the effect to update
  27629. * @returns The hemispheric light
  27630. */
  27631. transferToEffect(effect: Effect, lightIndex: string): HemisphericLight;
  27632. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  27633. /**
  27634. * Computes the world matrix of the node
  27635. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  27636. * @param useWasUpdatedFlag defines a reserved property
  27637. * @returns the world matrix
  27638. */
  27639. computeWorldMatrix(): Matrix;
  27640. /**
  27641. * Returns the integer 3.
  27642. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  27643. */
  27644. getTypeID(): number;
  27645. /**
  27646. * Prepares the list of defines specific to the light type.
  27647. * @param defines the list of defines
  27648. * @param lightIndex defines the index of the light for the effect
  27649. */
  27650. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  27651. }
  27652. }
  27653. declare module BABYLON {
  27654. /** @hidden */
  27655. export var vrMultiviewToSingleviewPixelShader: {
  27656. name: string;
  27657. shader: string;
  27658. };
  27659. }
  27660. declare module BABYLON {
  27661. /**
  27662. * Renders to multiple views with a single draw call
  27663. * @see https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/
  27664. */
  27665. export class MultiviewRenderTarget extends RenderTargetTexture {
  27666. /**
  27667. * Creates a multiview render target
  27668. * @param scene scene used with the render target
  27669. * @param size the size of the render target (used for each view)
  27670. */
  27671. constructor(scene: Scene, size?: number | {
  27672. width: number;
  27673. height: number;
  27674. } | {
  27675. ratio: number;
  27676. });
  27677. /**
  27678. * @hidden
  27679. * @param faceIndex the face index, if its a cube texture
  27680. */
  27681. _bindFrameBuffer(faceIndex?: number): void;
  27682. /**
  27683. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  27684. * @returns the view count
  27685. */
  27686. getViewCount(): number;
  27687. }
  27688. }
  27689. declare module BABYLON {
  27690. interface Engine {
  27691. /**
  27692. * Creates a new multiview render target
  27693. * @param width defines the width of the texture
  27694. * @param height defines the height of the texture
  27695. * @returns the created multiview texture
  27696. */
  27697. createMultiviewRenderTargetTexture(width: number, height: number): InternalTexture;
  27698. /**
  27699. * Binds a multiview framebuffer to be drawn to
  27700. * @param multiviewTexture texture to bind
  27701. */
  27702. bindMultiviewFramebuffer(multiviewTexture: InternalTexture): void;
  27703. }
  27704. interface Camera {
  27705. /**
  27706. * @hidden
  27707. * 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)
  27708. */
  27709. _useMultiviewToSingleView: boolean;
  27710. /**
  27711. * @hidden
  27712. * 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)
  27713. */
  27714. _multiviewTexture: Nullable<RenderTargetTexture>;
  27715. /**
  27716. * @hidden
  27717. * ensures the multiview texture of the camera exists and has the specified width/height
  27718. * @param width height to set on the multiview texture
  27719. * @param height width to set on the multiview texture
  27720. */
  27721. _resizeOrCreateMultiviewTexture(width: number, height: number): void;
  27722. }
  27723. interface Scene {
  27724. /** @hidden */
  27725. _transformMatrixR: Matrix;
  27726. /** @hidden */
  27727. _multiviewSceneUbo: Nullable<UniformBuffer>;
  27728. /** @hidden */
  27729. _createMultiviewUbo(): void;
  27730. /** @hidden */
  27731. _updateMultiviewUbo(viewR?: Matrix, projectionR?: Matrix): void;
  27732. /** @hidden */
  27733. _renderMultiviewToSingleView(camera: Camera): void;
  27734. }
  27735. }
  27736. declare module BABYLON {
  27737. /**
  27738. * VRMultiviewToSingleview used to convert multiview texture arrays to standard textures for scenarios such as webVR
  27739. * This will not be used for webXR as it supports displaying texture arrays directly
  27740. */
  27741. export class VRMultiviewToSingleviewPostProcess extends PostProcess {
  27742. /**
  27743. * Gets a string identifying the name of the class
  27744. * @returns "VRMultiviewToSingleviewPostProcess" string
  27745. */
  27746. getClassName(): string;
  27747. /**
  27748. * Initializes a VRMultiviewToSingleview
  27749. * @param name name of the post process
  27750. * @param camera camera to be applied to
  27751. * @param scaleFactor scaling factor to the size of the output texture
  27752. */
  27753. constructor(name: string, camera: Camera, scaleFactor: number);
  27754. }
  27755. }
  27756. declare module BABYLON {
  27757. /**
  27758. * Interface used to define additional presentation attributes
  27759. */
  27760. export interface IVRPresentationAttributes {
  27761. /**
  27762. * Defines a boolean indicating that we want to get 72hz mode on Oculus Browser (default is off eg. 60hz)
  27763. */
  27764. highRefreshRate: boolean;
  27765. /**
  27766. * Enables foveation in VR to improve perf. 0 none, 1 low, 2 medium, 3 high (Default is 1)
  27767. */
  27768. foveationLevel: number;
  27769. }
  27770. interface Engine {
  27771. /** @hidden */
  27772. _vrDisplay: any;
  27773. /** @hidden */
  27774. _vrSupported: boolean;
  27775. /** @hidden */
  27776. _oldSize: Size;
  27777. /** @hidden */
  27778. _oldHardwareScaleFactor: number;
  27779. /** @hidden */
  27780. _vrExclusivePointerMode: boolean;
  27781. /** @hidden */
  27782. _webVRInitPromise: Promise<IDisplayChangedEventArgs>;
  27783. /** @hidden */
  27784. _onVRDisplayPointerRestricted: () => void;
  27785. /** @hidden */
  27786. _onVRDisplayPointerUnrestricted: () => void;
  27787. /** @hidden */
  27788. _onVrDisplayConnect: Nullable<(display: any) => void>;
  27789. /** @hidden */
  27790. _onVrDisplayDisconnect: Nullable<() => void>;
  27791. /** @hidden */
  27792. _onVrDisplayPresentChange: Nullable<() => void>;
  27793. /**
  27794. * Observable signaled when VR display mode changes
  27795. */
  27796. onVRDisplayChangedObservable: Observable<IDisplayChangedEventArgs>;
  27797. /**
  27798. * Observable signaled when VR request present is complete
  27799. */
  27800. onVRRequestPresentComplete: Observable<boolean>;
  27801. /**
  27802. * Observable signaled when VR request present starts
  27803. */
  27804. onVRRequestPresentStart: Observable<Engine>;
  27805. /**
  27806. * Gets a boolean indicating that the engine is currently in VR exclusive mode for the pointers
  27807. * @see https://docs.microsoft.com/en-us/microsoft-edge/webvr/essentials#mouse-input
  27808. */
  27809. isInVRExclusivePointerMode: boolean;
  27810. /**
  27811. * Gets a boolean indicating if a webVR device was detected
  27812. * @returns true if a webVR device was detected
  27813. */
  27814. isVRDevicePresent(): boolean;
  27815. /**
  27816. * Gets the current webVR device
  27817. * @returns the current webVR device (or null)
  27818. */
  27819. getVRDevice(): any;
  27820. /**
  27821. * Initializes a webVR display and starts listening to display change events
  27822. * The onVRDisplayChangedObservable will be notified upon these changes
  27823. * @returns A promise containing a VRDisplay and if vr is supported
  27824. */
  27825. initWebVRAsync(): Promise<IDisplayChangedEventArgs>;
  27826. /** @hidden */
  27827. _getVRDisplaysAsync(): Promise<IDisplayChangedEventArgs>;
  27828. /**
  27829. * Gets or sets the presentation attributes used to configure VR rendering
  27830. */
  27831. vrPresentationAttributes?: IVRPresentationAttributes;
  27832. /**
  27833. * Call this function to switch to webVR mode
  27834. * Will do nothing if webVR is not supported or if there is no webVR device
  27835. * @param options the webvr options provided to the camera. mainly used for multiview
  27836. * @see https://doc.babylonjs.com/how_to/webvr_camera
  27837. */
  27838. enableVR(options: WebVROptions): void;
  27839. /** @hidden */
  27840. _onVRFullScreenTriggered(): void;
  27841. }
  27842. }
  27843. declare module BABYLON {
  27844. /**
  27845. * This is a copy of VRPose. See https://developer.mozilla.org/en-US/docs/Web/API/VRPose
  27846. * IMPORTANT!! The data is right-hand data.
  27847. * @export
  27848. * @interface DevicePose
  27849. */
  27850. export interface DevicePose {
  27851. /**
  27852. * The position of the device, values in array are [x,y,z].
  27853. */
  27854. readonly position: Nullable<Float32Array>;
  27855. /**
  27856. * The linearVelocity of the device, values in array are [x,y,z].
  27857. */
  27858. readonly linearVelocity: Nullable<Float32Array>;
  27859. /**
  27860. * The linearAcceleration of the device, values in array are [x,y,z].
  27861. */
  27862. readonly linearAcceleration: Nullable<Float32Array>;
  27863. /**
  27864. * The orientation of the device in a quaternion array, values in array are [x,y,z,w].
  27865. */
  27866. readonly orientation: Nullable<Float32Array>;
  27867. /**
  27868. * The angularVelocity of the device, values in array are [x,y,z].
  27869. */
  27870. readonly angularVelocity: Nullable<Float32Array>;
  27871. /**
  27872. * The angularAcceleration of the device, values in array are [x,y,z].
  27873. */
  27874. readonly angularAcceleration: Nullable<Float32Array>;
  27875. }
  27876. /**
  27877. * Interface representing a pose controlled object in Babylon.
  27878. * A pose controlled object has both regular pose values as well as pose values
  27879. * from an external device such as a VR head mounted display
  27880. */
  27881. export interface PoseControlled {
  27882. /**
  27883. * The position of the object in babylon space.
  27884. */
  27885. position: Vector3;
  27886. /**
  27887. * The rotation quaternion of the object in babylon space.
  27888. */
  27889. rotationQuaternion: Quaternion;
  27890. /**
  27891. * The position of the device in babylon space.
  27892. */
  27893. devicePosition?: Vector3;
  27894. /**
  27895. * The rotation quaternion of the device in babylon space.
  27896. */
  27897. deviceRotationQuaternion: Quaternion;
  27898. /**
  27899. * The raw pose coming from the device.
  27900. */
  27901. rawPose: Nullable<DevicePose>;
  27902. /**
  27903. * The scale of the device to be used when translating from device space to babylon space.
  27904. */
  27905. deviceScaleFactor: number;
  27906. /**
  27907. * Updates the poseControlled values based on the input device pose.
  27908. * @param poseData the pose data to update the object with
  27909. */
  27910. updateFromDevice(poseData: DevicePose): void;
  27911. }
  27912. /**
  27913. * Set of options to customize the webVRCamera
  27914. */
  27915. export interface WebVROptions {
  27916. /**
  27917. * Sets if the webVR camera should be tracked to the vrDevice. (default: true)
  27918. */
  27919. trackPosition?: boolean;
  27920. /**
  27921. * Sets the scale of the vrDevice in babylon space. (default: 1)
  27922. */
  27923. positionScale?: number;
  27924. /**
  27925. * If there are more than one VRDisplays, this will choose the display matching this name. (default: pick first vrDisplay)
  27926. */
  27927. displayName?: string;
  27928. /**
  27929. * Should the native controller meshes be initialized. (default: true)
  27930. */
  27931. controllerMeshes?: boolean;
  27932. /**
  27933. * Creating a default HemiLight only on controllers. (default: true)
  27934. */
  27935. defaultLightingOnControllers?: boolean;
  27936. /**
  27937. * If you don't want to use the default VR button of the helper. (default: false)
  27938. */
  27939. useCustomVRButton?: boolean;
  27940. /**
  27941. * If you'd like to provide your own button to the VRHelper. (default: standard babylon vr button)
  27942. */
  27943. customVRButton?: HTMLButtonElement;
  27944. /**
  27945. * To change the length of the ray for gaze/controllers. Will be scaled by positionScale. (default: 100)
  27946. */
  27947. rayLength?: number;
  27948. /**
  27949. * To change the default offset from the ground to account for user's height in meters. Will be scaled by positionScale. (default: 1.7)
  27950. */
  27951. defaultHeight?: number;
  27952. /**
  27953. * If multiview should be used if available (default: false)
  27954. */
  27955. useMultiview?: boolean;
  27956. }
  27957. /**
  27958. * This represents a WebVR camera.
  27959. * The WebVR camera is Babylon's simple interface to interaction with Windows Mixed Reality, HTC Vive and Oculus Rift.
  27960. * @example https://doc.babylonjs.com/how_to/webvr_camera
  27961. */
  27962. export class WebVRFreeCamera extends FreeCamera implements PoseControlled {
  27963. private webVROptions;
  27964. /**
  27965. * @hidden
  27966. * The vrDisplay tied to the camera. See https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay
  27967. */
  27968. _vrDevice: any;
  27969. /**
  27970. * The rawPose of the vrDevice.
  27971. */
  27972. rawPose: Nullable<DevicePose>;
  27973. private _onVREnabled;
  27974. private _specsVersion;
  27975. private _attached;
  27976. private _frameData;
  27977. protected _descendants: Array<Node>;
  27978. private _deviceRoomPosition;
  27979. /** @hidden */
  27980. _deviceRoomRotationQuaternion: Quaternion;
  27981. private _standingMatrix;
  27982. /**
  27983. * Represents device position in babylon space.
  27984. */
  27985. devicePosition: Vector3;
  27986. /**
  27987. * Represents device rotation in babylon space.
  27988. */
  27989. deviceRotationQuaternion: Quaternion;
  27990. /**
  27991. * The scale of the device to be used when translating from device space to babylon space.
  27992. */
  27993. deviceScaleFactor: number;
  27994. private _deviceToWorld;
  27995. private _worldToDevice;
  27996. /**
  27997. * References to the webVR controllers for the vrDevice.
  27998. */
  27999. controllers: Array<WebVRController>;
  28000. /**
  28001. * Emits an event when a controller is attached.
  28002. */
  28003. onControllersAttachedObservable: Observable<WebVRController[]>;
  28004. /**
  28005. * Emits an event when a controller's mesh has been loaded;
  28006. */
  28007. onControllerMeshLoadedObservable: Observable<WebVRController>;
  28008. /**
  28009. * Emits an event when the HMD's pose has been updated.
  28010. */
  28011. onPoseUpdatedFromDeviceObservable: Observable<any>;
  28012. private _poseSet;
  28013. /**
  28014. * If the rig cameras be used as parent instead of this camera.
  28015. */
  28016. rigParenting: boolean;
  28017. private _lightOnControllers;
  28018. private _defaultHeight?;
  28019. /**
  28020. * Instantiates a WebVRFreeCamera.
  28021. * @param name The name of the WebVRFreeCamera
  28022. * @param position The starting anchor position for the camera
  28023. * @param scene The scene the camera belongs to
  28024. * @param webVROptions a set of customizable options for the webVRCamera
  28025. */
  28026. constructor(name: string, position: Vector3, scene: Scene, webVROptions?: WebVROptions);
  28027. /**
  28028. * Gets the device distance from the ground in meters.
  28029. * @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.
  28030. */
  28031. deviceDistanceToRoomGround(): number;
  28032. /**
  28033. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  28034. * @param callback will be called when the standing matrix is set. Callback parameter is if the standing matrix is supported.
  28035. */
  28036. useStandingMatrix(callback?: (bool: boolean) => void): void;
  28037. /**
  28038. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  28039. * @returns A promise with a boolean set to if the standing matrix is supported.
  28040. */
  28041. useStandingMatrixAsync(): Promise<boolean>;
  28042. /**
  28043. * Disposes the camera
  28044. */
  28045. dispose(): void;
  28046. /**
  28047. * Gets a vrController by name.
  28048. * @param name The name of the controller to retreive
  28049. * @returns the controller matching the name specified or null if not found
  28050. */
  28051. getControllerByName(name: string): Nullable<WebVRController>;
  28052. private _leftController;
  28053. /**
  28054. * The controller corresponding to the users left hand.
  28055. */
  28056. get leftController(): Nullable<WebVRController>;
  28057. private _rightController;
  28058. /**
  28059. * The controller corresponding to the users right hand.
  28060. */
  28061. get rightController(): Nullable<WebVRController>;
  28062. /**
  28063. * Casts a ray forward from the vrCamera's gaze.
  28064. * @param length Length of the ray (default: 100)
  28065. * @returns the ray corresponding to the gaze
  28066. */
  28067. getForwardRay(length?: number): Ray;
  28068. /**
  28069. * @hidden
  28070. * Updates the camera based on device's frame data
  28071. */
  28072. _checkInputs(): void;
  28073. /**
  28074. * Updates the poseControlled values based on the input device pose.
  28075. * @param poseData Pose coming from the device
  28076. */
  28077. updateFromDevice(poseData: DevicePose): void;
  28078. private _detachIfAttached;
  28079. /**
  28080. * WebVR's attach control will start broadcasting frames to the device.
  28081. * Note that in certain browsers (chrome for example) this function must be called
  28082. * within a user-interaction callback. Example:
  28083. * <pre> scene.onPointerDown = function() { camera.attachControl(canvas); }</pre>
  28084. *
  28085. * @param noPreventDefault prevent the default html element operation when attaching the vrDevice
  28086. */
  28087. attachControl(noPreventDefault?: boolean): void;
  28088. /**
  28089. * Detach the current controls from the specified dom element.
  28090. */
  28091. detachControl(): void;
  28092. /**
  28093. * @returns the name of this class
  28094. */
  28095. getClassName(): string;
  28096. /**
  28097. * Calls resetPose on the vrDisplay
  28098. * See: https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay/resetPose
  28099. */
  28100. resetToCurrentRotation(): void;
  28101. /**
  28102. * @hidden
  28103. * Updates the rig cameras (left and right eye)
  28104. */
  28105. _updateRigCameras(): void;
  28106. private _workingVector;
  28107. private _oneVector;
  28108. private _workingMatrix;
  28109. private updateCacheCalled;
  28110. private _correctPositionIfNotTrackPosition;
  28111. /**
  28112. * @hidden
  28113. * Updates the cached values of the camera
  28114. * @param ignoreParentClass ignores updating the parent class's cache (default: false)
  28115. */
  28116. _updateCache(ignoreParentClass?: boolean): void;
  28117. /**
  28118. * @hidden
  28119. * Get current device position in babylon world
  28120. */
  28121. _computeDevicePosition(): void;
  28122. /**
  28123. * Updates the current device position and rotation in the babylon world
  28124. */
  28125. update(): void;
  28126. /**
  28127. * @hidden
  28128. * Gets the view matrix of this camera (Always set to identity as left and right eye cameras contain the actual view matrix)
  28129. * @returns an identity matrix
  28130. */
  28131. _getViewMatrix(): Matrix;
  28132. private _tmpMatrix;
  28133. /**
  28134. * This function is called by the two RIG cameras.
  28135. * 'this' is the left or right camera (and NOT (!!!) the WebVRFreeCamera instance)
  28136. * @hidden
  28137. */
  28138. _getWebVRViewMatrix(): Matrix;
  28139. /** @hidden */
  28140. _getWebVRProjectionMatrix(): Matrix;
  28141. private _onGamepadConnectedObserver;
  28142. private _onGamepadDisconnectedObserver;
  28143. private _updateCacheWhenTrackingDisabledObserver;
  28144. /**
  28145. * Initializes the controllers and their meshes
  28146. */
  28147. initControllers(): void;
  28148. }
  28149. }
  28150. declare module BABYLON {
  28151. /**
  28152. * "Static Class" containing the most commonly used helper while dealing with material for rendering purpose.
  28153. *
  28154. * It contains the basic tools to help defining defines, binding uniform for the common part of the materials.
  28155. *
  28156. * This works by convention in BabylonJS but is meant to be use only with shader following the in place naming rules and conventions.
  28157. */
  28158. export class MaterialHelper {
  28159. /**
  28160. * Bind the current view position to an effect.
  28161. * @param effect The effect to be bound
  28162. * @param scene The scene the eyes position is used from
  28163. * @param variableName name of the shader variable that will hold the eye position
  28164. * @param isVector3 true to indicates that variableName is a Vector3 and not a Vector4
  28165. * @return the computed eye position
  28166. */
  28167. static BindEyePosition(effect: Nullable<Effect>, scene: Scene, variableName?: string, isVector3?: boolean): Vector4;
  28168. /**
  28169. * Update the scene ubo before it can be used in rendering processing
  28170. * @param scene the scene to retrieve the ubo from
  28171. * @returns the scene UniformBuffer
  28172. */
  28173. static FinalizeSceneUbo(scene: Scene): UniformBuffer;
  28174. /**
  28175. * Binds the scene's uniform buffer to the effect.
  28176. * @param effect defines the effect to bind to the scene uniform buffer
  28177. * @param sceneUbo defines the uniform buffer storing scene data
  28178. */
  28179. static BindSceneUniformBuffer(effect: Effect, sceneUbo: UniformBuffer): void;
  28180. /**
  28181. * Helps preparing the defines values about the UVs in used in the effect.
  28182. * UVs are shared as much as we can across channels in the shaders.
  28183. * @param texture The texture we are preparing the UVs for
  28184. * @param defines The defines to update
  28185. * @param key The channel key "diffuse", "specular"... used in the shader
  28186. */
  28187. static PrepareDefinesForMergedUV(texture: BaseTexture, defines: any, key: string): void;
  28188. /**
  28189. * Binds a texture matrix value to its corresponding uniform
  28190. * @param texture The texture to bind the matrix for
  28191. * @param uniformBuffer The uniform buffer receiving the data
  28192. * @param key The channel key "diffuse", "specular"... used in the shader
  28193. */
  28194. static BindTextureMatrix(texture: BaseTexture, uniformBuffer: UniformBuffer, key: string): void;
  28195. /**
  28196. * Gets the current status of the fog (should it be enabled?)
  28197. * @param mesh defines the mesh to evaluate for fog support
  28198. * @param scene defines the hosting scene
  28199. * @returns true if fog must be enabled
  28200. */
  28201. static GetFogState(mesh: AbstractMesh, scene: Scene): boolean;
  28202. /**
  28203. * Helper used to prepare the list of defines associated with misc. values for shader compilation
  28204. * @param mesh defines the current mesh
  28205. * @param scene defines the current scene
  28206. * @param useLogarithmicDepth defines if logarithmic depth has to be turned on
  28207. * @param pointsCloud defines if point cloud rendering has to be turned on
  28208. * @param fogEnabled defines if fog has to be turned on
  28209. * @param alphaTest defines if alpha testing has to be turned on
  28210. * @param defines defines the current list of defines
  28211. */
  28212. static PrepareDefinesForMisc(mesh: AbstractMesh, scene: Scene, useLogarithmicDepth: boolean, pointsCloud: boolean, fogEnabled: boolean, alphaTest: boolean, defines: any): void;
  28213. /**
  28214. * Helper used to prepare the list of defines associated with frame values for shader compilation
  28215. * @param scene defines the current scene
  28216. * @param engine defines the current engine
  28217. * @param defines specifies the list of active defines
  28218. * @param useInstances defines if instances have to be turned on
  28219. * @param useClipPlane defines if clip plane have to be turned on
  28220. * @param useInstances defines if instances have to be turned on
  28221. * @param useThinInstances defines if thin instances have to be turned on
  28222. */
  28223. static PrepareDefinesForFrameBoundValues(scene: Scene, engine: Engine, defines: any, useInstances: boolean, useClipPlane?: Nullable<boolean>, useThinInstances?: boolean): void;
  28224. /**
  28225. * Prepares the defines for bones
  28226. * @param mesh The mesh containing the geometry data we will draw
  28227. * @param defines The defines to update
  28228. */
  28229. static PrepareDefinesForBones(mesh: AbstractMesh, defines: any): void;
  28230. /**
  28231. * Prepares the defines for morph targets
  28232. * @param mesh The mesh containing the geometry data we will draw
  28233. * @param defines The defines to update
  28234. */
  28235. static PrepareDefinesForMorphTargets(mesh: AbstractMesh, defines: any): void;
  28236. /**
  28237. * Prepares the defines used in the shader depending on the attributes data available in the mesh
  28238. * @param mesh The mesh containing the geometry data we will draw
  28239. * @param defines The defines to update
  28240. * @param useVertexColor Precise whether vertex colors should be used or not (override mesh info)
  28241. * @param useBones Precise whether bones should be used or not (override mesh info)
  28242. * @param useMorphTargets Precise whether morph targets should be used or not (override mesh info)
  28243. * @param useVertexAlpha Precise whether vertex alpha should be used or not (override mesh info)
  28244. * @returns false if defines are considered not dirty and have not been checked
  28245. */
  28246. static PrepareDefinesForAttributes(mesh: AbstractMesh, defines: any, useVertexColor: boolean, useBones: boolean, useMorphTargets?: boolean, useVertexAlpha?: boolean): boolean;
  28247. /**
  28248. * Prepares the defines related to multiview
  28249. * @param scene The scene we are intending to draw
  28250. * @param defines The defines to update
  28251. */
  28252. static PrepareDefinesForMultiview(scene: Scene, defines: any): void;
  28253. /**
  28254. * Prepares the defines related to the prepass
  28255. * @param scene The scene we are intending to draw
  28256. * @param defines The defines to update
  28257. * @param canRenderToMRT Indicates if this material renders to several textures in the prepass
  28258. */
  28259. static PrepareDefinesForPrePass(scene: Scene, defines: any, canRenderToMRT: boolean): void;
  28260. /**
  28261. * Prepares the defines related to the light information passed in parameter
  28262. * @param scene The scene we are intending to draw
  28263. * @param mesh The mesh the effect is compiling for
  28264. * @param light The light the effect is compiling for
  28265. * @param lightIndex The index of the light
  28266. * @param defines The defines to update
  28267. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  28268. * @param state Defines the current state regarding what is needed (normals, etc...)
  28269. */
  28270. static PrepareDefinesForLight(scene: Scene, mesh: AbstractMesh, light: Light, lightIndex: number, defines: any, specularSupported: boolean, state: {
  28271. needNormals: boolean;
  28272. needRebuild: boolean;
  28273. shadowEnabled: boolean;
  28274. specularEnabled: boolean;
  28275. lightmapMode: boolean;
  28276. }): void;
  28277. /**
  28278. * Prepares the defines related to the light information passed in parameter
  28279. * @param scene The scene we are intending to draw
  28280. * @param mesh The mesh the effect is compiling for
  28281. * @param defines The defines to update
  28282. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  28283. * @param maxSimultaneousLights Specifies how manuy lights can be added to the effect at max
  28284. * @param disableLighting Specifies whether the lighting is disabled (override scene and light)
  28285. * @returns true if normals will be required for the rest of the effect
  28286. */
  28287. static PrepareDefinesForLights(scene: Scene, mesh: AbstractMesh, defines: any, specularSupported: boolean, maxSimultaneousLights?: number, disableLighting?: boolean): boolean;
  28288. /**
  28289. * Prepares the uniforms and samplers list to be used in the effect (for a specific light)
  28290. * @param lightIndex defines the light index
  28291. * @param uniformsList The uniform list
  28292. * @param samplersList The sampler list
  28293. * @param projectedLightTexture defines if projected texture must be used
  28294. * @param uniformBuffersList defines an optional list of uniform buffers
  28295. * @param updateOnlyBuffersList True to only update the uniformBuffersList array
  28296. */
  28297. static PrepareUniformsAndSamplersForLight(lightIndex: number, uniformsList: string[], samplersList: string[], projectedLightTexture?: any, uniformBuffersList?: Nullable<string[]>, updateOnlyBuffersList?: boolean): void;
  28298. /**
  28299. * Prepares the uniforms and samplers list to be used in the effect
  28300. * @param uniformsListOrOptions The uniform names to prepare or an EffectCreationOptions containing the list and extra information
  28301. * @param samplersList The sampler list
  28302. * @param defines The defines helping in the list generation
  28303. * @param maxSimultaneousLights The maximum number of simultaneous light allowed in the effect
  28304. */
  28305. static PrepareUniformsAndSamplersList(uniformsListOrOptions: string[] | IEffectCreationOptions, samplersList?: string[], defines?: any, maxSimultaneousLights?: number): void;
  28306. /**
  28307. * This helps decreasing rank by rank the shadow quality (0 being the highest rank and quality)
  28308. * @param defines The defines to update while falling back
  28309. * @param fallbacks The authorized effect fallbacks
  28310. * @param maxSimultaneousLights The maximum number of lights allowed
  28311. * @param rank the current rank of the Effect
  28312. * @returns The newly affected rank
  28313. */
  28314. static HandleFallbacksForShadows(defines: any, fallbacks: EffectFallbacks, maxSimultaneousLights?: number, rank?: number): number;
  28315. private static _TmpMorphInfluencers;
  28316. /**
  28317. * Prepares the list of attributes required for morph targets according to the effect defines.
  28318. * @param attribs The current list of supported attribs
  28319. * @param mesh The mesh to prepare the morph targets attributes for
  28320. * @param influencers The number of influencers
  28321. */
  28322. static PrepareAttributesForMorphTargetsInfluencers(attribs: string[], mesh: AbstractMesh, influencers: number): void;
  28323. /**
  28324. * Prepares the list of attributes required for morph targets according to the effect defines.
  28325. * @param attribs The current list of supported attribs
  28326. * @param mesh The mesh to prepare the morph targets attributes for
  28327. * @param defines The current Defines of the effect
  28328. */
  28329. static PrepareAttributesForMorphTargets(attribs: string[], mesh: AbstractMesh, defines: any): void;
  28330. /**
  28331. * Prepares the list of attributes required for bones according to the effect defines.
  28332. * @param attribs The current list of supported attribs
  28333. * @param mesh The mesh to prepare the bones attributes for
  28334. * @param defines The current Defines of the effect
  28335. * @param fallbacks The current effect fallback strategy
  28336. */
  28337. static PrepareAttributesForBones(attribs: string[], mesh: AbstractMesh, defines: any, fallbacks: EffectFallbacks): void;
  28338. /**
  28339. * Check and prepare the list of attributes required for instances according to the effect defines.
  28340. * @param attribs The current list of supported attribs
  28341. * @param defines The current MaterialDefines of the effect
  28342. */
  28343. static PrepareAttributesForInstances(attribs: string[], defines: MaterialDefines): void;
  28344. /**
  28345. * Add the list of attributes required for instances to the attribs array.
  28346. * @param attribs The current list of supported attribs
  28347. */
  28348. static PushAttributesForInstances(attribs: string[]): void;
  28349. /**
  28350. * Binds the light information to the effect.
  28351. * @param light The light containing the generator
  28352. * @param effect The effect we are binding the data to
  28353. * @param lightIndex The light index in the effect used to render
  28354. */
  28355. static BindLightProperties(light: Light, effect: Effect, lightIndex: number): void;
  28356. /**
  28357. * Binds the lights information from the scene to the effect for the given mesh.
  28358. * @param light Light to bind
  28359. * @param lightIndex Light index
  28360. * @param scene The scene where the light belongs to
  28361. * @param effect The effect we are binding the data to
  28362. * @param useSpecular Defines if specular is supported
  28363. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  28364. */
  28365. static BindLight(light: Light, lightIndex: number, scene: Scene, effect: Effect, useSpecular: boolean, rebuildInParallel?: boolean): void;
  28366. /**
  28367. * Binds the lights information from the scene to the effect for the given mesh.
  28368. * @param scene The scene the lights belongs to
  28369. * @param mesh The mesh we are binding the information to render
  28370. * @param effect The effect we are binding the data to
  28371. * @param defines The generated defines for the effect
  28372. * @param maxSimultaneousLights The maximum number of light that can be bound to the effect
  28373. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  28374. */
  28375. static BindLights(scene: Scene, mesh: AbstractMesh, effect: Effect, defines: any, maxSimultaneousLights?: number, rebuildInParallel?: boolean): void;
  28376. private static _tempFogColor;
  28377. /**
  28378. * Binds the fog information from the scene to the effect for the given mesh.
  28379. * @param scene The scene the lights belongs to
  28380. * @param mesh The mesh we are binding the information to render
  28381. * @param effect The effect we are binding the data to
  28382. * @param linearSpace Defines if the fog effect is applied in linear space
  28383. */
  28384. static BindFogParameters(scene: Scene, mesh: AbstractMesh, effect: Effect, linearSpace?: boolean): void;
  28385. /**
  28386. * Binds the bones information from the mesh to the effect.
  28387. * @param mesh The mesh we are binding the information to render
  28388. * @param effect The effect we are binding the data to
  28389. * @param prePassConfiguration Configuration for the prepass, in case prepass is activated
  28390. */
  28391. static BindBonesParameters(mesh?: AbstractMesh, effect?: Effect, prePassConfiguration?: PrePassConfiguration): void;
  28392. private static _CopyBonesTransformationMatrices;
  28393. /**
  28394. * Binds the morph targets information from the mesh to the effect.
  28395. * @param abstractMesh The mesh we are binding the information to render
  28396. * @param effect The effect we are binding the data to
  28397. */
  28398. static BindMorphTargetParameters(abstractMesh: AbstractMesh, effect: Effect): void;
  28399. /**
  28400. * Binds the logarithmic depth information from the scene to the effect for the given defines.
  28401. * @param defines The generated defines used in the effect
  28402. * @param effect The effect we are binding the data to
  28403. * @param scene The scene we are willing to render with logarithmic scale for
  28404. */
  28405. static BindLogDepth(defines: any, effect: Effect, scene: Scene): void;
  28406. /**
  28407. * Binds the clip plane information from the scene to the effect.
  28408. * @param scene The scene the clip plane information are extracted from
  28409. * @param effect The effect we are binding the data to
  28410. */
  28411. static BindClipPlane(effect: Effect, scene: Scene): void;
  28412. }
  28413. }
  28414. declare module BABYLON {
  28415. /** @hidden */
  28416. export var bayerDitherFunctions: {
  28417. name: string;
  28418. shader: string;
  28419. };
  28420. }
  28421. declare module BABYLON {
  28422. /** @hidden */
  28423. export var shadowMapFragmentDeclaration: {
  28424. name: string;
  28425. shader: string;
  28426. };
  28427. }
  28428. declare module BABYLON {
  28429. /** @hidden */
  28430. export var shadowMapFragment: {
  28431. name: string;
  28432. shader: string;
  28433. };
  28434. }
  28435. declare module BABYLON {
  28436. /** @hidden */
  28437. export var shadowMapPixelShader: {
  28438. name: string;
  28439. shader: string;
  28440. };
  28441. }
  28442. declare module BABYLON {
  28443. /** @hidden */
  28444. export var shadowMapVertexDeclaration: {
  28445. name: string;
  28446. shader: string;
  28447. };
  28448. }
  28449. declare module BABYLON {
  28450. /** @hidden */
  28451. export var shadowMapVertexNormalBias: {
  28452. name: string;
  28453. shader: string;
  28454. };
  28455. }
  28456. declare module BABYLON {
  28457. /** @hidden */
  28458. export var shadowMapVertexMetric: {
  28459. name: string;
  28460. shader: string;
  28461. };
  28462. }
  28463. declare module BABYLON {
  28464. /** @hidden */
  28465. export var shadowMapVertexShader: {
  28466. name: string;
  28467. shader: string;
  28468. };
  28469. }
  28470. declare module BABYLON {
  28471. /** @hidden */
  28472. export var depthBoxBlurPixelShader: {
  28473. name: string;
  28474. shader: string;
  28475. };
  28476. }
  28477. declare module BABYLON {
  28478. /** @hidden */
  28479. export var shadowMapFragmentSoftTransparentShadow: {
  28480. name: string;
  28481. shader: string;
  28482. };
  28483. }
  28484. declare module BABYLON {
  28485. /**
  28486. * Creates an instance based on a source mesh.
  28487. */
  28488. export class InstancedMesh extends AbstractMesh {
  28489. private _sourceMesh;
  28490. private _currentLOD;
  28491. /** @hidden */
  28492. _indexInSourceMeshInstanceArray: number;
  28493. constructor(name: string, source: Mesh);
  28494. /**
  28495. * Returns the string "InstancedMesh".
  28496. */
  28497. getClassName(): string;
  28498. /** Gets the list of lights affecting that mesh */
  28499. get lightSources(): Light[];
  28500. _resyncLightSources(): void;
  28501. _resyncLightSource(light: Light): void;
  28502. _removeLightSource(light: Light, dispose: boolean): void;
  28503. /**
  28504. * If the source mesh receives shadows
  28505. */
  28506. get receiveShadows(): boolean;
  28507. /**
  28508. * The material of the source mesh
  28509. */
  28510. get material(): Nullable<Material>;
  28511. /**
  28512. * Visibility of the source mesh
  28513. */
  28514. get visibility(): number;
  28515. /**
  28516. * Skeleton of the source mesh
  28517. */
  28518. get skeleton(): Nullable<Skeleton>;
  28519. /**
  28520. * Rendering ground id of the source mesh
  28521. */
  28522. get renderingGroupId(): number;
  28523. set renderingGroupId(value: number);
  28524. /**
  28525. * Returns the total number of vertices (integer).
  28526. */
  28527. getTotalVertices(): number;
  28528. /**
  28529. * Returns a positive integer : the total number of indices in this mesh geometry.
  28530. * @returns the numner of indices or zero if the mesh has no geometry.
  28531. */
  28532. getTotalIndices(): number;
  28533. /**
  28534. * The source mesh of the instance
  28535. */
  28536. get sourceMesh(): Mesh;
  28537. /**
  28538. * Creates a new InstancedMesh object from the mesh model.
  28539. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  28540. * @param name defines the name of the new instance
  28541. * @returns a new InstancedMesh
  28542. */
  28543. createInstance(name: string): InstancedMesh;
  28544. /**
  28545. * Is this node ready to be used/rendered
  28546. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  28547. * @return {boolean} is it ready
  28548. */
  28549. isReady(completeCheck?: boolean): boolean;
  28550. /**
  28551. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  28552. * @param kind kind of verticies to retrieve (eg. positions, normals, uvs, etc.)
  28553. * @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.
  28554. * @returns a float array or a Float32Array of the requested kind of data : positions, normals, uvs, etc.
  28555. */
  28556. getVerticesData(kind: string, copyWhenShared?: boolean): Nullable<FloatArray>;
  28557. /**
  28558. * Sets the vertex data of the mesh geometry for the requested `kind`.
  28559. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  28560. * The `data` are either a numeric array either a Float32Array.
  28561. * The parameter `updatable` is passed as is to the underlying Geometry object constructor (if initially none) or updater.
  28562. * 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).
  28563. * Note that a new underlying VertexBuffer object is created each call.
  28564. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  28565. *
  28566. * Possible `kind` values :
  28567. * - VertexBuffer.PositionKind
  28568. * - VertexBuffer.UVKind
  28569. * - VertexBuffer.UV2Kind
  28570. * - VertexBuffer.UV3Kind
  28571. * - VertexBuffer.UV4Kind
  28572. * - VertexBuffer.UV5Kind
  28573. * - VertexBuffer.UV6Kind
  28574. * - VertexBuffer.ColorKind
  28575. * - VertexBuffer.MatricesIndicesKind
  28576. * - VertexBuffer.MatricesIndicesExtraKind
  28577. * - VertexBuffer.MatricesWeightsKind
  28578. * - VertexBuffer.MatricesWeightsExtraKind
  28579. *
  28580. * Returns the Mesh.
  28581. */
  28582. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  28583. /**
  28584. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  28585. * If the mesh has no geometry, it is simply returned as it is.
  28586. * The `data` are either a numeric array either a Float32Array.
  28587. * No new underlying VertexBuffer object is created.
  28588. * 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.
  28589. * If the parameter `makeItUnique` is true, a new global geometry is created from this positions and is set to the mesh.
  28590. *
  28591. * Possible `kind` values :
  28592. * - VertexBuffer.PositionKind
  28593. * - VertexBuffer.UVKind
  28594. * - VertexBuffer.UV2Kind
  28595. * - VertexBuffer.UV3Kind
  28596. * - VertexBuffer.UV4Kind
  28597. * - VertexBuffer.UV5Kind
  28598. * - VertexBuffer.UV6Kind
  28599. * - VertexBuffer.ColorKind
  28600. * - VertexBuffer.MatricesIndicesKind
  28601. * - VertexBuffer.MatricesIndicesExtraKind
  28602. * - VertexBuffer.MatricesWeightsKind
  28603. * - VertexBuffer.MatricesWeightsExtraKind
  28604. *
  28605. * Returns the Mesh.
  28606. */
  28607. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): Mesh;
  28608. /**
  28609. * Sets the mesh indices.
  28610. * Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array).
  28611. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  28612. * This method creates a new index buffer each call.
  28613. * Returns the Mesh.
  28614. */
  28615. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>): Mesh;
  28616. /**
  28617. * Boolean : True if the mesh owns the requested kind of data.
  28618. */
  28619. isVerticesDataPresent(kind: string): boolean;
  28620. /**
  28621. * Returns an array of indices (IndicesArray).
  28622. */
  28623. getIndices(): Nullable<IndicesArray>;
  28624. get _positions(): Nullable<Vector3[]>;
  28625. /**
  28626. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  28627. * This means the mesh underlying bounding box and sphere are recomputed.
  28628. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  28629. * @returns the current mesh
  28630. */
  28631. refreshBoundingInfo(applySkeleton?: boolean): InstancedMesh;
  28632. /** @hidden */
  28633. _preActivate(): InstancedMesh;
  28634. /** @hidden */
  28635. _activate(renderId: number, intermediateRendering: boolean): boolean;
  28636. /** @hidden */
  28637. _postActivate(): void;
  28638. getWorldMatrix(): Matrix;
  28639. get isAnInstance(): boolean;
  28640. /**
  28641. * Returns the current associated LOD AbstractMesh.
  28642. */
  28643. getLOD(camera: Camera): AbstractMesh;
  28644. /** @hidden */
  28645. _preActivateForIntermediateRendering(renderId: number): Mesh;
  28646. /** @hidden */
  28647. _syncSubMeshes(): InstancedMesh;
  28648. /** @hidden */
  28649. _generatePointsArray(): boolean;
  28650. /** @hidden */
  28651. _updateBoundingInfo(): AbstractMesh;
  28652. /**
  28653. * Creates a new InstancedMesh from the current mesh.
  28654. * - name (string) : the cloned mesh name
  28655. * - newParent (optional Node) : the optional Node to parent the clone to.
  28656. * - doNotCloneChildren (optional boolean, default `false`) : if `true` the model children aren't cloned.
  28657. *
  28658. * Returns the clone.
  28659. */
  28660. clone(name: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean): InstancedMesh;
  28661. /**
  28662. * Disposes the InstancedMesh.
  28663. * Returns nothing.
  28664. */
  28665. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  28666. }
  28667. interface Mesh {
  28668. /**
  28669. * Register a custom buffer that will be instanced
  28670. * @see https://doc.babylonjs.com/how_to/how_to_use_instances#custom-buffers
  28671. * @param kind defines the buffer kind
  28672. * @param stride defines the stride in floats
  28673. */
  28674. registerInstancedBuffer(kind: string, stride: number): void;
  28675. /**
  28676. * Invalidate VertexArrayObjects belonging to the mesh (but not to the Geometry of the mesh).
  28677. */
  28678. _invalidateInstanceVertexArrayObject(): void;
  28679. /**
  28680. * true to use the edge renderer for all instances of this mesh
  28681. */
  28682. edgesShareWithInstances: boolean;
  28683. /** @hidden */
  28684. _userInstancedBuffersStorage: {
  28685. data: {
  28686. [key: string]: Float32Array;
  28687. };
  28688. sizes: {
  28689. [key: string]: number;
  28690. };
  28691. vertexBuffers: {
  28692. [key: string]: Nullable<VertexBuffer>;
  28693. };
  28694. strides: {
  28695. [key: string]: number;
  28696. };
  28697. vertexArrayObjects?: {
  28698. [key: string]: WebGLVertexArrayObject;
  28699. };
  28700. };
  28701. }
  28702. interface AbstractMesh {
  28703. /**
  28704. * Object used to store instanced buffers defined by user
  28705. * @see https://doc.babylonjs.com/how_to/how_to_use_instances#custom-buffers
  28706. */
  28707. instancedBuffers: {
  28708. [key: string]: any;
  28709. };
  28710. }
  28711. }
  28712. declare module BABYLON {
  28713. /**
  28714. * Defines the options associated with the creation of a shader material.
  28715. */
  28716. export interface IShaderMaterialOptions {
  28717. /**
  28718. * Does the material work in alpha blend mode
  28719. */
  28720. needAlphaBlending: boolean;
  28721. /**
  28722. * Does the material work in alpha test mode
  28723. */
  28724. needAlphaTesting: boolean;
  28725. /**
  28726. * The list of attribute names used in the shader
  28727. */
  28728. attributes: string[];
  28729. /**
  28730. * The list of uniform names used in the shader
  28731. */
  28732. uniforms: string[];
  28733. /**
  28734. * The list of UBO names used in the shader
  28735. */
  28736. uniformBuffers: string[];
  28737. /**
  28738. * The list of sampler names used in the shader
  28739. */
  28740. samplers: string[];
  28741. /**
  28742. * The list of defines used in the shader
  28743. */
  28744. defines: string[];
  28745. }
  28746. /**
  28747. * 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.
  28748. *
  28749. * This returned material effects how the mesh will look based on the code in the shaders.
  28750. *
  28751. * @see https://doc.babylonjs.com/how_to/shader_material
  28752. */
  28753. export class ShaderMaterial extends Material {
  28754. private _shaderPath;
  28755. private _options;
  28756. private _textures;
  28757. private _textureArrays;
  28758. private _floats;
  28759. private _ints;
  28760. private _floatsArrays;
  28761. private _colors3;
  28762. private _colors3Arrays;
  28763. private _colors4;
  28764. private _colors4Arrays;
  28765. private _vectors2;
  28766. private _vectors3;
  28767. private _vectors4;
  28768. private _matrices;
  28769. private _matrixArrays;
  28770. private _matrices3x3;
  28771. private _matrices2x2;
  28772. private _vectors2Arrays;
  28773. private _vectors3Arrays;
  28774. private _vectors4Arrays;
  28775. private _cachedWorldViewMatrix;
  28776. private _cachedWorldViewProjectionMatrix;
  28777. private _renderId;
  28778. private _multiview;
  28779. private _cachedDefines;
  28780. /** Define the Url to load snippets */
  28781. static SnippetUrl: string;
  28782. /** Snippet ID if the material was created from the snippet server */
  28783. snippetId: string;
  28784. /**
  28785. * Instantiate a new shader material.
  28786. * 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.
  28787. * This returned material effects how the mesh will look based on the code in the shaders.
  28788. * @see https://doc.babylonjs.com/how_to/shader_material
  28789. * @param name Define the name of the material in the scene
  28790. * @param scene Define the scene the material belongs to
  28791. * @param shaderPath Defines the route to the shader code in one of three ways:
  28792. * * object: { vertex: "custom", fragment: "custom" }, used with Effect.ShadersStore["customVertexShader"] and Effect.ShadersStore["customFragmentShader"]
  28793. * * object: { vertexElement: "vertexShaderCode", fragmentElement: "fragmentShaderCode" }, used with shader code in script tags
  28794. * * object: { vertexSource: "vertex shader code string", fragmentSource: "fragment shader code string" } using with strings containing the shaders code
  28795. * * string: "./COMMON_NAME", used with external files COMMON_NAME.vertex.fx and COMMON_NAME.fragment.fx in index.html folder.
  28796. * @param options Define the options used to create the shader
  28797. */
  28798. constructor(name: string, scene: Scene, shaderPath: any, options?: Partial<IShaderMaterialOptions>);
  28799. /**
  28800. * Gets the shader path used to define the shader code
  28801. * It can be modified to trigger a new compilation
  28802. */
  28803. get shaderPath(): any;
  28804. /**
  28805. * Sets the shader path used to define the shader code
  28806. * It can be modified to trigger a new compilation
  28807. */
  28808. set shaderPath(shaderPath: any);
  28809. /**
  28810. * Gets the options used to compile the shader.
  28811. * They can be modified to trigger a new compilation
  28812. */
  28813. get options(): IShaderMaterialOptions;
  28814. /**
  28815. * Gets the current class name of the material e.g. "ShaderMaterial"
  28816. * Mainly use in serialization.
  28817. * @returns the class name
  28818. */
  28819. getClassName(): string;
  28820. /**
  28821. * Specifies if the material will require alpha blending
  28822. * @returns a boolean specifying if alpha blending is needed
  28823. */
  28824. needAlphaBlending(): boolean;
  28825. /**
  28826. * Specifies if this material should be rendered in alpha test mode
  28827. * @returns a boolean specifying if an alpha test is needed.
  28828. */
  28829. needAlphaTesting(): boolean;
  28830. private _checkUniform;
  28831. /**
  28832. * Set a texture in the shader.
  28833. * @param name Define the name of the uniform samplers as defined in the shader
  28834. * @param texture Define the texture to bind to this sampler
  28835. * @return the material itself allowing "fluent" like uniform updates
  28836. */
  28837. setTexture(name: string, texture: BaseTexture): ShaderMaterial;
  28838. /**
  28839. * Set a texture array in the shader.
  28840. * @param name Define the name of the uniform sampler array as defined in the shader
  28841. * @param textures Define the list of textures to bind to this sampler
  28842. * @return the material itself allowing "fluent" like uniform updates
  28843. */
  28844. setTextureArray(name: string, textures: BaseTexture[]): ShaderMaterial;
  28845. /**
  28846. * Set a float in the shader.
  28847. * @param name Define the name of the uniform as defined in the shader
  28848. * @param value Define the value to give to the uniform
  28849. * @return the material itself allowing "fluent" like uniform updates
  28850. */
  28851. setFloat(name: string, value: number): ShaderMaterial;
  28852. /**
  28853. * Set a int in the shader.
  28854. * @param name Define the name of the uniform as defined in the shader
  28855. * @param value Define the value to give to the uniform
  28856. * @return the material itself allowing "fluent" like uniform updates
  28857. */
  28858. setInt(name: string, value: number): ShaderMaterial;
  28859. /**
  28860. * Set an array of floats in the shader.
  28861. * @param name Define the name of the uniform as defined in the shader
  28862. * @param value Define the value to give to the uniform
  28863. * @return the material itself allowing "fluent" like uniform updates
  28864. */
  28865. setFloats(name: string, value: number[]): ShaderMaterial;
  28866. /**
  28867. * Set a vec3 in the shader from a Color3.
  28868. * @param name Define the name of the uniform as defined in the shader
  28869. * @param value Define the value to give to the uniform
  28870. * @return the material itself allowing "fluent" like uniform updates
  28871. */
  28872. setColor3(name: string, value: Color3): ShaderMaterial;
  28873. /**
  28874. * Set a vec3 array in the shader from a Color3 array.
  28875. * @param name Define the name of the uniform as defined in the shader
  28876. * @param value Define the value to give to the uniform
  28877. * @return the material itself allowing "fluent" like uniform updates
  28878. */
  28879. setColor3Array(name: string, value: Color3[]): ShaderMaterial;
  28880. /**
  28881. * Set a vec4 in the shader from a Color4.
  28882. * @param name Define the name of the uniform as defined in the shader
  28883. * @param value Define the value to give to the uniform
  28884. * @return the material itself allowing "fluent" like uniform updates
  28885. */
  28886. setColor4(name: string, value: Color4): ShaderMaterial;
  28887. /**
  28888. * Set a vec4 array in the shader from a Color4 array.
  28889. * @param name Define the name of the uniform as defined in the shader
  28890. * @param value Define the value to give to the uniform
  28891. * @return the material itself allowing "fluent" like uniform updates
  28892. */
  28893. setColor4Array(name: string, value: Color4[]): ShaderMaterial;
  28894. /**
  28895. * Set a vec2 in the shader from a Vector2.
  28896. * @param name Define the name of the uniform as defined in the shader
  28897. * @param value Define the value to give to the uniform
  28898. * @return the material itself allowing "fluent" like uniform updates
  28899. */
  28900. setVector2(name: string, value: Vector2): ShaderMaterial;
  28901. /**
  28902. * Set a vec3 in the shader from a Vector3.
  28903. * @param name Define the name of the uniform as defined in the shader
  28904. * @param value Define the value to give to the uniform
  28905. * @return the material itself allowing "fluent" like uniform updates
  28906. */
  28907. setVector3(name: string, value: Vector3): ShaderMaterial;
  28908. /**
  28909. * Set a vec4 in the shader from a Vector4.
  28910. * @param name Define the name of the uniform as defined in the shader
  28911. * @param value Define the value to give to the uniform
  28912. * @return the material itself allowing "fluent" like uniform updates
  28913. */
  28914. setVector4(name: string, value: Vector4): ShaderMaterial;
  28915. /**
  28916. * Set a mat4 in the shader from a Matrix.
  28917. * @param name Define the name of the uniform as defined in the shader
  28918. * @param value Define the value to give to the uniform
  28919. * @return the material itself allowing "fluent" like uniform updates
  28920. */
  28921. setMatrix(name: string, value: Matrix): ShaderMaterial;
  28922. /**
  28923. * Set a float32Array in the shader from a matrix array.
  28924. * @param name Define the name of the uniform as defined in the shader
  28925. * @param value Define the value to give to the uniform
  28926. * @return the material itself allowing "fluent" like uniform updates
  28927. */
  28928. setMatrices(name: string, value: Matrix[]): ShaderMaterial;
  28929. /**
  28930. * Set a mat3 in the shader from a Float32Array.
  28931. * @param name Define the name of the uniform as defined in the shader
  28932. * @param value Define the value to give to the uniform
  28933. * @return the material itself allowing "fluent" like uniform updates
  28934. */
  28935. setMatrix3x3(name: string, value: Float32Array | Array<number>): ShaderMaterial;
  28936. /**
  28937. * Set a mat2 in the shader from a Float32Array.
  28938. * @param name Define the name of the uniform as defined in the shader
  28939. * @param value Define the value to give to the uniform
  28940. * @return the material itself allowing "fluent" like uniform updates
  28941. */
  28942. setMatrix2x2(name: string, value: Float32Array | Array<number>): ShaderMaterial;
  28943. /**
  28944. * Set a vec2 array in the shader from a number array.
  28945. * @param name Define the name of the uniform as defined in the shader
  28946. * @param value Define the value to give to the uniform
  28947. * @return the material itself allowing "fluent" like uniform updates
  28948. */
  28949. setArray2(name: string, value: number[]): ShaderMaterial;
  28950. /**
  28951. * Set a vec3 array in the shader from a number array.
  28952. * @param name Define the name of the uniform as defined in the shader
  28953. * @param value Define the value to give to the uniform
  28954. * @return the material itself allowing "fluent" like uniform updates
  28955. */
  28956. setArray3(name: string, value: number[]): ShaderMaterial;
  28957. /**
  28958. * Set a vec4 array in the shader from a number array.
  28959. * @param name Define the name of the uniform as defined in the shader
  28960. * @param value Define the value to give to the uniform
  28961. * @return the material itself allowing "fluent" like uniform updates
  28962. */
  28963. setArray4(name: string, value: number[]): ShaderMaterial;
  28964. private _checkCache;
  28965. /**
  28966. * Specifies that the submesh is ready to be used
  28967. * @param mesh defines the mesh to check
  28968. * @param subMesh defines which submesh to check
  28969. * @param useInstances specifies that instances should be used
  28970. * @returns a boolean indicating that the submesh is ready or not
  28971. */
  28972. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  28973. /**
  28974. * Checks if the material is ready to render the requested mesh
  28975. * @param mesh Define the mesh to render
  28976. * @param useInstances Define whether or not the material is used with instances
  28977. * @returns true if ready, otherwise false
  28978. */
  28979. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  28980. /**
  28981. * Binds the world matrix to the material
  28982. * @param world defines the world transformation matrix
  28983. * @param effectOverride - If provided, use this effect instead of internal effect
  28984. */
  28985. bindOnlyWorldMatrix(world: Matrix, effectOverride?: Nullable<Effect>): void;
  28986. /**
  28987. * Binds the submesh to this material by preparing the effect and shader to draw
  28988. * @param world defines the world transformation matrix
  28989. * @param mesh defines the mesh containing the submesh
  28990. * @param subMesh defines the submesh to bind the material to
  28991. */
  28992. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  28993. /**
  28994. * Binds the material to the mesh
  28995. * @param world defines the world transformation matrix
  28996. * @param mesh defines the mesh to bind the material to
  28997. * @param effectOverride - If provided, use this effect instead of internal effect
  28998. */
  28999. bind(world: Matrix, mesh?: Mesh, effectOverride?: Nullable<Effect>): void;
  29000. protected _afterBind(mesh?: Mesh, effect?: Nullable<Effect>): void;
  29001. /**
  29002. * Gets the active textures from the material
  29003. * @returns an array of textures
  29004. */
  29005. getActiveTextures(): BaseTexture[];
  29006. /**
  29007. * Specifies if the material uses a texture
  29008. * @param texture defines the texture to check against the material
  29009. * @returns a boolean specifying if the material uses the texture
  29010. */
  29011. hasTexture(texture: BaseTexture): boolean;
  29012. /**
  29013. * Makes a duplicate of the material, and gives it a new name
  29014. * @param name defines the new name for the duplicated material
  29015. * @returns the cloned material
  29016. */
  29017. clone(name: string): ShaderMaterial;
  29018. /**
  29019. * Disposes the material
  29020. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  29021. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  29022. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  29023. */
  29024. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  29025. /**
  29026. * Serializes this material in a JSON representation
  29027. * @returns the serialized material object
  29028. */
  29029. serialize(): any;
  29030. /**
  29031. * Creates a shader material from parsed shader material data
  29032. * @param source defines the JSON representation of the material
  29033. * @param scene defines the hosting scene
  29034. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  29035. * @returns a new material
  29036. */
  29037. static Parse(source: any, scene: Scene, rootUrl: string): ShaderMaterial;
  29038. /**
  29039. * Creates a new ShaderMaterial from a snippet saved in a remote file
  29040. * @param name defines the name of the ShaderMaterial to create (can be null or empty to use the one from the json data)
  29041. * @param url defines the url to load from
  29042. * @param scene defines the hosting scene
  29043. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  29044. * @returns a promise that will resolve to the new ShaderMaterial
  29045. */
  29046. static ParseFromFileAsync(name: Nullable<string>, url: string, scene: Scene, rootUrl?: string): Promise<ShaderMaterial>;
  29047. /**
  29048. * Creates a ShaderMaterial from a snippet saved by the Inspector
  29049. * @param snippetId defines the snippet to load
  29050. * @param scene defines the hosting scene
  29051. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  29052. * @returns a promise that will resolve to the new ShaderMaterial
  29053. */
  29054. static CreateFromSnippetAsync(snippetId: string, scene: Scene, rootUrl?: string): Promise<ShaderMaterial>;
  29055. }
  29056. }
  29057. declare module BABYLON {
  29058. /** @hidden */
  29059. export var colorPixelShader: {
  29060. name: string;
  29061. shader: string;
  29062. };
  29063. }
  29064. declare module BABYLON {
  29065. /** @hidden */
  29066. export var colorVertexShader: {
  29067. name: string;
  29068. shader: string;
  29069. };
  29070. }
  29071. declare module BABYLON {
  29072. /**
  29073. * Line mesh
  29074. * @see https://doc.babylonjs.com/babylon101/parametric_shapes
  29075. */
  29076. export class LinesMesh extends Mesh {
  29077. /**
  29078. * If vertex color should be applied to the mesh
  29079. */
  29080. readonly useVertexColor?: boolean | undefined;
  29081. /**
  29082. * If vertex alpha should be applied to the mesh
  29083. */
  29084. readonly useVertexAlpha?: boolean | undefined;
  29085. /**
  29086. * Color of the line (Default: White)
  29087. */
  29088. color: Color3;
  29089. /**
  29090. * Alpha of the line (Default: 1)
  29091. */
  29092. alpha: number;
  29093. /**
  29094. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  29095. * This margin is expressed in world space coordinates, so its value may vary.
  29096. * Default value is 0.1
  29097. */
  29098. intersectionThreshold: number;
  29099. private _colorShader;
  29100. private color4;
  29101. /**
  29102. * Creates a new LinesMesh
  29103. * @param name defines the name
  29104. * @param scene defines the hosting scene
  29105. * @param parent defines the parent mesh if any
  29106. * @param source defines the optional source LinesMesh used to clone data from
  29107. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  29108. * When false, achieved by calling a clone(), also passing False.
  29109. * This will make creation of children, recursive.
  29110. * @param useVertexColor defines if this LinesMesh supports vertex color
  29111. * @param useVertexAlpha defines if this LinesMesh supports vertex alpha
  29112. */
  29113. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<LinesMesh>, doNotCloneChildren?: boolean,
  29114. /**
  29115. * If vertex color should be applied to the mesh
  29116. */
  29117. useVertexColor?: boolean | undefined,
  29118. /**
  29119. * If vertex alpha should be applied to the mesh
  29120. */
  29121. useVertexAlpha?: boolean | undefined);
  29122. private _addClipPlaneDefine;
  29123. private _removeClipPlaneDefine;
  29124. isReady(): boolean;
  29125. /**
  29126. * Returns the string "LineMesh"
  29127. */
  29128. getClassName(): string;
  29129. /**
  29130. * @hidden
  29131. */
  29132. get material(): Material;
  29133. /**
  29134. * @hidden
  29135. */
  29136. set material(value: Material);
  29137. /**
  29138. * @hidden
  29139. */
  29140. get checkCollisions(): boolean;
  29141. set checkCollisions(value: boolean);
  29142. /** @hidden */
  29143. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  29144. /** @hidden */
  29145. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): Mesh;
  29146. /**
  29147. * Disposes of the line mesh
  29148. * @param doNotRecurse If children should be disposed
  29149. */
  29150. dispose(doNotRecurse?: boolean): void;
  29151. /**
  29152. * Returns a new LineMesh object cloned from the current one.
  29153. */
  29154. clone(name: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean): LinesMesh;
  29155. /**
  29156. * Creates a new InstancedLinesMesh object from the mesh model.
  29157. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  29158. * @param name defines the name of the new instance
  29159. * @returns a new InstancedLinesMesh
  29160. */
  29161. createInstance(name: string): InstancedLinesMesh;
  29162. }
  29163. /**
  29164. * Creates an instance based on a source LinesMesh
  29165. */
  29166. export class InstancedLinesMesh extends InstancedMesh {
  29167. /**
  29168. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  29169. * This margin is expressed in world space coordinates, so its value may vary.
  29170. * Initialized with the intersectionThreshold value of the source LinesMesh
  29171. */
  29172. intersectionThreshold: number;
  29173. constructor(name: string, source: LinesMesh);
  29174. /**
  29175. * Returns the string "InstancedLinesMesh".
  29176. */
  29177. getClassName(): string;
  29178. }
  29179. }
  29180. declare module BABYLON {
  29181. /** @hidden */
  29182. export var linePixelShader: {
  29183. name: string;
  29184. shader: string;
  29185. };
  29186. }
  29187. declare module BABYLON {
  29188. /** @hidden */
  29189. export var lineVertexShader: {
  29190. name: string;
  29191. shader: string;
  29192. };
  29193. }
  29194. declare module BABYLON {
  29195. interface Scene {
  29196. /** @hidden */
  29197. _edgeRenderLineShader: Nullable<ShaderMaterial>;
  29198. }
  29199. interface AbstractMesh {
  29200. /**
  29201. * Gets the edgesRenderer associated with the mesh
  29202. */
  29203. edgesRenderer: Nullable<EdgesRenderer>;
  29204. }
  29205. interface LinesMesh {
  29206. /**
  29207. * Enables the edge rendering mode on the mesh.
  29208. * This mode makes the mesh edges visible
  29209. * @param epsilon defines the maximal distance between two angles to detect a face
  29210. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  29211. * @returns the currentAbstractMesh
  29212. * @see https://www.babylonjs-playground.com/#19O9TU#0
  29213. */
  29214. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  29215. }
  29216. interface InstancedLinesMesh {
  29217. /**
  29218. * Enables the edge rendering mode on the mesh.
  29219. * This mode makes the mesh edges visible
  29220. * @param epsilon defines the maximal distance between two angles to detect a face
  29221. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  29222. * @returns the current InstancedLinesMesh
  29223. * @see https://www.babylonjs-playground.com/#19O9TU#0
  29224. */
  29225. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): InstancedLinesMesh;
  29226. }
  29227. /**
  29228. * Defines the minimum contract an Edges renderer should follow.
  29229. */
  29230. export interface IEdgesRenderer extends IDisposable {
  29231. /**
  29232. * Gets or sets a boolean indicating if the edgesRenderer is active
  29233. */
  29234. isEnabled: boolean;
  29235. /**
  29236. * Renders the edges of the attached mesh,
  29237. */
  29238. render(): void;
  29239. /**
  29240. * Checks wether or not the edges renderer is ready to render.
  29241. * @return true if ready, otherwise false.
  29242. */
  29243. isReady(): boolean;
  29244. /**
  29245. * List of instances to render in case the source mesh has instances
  29246. */
  29247. customInstances: SmartArray<Matrix>;
  29248. }
  29249. /**
  29250. * Defines the additional options of the edges renderer
  29251. */
  29252. export interface IEdgesRendererOptions {
  29253. /**
  29254. * Gets or sets a boolean indicating that the alternate edge finder algorithm must be used
  29255. * If not defined, the default value is true
  29256. */
  29257. useAlternateEdgeFinder?: boolean;
  29258. /**
  29259. * Gets or sets a boolean indicating that the vertex merger fast processing must be used.
  29260. * If not defined, the default value is true.
  29261. * 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)
  29262. * This option is used only if useAlternateEdgeFinder = true
  29263. */
  29264. useFastVertexMerger?: boolean;
  29265. /**
  29266. * During edges processing, the vertices are merged if they are close enough: epsilonVertexMerge is the limit whithin which vertices are considered to be equal.
  29267. * The default value is 1e-6
  29268. * This option is used only if useAlternateEdgeFinder = true
  29269. */
  29270. epsilonVertexMerge?: number;
  29271. /**
  29272. * 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
  29273. * 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.
  29274. * This option is used only if useAlternateEdgeFinder = true
  29275. */
  29276. applyTessellation?: boolean;
  29277. /**
  29278. * 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
  29279. * The default value is 1e-6
  29280. * This option is used only if useAlternateEdgeFinder = true
  29281. */
  29282. epsilonVertexAligned?: number;
  29283. }
  29284. /**
  29285. * This class is used to generate edges of the mesh that could then easily be rendered in a scene.
  29286. */
  29287. export class EdgesRenderer implements IEdgesRenderer {
  29288. /**
  29289. * Define the size of the edges with an orthographic camera
  29290. */
  29291. edgesWidthScalerForOrthographic: number;
  29292. /**
  29293. * Define the size of the edges with a perspective camera
  29294. */
  29295. edgesWidthScalerForPerspective: number;
  29296. protected _source: AbstractMesh;
  29297. protected _linesPositions: number[];
  29298. protected _linesNormals: number[];
  29299. protected _linesIndices: number[];
  29300. protected _epsilon: number;
  29301. protected _indicesCount: number;
  29302. protected _lineShader: ShaderMaterial;
  29303. protected _ib: DataBuffer;
  29304. protected _buffers: {
  29305. [key: string]: Nullable<VertexBuffer>;
  29306. };
  29307. protected _buffersForInstances: {
  29308. [key: string]: Nullable<VertexBuffer>;
  29309. };
  29310. protected _checkVerticesInsteadOfIndices: boolean;
  29311. protected _options: Nullable<IEdgesRendererOptions>;
  29312. private _meshRebuildObserver;
  29313. private _meshDisposeObserver;
  29314. /** Gets or sets a boolean indicating if the edgesRenderer is active */
  29315. isEnabled: boolean;
  29316. /** Gets the vertices generated by the edge renderer */
  29317. get linesPositions(): Immutable<Array<number>>;
  29318. /** Gets the normals generated by the edge renderer */
  29319. get linesNormals(): Immutable<Array<number>>;
  29320. /** Gets the indices generated by the edge renderer */
  29321. get linesIndices(): Immutable<Array<number>>;
  29322. /**
  29323. * List of instances to render in case the source mesh has instances
  29324. */
  29325. customInstances: SmartArray<Matrix>;
  29326. private static GetShader;
  29327. /**
  29328. * Creates an instance of the EdgesRenderer. It is primarily use to display edges of a mesh.
  29329. * Beware when you use this class with complex objects as the adjacencies computation can be really long
  29330. * @param source Mesh used to create edges
  29331. * @param epsilon sum of angles in adjacency to check for edge
  29332. * @param checkVerticesInsteadOfIndices bases the edges detection on vertices vs indices. Note that this parameter is not used if options.useAlternateEdgeFinder = true
  29333. * @param generateEdgesLines - should generate Lines or only prepare resources.
  29334. * @param options The options to apply when generating the edges
  29335. */
  29336. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean, generateEdgesLines?: boolean, options?: IEdgesRendererOptions);
  29337. protected _prepareRessources(): void;
  29338. /** @hidden */
  29339. _rebuild(): void;
  29340. /**
  29341. * Releases the required resources for the edges renderer
  29342. */
  29343. dispose(): void;
  29344. protected _processEdgeForAdjacencies(pa: number, pb: number, p0: number, p1: number, p2: number): number;
  29345. protected _processEdgeForAdjacenciesWithVertices(pa: Vector3, pb: Vector3, p0: Vector3, p1: Vector3, p2: Vector3): number;
  29346. /**
  29347. * Checks if the pair of p0 and p1 is en edge
  29348. * @param faceIndex
  29349. * @param edge
  29350. * @param faceNormals
  29351. * @param p0
  29352. * @param p1
  29353. * @private
  29354. */
  29355. protected _checkEdge(faceIndex: number, edge: number, faceNormals: Array<Vector3>, p0: Vector3, p1: Vector3): void;
  29356. /**
  29357. * push line into the position, normal and index buffer
  29358. * @protected
  29359. */
  29360. protected createLine(p0: Vector3, p1: Vector3, offset: number): void;
  29361. /**
  29362. * See https://playground.babylonjs.com/#R3JR6V#1 for a visual display of the algorithm
  29363. */
  29364. private _tessellateTriangle;
  29365. private _generateEdgesLinesAlternate;
  29366. /**
  29367. * Generates lines edges from adjacencjes
  29368. * @private
  29369. */
  29370. _generateEdgesLines(): void;
  29371. /**
  29372. * Checks wether or not the edges renderer is ready to render.
  29373. * @return true if ready, otherwise false.
  29374. */
  29375. isReady(): boolean;
  29376. /**
  29377. * Renders the edges of the attached mesh,
  29378. */
  29379. render(): void;
  29380. }
  29381. /**
  29382. * LineEdgesRenderer for LineMeshes to remove unnecessary triangulation
  29383. */
  29384. export class LineEdgesRenderer extends EdgesRenderer {
  29385. /**
  29386. * This constructor turns off auto generating edges line in Edges Renderer to make it here.
  29387. * @param source LineMesh used to generate edges
  29388. * @param epsilon not important (specified angle for edge detection)
  29389. * @param checkVerticesInsteadOfIndices not important for LineMesh
  29390. */
  29391. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean);
  29392. /**
  29393. * Generate edges for each line in LinesMesh. Every Line should be rendered as edge.
  29394. */
  29395. _generateEdgesLines(): void;
  29396. }
  29397. }
  29398. declare module BABYLON {
  29399. /**
  29400. * This represents the object necessary to create a rendering group.
  29401. * This is exclusively used and created by the rendering manager.
  29402. * To modify the behavior, you use the available helpers in your scene or meshes.
  29403. * @hidden
  29404. */
  29405. export class RenderingGroup {
  29406. index: number;
  29407. private static _zeroVector;
  29408. private _scene;
  29409. private _opaqueSubMeshes;
  29410. private _transparentSubMeshes;
  29411. private _alphaTestSubMeshes;
  29412. private _depthOnlySubMeshes;
  29413. private _particleSystems;
  29414. private _spriteManagers;
  29415. private _opaqueSortCompareFn;
  29416. private _alphaTestSortCompareFn;
  29417. private _transparentSortCompareFn;
  29418. private _renderOpaque;
  29419. private _renderAlphaTest;
  29420. private _renderTransparent;
  29421. /** @hidden */
  29422. _edgesRenderers: SmartArrayNoDuplicate<IEdgesRenderer>;
  29423. onBeforeTransparentRendering: () => void;
  29424. /**
  29425. * Set the opaque sort comparison function.
  29426. * If null the sub meshes will be render in the order they were created
  29427. */
  29428. set opaqueSortCompareFn(value: Nullable<(a: SubMesh, b: SubMesh) => number>);
  29429. /**
  29430. * Set the alpha test sort comparison function.
  29431. * If null the sub meshes will be render in the order they were created
  29432. */
  29433. set alphaTestSortCompareFn(value: Nullable<(a: SubMesh, b: SubMesh) => number>);
  29434. /**
  29435. * Set the transparent sort comparison function.
  29436. * If null the sub meshes will be render in the order they were created
  29437. */
  29438. set transparentSortCompareFn(value: Nullable<(a: SubMesh, b: SubMesh) => number>);
  29439. /**
  29440. * Creates a new rendering group.
  29441. * @param index The rendering group index
  29442. * @param opaqueSortCompareFn The opaque sort comparison function. If null no order is applied
  29443. * @param alphaTestSortCompareFn The alpha test sort comparison function. If null no order is applied
  29444. * @param transparentSortCompareFn The transparent sort comparison function. If null back to front + alpha index sort is applied
  29445. */
  29446. 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>);
  29447. /**
  29448. * Render all the sub meshes contained in the group.
  29449. * @param customRenderFunction Used to override the default render behaviour of the group.
  29450. * @returns true if rendered some submeshes.
  29451. */
  29452. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, renderSprites: boolean, renderParticles: boolean, activeMeshes: Nullable<AbstractMesh[]>): void;
  29453. /**
  29454. * Renders the opaque submeshes in the order from the opaqueSortCompareFn.
  29455. * @param subMeshes The submeshes to render
  29456. */
  29457. private renderOpaqueSorted;
  29458. /**
  29459. * Renders the opaque submeshes in the order from the alphatestSortCompareFn.
  29460. * @param subMeshes The submeshes to render
  29461. */
  29462. private renderAlphaTestSorted;
  29463. /**
  29464. * Renders the opaque submeshes in the order from the transparentSortCompareFn.
  29465. * @param subMeshes The submeshes to render
  29466. */
  29467. private renderTransparentSorted;
  29468. /**
  29469. * Renders the submeshes in a specified order.
  29470. * @param subMeshes The submeshes to sort before render
  29471. * @param sortCompareFn The comparison function use to sort
  29472. * @param cameraPosition The camera position use to preprocess the submeshes to help sorting
  29473. * @param transparent Specifies to activate blending if true
  29474. */
  29475. private static renderSorted;
  29476. /**
  29477. * Renders the submeshes in the order they were dispatched (no sort applied).
  29478. * @param subMeshes The submeshes to render
  29479. */
  29480. private static renderUnsorted;
  29481. /**
  29482. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  29483. * are rendered back to front if in the same alpha index.
  29484. *
  29485. * @param a The first submesh
  29486. * @param b The second submesh
  29487. * @returns The result of the comparison
  29488. */
  29489. static defaultTransparentSortCompare(a: SubMesh, b: SubMesh): number;
  29490. /**
  29491. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  29492. * are rendered back to front.
  29493. *
  29494. * @param a The first submesh
  29495. * @param b The second submesh
  29496. * @returns The result of the comparison
  29497. */
  29498. static backToFrontSortCompare(a: SubMesh, b: SubMesh): number;
  29499. /**
  29500. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  29501. * are rendered front to back (prevent overdraw).
  29502. *
  29503. * @param a The first submesh
  29504. * @param b The second submesh
  29505. * @returns The result of the comparison
  29506. */
  29507. static frontToBackSortCompare(a: SubMesh, b: SubMesh): number;
  29508. /**
  29509. * Resets the different lists of submeshes to prepare a new frame.
  29510. */
  29511. prepare(): void;
  29512. dispose(): void;
  29513. /**
  29514. * Inserts the submesh in its correct queue depending on its material.
  29515. * @param subMesh The submesh to dispatch
  29516. * @param [mesh] Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  29517. * @param [material] Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  29518. */
  29519. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  29520. dispatchSprites(spriteManager: ISpriteManager): void;
  29521. dispatchParticles(particleSystem: IParticleSystem): void;
  29522. private _renderParticles;
  29523. private _renderSprites;
  29524. }
  29525. }
  29526. declare module BABYLON {
  29527. /**
  29528. * Interface describing the different options available in the rendering manager
  29529. * regarding Auto Clear between groups.
  29530. */
  29531. export interface IRenderingManagerAutoClearSetup {
  29532. /**
  29533. * Defines whether or not autoclear is enable.
  29534. */
  29535. autoClear: boolean;
  29536. /**
  29537. * Defines whether or not to autoclear the depth buffer.
  29538. */
  29539. depth: boolean;
  29540. /**
  29541. * Defines whether or not to autoclear the stencil buffer.
  29542. */
  29543. stencil: boolean;
  29544. }
  29545. /**
  29546. * This class is used by the onRenderingGroupObservable
  29547. */
  29548. export class RenderingGroupInfo {
  29549. /**
  29550. * The Scene that being rendered
  29551. */
  29552. scene: Scene;
  29553. /**
  29554. * The camera currently used for the rendering pass
  29555. */
  29556. camera: Nullable<Camera>;
  29557. /**
  29558. * The ID of the renderingGroup being processed
  29559. */
  29560. renderingGroupId: number;
  29561. }
  29562. /**
  29563. * This is the manager responsible of all the rendering for meshes sprites and particles.
  29564. * It is enable to manage the different groups as well as the different necessary sort functions.
  29565. * This should not be used directly aside of the few static configurations
  29566. */
  29567. export class RenderingManager {
  29568. /**
  29569. * The max id used for rendering groups (not included)
  29570. */
  29571. static MAX_RENDERINGGROUPS: number;
  29572. /**
  29573. * The min id used for rendering groups (included)
  29574. */
  29575. static MIN_RENDERINGGROUPS: number;
  29576. /**
  29577. * Used to globally prevent autoclearing scenes.
  29578. */
  29579. static AUTOCLEAR: boolean;
  29580. /**
  29581. * @hidden
  29582. */
  29583. _useSceneAutoClearSetup: boolean;
  29584. private _scene;
  29585. private _renderingGroups;
  29586. private _depthStencilBufferAlreadyCleaned;
  29587. private _autoClearDepthStencil;
  29588. private _customOpaqueSortCompareFn;
  29589. private _customAlphaTestSortCompareFn;
  29590. private _customTransparentSortCompareFn;
  29591. private _renderingGroupInfo;
  29592. /**
  29593. * Instantiates a new rendering group for a particular scene
  29594. * @param scene Defines the scene the groups belongs to
  29595. */
  29596. constructor(scene: Scene);
  29597. private _clearDepthStencilBuffer;
  29598. /**
  29599. * Renders the entire managed groups. This is used by the scene or the different rennder targets.
  29600. * @hidden
  29601. */
  29602. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, activeMeshes: Nullable<AbstractMesh[]>, renderParticles: boolean, renderSprites: boolean): void;
  29603. /**
  29604. * Resets the different information of the group to prepare a new frame
  29605. * @hidden
  29606. */
  29607. reset(): void;
  29608. /**
  29609. * Dispose and release the group and its associated resources.
  29610. * @hidden
  29611. */
  29612. dispose(): void;
  29613. /**
  29614. * Clear the info related to rendering groups preventing retention points during dispose.
  29615. */
  29616. freeRenderingGroups(): void;
  29617. private _prepareRenderingGroup;
  29618. /**
  29619. * Add a sprite manager to the rendering manager in order to render it this frame.
  29620. * @param spriteManager Define the sprite manager to render
  29621. */
  29622. dispatchSprites(spriteManager: ISpriteManager): void;
  29623. /**
  29624. * Add a particle system to the rendering manager in order to render it this frame.
  29625. * @param particleSystem Define the particle system to render
  29626. */
  29627. dispatchParticles(particleSystem: IParticleSystem): void;
  29628. /**
  29629. * Add a submesh to the manager in order to render it this frame
  29630. * @param subMesh The submesh to dispatch
  29631. * @param mesh Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  29632. * @param material Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  29633. */
  29634. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  29635. /**
  29636. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  29637. * This allowed control for front to back rendering or reversly depending of the special needs.
  29638. *
  29639. * @param renderingGroupId The rendering group id corresponding to its index
  29640. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  29641. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  29642. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  29643. */
  29644. 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;
  29645. /**
  29646. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  29647. *
  29648. * @param renderingGroupId The rendering group id corresponding to its index
  29649. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  29650. * @param depth Automatically clears depth between groups if true and autoClear is true.
  29651. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  29652. */
  29653. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  29654. /**
  29655. * Gets the current auto clear configuration for one rendering group of the rendering
  29656. * manager.
  29657. * @param index the rendering group index to get the information for
  29658. * @returns The auto clear setup for the requested rendering group
  29659. */
  29660. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  29661. }
  29662. }
  29663. declare module BABYLON {
  29664. /**
  29665. * Defines the options associated with the creation of a custom shader for a shadow generator.
  29666. */
  29667. export interface ICustomShaderOptions {
  29668. /**
  29669. * Gets or sets the custom shader name to use
  29670. */
  29671. shaderName: string;
  29672. /**
  29673. * The list of attribute names used in the shader
  29674. */
  29675. attributes?: string[];
  29676. /**
  29677. * The list of uniform names used in the shader
  29678. */
  29679. uniforms?: string[];
  29680. /**
  29681. * The list of sampler names used in the shader
  29682. */
  29683. samplers?: string[];
  29684. /**
  29685. * The list of defines used in the shader
  29686. */
  29687. defines?: string[];
  29688. }
  29689. /**
  29690. * Interface to implement to create a shadow generator compatible with BJS.
  29691. */
  29692. export interface IShadowGenerator {
  29693. /** Gets or set the id of the shadow generator. It will be the one from the light if not defined */
  29694. id: string;
  29695. /**
  29696. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  29697. * @returns The render target texture if present otherwise, null
  29698. */
  29699. getShadowMap(): Nullable<RenderTargetTexture>;
  29700. /**
  29701. * Determine whether the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  29702. * @param subMesh The submesh we want to render in the shadow map
  29703. * @param useInstances Defines whether will draw in the map using instances
  29704. * @param isTransparent Indicates that isReady is called for a transparent subMesh
  29705. * @returns true if ready otherwise, false
  29706. */
  29707. isReady(subMesh: SubMesh, useInstances: boolean, isTransparent: boolean): boolean;
  29708. /**
  29709. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  29710. * @param defines Defines of the material we want to update
  29711. * @param lightIndex Index of the light in the enabled light list of the material
  29712. */
  29713. prepareDefines(defines: MaterialDefines, lightIndex: number): void;
  29714. /**
  29715. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  29716. * defined in the generator but impacting the effect).
  29717. * It implies the uniforms available on the materials are the standard BJS ones.
  29718. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  29719. * @param effect The effect we are binding the information for
  29720. */
  29721. bindShadowLight(lightIndex: string, effect: Effect): void;
  29722. /**
  29723. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  29724. * (eq to shadow projection matrix * light transform matrix)
  29725. * @returns The transform matrix used to create the shadow map
  29726. */
  29727. getTransformMatrix(): Matrix;
  29728. /**
  29729. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  29730. * Cube and 2D textures for instance.
  29731. */
  29732. recreateShadowMap(): void;
  29733. /**
  29734. * Forces all the attached effect to compile to enable rendering only once ready vs. lazily compiling effects.
  29735. * @param onCompiled Callback triggered at the and of the effects compilation
  29736. * @param options Sets of optional options forcing the compilation with different modes
  29737. */
  29738. forceCompilation(onCompiled?: (generator: IShadowGenerator) => void, options?: Partial<{
  29739. useInstances: boolean;
  29740. }>): void;
  29741. /**
  29742. * Forces all the attached effect to compile to enable rendering only once ready vs. lazily compiling effects.
  29743. * @param options Sets of optional options forcing the compilation with different modes
  29744. * @returns A promise that resolves when the compilation completes
  29745. */
  29746. forceCompilationAsync(options?: Partial<{
  29747. useInstances: boolean;
  29748. }>): Promise<void>;
  29749. /**
  29750. * Serializes the shadow generator setup to a json object.
  29751. * @returns The serialized JSON object
  29752. */
  29753. serialize(): any;
  29754. /**
  29755. * Disposes the Shadow map and related Textures and effects.
  29756. */
  29757. dispose(): void;
  29758. }
  29759. /**
  29760. * Default implementation IShadowGenerator.
  29761. * This is the main object responsible of generating shadows in the framework.
  29762. * Documentation: https://doc.babylonjs.com/babylon101/shadows
  29763. */
  29764. export class ShadowGenerator implements IShadowGenerator {
  29765. private static _Counter;
  29766. /**
  29767. * Name of the shadow generator class
  29768. */
  29769. static CLASSNAME: string;
  29770. /**
  29771. * Shadow generator mode None: no filtering applied.
  29772. */
  29773. static readonly FILTER_NONE: number;
  29774. /**
  29775. * Shadow generator mode ESM: Exponential Shadow Mapping.
  29776. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  29777. */
  29778. static readonly FILTER_EXPONENTIALSHADOWMAP: number;
  29779. /**
  29780. * Shadow generator mode Poisson Sampling: Percentage Closer Filtering.
  29781. * (Multiple Tap around evenly distributed around the pixel are used to evaluate the shadow strength)
  29782. */
  29783. static readonly FILTER_POISSONSAMPLING: number;
  29784. /**
  29785. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping.
  29786. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  29787. */
  29788. static readonly FILTER_BLUREXPONENTIALSHADOWMAP: number;
  29789. /**
  29790. * Shadow generator mode ESM: Exponential Shadow Mapping using the inverse of the exponential preventing
  29791. * edge artifacts on steep falloff.
  29792. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  29793. */
  29794. static readonly FILTER_CLOSEEXPONENTIALSHADOWMAP: number;
  29795. /**
  29796. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping using the inverse of the exponential preventing
  29797. * edge artifacts on steep falloff.
  29798. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  29799. */
  29800. static readonly FILTER_BLURCLOSEEXPONENTIALSHADOWMAP: number;
  29801. /**
  29802. * Shadow generator mode PCF: Percentage Closer Filtering
  29803. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  29804. * (https://developer.nvidia.com/gpugems/GPUGems/gpugems_ch11.html)
  29805. */
  29806. static readonly FILTER_PCF: number;
  29807. /**
  29808. * Shadow generator mode PCSS: Percentage Closering Soft Shadow.
  29809. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  29810. * Contact Hardening
  29811. */
  29812. static readonly FILTER_PCSS: number;
  29813. /**
  29814. * Reserved for PCF and PCSS
  29815. * Highest Quality.
  29816. *
  29817. * Execute PCF on a 5*5 kernel improving a lot the shadow aliasing artifacts.
  29818. *
  29819. * Execute PCSS with 32 taps blocker search and 64 taps PCF.
  29820. */
  29821. static readonly QUALITY_HIGH: number;
  29822. /**
  29823. * Reserved for PCF and PCSS
  29824. * Good tradeoff for quality/perf cross devices
  29825. *
  29826. * Execute PCF on a 3*3 kernel.
  29827. *
  29828. * Execute PCSS with 16 taps blocker search and 32 taps PCF.
  29829. */
  29830. static readonly QUALITY_MEDIUM: number;
  29831. /**
  29832. * Reserved for PCF and PCSS
  29833. * The lowest quality but the fastest.
  29834. *
  29835. * Execute PCF on a 1*1 kernel.
  29836. *
  29837. * Execute PCSS with 16 taps blocker search and 16 taps PCF.
  29838. */
  29839. static readonly QUALITY_LOW: number;
  29840. /** Gets or set the id of the shadow generator. It will be the one from the light if not defined */
  29841. id: string;
  29842. /** Gets or sets the custom shader name to use */
  29843. customShaderOptions: ICustomShaderOptions;
  29844. /** Gets or sets a custom function to allow/disallow rendering a sub mesh in the shadow map */
  29845. customAllowRendering: (subMesh: SubMesh) => boolean;
  29846. /**
  29847. * Observable triggered before the shadow is rendered. Can be used to update internal effect state
  29848. */
  29849. onBeforeShadowMapRenderObservable: Observable<Effect>;
  29850. /**
  29851. * Observable triggered after the shadow is rendered. Can be used to restore internal effect state
  29852. */
  29853. onAfterShadowMapRenderObservable: Observable<Effect>;
  29854. /**
  29855. * Observable triggered before a mesh is rendered in the shadow map.
  29856. * Can be used to update internal effect state (that you can get from the onBeforeShadowMapRenderObservable)
  29857. */
  29858. onBeforeShadowMapRenderMeshObservable: Observable<Mesh>;
  29859. /**
  29860. * Observable triggered after a mesh is rendered in the shadow map.
  29861. * Can be used to update internal effect state (that you can get from the onAfterShadowMapRenderObservable)
  29862. */
  29863. onAfterShadowMapRenderMeshObservable: Observable<Mesh>;
  29864. protected _bias: number;
  29865. /**
  29866. * Gets the bias: offset applied on the depth preventing acnea (in light direction).
  29867. */
  29868. get bias(): number;
  29869. /**
  29870. * Sets the bias: offset applied on the depth preventing acnea (in light direction).
  29871. */
  29872. set bias(bias: number);
  29873. protected _normalBias: number;
  29874. /**
  29875. * Gets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportional to the light/normal angle).
  29876. */
  29877. get normalBias(): number;
  29878. /**
  29879. * Sets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportional to the light/normal angle).
  29880. */
  29881. set normalBias(normalBias: number);
  29882. protected _blurBoxOffset: number;
  29883. /**
  29884. * Gets the blur box offset: offset applied during the blur pass.
  29885. * Only useful if useKernelBlur = false
  29886. */
  29887. get blurBoxOffset(): number;
  29888. /**
  29889. * Sets the blur box offset: offset applied during the blur pass.
  29890. * Only useful if useKernelBlur = false
  29891. */
  29892. set blurBoxOffset(value: number);
  29893. protected _blurScale: number;
  29894. /**
  29895. * Gets the blur scale: scale of the blurred texture compared to the main shadow map.
  29896. * 2 means half of the size.
  29897. */
  29898. get blurScale(): number;
  29899. /**
  29900. * Sets the blur scale: scale of the blurred texture compared to the main shadow map.
  29901. * 2 means half of the size.
  29902. */
  29903. set blurScale(value: number);
  29904. protected _blurKernel: number;
  29905. /**
  29906. * Gets the blur kernel: kernel size of the blur pass.
  29907. * Only useful if useKernelBlur = true
  29908. */
  29909. get blurKernel(): number;
  29910. /**
  29911. * Sets the blur kernel: kernel size of the blur pass.
  29912. * Only useful if useKernelBlur = true
  29913. */
  29914. set blurKernel(value: number);
  29915. protected _useKernelBlur: boolean;
  29916. /**
  29917. * Gets whether the blur pass is a kernel blur (if true) or box blur.
  29918. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  29919. */
  29920. get useKernelBlur(): boolean;
  29921. /**
  29922. * Sets whether the blur pass is a kernel blur (if true) or box blur.
  29923. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  29924. */
  29925. set useKernelBlur(value: boolean);
  29926. protected _depthScale: number;
  29927. /**
  29928. * Gets the depth scale used in ESM mode.
  29929. */
  29930. get depthScale(): number;
  29931. /**
  29932. * Sets the depth scale used in ESM mode.
  29933. * This can override the scale stored on the light.
  29934. */
  29935. set depthScale(value: number);
  29936. protected _validateFilter(filter: number): number;
  29937. protected _filter: number;
  29938. /**
  29939. * Gets the current mode of the shadow generator (normal, PCF, ESM...).
  29940. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  29941. */
  29942. get filter(): number;
  29943. /**
  29944. * Sets the current mode of the shadow generator (normal, PCF, ESM...).
  29945. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  29946. */
  29947. set filter(value: number);
  29948. /**
  29949. * Gets if the current filter is set to Poisson Sampling.
  29950. */
  29951. get usePoissonSampling(): boolean;
  29952. /**
  29953. * Sets the current filter to Poisson Sampling.
  29954. */
  29955. set usePoissonSampling(value: boolean);
  29956. /**
  29957. * Gets if the current filter is set to ESM.
  29958. */
  29959. get useExponentialShadowMap(): boolean;
  29960. /**
  29961. * Sets the current filter is to ESM.
  29962. */
  29963. set useExponentialShadowMap(value: boolean);
  29964. /**
  29965. * Gets if the current filter is set to filtered ESM.
  29966. */
  29967. get useBlurExponentialShadowMap(): boolean;
  29968. /**
  29969. * Gets if the current filter is set to filtered ESM.
  29970. */
  29971. set useBlurExponentialShadowMap(value: boolean);
  29972. /**
  29973. * Gets if the current filter is set to "close ESM" (using the inverse of the
  29974. * exponential to prevent steep falloff artifacts).
  29975. */
  29976. get useCloseExponentialShadowMap(): boolean;
  29977. /**
  29978. * Sets the current filter to "close ESM" (using the inverse of the
  29979. * exponential to prevent steep falloff artifacts).
  29980. */
  29981. set useCloseExponentialShadowMap(value: boolean);
  29982. /**
  29983. * Gets if the current filter is set to filtered "close ESM" (using the inverse of the
  29984. * exponential to prevent steep falloff artifacts).
  29985. */
  29986. get useBlurCloseExponentialShadowMap(): boolean;
  29987. /**
  29988. * Sets the current filter to filtered "close ESM" (using the inverse of the
  29989. * exponential to prevent steep falloff artifacts).
  29990. */
  29991. set useBlurCloseExponentialShadowMap(value: boolean);
  29992. /**
  29993. * Gets if the current filter is set to "PCF" (percentage closer filtering).
  29994. */
  29995. get usePercentageCloserFiltering(): boolean;
  29996. /**
  29997. * Sets the current filter to "PCF" (percentage closer filtering).
  29998. */
  29999. set usePercentageCloserFiltering(value: boolean);
  30000. protected _filteringQuality: number;
  30001. /**
  30002. * Gets the PCF or PCSS Quality.
  30003. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  30004. */
  30005. get filteringQuality(): number;
  30006. /**
  30007. * Sets the PCF or PCSS Quality.
  30008. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  30009. */
  30010. set filteringQuality(filteringQuality: number);
  30011. /**
  30012. * Gets if the current filter is set to "PCSS" (contact hardening).
  30013. */
  30014. get useContactHardeningShadow(): boolean;
  30015. /**
  30016. * Sets the current filter to "PCSS" (contact hardening).
  30017. */
  30018. set useContactHardeningShadow(value: boolean);
  30019. protected _contactHardeningLightSizeUVRatio: number;
  30020. /**
  30021. * Gets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  30022. * Using a ratio helps keeping shape stability independently of the map size.
  30023. *
  30024. * It does not account for the light projection as it was having too much
  30025. * instability during the light setup or during light position changes.
  30026. *
  30027. * Only valid if useContactHardeningShadow is true.
  30028. */
  30029. get contactHardeningLightSizeUVRatio(): number;
  30030. /**
  30031. * Sets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  30032. * Using a ratio helps keeping shape stability independently of the map size.
  30033. *
  30034. * It does not account for the light projection as it was having too much
  30035. * instability during the light setup or during light position changes.
  30036. *
  30037. * Only valid if useContactHardeningShadow is true.
  30038. */
  30039. set contactHardeningLightSizeUVRatio(contactHardeningLightSizeUVRatio: number);
  30040. protected _darkness: number;
  30041. /** Gets or sets the actual darkness of a shadow */
  30042. get darkness(): number;
  30043. set darkness(value: number);
  30044. /**
  30045. * Returns the darkness value (float). This can only decrease the actual darkness of a shadow.
  30046. * 0 means strongest and 1 would means no shadow.
  30047. * @returns the darkness.
  30048. */
  30049. getDarkness(): number;
  30050. /**
  30051. * Sets the darkness value (float). This can only decrease the actual darkness of a shadow.
  30052. * @param darkness The darkness value 0 means strongest and 1 would means no shadow.
  30053. * @returns the shadow generator allowing fluent coding.
  30054. */
  30055. setDarkness(darkness: number): ShadowGenerator;
  30056. protected _transparencyShadow: boolean;
  30057. /** Gets or sets the ability to have transparent shadow */
  30058. get transparencyShadow(): boolean;
  30059. set transparencyShadow(value: boolean);
  30060. /**
  30061. * Sets the ability to have transparent shadow (boolean).
  30062. * @param transparent True if transparent else False
  30063. * @returns the shadow generator allowing fluent coding
  30064. */
  30065. setTransparencyShadow(transparent: boolean): ShadowGenerator;
  30066. /**
  30067. * Enables or disables shadows with varying strength based on the transparency
  30068. * When it is enabled, the strength of the shadow is taken equal to mesh.visibility
  30069. * If you enabled an alpha texture on your material, the alpha value red from the texture is also combined to compute the strength:
  30070. * mesh.visibility * alphaTexture.a
  30071. * Note that by definition transparencyShadow must be set to true for enableSoftTransparentShadow to work!
  30072. */
  30073. enableSoftTransparentShadow: boolean;
  30074. protected _shadowMap: Nullable<RenderTargetTexture>;
  30075. protected _shadowMap2: Nullable<RenderTargetTexture>;
  30076. /**
  30077. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  30078. * @returns The render target texture if present otherwise, null
  30079. */
  30080. getShadowMap(): Nullable<RenderTargetTexture>;
  30081. /**
  30082. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  30083. * @returns The render target texture if the shadow map is present otherwise, null
  30084. */
  30085. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  30086. /**
  30087. * Gets the class name of that object
  30088. * @returns "ShadowGenerator"
  30089. */
  30090. getClassName(): string;
  30091. /**
  30092. * Helper function to add a mesh and its descendants to the list of shadow casters.
  30093. * @param mesh Mesh to add
  30094. * @param includeDescendants boolean indicating if the descendants should be added. Default to true
  30095. * @returns the Shadow Generator itself
  30096. */
  30097. addShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  30098. /**
  30099. * Helper function to remove a mesh and its descendants from the list of shadow casters
  30100. * @param mesh Mesh to remove
  30101. * @param includeDescendants boolean indicating if the descendants should be removed. Default to true
  30102. * @returns the Shadow Generator itself
  30103. */
  30104. removeShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  30105. /**
  30106. * Controls the extent to which the shadows fade out at the edge of the frustum
  30107. */
  30108. frustumEdgeFalloff: number;
  30109. protected _light: IShadowLight;
  30110. /**
  30111. * Returns the associated light object.
  30112. * @returns the light generating the shadow
  30113. */
  30114. getLight(): IShadowLight;
  30115. /**
  30116. * If true the shadow map is generated by rendering the back face of the mesh instead of the front face.
  30117. * This can help with self-shadowing as the geometry making up the back of objects is slightly offset.
  30118. * It might on the other hand introduce peter panning.
  30119. */
  30120. forceBackFacesOnly: boolean;
  30121. protected _scene: Scene;
  30122. protected _lightDirection: Vector3;
  30123. protected _viewMatrix: Matrix;
  30124. protected _projectionMatrix: Matrix;
  30125. protected _transformMatrix: Matrix;
  30126. protected _cachedPosition: Vector3;
  30127. protected _cachedDirection: Vector3;
  30128. protected _cachedDefines: string;
  30129. protected _currentRenderID: number;
  30130. protected _boxBlurPostprocess: Nullable<PostProcess>;
  30131. protected _kernelBlurXPostprocess: Nullable<PostProcess>;
  30132. protected _kernelBlurYPostprocess: Nullable<PostProcess>;
  30133. protected _blurPostProcesses: PostProcess[];
  30134. protected _mapSize: number;
  30135. protected _currentFaceIndex: number;
  30136. protected _currentFaceIndexCache: number;
  30137. protected _textureType: number;
  30138. protected _defaultTextureMatrix: Matrix;
  30139. protected _storedUniqueId: Nullable<number>;
  30140. protected _nameForCustomEffect: string;
  30141. /** @hidden */
  30142. static _SceneComponentInitialization: (scene: Scene) => void;
  30143. /**
  30144. * Gets or sets the size of the texture what stores the shadows
  30145. */
  30146. get mapSize(): number;
  30147. set mapSize(size: number);
  30148. /**
  30149. * Creates a ShadowGenerator object.
  30150. * A ShadowGenerator is the required tool to use the shadows.
  30151. * Each light casting shadows needs to use its own ShadowGenerator.
  30152. * Documentation : https://doc.babylonjs.com/babylon101/shadows
  30153. * @param mapSize The size of the texture what stores the shadows. Example : 1024.
  30154. * @param light The light object generating the shadows.
  30155. * @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.
  30156. */
  30157. constructor(mapSize: number, light: IShadowLight, usefulFloatFirst?: boolean);
  30158. protected _initializeGenerator(): void;
  30159. protected _createTargetRenderTexture(): void;
  30160. protected _initializeShadowMap(): void;
  30161. protected _initializeBlurRTTAndPostProcesses(): void;
  30162. protected _renderForShadowMap(opaqueSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>): void;
  30163. protected _bindCustomEffectForRenderSubMeshForShadowMap(subMesh: SubMesh, effect: Effect, matriceNames: any, mesh: AbstractMesh): void;
  30164. protected _renderSubMeshForShadowMap(subMesh: SubMesh, isTransparent?: boolean): void;
  30165. protected _applyFilterValues(): void;
  30166. /**
  30167. * Forces all the attached effect to compile to enable rendering only once ready vs. lazily compiling effects.
  30168. * @param onCompiled Callback triggered at the and of the effects compilation
  30169. * @param options Sets of optional options forcing the compilation with different modes
  30170. */
  30171. forceCompilation(onCompiled?: (generator: IShadowGenerator) => void, options?: Partial<{
  30172. useInstances: boolean;
  30173. }>): void;
  30174. /**
  30175. * Forces all the attached effect to compile to enable rendering only once ready vs. lazily compiling effects.
  30176. * @param options Sets of optional options forcing the compilation with different modes
  30177. * @returns A promise that resolves when the compilation completes
  30178. */
  30179. forceCompilationAsync(options?: Partial<{
  30180. useInstances: boolean;
  30181. }>): Promise<void>;
  30182. protected _isReadyCustomDefines(defines: any, subMesh: SubMesh, useInstances: boolean): void;
  30183. private _prepareShadowDefines;
  30184. /**
  30185. * Determine whether the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  30186. * @param subMesh The submesh we want to render in the shadow map
  30187. * @param useInstances Defines whether will draw in the map using instances
  30188. * @param isTransparent Indicates that isReady is called for a transparent subMesh
  30189. * @returns true if ready otherwise, false
  30190. */
  30191. isReady(subMesh: SubMesh, useInstances: boolean, isTransparent: boolean): boolean;
  30192. /**
  30193. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  30194. * @param defines Defines of the material we want to update
  30195. * @param lightIndex Index of the light in the enabled light list of the material
  30196. */
  30197. prepareDefines(defines: any, lightIndex: number): void;
  30198. /**
  30199. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  30200. * defined in the generator but impacting the effect).
  30201. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  30202. * @param effect The effect we are binding the information for
  30203. */
  30204. bindShadowLight(lightIndex: string, effect: Effect): void;
  30205. /**
  30206. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  30207. * (eq to shadow projection matrix * light transform matrix)
  30208. * @returns The transform matrix used to create the shadow map
  30209. */
  30210. getTransformMatrix(): Matrix;
  30211. /**
  30212. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  30213. * Cube and 2D textures for instance.
  30214. */
  30215. recreateShadowMap(): void;
  30216. protected _disposeBlurPostProcesses(): void;
  30217. protected _disposeRTTandPostProcesses(): void;
  30218. /**
  30219. * Disposes the ShadowGenerator.
  30220. * Returns nothing.
  30221. */
  30222. dispose(): void;
  30223. /**
  30224. * Serializes the shadow generator setup to a json object.
  30225. * @returns The serialized JSON object
  30226. */
  30227. serialize(): any;
  30228. /**
  30229. * Parses a serialized ShadowGenerator and returns a new ShadowGenerator.
  30230. * @param parsedShadowGenerator The JSON object to parse
  30231. * @param scene The scene to create the shadow map for
  30232. * @param constr A function that builds a shadow generator or undefined to create an instance of the default shadow generator
  30233. * @returns The parsed shadow generator
  30234. */
  30235. static Parse(parsedShadowGenerator: any, scene: Scene, constr?: (mapSize: number, light: IShadowLight) => ShadowGenerator): ShadowGenerator;
  30236. }
  30237. }
  30238. declare module BABYLON {
  30239. /**
  30240. * Options to be used when creating a shadow depth material
  30241. */
  30242. export interface IIOptionShadowDepthMaterial {
  30243. /** Variables in the vertex shader code that need to have their names remapped.
  30244. * The format is: ["var_name", "var_remapped_name", "var_name", "var_remapped_name", ...]
  30245. * "var_name" should be either: worldPos or vNormalW
  30246. * So, if the variable holding the world position in your vertex shader is not named worldPos, you must tell the system
  30247. * the name to use instead by using: ["worldPos", "myWorldPosVar"] assuming the variable is named myWorldPosVar in your code.
  30248. * If the normal must also be remapped: ["worldPos", "myWorldPosVar", "vNormalW", "myWorldNormal"]
  30249. */
  30250. remappedVariables?: string[];
  30251. /** Set standalone to true if the base material wrapped by ShadowDepthMaterial is not used for a regular object but for depth shadow generation only */
  30252. standalone?: boolean;
  30253. }
  30254. /**
  30255. * Class that can be used to wrap a base material to generate accurate shadows when using custom vertex/fragment code in the base material
  30256. */
  30257. export class ShadowDepthWrapper {
  30258. private _scene;
  30259. private _options?;
  30260. private _baseMaterial;
  30261. private _onEffectCreatedObserver;
  30262. private _subMeshToEffect;
  30263. private _subMeshToDepthEffect;
  30264. private _meshes;
  30265. /** @hidden */
  30266. _matriceNames: any;
  30267. /** Gets the standalone status of the wrapper */
  30268. get standalone(): boolean;
  30269. /** Gets the base material the wrapper is built upon */
  30270. get baseMaterial(): Material;
  30271. /**
  30272. * Instantiate a new shadow depth wrapper.
  30273. * It works by injecting some specific code in the vertex/fragment shaders of the base material and is used by a shadow generator to
  30274. * generate the shadow depth map. For more information, please refer to the documentation:
  30275. * https://doc.babylonjs.com/babylon101/shadows
  30276. * @param baseMaterial Material to wrap
  30277. * @param scene Define the scene the material belongs to
  30278. * @param options Options used to create the wrapper
  30279. */
  30280. constructor(baseMaterial: Material, scene: Scene, options?: IIOptionShadowDepthMaterial);
  30281. /**
  30282. * Gets the effect to use to generate the depth map
  30283. * @param subMesh subMesh to get the effect for
  30284. * @param shadowGenerator shadow generator to get the effect for
  30285. * @returns the effect to use to generate the depth map for the subMesh + shadow generator specified
  30286. */
  30287. getEffect(subMesh: Nullable<SubMesh>, shadowGenerator: ShadowGenerator): Nullable<Effect>;
  30288. /**
  30289. * Specifies that the submesh is ready to be used for depth rendering
  30290. * @param subMesh submesh to check
  30291. * @param defines the list of defines to take into account when checking the effect
  30292. * @param shadowGenerator combined with subMesh, it defines the effect to check
  30293. * @param useInstances specifies that instances should be used
  30294. * @returns a boolean indicating that the submesh is ready or not
  30295. */
  30296. isReadyForSubMesh(subMesh: SubMesh, defines: string[], shadowGenerator: ShadowGenerator, useInstances: boolean): boolean;
  30297. /**
  30298. * Disposes the resources
  30299. */
  30300. dispose(): void;
  30301. private _makeEffect;
  30302. }
  30303. }
  30304. declare module BABYLON {
  30305. /**
  30306. * Options for compiling materials.
  30307. */
  30308. export interface IMaterialCompilationOptions {
  30309. /**
  30310. * Defines whether clip planes are enabled.
  30311. */
  30312. clipPlane: boolean;
  30313. /**
  30314. * Defines whether instances are enabled.
  30315. */
  30316. useInstances: boolean;
  30317. }
  30318. /**
  30319. * Options passed when calling customShaderNameResolve
  30320. */
  30321. export interface ICustomShaderNameResolveOptions {
  30322. /**
  30323. * 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
  30324. */
  30325. processFinalCode?: Nullable<(shaderType: string, code: string) => string>;
  30326. }
  30327. /**
  30328. * Base class for the main features of a material in Babylon.js
  30329. */
  30330. export class Material implements IAnimatable {
  30331. /**
  30332. * Returns the triangle fill mode
  30333. */
  30334. static readonly TriangleFillMode: number;
  30335. /**
  30336. * Returns the wireframe mode
  30337. */
  30338. static readonly WireFrameFillMode: number;
  30339. /**
  30340. * Returns the point fill mode
  30341. */
  30342. static readonly PointFillMode: number;
  30343. /**
  30344. * Returns the point list draw mode
  30345. */
  30346. static readonly PointListDrawMode: number;
  30347. /**
  30348. * Returns the line list draw mode
  30349. */
  30350. static readonly LineListDrawMode: number;
  30351. /**
  30352. * Returns the line loop draw mode
  30353. */
  30354. static readonly LineLoopDrawMode: number;
  30355. /**
  30356. * Returns the line strip draw mode
  30357. */
  30358. static readonly LineStripDrawMode: number;
  30359. /**
  30360. * Returns the triangle strip draw mode
  30361. */
  30362. static readonly TriangleStripDrawMode: number;
  30363. /**
  30364. * Returns the triangle fan draw mode
  30365. */
  30366. static readonly TriangleFanDrawMode: number;
  30367. /**
  30368. * Stores the clock-wise side orientation
  30369. */
  30370. static readonly ClockWiseSideOrientation: number;
  30371. /**
  30372. * Stores the counter clock-wise side orientation
  30373. */
  30374. static readonly CounterClockWiseSideOrientation: number;
  30375. /**
  30376. * The dirty texture flag value
  30377. */
  30378. static readonly TextureDirtyFlag: number;
  30379. /**
  30380. * The dirty light flag value
  30381. */
  30382. static readonly LightDirtyFlag: number;
  30383. /**
  30384. * The dirty fresnel flag value
  30385. */
  30386. static readonly FresnelDirtyFlag: number;
  30387. /**
  30388. * The dirty attribute flag value
  30389. */
  30390. static readonly AttributesDirtyFlag: number;
  30391. /**
  30392. * The dirty misc flag value
  30393. */
  30394. static readonly MiscDirtyFlag: number;
  30395. /**
  30396. * The dirty prepass flag value
  30397. */
  30398. static readonly PrePassDirtyFlag: number;
  30399. /**
  30400. * The all dirty flag value
  30401. */
  30402. static readonly AllDirtyFlag: number;
  30403. /**
  30404. * MaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  30405. */
  30406. static readonly MATERIAL_OPAQUE: number;
  30407. /**
  30408. * MaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  30409. */
  30410. static readonly MATERIAL_ALPHATEST: number;
  30411. /**
  30412. * MaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  30413. */
  30414. static readonly MATERIAL_ALPHABLEND: number;
  30415. /**
  30416. * MaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  30417. * They are also discarded below the alpha cutoff threshold to improve performances.
  30418. */
  30419. static readonly MATERIAL_ALPHATESTANDBLEND: number;
  30420. /**
  30421. * The Whiteout method is used to blend normals.
  30422. * Details of the algorithm can be found here: https://blog.selfshadow.com/publications/blending-in-detail/
  30423. */
  30424. static readonly MATERIAL_NORMALBLENDMETHOD_WHITEOUT: number;
  30425. /**
  30426. * The Reoriented Normal Mapping method is used to blend normals.
  30427. * Details of the algorithm can be found here: https://blog.selfshadow.com/publications/blending-in-detail/
  30428. */
  30429. static readonly MATERIAL_NORMALBLENDMETHOD_RNM: number;
  30430. /**
  30431. * Custom callback helping to override the default shader used in the material.
  30432. */
  30433. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: MaterialDefines | string[], attributes?: string[], options?: ICustomShaderNameResolveOptions) => string;
  30434. /**
  30435. * Custom shadow depth material to use for shadow rendering instead of the in-built one
  30436. */
  30437. shadowDepthWrapper: Nullable<ShadowDepthWrapper>;
  30438. /**
  30439. * Gets or sets a boolean indicating that the material is allowed (if supported) to do shader hot swapping.
  30440. * This means that the material can keep using a previous shader while a new one is being compiled.
  30441. * This is mostly used when shader parallel compilation is supported (true by default)
  30442. */
  30443. allowShaderHotSwapping: boolean;
  30444. /**
  30445. * The ID of the material
  30446. */
  30447. id: string;
  30448. /**
  30449. * Gets or sets the unique id of the material
  30450. */
  30451. uniqueId: number;
  30452. /**
  30453. * The name of the material
  30454. */
  30455. name: string;
  30456. /**
  30457. * Gets or sets user defined metadata
  30458. */
  30459. metadata: any;
  30460. /**
  30461. * For internal use only. Please do not use.
  30462. */
  30463. reservedDataStore: any;
  30464. /**
  30465. * Specifies if the ready state should be checked on each call
  30466. */
  30467. checkReadyOnEveryCall: boolean;
  30468. /**
  30469. * Specifies if the ready state should be checked once
  30470. */
  30471. checkReadyOnlyOnce: boolean;
  30472. /**
  30473. * The state of the material
  30474. */
  30475. state: string;
  30476. /**
  30477. * If the material can be rendered to several textures with MRT extension
  30478. */
  30479. get canRenderToMRT(): boolean;
  30480. /**
  30481. * The alpha value of the material
  30482. */
  30483. protected _alpha: number;
  30484. /**
  30485. * List of inspectable custom properties (used by the Inspector)
  30486. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  30487. */
  30488. inspectableCustomProperties: IInspectable[];
  30489. /**
  30490. * Sets the alpha value of the material
  30491. */
  30492. set alpha(value: number);
  30493. /**
  30494. * Gets the alpha value of the material
  30495. */
  30496. get alpha(): number;
  30497. /**
  30498. * Specifies if back face culling is enabled
  30499. */
  30500. protected _backFaceCulling: boolean;
  30501. /**
  30502. * Sets the back-face culling state
  30503. */
  30504. set backFaceCulling(value: boolean);
  30505. /**
  30506. * Gets the back-face culling state
  30507. */
  30508. get backFaceCulling(): boolean;
  30509. /**
  30510. * Stores the value for side orientation
  30511. */
  30512. sideOrientation: number;
  30513. /**
  30514. * Callback triggered when the material is compiled
  30515. */
  30516. onCompiled: Nullable<(effect: Effect) => void>;
  30517. /**
  30518. * Callback triggered when an error occurs
  30519. */
  30520. onError: Nullable<(effect: Effect, errors: string) => void>;
  30521. /**
  30522. * Callback triggered to get the render target textures
  30523. */
  30524. getRenderTargetTextures: Nullable<() => SmartArray<RenderTargetTexture>>;
  30525. /**
  30526. * Gets a boolean indicating that current material needs to register RTT
  30527. */
  30528. get hasRenderTargetTextures(): boolean;
  30529. /**
  30530. * Specifies if the material should be serialized
  30531. */
  30532. doNotSerialize: boolean;
  30533. /**
  30534. * @hidden
  30535. */
  30536. _storeEffectOnSubMeshes: boolean;
  30537. /**
  30538. * Stores the animations for the material
  30539. */
  30540. animations: Nullable<Array<Animation>>;
  30541. /**
  30542. * An event triggered when the material is disposed
  30543. */
  30544. onDisposeObservable: Observable<Material>;
  30545. /**
  30546. * An observer which watches for dispose events
  30547. */
  30548. private _onDisposeObserver;
  30549. private _onUnBindObservable;
  30550. /**
  30551. * Called during a dispose event
  30552. */
  30553. set onDispose(callback: () => void);
  30554. private _onBindObservable;
  30555. /**
  30556. * An event triggered when the material is bound
  30557. */
  30558. get onBindObservable(): Observable<AbstractMesh>;
  30559. /**
  30560. * An observer which watches for bind events
  30561. */
  30562. private _onBindObserver;
  30563. /**
  30564. * Called during a bind event
  30565. */
  30566. set onBind(callback: (Mesh: AbstractMesh) => void);
  30567. /**
  30568. * An event triggered when the material is unbound
  30569. */
  30570. get onUnBindObservable(): Observable<Material>;
  30571. protected _onEffectCreatedObservable: Nullable<Observable<{
  30572. effect: Effect;
  30573. subMesh: Nullable<SubMesh>;
  30574. }>>;
  30575. /**
  30576. * An event triggered when the effect is (re)created
  30577. */
  30578. get onEffectCreatedObservable(): Observable<{
  30579. effect: Effect;
  30580. subMesh: Nullable<SubMesh>;
  30581. }>;
  30582. /**
  30583. * Stores the value of the alpha mode
  30584. */
  30585. private _alphaMode;
  30586. /**
  30587. * Sets the value of the alpha mode.
  30588. *
  30589. * | Value | Type | Description |
  30590. * | --- | --- | --- |
  30591. * | 0 | ALPHA_DISABLE | |
  30592. * | 1 | ALPHA_ADD | |
  30593. * | 2 | ALPHA_COMBINE | |
  30594. * | 3 | ALPHA_SUBTRACT | |
  30595. * | 4 | ALPHA_MULTIPLY | |
  30596. * | 5 | ALPHA_MAXIMIZED | |
  30597. * | 6 | ALPHA_ONEONE | |
  30598. * | 7 | ALPHA_PREMULTIPLIED | |
  30599. * | 8 | ALPHA_PREMULTIPLIED_PORTERDUFF | |
  30600. * | 9 | ALPHA_INTERPOLATE | |
  30601. * | 10 | ALPHA_SCREENMODE | |
  30602. *
  30603. */
  30604. set alphaMode(value: number);
  30605. /**
  30606. * Gets the value of the alpha mode
  30607. */
  30608. get alphaMode(): number;
  30609. /**
  30610. * Stores the state of the need depth pre-pass value
  30611. */
  30612. private _needDepthPrePass;
  30613. /**
  30614. * Sets the need depth pre-pass value
  30615. */
  30616. set needDepthPrePass(value: boolean);
  30617. /**
  30618. * Gets the depth pre-pass value
  30619. */
  30620. get needDepthPrePass(): boolean;
  30621. /**
  30622. * Can this material render to prepass
  30623. */
  30624. get isPrePassCapable(): boolean;
  30625. /**
  30626. * Specifies if depth writing should be disabled
  30627. */
  30628. disableDepthWrite: boolean;
  30629. /**
  30630. * Specifies if color writing should be disabled
  30631. */
  30632. disableColorWrite: boolean;
  30633. /**
  30634. * Specifies if depth writing should be forced
  30635. */
  30636. forceDepthWrite: boolean;
  30637. /**
  30638. * Specifies the depth function that should be used. 0 means the default engine function
  30639. */
  30640. depthFunction: number;
  30641. /**
  30642. * Specifies if there should be a separate pass for culling
  30643. */
  30644. separateCullingPass: boolean;
  30645. /**
  30646. * Stores the state specifying if fog should be enabled
  30647. */
  30648. private _fogEnabled;
  30649. /**
  30650. * Sets the state for enabling fog
  30651. */
  30652. set fogEnabled(value: boolean);
  30653. /**
  30654. * Gets the value of the fog enabled state
  30655. */
  30656. get fogEnabled(): boolean;
  30657. /**
  30658. * Stores the size of points
  30659. */
  30660. pointSize: number;
  30661. /**
  30662. * Stores the z offset value
  30663. */
  30664. zOffset: number;
  30665. get wireframe(): boolean;
  30666. /**
  30667. * Sets the state of wireframe mode
  30668. */
  30669. set wireframe(value: boolean);
  30670. /**
  30671. * Gets the value specifying if point clouds are enabled
  30672. */
  30673. get pointsCloud(): boolean;
  30674. /**
  30675. * Sets the state of point cloud mode
  30676. */
  30677. set pointsCloud(value: boolean);
  30678. /**
  30679. * Gets the material fill mode
  30680. */
  30681. get fillMode(): number;
  30682. /**
  30683. * Sets the material fill mode
  30684. */
  30685. set fillMode(value: number);
  30686. /**
  30687. * @hidden
  30688. * Stores the effects for the material
  30689. */
  30690. _effect: Nullable<Effect>;
  30691. /**
  30692. * Specifies if uniform buffers should be used
  30693. */
  30694. private _useUBO;
  30695. /**
  30696. * Stores a reference to the scene
  30697. */
  30698. private _scene;
  30699. private _needToBindSceneUbo;
  30700. /**
  30701. * Stores the fill mode state
  30702. */
  30703. private _fillMode;
  30704. /**
  30705. * Specifies if the depth write state should be cached
  30706. */
  30707. private _cachedDepthWriteState;
  30708. /**
  30709. * Specifies if the color write state should be cached
  30710. */
  30711. private _cachedColorWriteState;
  30712. /**
  30713. * Specifies if the depth function state should be cached
  30714. */
  30715. private _cachedDepthFunctionState;
  30716. /**
  30717. * Stores the uniform buffer
  30718. */
  30719. protected _uniformBuffer: UniformBuffer;
  30720. /** @hidden */
  30721. _indexInSceneMaterialArray: number;
  30722. /** @hidden */
  30723. meshMap: Nullable<{
  30724. [id: string]: AbstractMesh | undefined;
  30725. }>;
  30726. /**
  30727. * Creates a material instance
  30728. * @param name defines the name of the material
  30729. * @param scene defines the scene to reference
  30730. * @param doNotAdd specifies if the material should be added to the scene
  30731. */
  30732. constructor(name: string, scene: Scene, doNotAdd?: boolean);
  30733. /**
  30734. * Returns a string representation of the current material
  30735. * @param fullDetails defines a boolean indicating which levels of logging is desired
  30736. * @returns a string with material information
  30737. */
  30738. toString(fullDetails?: boolean): string;
  30739. /**
  30740. * Gets the class name of the material
  30741. * @returns a string with the class name of the material
  30742. */
  30743. getClassName(): string;
  30744. /**
  30745. * Specifies if updates for the material been locked
  30746. */
  30747. get isFrozen(): boolean;
  30748. /**
  30749. * Locks updates for the material
  30750. */
  30751. freeze(): void;
  30752. /**
  30753. * Unlocks updates for the material
  30754. */
  30755. unfreeze(): void;
  30756. /**
  30757. * Specifies if the material is ready to be used
  30758. * @param mesh defines the mesh to check
  30759. * @param useInstances specifies if instances should be used
  30760. * @returns a boolean indicating if the material is ready to be used
  30761. */
  30762. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  30763. /**
  30764. * Specifies that the submesh is ready to be used
  30765. * @param mesh defines the mesh to check
  30766. * @param subMesh defines which submesh to check
  30767. * @param useInstances specifies that instances should be used
  30768. * @returns a boolean indicating that the submesh is ready or not
  30769. */
  30770. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  30771. /**
  30772. * Returns the material effect
  30773. * @returns the effect associated with the material
  30774. */
  30775. getEffect(): Nullable<Effect>;
  30776. /**
  30777. * Returns the current scene
  30778. * @returns a Scene
  30779. */
  30780. getScene(): Scene;
  30781. /**
  30782. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  30783. */
  30784. protected _forceAlphaTest: boolean;
  30785. /**
  30786. * The transparency mode of the material.
  30787. */
  30788. protected _transparencyMode: Nullable<number>;
  30789. /**
  30790. * Gets the current transparency mode.
  30791. */
  30792. get transparencyMode(): Nullable<number>;
  30793. /**
  30794. * Sets the transparency mode of the material.
  30795. *
  30796. * | Value | Type | Description |
  30797. * | ----- | ----------------------------------- | ----------- |
  30798. * | 0 | OPAQUE | |
  30799. * | 1 | ALPHATEST | |
  30800. * | 2 | ALPHABLEND | |
  30801. * | 3 | ALPHATESTANDBLEND | |
  30802. *
  30803. */
  30804. set transparencyMode(value: Nullable<number>);
  30805. /**
  30806. * Returns true if alpha blending should be disabled.
  30807. */
  30808. protected get _disableAlphaBlending(): boolean;
  30809. /**
  30810. * Specifies whether or not this material should be rendered in alpha blend mode.
  30811. * @returns a boolean specifying if alpha blending is needed
  30812. */
  30813. needAlphaBlending(): boolean;
  30814. /**
  30815. * Specifies if the mesh will require alpha blending
  30816. * @param mesh defines the mesh to check
  30817. * @returns a boolean specifying if alpha blending is needed for the mesh
  30818. */
  30819. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  30820. /**
  30821. * Specifies whether or not this material should be rendered in alpha test mode.
  30822. * @returns a boolean specifying if an alpha test is needed.
  30823. */
  30824. needAlphaTesting(): boolean;
  30825. /**
  30826. * Specifies if material alpha testing should be turned on for the mesh
  30827. * @param mesh defines the mesh to check
  30828. */
  30829. protected _shouldTurnAlphaTestOn(mesh: AbstractMesh): boolean;
  30830. /**
  30831. * Gets the texture used for the alpha test
  30832. * @returns the texture to use for alpha testing
  30833. */
  30834. getAlphaTestTexture(): Nullable<BaseTexture>;
  30835. /**
  30836. * Marks the material to indicate that it needs to be re-calculated
  30837. */
  30838. markDirty(): void;
  30839. /** @hidden */
  30840. _preBind(effect?: Effect, overrideOrientation?: Nullable<number>): boolean;
  30841. /**
  30842. * Binds the material to the mesh
  30843. * @param world defines the world transformation matrix
  30844. * @param mesh defines the mesh to bind the material to
  30845. */
  30846. bind(world: Matrix, mesh?: Mesh): void;
  30847. /**
  30848. * Binds the submesh to the material
  30849. * @param world defines the world transformation matrix
  30850. * @param mesh defines the mesh containing the submesh
  30851. * @param subMesh defines the submesh to bind the material to
  30852. */
  30853. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  30854. /**
  30855. * Binds the world matrix to the material
  30856. * @param world defines the world transformation matrix
  30857. */
  30858. bindOnlyWorldMatrix(world: Matrix): void;
  30859. /**
  30860. * Binds the view matrix to the effect
  30861. * @param effect defines the effect to bind the view matrix to
  30862. */
  30863. bindView(effect: Effect): void;
  30864. /**
  30865. * Binds the view projection and projection matrices to the effect
  30866. * @param effect defines the effect to bind the view projection and projection matrices to
  30867. */
  30868. bindViewProjection(effect: Effect): void;
  30869. /**
  30870. * Binds the view matrix to the effect
  30871. * @param effect defines the effect to bind the view matrix to
  30872. * @param variableName name of the shader variable that will hold the eye position
  30873. */
  30874. bindEyePosition(effect: Effect, variableName?: string): void;
  30875. /**
  30876. * Processes to execute after binding the material to a mesh
  30877. * @param mesh defines the rendered mesh
  30878. */
  30879. protected _afterBind(mesh?: Mesh, effect?: Nullable<Effect>): void;
  30880. /**
  30881. * Unbinds the material from the mesh
  30882. */
  30883. unbind(): void;
  30884. /**
  30885. * Gets the active textures from the material
  30886. * @returns an array of textures
  30887. */
  30888. getActiveTextures(): BaseTexture[];
  30889. /**
  30890. * Specifies if the material uses a texture
  30891. * @param texture defines the texture to check against the material
  30892. * @returns a boolean specifying if the material uses the texture
  30893. */
  30894. hasTexture(texture: BaseTexture): boolean;
  30895. /**
  30896. * Makes a duplicate of the material, and gives it a new name
  30897. * @param name defines the new name for the duplicated material
  30898. * @returns the cloned material
  30899. */
  30900. clone(name: string): Nullable<Material>;
  30901. /**
  30902. * Gets the meshes bound to the material
  30903. * @returns an array of meshes bound to the material
  30904. */
  30905. getBindedMeshes(): AbstractMesh[];
  30906. /**
  30907. * Force shader compilation
  30908. * @param mesh defines the mesh associated with this material
  30909. * @param onCompiled defines a function to execute once the material is compiled
  30910. * @param options defines the options to configure the compilation
  30911. * @param onError defines a function to execute if the material fails compiling
  30912. */
  30913. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<IMaterialCompilationOptions>, onError?: (reason: string) => void): void;
  30914. /**
  30915. * Force shader compilation
  30916. * @param mesh defines the mesh that will use this material
  30917. * @param options defines additional options for compiling the shaders
  30918. * @returns a promise that resolves when the compilation completes
  30919. */
  30920. forceCompilationAsync(mesh: AbstractMesh, options?: Partial<IMaterialCompilationOptions>): Promise<void>;
  30921. private static readonly _AllDirtyCallBack;
  30922. private static readonly _ImageProcessingDirtyCallBack;
  30923. private static readonly _TextureDirtyCallBack;
  30924. private static readonly _FresnelDirtyCallBack;
  30925. private static readonly _MiscDirtyCallBack;
  30926. private static readonly _PrePassDirtyCallBack;
  30927. private static readonly _LightsDirtyCallBack;
  30928. private static readonly _AttributeDirtyCallBack;
  30929. private static _FresnelAndMiscDirtyCallBack;
  30930. private static _TextureAndMiscDirtyCallBack;
  30931. private static readonly _DirtyCallbackArray;
  30932. private static readonly _RunDirtyCallBacks;
  30933. /**
  30934. * Marks a define in the material to indicate that it needs to be re-computed
  30935. * @param flag defines a flag used to determine which parts of the material have to be marked as dirty
  30936. */
  30937. markAsDirty(flag: number): void;
  30938. /**
  30939. * Marks all submeshes of a material to indicate that their material defines need to be re-calculated
  30940. * @param func defines a function which checks material defines against the submeshes
  30941. */
  30942. protected _markAllSubMeshesAsDirty(func: (defines: MaterialDefines) => void): void;
  30943. /**
  30944. * Indicates that the scene should check if the rendering now needs a prepass
  30945. */
  30946. protected _markScenePrePassDirty(): void;
  30947. /**
  30948. * Indicates that we need to re-calculated for all submeshes
  30949. */
  30950. protected _markAllSubMeshesAsAllDirty(): void;
  30951. /**
  30952. * Indicates that image processing needs to be re-calculated for all submeshes
  30953. */
  30954. protected _markAllSubMeshesAsImageProcessingDirty(): void;
  30955. /**
  30956. * Indicates that textures need to be re-calculated for all submeshes
  30957. */
  30958. protected _markAllSubMeshesAsTexturesDirty(): void;
  30959. /**
  30960. * Indicates that fresnel needs to be re-calculated for all submeshes
  30961. */
  30962. protected _markAllSubMeshesAsFresnelDirty(): void;
  30963. /**
  30964. * Indicates that fresnel and misc need to be re-calculated for all submeshes
  30965. */
  30966. protected _markAllSubMeshesAsFresnelAndMiscDirty(): void;
  30967. /**
  30968. * Indicates that lights need to be re-calculated for all submeshes
  30969. */
  30970. protected _markAllSubMeshesAsLightsDirty(): void;
  30971. /**
  30972. * Indicates that attributes need to be re-calculated for all submeshes
  30973. */
  30974. protected _markAllSubMeshesAsAttributesDirty(): void;
  30975. /**
  30976. * Indicates that misc needs to be re-calculated for all submeshes
  30977. */
  30978. protected _markAllSubMeshesAsMiscDirty(): void;
  30979. /**
  30980. * Indicates that prepass needs to be re-calculated for all submeshes
  30981. */
  30982. protected _markAllSubMeshesAsPrePassDirty(): void;
  30983. /**
  30984. * Indicates that textures and misc need to be re-calculated for all submeshes
  30985. */
  30986. protected _markAllSubMeshesAsTexturesAndMiscDirty(): void;
  30987. /**
  30988. * Sets the required values to the prepass renderer.
  30989. * @param prePassRenderer defines the prepass renderer to setup.
  30990. * @returns true if the pre pass is needed.
  30991. */
  30992. setPrePassRenderer(prePassRenderer: PrePassRenderer): boolean;
  30993. /**
  30994. * Disposes the material
  30995. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  30996. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  30997. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  30998. */
  30999. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  31000. /** @hidden */
  31001. private releaseVertexArrayObject;
  31002. /**
  31003. * Serializes this material
  31004. * @returns the serialized material object
  31005. */
  31006. serialize(): any;
  31007. /**
  31008. * Creates a material from parsed material data
  31009. * @param parsedMaterial defines parsed material data
  31010. * @param scene defines the hosting scene
  31011. * @param rootUrl defines the root URL to use to load textures
  31012. * @returns a new material
  31013. */
  31014. static Parse(parsedMaterial: any, scene: Scene, rootUrl: string): Nullable<Material>;
  31015. }
  31016. }
  31017. declare module BABYLON {
  31018. /**
  31019. * A multi-material is used to apply different materials to different parts of the same object without the need of
  31020. * separate meshes. This can be use to improve performances.
  31021. * @see https://doc.babylonjs.com/how_to/multi_materials
  31022. */
  31023. export class MultiMaterial extends Material {
  31024. private _subMaterials;
  31025. /**
  31026. * Gets or Sets the list of Materials used within the multi material.
  31027. * They need to be ordered according to the submeshes order in the associated mesh
  31028. */
  31029. get subMaterials(): Nullable<Material>[];
  31030. set subMaterials(value: Nullable<Material>[]);
  31031. /**
  31032. * Function used to align with Node.getChildren()
  31033. * @returns the list of Materials used within the multi material
  31034. */
  31035. getChildren(): Nullable<Material>[];
  31036. /**
  31037. * Instantiates a new Multi Material
  31038. * A multi-material is used to apply different materials to different parts of the same object without the need of
  31039. * separate meshes. This can be use to improve performances.
  31040. * @see https://doc.babylonjs.com/how_to/multi_materials
  31041. * @param name Define the name in the scene
  31042. * @param scene Define the scene the material belongs to
  31043. */
  31044. constructor(name: string, scene: Scene);
  31045. private _hookArray;
  31046. /**
  31047. * Get one of the submaterial by its index in the submaterials array
  31048. * @param index The index to look the sub material at
  31049. * @returns The Material if the index has been defined
  31050. */
  31051. getSubMaterial(index: number): Nullable<Material>;
  31052. /**
  31053. * Get the list of active textures for the whole sub materials list.
  31054. * @returns All the textures that will be used during the rendering
  31055. */
  31056. getActiveTextures(): BaseTexture[];
  31057. /**
  31058. * Specifies if any sub-materials of this multi-material use a given texture.
  31059. * @param texture Defines the texture to check against this multi-material's sub-materials.
  31060. * @returns A boolean specifying if any sub-material of this multi-material uses the texture.
  31061. */
  31062. hasTexture(texture: BaseTexture): boolean;
  31063. /**
  31064. * Gets the current class name of the material e.g. "MultiMaterial"
  31065. * Mainly use in serialization.
  31066. * @returns the class name
  31067. */
  31068. getClassName(): string;
  31069. /**
  31070. * Checks if the material is ready to render the requested sub mesh
  31071. * @param mesh Define the mesh the submesh belongs to
  31072. * @param subMesh Define the sub mesh to look readiness for
  31073. * @param useInstances Define whether or not the material is used with instances
  31074. * @returns true if ready, otherwise false
  31075. */
  31076. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  31077. /**
  31078. * Clones the current material and its related sub materials
  31079. * @param name Define the name of the newly cloned material
  31080. * @param cloneChildren Define if submaterial will be cloned or shared with the parent instance
  31081. * @returns the cloned material
  31082. */
  31083. clone(name: string, cloneChildren?: boolean): MultiMaterial;
  31084. /**
  31085. * Serializes the materials into a JSON representation.
  31086. * @returns the JSON representation
  31087. */
  31088. serialize(): any;
  31089. /**
  31090. * Dispose the material and release its associated resources
  31091. * @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)
  31092. * @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)
  31093. * @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)
  31094. */
  31095. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, forceDisposeChildren?: boolean): void;
  31096. /**
  31097. * Creates a MultiMaterial from parsed MultiMaterial data.
  31098. * @param parsedMultiMaterial defines parsed MultiMaterial data.
  31099. * @param scene defines the hosting scene
  31100. * @returns a new MultiMaterial
  31101. */
  31102. static ParseMultiMaterial(parsedMultiMaterial: any, scene: Scene): MultiMaterial;
  31103. }
  31104. }
  31105. declare module BABYLON {
  31106. /** @hidden */
  31107. export interface ICustomEffect {
  31108. effect: Effect;
  31109. defines: string;
  31110. }
  31111. /**
  31112. * Defines a subdivision inside a mesh
  31113. */
  31114. export class SubMesh implements ICullable {
  31115. /** the material index to use */
  31116. materialIndex: number;
  31117. /** vertex index start */
  31118. verticesStart: number;
  31119. /** vertices count */
  31120. verticesCount: number;
  31121. /** index start */
  31122. indexStart: number;
  31123. /** indices count */
  31124. indexCount: number;
  31125. /** @hidden */
  31126. _materialDefines: Nullable<MaterialDefines>;
  31127. /** @hidden */
  31128. _materialEffect: Nullable<Effect>;
  31129. /** @hidden */
  31130. _effectOverride: Nullable<Effect>;
  31131. private _customEffects;
  31132. /**
  31133. * Gets material defines used by the effect associated to the sub mesh
  31134. */
  31135. get materialDefines(): Nullable<MaterialDefines>;
  31136. /**
  31137. * Sets material defines used by the effect associated to the sub mesh
  31138. */
  31139. set materialDefines(defines: Nullable<MaterialDefines>);
  31140. /** @hidden */
  31141. _getCustomEffect(name: string, createIfNotExisting?: boolean): Nullable<ICustomEffect>;
  31142. /** @hidden */
  31143. _removeCustomEffect(name: string): void;
  31144. /**
  31145. * Gets associated effect
  31146. */
  31147. get effect(): Nullable<Effect>;
  31148. /**
  31149. * Sets associated effect (effect used to render this submesh)
  31150. * @param effect defines the effect to associate with
  31151. * @param defines defines the set of defines used to compile this effect
  31152. */
  31153. setEffect(effect: Nullable<Effect>, defines?: Nullable<MaterialDefines>): void;
  31154. /** @hidden */
  31155. _linesIndexCount: number;
  31156. private _mesh;
  31157. private _renderingMesh;
  31158. private _boundingInfo;
  31159. private _linesIndexBuffer;
  31160. /** @hidden */
  31161. _lastColliderWorldVertices: Nullable<Vector3[]>;
  31162. /** @hidden */
  31163. _trianglePlanes: Plane[];
  31164. /** @hidden */
  31165. _lastColliderTransformMatrix: Nullable<Matrix>;
  31166. /** @hidden */
  31167. _renderId: number;
  31168. /** @hidden */
  31169. _alphaIndex: number;
  31170. /** @hidden */
  31171. _distanceToCamera: number;
  31172. /** @hidden */
  31173. _id: number;
  31174. private _currentMaterial;
  31175. /**
  31176. * Add a new submesh to a mesh
  31177. * @param materialIndex defines the material index to use
  31178. * @param verticesStart defines vertex index start
  31179. * @param verticesCount defines vertices count
  31180. * @param indexStart defines index start
  31181. * @param indexCount defines indices count
  31182. * @param mesh defines the parent mesh
  31183. * @param renderingMesh defines an optional rendering mesh
  31184. * @param createBoundingBox defines if bounding box should be created for this submesh
  31185. * @returns the new submesh
  31186. */
  31187. static AddToMesh(materialIndex: number, verticesStart: number, verticesCount: number, indexStart: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean): SubMesh;
  31188. /**
  31189. * Creates a new submesh
  31190. * @param materialIndex defines the material index to use
  31191. * @param verticesStart defines vertex index start
  31192. * @param verticesCount defines vertices count
  31193. * @param indexStart defines index start
  31194. * @param indexCount defines indices count
  31195. * @param mesh defines the parent mesh
  31196. * @param renderingMesh defines an optional rendering mesh
  31197. * @param createBoundingBox defines if bounding box should be created for this submesh
  31198. * @param addToMesh defines a boolean indicating that the submesh must be added to the mesh.subMeshes array (true by default)
  31199. */
  31200. constructor(
  31201. /** the material index to use */
  31202. materialIndex: number,
  31203. /** vertex index start */
  31204. verticesStart: number,
  31205. /** vertices count */
  31206. verticesCount: number,
  31207. /** index start */
  31208. indexStart: number,
  31209. /** indices count */
  31210. indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean, addToMesh?: boolean);
  31211. /**
  31212. * Returns true if this submesh covers the entire parent mesh
  31213. * @ignorenaming
  31214. */
  31215. get IsGlobal(): boolean;
  31216. /**
  31217. * Returns the submesh BoundingInfo object
  31218. * @returns current bounding info (or mesh's one if the submesh is global)
  31219. */
  31220. getBoundingInfo(): BoundingInfo;
  31221. /**
  31222. * Sets the submesh BoundingInfo
  31223. * @param boundingInfo defines the new bounding info to use
  31224. * @returns the SubMesh
  31225. */
  31226. setBoundingInfo(boundingInfo: BoundingInfo): SubMesh;
  31227. /**
  31228. * Returns the mesh of the current submesh
  31229. * @return the parent mesh
  31230. */
  31231. getMesh(): AbstractMesh;
  31232. /**
  31233. * Returns the rendering mesh of the submesh
  31234. * @returns the rendering mesh (could be different from parent mesh)
  31235. */
  31236. getRenderingMesh(): Mesh;
  31237. /**
  31238. * Returns the replacement mesh of the submesh
  31239. * @returns the replacement mesh (could be different from parent mesh)
  31240. */
  31241. getReplacementMesh(): Nullable<AbstractMesh>;
  31242. /**
  31243. * Returns the effective mesh of the submesh
  31244. * @returns the effective mesh (could be different from parent mesh)
  31245. */
  31246. getEffectiveMesh(): AbstractMesh;
  31247. /**
  31248. * Returns the submesh material
  31249. * @returns null or the current material
  31250. */
  31251. getMaterial(): Nullable<Material>;
  31252. private _IsMultiMaterial;
  31253. /**
  31254. * Sets a new updated BoundingInfo object to the submesh
  31255. * @param data defines an optional position array to use to determine the bounding info
  31256. * @returns the SubMesh
  31257. */
  31258. refreshBoundingInfo(data?: Nullable<FloatArray>): SubMesh;
  31259. /** @hidden */
  31260. _checkCollision(collider: Collider): boolean;
  31261. /**
  31262. * Updates the submesh BoundingInfo
  31263. * @param world defines the world matrix to use to update the bounding info
  31264. * @returns the submesh
  31265. */
  31266. updateBoundingInfo(world: DeepImmutable<Matrix>): SubMesh;
  31267. /**
  31268. * True is the submesh bounding box intersects the frustum defined by the passed array of planes.
  31269. * @param frustumPlanes defines the frustum planes
  31270. * @returns true if the submesh is intersecting with the frustum
  31271. */
  31272. isInFrustum(frustumPlanes: Plane[]): boolean;
  31273. /**
  31274. * True is the submesh bounding box is completely inside the frustum defined by the passed array of planes
  31275. * @param frustumPlanes defines the frustum planes
  31276. * @returns true if the submesh is inside the frustum
  31277. */
  31278. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  31279. /**
  31280. * Renders the submesh
  31281. * @param enableAlphaMode defines if alpha needs to be used
  31282. * @returns the submesh
  31283. */
  31284. render(enableAlphaMode: boolean): SubMesh;
  31285. /**
  31286. * @hidden
  31287. */
  31288. _getLinesIndexBuffer(indices: IndicesArray, engine: Engine): DataBuffer;
  31289. /**
  31290. * Checks if the submesh intersects with a ray
  31291. * @param ray defines the ray to test
  31292. * @returns true is the passed ray intersects the submesh bounding box
  31293. */
  31294. canIntersects(ray: Ray): boolean;
  31295. /**
  31296. * Intersects current submesh with a ray
  31297. * @param ray defines the ray to test
  31298. * @param positions defines mesh's positions array
  31299. * @param indices defines mesh's indices array
  31300. * @param fastCheck defines if the first intersection will be used (and not the closest)
  31301. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  31302. * @returns intersection info or null if no intersection
  31303. */
  31304. intersects(ray: Ray, positions: Vector3[], indices: IndicesArray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<IntersectionInfo>;
  31305. /** @hidden */
  31306. private _intersectLines;
  31307. /** @hidden */
  31308. private _intersectUnIndexedLines;
  31309. /** @hidden */
  31310. private _intersectTriangles;
  31311. /** @hidden */
  31312. private _intersectUnIndexedTriangles;
  31313. /** @hidden */
  31314. _rebuild(): void;
  31315. /**
  31316. * Creates a new submesh from the passed mesh
  31317. * @param newMesh defines the new hosting mesh
  31318. * @param newRenderingMesh defines an optional rendering mesh
  31319. * @returns the new submesh
  31320. */
  31321. clone(newMesh: AbstractMesh, newRenderingMesh?: Mesh): SubMesh;
  31322. /**
  31323. * Release associated resources
  31324. */
  31325. dispose(): void;
  31326. /**
  31327. * Gets the class name
  31328. * @returns the string "SubMesh".
  31329. */
  31330. getClassName(): string;
  31331. /**
  31332. * Creates a new submesh from indices data
  31333. * @param materialIndex the index of the main mesh material
  31334. * @param startIndex the index where to start the copy in the mesh indices array
  31335. * @param indexCount the number of indices to copy then from the startIndex
  31336. * @param mesh the main mesh to create the submesh from
  31337. * @param renderingMesh the optional rendering mesh
  31338. * @returns a new submesh
  31339. */
  31340. static CreateFromIndices(materialIndex: number, startIndex: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh): SubMesh;
  31341. }
  31342. }
  31343. declare module BABYLON {
  31344. /**
  31345. * Class used to represent data loading progression
  31346. */
  31347. export class SceneLoaderFlags {
  31348. private static _ForceFullSceneLoadingForIncremental;
  31349. private static _ShowLoadingScreen;
  31350. private static _CleanBoneMatrixWeights;
  31351. private static _loggingLevel;
  31352. /**
  31353. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  31354. */
  31355. static get ForceFullSceneLoadingForIncremental(): boolean;
  31356. static set ForceFullSceneLoadingForIncremental(value: boolean);
  31357. /**
  31358. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  31359. */
  31360. static get ShowLoadingScreen(): boolean;
  31361. static set ShowLoadingScreen(value: boolean);
  31362. /**
  31363. * Defines the current logging level (while loading the scene)
  31364. * @ignorenaming
  31365. */
  31366. static get loggingLevel(): number;
  31367. static set loggingLevel(value: number);
  31368. /**
  31369. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  31370. */
  31371. static get CleanBoneMatrixWeights(): boolean;
  31372. static set CleanBoneMatrixWeights(value: boolean);
  31373. }
  31374. }
  31375. declare module BABYLON {
  31376. /**
  31377. * Class used to store geometry data (vertex buffers + index buffer)
  31378. */
  31379. export class Geometry implements IGetSetVerticesData {
  31380. /**
  31381. * Gets or sets the ID of the geometry
  31382. */
  31383. id: string;
  31384. /**
  31385. * Gets or sets the unique ID of the geometry
  31386. */
  31387. uniqueId: number;
  31388. /**
  31389. * Gets the delay loading state of the geometry (none by default which means not delayed)
  31390. */
  31391. delayLoadState: number;
  31392. /**
  31393. * Gets the file containing the data to load when running in delay load state
  31394. */
  31395. delayLoadingFile: Nullable<string>;
  31396. /**
  31397. * Callback called when the geometry is updated
  31398. */
  31399. onGeometryUpdated: (geometry: Geometry, kind?: string) => void;
  31400. private _scene;
  31401. private _engine;
  31402. private _meshes;
  31403. private _totalVertices;
  31404. /** @hidden */
  31405. _indices: IndicesArray;
  31406. /** @hidden */
  31407. _vertexBuffers: {
  31408. [key: string]: VertexBuffer;
  31409. };
  31410. private _isDisposed;
  31411. private _extend;
  31412. private _boundingBias;
  31413. /** @hidden */
  31414. _delayInfo: Array<string>;
  31415. private _indexBuffer;
  31416. private _indexBufferIsUpdatable;
  31417. /** @hidden */
  31418. _boundingInfo: Nullable<BoundingInfo>;
  31419. /** @hidden */
  31420. _delayLoadingFunction: Nullable<(any: any, geometry: Geometry) => void>;
  31421. /** @hidden */
  31422. _softwareSkinningFrameId: number;
  31423. private _vertexArrayObjects;
  31424. private _updatable;
  31425. /** @hidden */
  31426. _positions: Nullable<Vector3[]>;
  31427. private _positionsCache;
  31428. /**
  31429. * 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
  31430. */
  31431. get boundingBias(): Vector2;
  31432. /**
  31433. * 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
  31434. */
  31435. set boundingBias(value: Vector2);
  31436. /**
  31437. * Static function used to attach a new empty geometry to a mesh
  31438. * @param mesh defines the mesh to attach the geometry to
  31439. * @returns the new Geometry
  31440. */
  31441. static CreateGeometryForMesh(mesh: Mesh): Geometry;
  31442. /** Get the list of meshes using this geometry */
  31443. get meshes(): Mesh[];
  31444. /**
  31445. * If set to true (false by default), the bounding info applied to the meshes sharing this geometry will be the bounding info defined at the class level
  31446. * and won't be computed based on the vertex positions (which is what we get when useBoundingInfoFromGeometry = false)
  31447. */
  31448. useBoundingInfoFromGeometry: boolean;
  31449. /**
  31450. * Creates a new geometry
  31451. * @param id defines the unique ID
  31452. * @param scene defines the hosting scene
  31453. * @param vertexData defines the VertexData used to get geometry data
  31454. * @param updatable defines if geometry must be updatable (false by default)
  31455. * @param mesh defines the mesh that will be associated with the geometry
  31456. */
  31457. constructor(id: string, scene: Scene, vertexData?: VertexData, updatable?: boolean, mesh?: Nullable<Mesh>);
  31458. /**
  31459. * Gets the current extend of the geometry
  31460. */
  31461. get extend(): {
  31462. minimum: Vector3;
  31463. maximum: Vector3;
  31464. };
  31465. /**
  31466. * Gets the hosting scene
  31467. * @returns the hosting Scene
  31468. */
  31469. getScene(): Scene;
  31470. /**
  31471. * Gets the hosting engine
  31472. * @returns the hosting Engine
  31473. */
  31474. getEngine(): Engine;
  31475. /**
  31476. * Defines if the geometry is ready to use
  31477. * @returns true if the geometry is ready to be used
  31478. */
  31479. isReady(): boolean;
  31480. /**
  31481. * Gets a value indicating that the geometry should not be serialized
  31482. */
  31483. get doNotSerialize(): boolean;
  31484. /** @hidden */
  31485. _rebuild(): void;
  31486. /**
  31487. * Affects all geometry data in one call
  31488. * @param vertexData defines the geometry data
  31489. * @param updatable defines if the geometry must be flagged as updatable (false as default)
  31490. */
  31491. setAllVerticesData(vertexData: VertexData, updatable?: boolean): void;
  31492. /**
  31493. * Set specific vertex data
  31494. * @param kind defines the data kind (Position, normal, etc...)
  31495. * @param data defines the vertex data to use
  31496. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  31497. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  31498. */
  31499. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): void;
  31500. /**
  31501. * Removes a specific vertex data
  31502. * @param kind defines the data kind (Position, normal, etc...)
  31503. */
  31504. removeVerticesData(kind: string): void;
  31505. /**
  31506. * Affect a vertex buffer to the geometry. the vertexBuffer.getKind() function is used to determine where to store the data
  31507. * @param buffer defines the vertex buffer to use
  31508. * @param totalVertices defines the total number of vertices for position kind (could be null)
  31509. */
  31510. setVerticesBuffer(buffer: VertexBuffer, totalVertices?: Nullable<number>): void;
  31511. /**
  31512. * Update a specific vertex buffer
  31513. * This function will directly update the underlying DataBuffer according to the passed numeric array or Float32Array
  31514. * It will do nothing if the buffer is not updatable
  31515. * @param kind defines the data kind (Position, normal, etc...)
  31516. * @param data defines the data to use
  31517. * @param offset defines the offset in the target buffer where to store the data
  31518. * @param useBytes set to true if the offset is in bytes
  31519. */
  31520. updateVerticesDataDirectly(kind: string, data: DataArray, offset: number, useBytes?: boolean): void;
  31521. /**
  31522. * Update a specific vertex buffer
  31523. * This function will create a new buffer if the current one is not updatable
  31524. * @param kind defines the data kind (Position, normal, etc...)
  31525. * @param data defines the data to use
  31526. * @param updateExtends defines if the geometry extends must be recomputed (false by default)
  31527. */
  31528. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean): void;
  31529. private _updateBoundingInfo;
  31530. /** @hidden */
  31531. _bind(effect: Nullable<Effect>, indexToBind?: Nullable<DataBuffer>, overrideVertexBuffers?: {
  31532. [kind: string]: Nullable<VertexBuffer>;
  31533. }, overrideVertexArrayObjects?: {
  31534. [key: string]: WebGLVertexArrayObject;
  31535. }): void;
  31536. /**
  31537. * Gets total number of vertices
  31538. * @returns the total number of vertices
  31539. */
  31540. getTotalVertices(): number;
  31541. /**
  31542. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  31543. * @param kind defines the data kind (Position, normal, etc...)
  31544. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  31545. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  31546. * @returns a float array containing vertex data
  31547. */
  31548. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  31549. /**
  31550. * Returns a boolean defining if the vertex data for the requested `kind` is updatable
  31551. * @param kind defines the data kind (Position, normal, etc...)
  31552. * @returns true if the vertex buffer with the specified kind is updatable
  31553. */
  31554. isVertexBufferUpdatable(kind: string): boolean;
  31555. /**
  31556. * Gets a specific vertex buffer
  31557. * @param kind defines the data kind (Position, normal, etc...)
  31558. * @returns a VertexBuffer
  31559. */
  31560. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  31561. /**
  31562. * Returns all vertex buffers
  31563. * @return an object holding all vertex buffers indexed by kind
  31564. */
  31565. getVertexBuffers(): Nullable<{
  31566. [key: string]: VertexBuffer;
  31567. }>;
  31568. /**
  31569. * Gets a boolean indicating if specific vertex buffer is present
  31570. * @param kind defines the data kind (Position, normal, etc...)
  31571. * @returns true if data is present
  31572. */
  31573. isVerticesDataPresent(kind: string): boolean;
  31574. /**
  31575. * Gets a list of all attached data kinds (Position, normal, etc...)
  31576. * @returns a list of string containing all kinds
  31577. */
  31578. getVerticesDataKinds(): string[];
  31579. /**
  31580. * Update index buffer
  31581. * @param indices defines the indices to store in the index buffer
  31582. * @param offset defines the offset in the target buffer where to store the data
  31583. * @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)
  31584. */
  31585. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): void;
  31586. /**
  31587. * Creates a new index buffer
  31588. * @param indices defines the indices to store in the index buffer
  31589. * @param totalVertices defines the total number of vertices (could be null)
  31590. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  31591. */
  31592. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): void;
  31593. /**
  31594. * Return the total number of indices
  31595. * @returns the total number of indices
  31596. */
  31597. getTotalIndices(): number;
  31598. /**
  31599. * Gets the index buffer array
  31600. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  31601. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  31602. * @returns the index buffer array
  31603. */
  31604. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  31605. /**
  31606. * Gets the index buffer
  31607. * @return the index buffer
  31608. */
  31609. getIndexBuffer(): Nullable<DataBuffer>;
  31610. /** @hidden */
  31611. _releaseVertexArrayObject(effect?: Nullable<Effect>): void;
  31612. /**
  31613. * Release the associated resources for a specific mesh
  31614. * @param mesh defines the source mesh
  31615. * @param shouldDispose defines if the geometry must be disposed if there is no more mesh pointing to it
  31616. */
  31617. releaseForMesh(mesh: Mesh, shouldDispose?: boolean): void;
  31618. /**
  31619. * Apply current geometry to a given mesh
  31620. * @param mesh defines the mesh to apply geometry to
  31621. */
  31622. applyToMesh(mesh: Mesh): void;
  31623. private _updateExtend;
  31624. private _applyToMesh;
  31625. private notifyUpdate;
  31626. /**
  31627. * Load the geometry if it was flagged as delay loaded
  31628. * @param scene defines the hosting scene
  31629. * @param onLoaded defines a callback called when the geometry is loaded
  31630. */
  31631. load(scene: Scene, onLoaded?: () => void): void;
  31632. private _queueLoad;
  31633. /**
  31634. * Invert the geometry to move from a right handed system to a left handed one.
  31635. */
  31636. toLeftHanded(): void;
  31637. /** @hidden */
  31638. _resetPointsArrayCache(): void;
  31639. /** @hidden */
  31640. _generatePointsArray(): boolean;
  31641. /**
  31642. * Gets a value indicating if the geometry is disposed
  31643. * @returns true if the geometry was disposed
  31644. */
  31645. isDisposed(): boolean;
  31646. private _disposeVertexArrayObjects;
  31647. /**
  31648. * Free all associated resources
  31649. */
  31650. dispose(): void;
  31651. /**
  31652. * Clone the current geometry into a new geometry
  31653. * @param id defines the unique ID of the new geometry
  31654. * @returns a new geometry object
  31655. */
  31656. copy(id: string): Geometry;
  31657. /**
  31658. * Serialize the current geometry info (and not the vertices data) into a JSON object
  31659. * @return a JSON representation of the current geometry data (without the vertices data)
  31660. */
  31661. serialize(): any;
  31662. private toNumberArray;
  31663. /**
  31664. * Serialize all vertices data into a JSON object
  31665. * @returns a JSON representation of the current geometry data
  31666. */
  31667. serializeVerticeData(): any;
  31668. /**
  31669. * Extracts a clone of a mesh geometry
  31670. * @param mesh defines the source mesh
  31671. * @param id defines the unique ID of the new geometry object
  31672. * @returns the new geometry object
  31673. */
  31674. static ExtractFromMesh(mesh: Mesh, id: string): Nullable<Geometry>;
  31675. /**
  31676. * You should now use Tools.RandomId(), this method is still here for legacy reasons.
  31677. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  31678. * Be aware Math.random() could cause collisions, but:
  31679. * "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"
  31680. * @returns a string containing a new GUID
  31681. */
  31682. static RandomId(): string;
  31683. /** @hidden */
  31684. static _ImportGeometry(parsedGeometry: any, mesh: Mesh): void;
  31685. private static _CleanMatricesWeights;
  31686. /**
  31687. * Create a new geometry from persisted data (Using .babylon file format)
  31688. * @param parsedVertexData defines the persisted data
  31689. * @param scene defines the hosting scene
  31690. * @param rootUrl defines the root url to use to load assets (like delayed data)
  31691. * @returns the new geometry object
  31692. */
  31693. static Parse(parsedVertexData: any, scene: Scene, rootUrl: string): Nullable<Geometry>;
  31694. }
  31695. }
  31696. declare module BABYLON {
  31697. /**
  31698. * Defines a target to use with MorphTargetManager
  31699. * @see https://doc.babylonjs.com/how_to/how_to_use_morphtargets
  31700. */
  31701. export class MorphTarget implements IAnimatable {
  31702. /** defines the name of the target */
  31703. name: string;
  31704. /**
  31705. * Gets or sets the list of animations
  31706. */
  31707. animations: Animation[];
  31708. private _scene;
  31709. private _positions;
  31710. private _normals;
  31711. private _tangents;
  31712. private _uvs;
  31713. private _influence;
  31714. private _uniqueId;
  31715. /**
  31716. * Observable raised when the influence changes
  31717. */
  31718. onInfluenceChanged: Observable<boolean>;
  31719. /** @hidden */
  31720. _onDataLayoutChanged: Observable<void>;
  31721. /**
  31722. * Gets or sets the influence of this target (ie. its weight in the overall morphing)
  31723. */
  31724. get influence(): number;
  31725. set influence(influence: number);
  31726. /**
  31727. * Gets or sets the id of the morph Target
  31728. */
  31729. id: string;
  31730. private _animationPropertiesOverride;
  31731. /**
  31732. * Gets or sets the animation properties override
  31733. */
  31734. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  31735. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  31736. /**
  31737. * Creates a new MorphTarget
  31738. * @param name defines the name of the target
  31739. * @param influence defines the influence to use
  31740. * @param scene defines the scene the morphtarget belongs to
  31741. */
  31742. constructor(
  31743. /** defines the name of the target */
  31744. name: string, influence?: number, scene?: Nullable<Scene>);
  31745. /**
  31746. * Gets the unique ID of this manager
  31747. */
  31748. get uniqueId(): number;
  31749. /**
  31750. * Gets a boolean defining if the target contains position data
  31751. */
  31752. get hasPositions(): boolean;
  31753. /**
  31754. * Gets a boolean defining if the target contains normal data
  31755. */
  31756. get hasNormals(): boolean;
  31757. /**
  31758. * Gets a boolean defining if the target contains tangent data
  31759. */
  31760. get hasTangents(): boolean;
  31761. /**
  31762. * Gets a boolean defining if the target contains texture coordinates data
  31763. */
  31764. get hasUVs(): boolean;
  31765. /**
  31766. * Affects position data to this target
  31767. * @param data defines the position data to use
  31768. */
  31769. setPositions(data: Nullable<FloatArray>): void;
  31770. /**
  31771. * Gets the position data stored in this target
  31772. * @returns a FloatArray containing the position data (or null if not present)
  31773. */
  31774. getPositions(): Nullable<FloatArray>;
  31775. /**
  31776. * Affects normal data to this target
  31777. * @param data defines the normal data to use
  31778. */
  31779. setNormals(data: Nullable<FloatArray>): void;
  31780. /**
  31781. * Gets the normal data stored in this target
  31782. * @returns a FloatArray containing the normal data (or null if not present)
  31783. */
  31784. getNormals(): Nullable<FloatArray>;
  31785. /**
  31786. * Affects tangent data to this target
  31787. * @param data defines the tangent data to use
  31788. */
  31789. setTangents(data: Nullable<FloatArray>): void;
  31790. /**
  31791. * Gets the tangent data stored in this target
  31792. * @returns a FloatArray containing the tangent data (or null if not present)
  31793. */
  31794. getTangents(): Nullable<FloatArray>;
  31795. /**
  31796. * Affects texture coordinates data to this target
  31797. * @param data defines the texture coordinates data to use
  31798. */
  31799. setUVs(data: Nullable<FloatArray>): void;
  31800. /**
  31801. * Gets the texture coordinates data stored in this target
  31802. * @returns a FloatArray containing the texture coordinates data (or null if not present)
  31803. */
  31804. getUVs(): Nullable<FloatArray>;
  31805. /**
  31806. * Clone the current target
  31807. * @returns a new MorphTarget
  31808. */
  31809. clone(): MorphTarget;
  31810. /**
  31811. * Serializes the current target into a Serialization object
  31812. * @returns the serialized object
  31813. */
  31814. serialize(): any;
  31815. /**
  31816. * Returns the string "MorphTarget"
  31817. * @returns "MorphTarget"
  31818. */
  31819. getClassName(): string;
  31820. /**
  31821. * Creates a new target from serialized data
  31822. * @param serializationObject defines the serialized data to use
  31823. * @returns a new MorphTarget
  31824. */
  31825. static Parse(serializationObject: any): MorphTarget;
  31826. /**
  31827. * Creates a MorphTarget from mesh data
  31828. * @param mesh defines the source mesh
  31829. * @param name defines the name to use for the new target
  31830. * @param influence defines the influence to attach to the target
  31831. * @returns a new MorphTarget
  31832. */
  31833. static FromMesh(mesh: AbstractMesh, name?: string, influence?: number): MorphTarget;
  31834. }
  31835. }
  31836. declare module BABYLON {
  31837. /**
  31838. * This class is used to deform meshes using morphing between different targets
  31839. * @see https://doc.babylonjs.com/how_to/how_to_use_morphtargets
  31840. */
  31841. export class MorphTargetManager {
  31842. private _targets;
  31843. private _targetInfluenceChangedObservers;
  31844. private _targetDataLayoutChangedObservers;
  31845. private _activeTargets;
  31846. private _scene;
  31847. private _influences;
  31848. private _supportsNormals;
  31849. private _supportsTangents;
  31850. private _supportsUVs;
  31851. private _vertexCount;
  31852. private _uniqueId;
  31853. private _tempInfluences;
  31854. /**
  31855. * Gets or sets a boolean indicating if normals must be morphed
  31856. */
  31857. enableNormalMorphing: boolean;
  31858. /**
  31859. * Gets or sets a boolean indicating if tangents must be morphed
  31860. */
  31861. enableTangentMorphing: boolean;
  31862. /**
  31863. * Gets or sets a boolean indicating if UV must be morphed
  31864. */
  31865. enableUVMorphing: boolean;
  31866. /**
  31867. * Creates a new MorphTargetManager
  31868. * @param scene defines the current scene
  31869. */
  31870. constructor(scene?: Nullable<Scene>);
  31871. /**
  31872. * Gets the unique ID of this manager
  31873. */
  31874. get uniqueId(): number;
  31875. /**
  31876. * Gets the number of vertices handled by this manager
  31877. */
  31878. get vertexCount(): number;
  31879. /**
  31880. * Gets a boolean indicating if this manager supports morphing of normals
  31881. */
  31882. get supportsNormals(): boolean;
  31883. /**
  31884. * Gets a boolean indicating if this manager supports morphing of tangents
  31885. */
  31886. get supportsTangents(): boolean;
  31887. /**
  31888. * Gets a boolean indicating if this manager supports morphing of texture coordinates
  31889. */
  31890. get supportsUVs(): boolean;
  31891. /**
  31892. * Gets the number of targets stored in this manager
  31893. */
  31894. get numTargets(): number;
  31895. /**
  31896. * Gets the number of influencers (ie. the number of targets with influences > 0)
  31897. */
  31898. get numInfluencers(): number;
  31899. /**
  31900. * Gets the list of influences (one per target)
  31901. */
  31902. get influences(): Float32Array;
  31903. /**
  31904. * Gets the active target at specified index. An active target is a target with an influence > 0
  31905. * @param index defines the index to check
  31906. * @returns the requested target
  31907. */
  31908. getActiveTarget(index: number): MorphTarget;
  31909. /**
  31910. * Gets the target at specified index
  31911. * @param index defines the index to check
  31912. * @returns the requested target
  31913. */
  31914. getTarget(index: number): MorphTarget;
  31915. /**
  31916. * Add a new target to this manager
  31917. * @param target defines the target to add
  31918. */
  31919. addTarget(target: MorphTarget): void;
  31920. /**
  31921. * Removes a target from the manager
  31922. * @param target defines the target to remove
  31923. */
  31924. removeTarget(target: MorphTarget): void;
  31925. /**
  31926. * Clone the current manager
  31927. * @returns a new MorphTargetManager
  31928. */
  31929. clone(): MorphTargetManager;
  31930. /**
  31931. * Serializes the current manager into a Serialization object
  31932. * @returns the serialized object
  31933. */
  31934. serialize(): any;
  31935. private _syncActiveTargets;
  31936. /**
  31937. * Syncrhonize the targets with all the meshes using this morph target manager
  31938. */
  31939. synchronize(): void;
  31940. /**
  31941. * Creates a new MorphTargetManager from serialized data
  31942. * @param serializationObject defines the serialized data
  31943. * @param scene defines the hosting scene
  31944. * @returns the new MorphTargetManager
  31945. */
  31946. static Parse(serializationObject: any, scene: Scene): MorphTargetManager;
  31947. }
  31948. }
  31949. declare module BABYLON {
  31950. /**
  31951. * Class used to represent a specific level of detail of a mesh
  31952. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  31953. */
  31954. export class MeshLODLevel {
  31955. /** Defines the distance where this level should start being displayed */
  31956. distance: number;
  31957. /** Defines the mesh to use to render this level */
  31958. mesh: Nullable<Mesh>;
  31959. /**
  31960. * Creates a new LOD level
  31961. * @param distance defines the distance where this level should star being displayed
  31962. * @param mesh defines the mesh to use to render this level
  31963. */
  31964. constructor(
  31965. /** Defines the distance where this level should start being displayed */
  31966. distance: number,
  31967. /** Defines the mesh to use to render this level */
  31968. mesh: Nullable<Mesh>);
  31969. }
  31970. }
  31971. declare module BABYLON {
  31972. /**
  31973. * Helper class used to generate a canvas to manipulate images
  31974. */
  31975. export class CanvasGenerator {
  31976. /**
  31977. * Create a new canvas (or offscreen canvas depending on the context)
  31978. * @param width defines the expected width
  31979. * @param height defines the expected height
  31980. * @return a new canvas or offscreen canvas
  31981. */
  31982. static CreateCanvas(width: number, height: number): HTMLCanvasElement | OffscreenCanvas;
  31983. }
  31984. }
  31985. declare module BABYLON {
  31986. /**
  31987. * Mesh representing the ground
  31988. */
  31989. export class GroundMesh extends Mesh {
  31990. /** If octree should be generated */
  31991. generateOctree: boolean;
  31992. private _heightQuads;
  31993. /** @hidden */
  31994. _subdivisionsX: number;
  31995. /** @hidden */
  31996. _subdivisionsY: number;
  31997. /** @hidden */
  31998. _width: number;
  31999. /** @hidden */
  32000. _height: number;
  32001. /** @hidden */
  32002. _minX: number;
  32003. /** @hidden */
  32004. _maxX: number;
  32005. /** @hidden */
  32006. _minZ: number;
  32007. /** @hidden */
  32008. _maxZ: number;
  32009. constructor(name: string, scene: Scene);
  32010. /**
  32011. * "GroundMesh"
  32012. * @returns "GroundMesh"
  32013. */
  32014. getClassName(): string;
  32015. /**
  32016. * The minimum of x and y subdivisions
  32017. */
  32018. get subdivisions(): number;
  32019. /**
  32020. * X subdivisions
  32021. */
  32022. get subdivisionsX(): number;
  32023. /**
  32024. * Y subdivisions
  32025. */
  32026. get subdivisionsY(): number;
  32027. /**
  32028. * This function will update an octree to help to select the right submeshes for rendering, picking and collision computations.
  32029. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  32030. * @param chunksCount the number of subdivisions for x and y
  32031. * @param octreeBlocksSize (Default: 32)
  32032. */
  32033. optimize(chunksCount: number, octreeBlocksSize?: number): void;
  32034. /**
  32035. * Returns a height (y) value in the World system :
  32036. * the ground altitude at the coordinates (x, z) expressed in the World system.
  32037. * @param x x coordinate
  32038. * @param z z coordinate
  32039. * @returns the ground y position if (x, z) are outside the ground surface.
  32040. */
  32041. getHeightAtCoordinates(x: number, z: number): number;
  32042. /**
  32043. * Returns a normalized vector (Vector3) orthogonal to the ground
  32044. * at the ground coordinates (x, z) expressed in the World system.
  32045. * @param x x coordinate
  32046. * @param z z coordinate
  32047. * @returns Vector3(0.0, 1.0, 0.0) if (x, z) are outside the ground surface.
  32048. */
  32049. getNormalAtCoordinates(x: number, z: number): Vector3;
  32050. /**
  32051. * Updates the Vector3 passed a reference with a normalized vector orthogonal to the ground
  32052. * at the ground coordinates (x, z) expressed in the World system.
  32053. * Doesn't update the reference Vector3 if (x, z) are outside the ground surface.
  32054. * @param x x coordinate
  32055. * @param z z coordinate
  32056. * @param ref vector to store the result
  32057. * @returns the GroundMesh.
  32058. */
  32059. getNormalAtCoordinatesToRef(x: number, z: number, ref: Vector3): GroundMesh;
  32060. /**
  32061. * Force the heights to be recomputed for getHeightAtCoordinates() or getNormalAtCoordinates()
  32062. * if the ground has been updated.
  32063. * This can be used in the render loop.
  32064. * @returns the GroundMesh.
  32065. */
  32066. updateCoordinateHeights(): GroundMesh;
  32067. private _getFacetAt;
  32068. private _initHeightQuads;
  32069. private _computeHeightQuads;
  32070. /**
  32071. * Serializes this ground mesh
  32072. * @param serializationObject object to write serialization to
  32073. */
  32074. serialize(serializationObject: any): void;
  32075. /**
  32076. * Parses a serialized ground mesh
  32077. * @param parsedMesh the serialized mesh
  32078. * @param scene the scene to create the ground mesh in
  32079. * @returns the created ground mesh
  32080. */
  32081. static Parse(parsedMesh: any, scene: Scene): GroundMesh;
  32082. }
  32083. }
  32084. declare module BABYLON {
  32085. /**
  32086. * Interface for Physics-Joint data
  32087. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  32088. */
  32089. export interface PhysicsJointData {
  32090. /**
  32091. * The main pivot of the joint
  32092. */
  32093. mainPivot?: Vector3;
  32094. /**
  32095. * The connected pivot of the joint
  32096. */
  32097. connectedPivot?: Vector3;
  32098. /**
  32099. * The main axis of the joint
  32100. */
  32101. mainAxis?: Vector3;
  32102. /**
  32103. * The connected axis of the joint
  32104. */
  32105. connectedAxis?: Vector3;
  32106. /**
  32107. * The collision of the joint
  32108. */
  32109. collision?: boolean;
  32110. /**
  32111. * Native Oimo/Cannon/Energy data
  32112. */
  32113. nativeParams?: any;
  32114. }
  32115. /**
  32116. * This is a holder class for the physics joint created by the physics plugin
  32117. * It holds a set of functions to control the underlying joint
  32118. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  32119. */
  32120. export class PhysicsJoint {
  32121. /**
  32122. * The type of the physics joint
  32123. */
  32124. type: number;
  32125. /**
  32126. * The data for the physics joint
  32127. */
  32128. jointData: PhysicsJointData;
  32129. private _physicsJoint;
  32130. protected _physicsPlugin: IPhysicsEnginePlugin;
  32131. /**
  32132. * Initializes the physics joint
  32133. * @param type The type of the physics joint
  32134. * @param jointData The data for the physics joint
  32135. */
  32136. constructor(
  32137. /**
  32138. * The type of the physics joint
  32139. */
  32140. type: number,
  32141. /**
  32142. * The data for the physics joint
  32143. */
  32144. jointData: PhysicsJointData);
  32145. /**
  32146. * Gets the physics joint
  32147. */
  32148. get physicsJoint(): any;
  32149. /**
  32150. * Sets the physics joint
  32151. */
  32152. set physicsJoint(newJoint: any);
  32153. /**
  32154. * Sets the physics plugin
  32155. */
  32156. set physicsPlugin(physicsPlugin: IPhysicsEnginePlugin);
  32157. /**
  32158. * Execute a function that is physics-plugin specific.
  32159. * @param {Function} func the function that will be executed.
  32160. * It accepts two parameters: the physics world and the physics joint
  32161. */
  32162. executeNativeFunction(func: (world: any, physicsJoint: any) => void): void;
  32163. /**
  32164. * Distance-Joint type
  32165. */
  32166. static DistanceJoint: number;
  32167. /**
  32168. * Hinge-Joint type
  32169. */
  32170. static HingeJoint: number;
  32171. /**
  32172. * Ball-and-Socket joint type
  32173. */
  32174. static BallAndSocketJoint: number;
  32175. /**
  32176. * Wheel-Joint type
  32177. */
  32178. static WheelJoint: number;
  32179. /**
  32180. * Slider-Joint type
  32181. */
  32182. static SliderJoint: number;
  32183. /**
  32184. * Prismatic-Joint type
  32185. */
  32186. static PrismaticJoint: number;
  32187. /**
  32188. * Universal-Joint type
  32189. * ENERGY FTW! (compare with this - @see http://ode-wiki.org/wiki/index.php?title=Manual:_Joint_Types_and_Functions)
  32190. */
  32191. static UniversalJoint: number;
  32192. /**
  32193. * Hinge-Joint 2 type
  32194. */
  32195. static Hinge2Joint: number;
  32196. /**
  32197. * Point to Point Joint type. Similar to a Ball-Joint. Different in parameters
  32198. */
  32199. static PointToPointJoint: number;
  32200. /**
  32201. * Spring-Joint type
  32202. */
  32203. static SpringJoint: number;
  32204. /**
  32205. * Lock-Joint type
  32206. */
  32207. static LockJoint: number;
  32208. }
  32209. /**
  32210. * A class representing a physics distance joint
  32211. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  32212. */
  32213. export class DistanceJoint extends PhysicsJoint {
  32214. /**
  32215. *
  32216. * @param jointData The data for the Distance-Joint
  32217. */
  32218. constructor(jointData: DistanceJointData);
  32219. /**
  32220. * Update the predefined distance.
  32221. * @param maxDistance The maximum preferred distance
  32222. * @param minDistance The minimum preferred distance
  32223. */
  32224. updateDistance(maxDistance: number, minDistance?: number): void;
  32225. }
  32226. /**
  32227. * Represents a Motor-Enabled Joint
  32228. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  32229. */
  32230. export class MotorEnabledJoint extends PhysicsJoint implements IMotorEnabledJoint {
  32231. /**
  32232. * Initializes the Motor-Enabled Joint
  32233. * @param type The type of the joint
  32234. * @param jointData The physical joint data for the joint
  32235. */
  32236. constructor(type: number, jointData: PhysicsJointData);
  32237. /**
  32238. * Set the motor values.
  32239. * Attention, this function is plugin specific. Engines won't react 100% the same.
  32240. * @param force the force to apply
  32241. * @param maxForce max force for this motor.
  32242. */
  32243. setMotor(force?: number, maxForce?: number): void;
  32244. /**
  32245. * Set the motor's limits.
  32246. * Attention, this function is plugin specific. Engines won't react 100% the same.
  32247. * @param upperLimit The upper limit of the motor
  32248. * @param lowerLimit The lower limit of the motor
  32249. */
  32250. setLimit(upperLimit: number, lowerLimit?: number): void;
  32251. }
  32252. /**
  32253. * This class represents a single physics Hinge-Joint
  32254. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  32255. */
  32256. export class HingeJoint extends MotorEnabledJoint {
  32257. /**
  32258. * Initializes the Hinge-Joint
  32259. * @param jointData The joint data for the Hinge-Joint
  32260. */
  32261. constructor(jointData: PhysicsJointData);
  32262. /**
  32263. * Set the motor values.
  32264. * Attention, this function is plugin specific. Engines won't react 100% the same.
  32265. * @param {number} force the force to apply
  32266. * @param {number} maxForce max force for this motor.
  32267. */
  32268. setMotor(force?: number, maxForce?: number): void;
  32269. /**
  32270. * Set the motor's limits.
  32271. * Attention, this function is plugin specific. Engines won't react 100% the same.
  32272. * @param upperLimit The upper limit of the motor
  32273. * @param lowerLimit The lower limit of the motor
  32274. */
  32275. setLimit(upperLimit: number, lowerLimit?: number): void;
  32276. }
  32277. /**
  32278. * This class represents a dual hinge physics joint (same as wheel joint)
  32279. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  32280. */
  32281. export class Hinge2Joint extends MotorEnabledJoint {
  32282. /**
  32283. * Initializes the Hinge2-Joint
  32284. * @param jointData The joint data for the Hinge2-Joint
  32285. */
  32286. constructor(jointData: PhysicsJointData);
  32287. /**
  32288. * Set the motor values.
  32289. * Attention, this function is plugin specific. Engines won't react 100% the same.
  32290. * @param {number} targetSpeed the speed the motor is to reach
  32291. * @param {number} maxForce max force for this motor.
  32292. * @param {motorIndex} the motor's index, 0 or 1.
  32293. */
  32294. setMotor(targetSpeed?: number, maxForce?: number, motorIndex?: number): void;
  32295. /**
  32296. * Set the motor limits.
  32297. * Attention, this function is plugin specific. Engines won't react 100% the same.
  32298. * @param {number} upperLimit the upper limit
  32299. * @param {number} lowerLimit lower limit
  32300. * @param {motorIndex} the motor's index, 0 or 1.
  32301. */
  32302. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  32303. }
  32304. /**
  32305. * Interface for a motor enabled joint
  32306. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  32307. */
  32308. export interface IMotorEnabledJoint {
  32309. /**
  32310. * Physics joint
  32311. */
  32312. physicsJoint: any;
  32313. /**
  32314. * Sets the motor of the motor-enabled joint
  32315. * @param force The force of the motor
  32316. * @param maxForce The maximum force of the motor
  32317. * @param motorIndex The index of the motor
  32318. */
  32319. setMotor(force?: number, maxForce?: number, motorIndex?: number): void;
  32320. /**
  32321. * Sets the limit of the motor
  32322. * @param upperLimit The upper limit of the motor
  32323. * @param lowerLimit The lower limit of the motor
  32324. * @param motorIndex The index of the motor
  32325. */
  32326. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  32327. }
  32328. /**
  32329. * Joint data for a Distance-Joint
  32330. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  32331. */
  32332. export interface DistanceJointData extends PhysicsJointData {
  32333. /**
  32334. * Max distance the 2 joint objects can be apart
  32335. */
  32336. maxDistance: number;
  32337. }
  32338. /**
  32339. * Joint data from a spring joint
  32340. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  32341. */
  32342. export interface SpringJointData extends PhysicsJointData {
  32343. /**
  32344. * Length of the spring
  32345. */
  32346. length: number;
  32347. /**
  32348. * Stiffness of the spring
  32349. */
  32350. stiffness: number;
  32351. /**
  32352. * Damping of the spring
  32353. */
  32354. damping: number;
  32355. /** this callback will be called when applying the force to the impostors. */
  32356. forceApplicationCallback: () => void;
  32357. }
  32358. }
  32359. declare module BABYLON {
  32360. /**
  32361. * Holds the data for the raycast result
  32362. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  32363. */
  32364. export class PhysicsRaycastResult {
  32365. private _hasHit;
  32366. private _hitDistance;
  32367. private _hitNormalWorld;
  32368. private _hitPointWorld;
  32369. private _rayFromWorld;
  32370. private _rayToWorld;
  32371. /**
  32372. * Gets if there was a hit
  32373. */
  32374. get hasHit(): boolean;
  32375. /**
  32376. * Gets the distance from the hit
  32377. */
  32378. get hitDistance(): number;
  32379. /**
  32380. * Gets the hit normal/direction in the world
  32381. */
  32382. get hitNormalWorld(): Vector3;
  32383. /**
  32384. * Gets the hit point in the world
  32385. */
  32386. get hitPointWorld(): Vector3;
  32387. /**
  32388. * Gets the ray "start point" of the ray in the world
  32389. */
  32390. get rayFromWorld(): Vector3;
  32391. /**
  32392. * Gets the ray "end point" of the ray in the world
  32393. */
  32394. get rayToWorld(): Vector3;
  32395. /**
  32396. * Sets the hit data (normal & point in world space)
  32397. * @param hitNormalWorld defines the normal in world space
  32398. * @param hitPointWorld defines the point in world space
  32399. */
  32400. setHitData(hitNormalWorld: IXYZ, hitPointWorld: IXYZ): void;
  32401. /**
  32402. * Sets the distance from the start point to the hit point
  32403. * @param distance
  32404. */
  32405. setHitDistance(distance: number): void;
  32406. /**
  32407. * Calculates the distance manually
  32408. */
  32409. calculateHitDistance(): void;
  32410. /**
  32411. * Resets all the values to default
  32412. * @param from The from point on world space
  32413. * @param to The to point on world space
  32414. */
  32415. reset(from?: Vector3, to?: Vector3): void;
  32416. }
  32417. /**
  32418. * Interface for the size containing width and height
  32419. */
  32420. interface IXYZ {
  32421. /**
  32422. * X
  32423. */
  32424. x: number;
  32425. /**
  32426. * Y
  32427. */
  32428. y: number;
  32429. /**
  32430. * Z
  32431. */
  32432. z: number;
  32433. }
  32434. }
  32435. declare module BABYLON {
  32436. /**
  32437. * Interface used to describe a physics joint
  32438. */
  32439. export interface PhysicsImpostorJoint {
  32440. /** Defines the main impostor to which the joint is linked */
  32441. mainImpostor: PhysicsImpostor;
  32442. /** Defines the impostor that is connected to the main impostor using this joint */
  32443. connectedImpostor: PhysicsImpostor;
  32444. /** Defines the joint itself */
  32445. joint: PhysicsJoint;
  32446. }
  32447. /** @hidden */
  32448. export interface IPhysicsEnginePlugin {
  32449. world: any;
  32450. name: string;
  32451. setGravity(gravity: Vector3): void;
  32452. setTimeStep(timeStep: number): void;
  32453. getTimeStep(): number;
  32454. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  32455. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  32456. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  32457. generatePhysicsBody(impostor: PhysicsImpostor): void;
  32458. removePhysicsBody(impostor: PhysicsImpostor): void;
  32459. generateJoint(joint: PhysicsImpostorJoint): void;
  32460. removeJoint(joint: PhysicsImpostorJoint): void;
  32461. isSupported(): boolean;
  32462. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  32463. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  32464. setLinearVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  32465. setAngularVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  32466. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  32467. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  32468. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  32469. getBodyMass(impostor: PhysicsImpostor): number;
  32470. getBodyFriction(impostor: PhysicsImpostor): number;
  32471. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  32472. getBodyRestitution(impostor: PhysicsImpostor): number;
  32473. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  32474. getBodyPressure?(impostor: PhysicsImpostor): number;
  32475. setBodyPressure?(impostor: PhysicsImpostor, pressure: number): void;
  32476. getBodyStiffness?(impostor: PhysicsImpostor): number;
  32477. setBodyStiffness?(impostor: PhysicsImpostor, stiffness: number): void;
  32478. getBodyVelocityIterations?(impostor: PhysicsImpostor): number;
  32479. setBodyVelocityIterations?(impostor: PhysicsImpostor, velocityIterations: number): void;
  32480. getBodyPositionIterations?(impostor: PhysicsImpostor): number;
  32481. setBodyPositionIterations?(impostor: PhysicsImpostor, positionIterations: number): void;
  32482. appendAnchor?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  32483. appendHook?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  32484. sleepBody(impostor: PhysicsImpostor): void;
  32485. wakeUpBody(impostor: PhysicsImpostor): void;
  32486. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  32487. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  32488. setMotor(joint: IMotorEnabledJoint, speed: number, maxForce?: number, motorIndex?: number): void;
  32489. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  32490. getRadius(impostor: PhysicsImpostor): number;
  32491. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  32492. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  32493. dispose(): void;
  32494. }
  32495. /**
  32496. * Interface used to define a physics engine
  32497. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  32498. */
  32499. export interface IPhysicsEngine {
  32500. /**
  32501. * Gets the gravity vector used by the simulation
  32502. */
  32503. gravity: Vector3;
  32504. /**
  32505. * Sets the gravity vector used by the simulation
  32506. * @param gravity defines the gravity vector to use
  32507. */
  32508. setGravity(gravity: Vector3): void;
  32509. /**
  32510. * Set the time step of the physics engine.
  32511. * Default is 1/60.
  32512. * To slow it down, enter 1/600 for example.
  32513. * To speed it up, 1/30
  32514. * @param newTimeStep the new timestep to apply to this world.
  32515. */
  32516. setTimeStep(newTimeStep: number): void;
  32517. /**
  32518. * Get the time step of the physics engine.
  32519. * @returns the current time step
  32520. */
  32521. getTimeStep(): number;
  32522. /**
  32523. * Set the sub time step of the physics engine.
  32524. * Default is 0 meaning there is no sub steps
  32525. * To increase physics resolution precision, set a small value (like 1 ms)
  32526. * @param subTimeStep defines the new sub timestep used for physics resolution.
  32527. */
  32528. setSubTimeStep(subTimeStep: number): void;
  32529. /**
  32530. * Get the sub time step of the physics engine.
  32531. * @returns the current sub time step
  32532. */
  32533. getSubTimeStep(): number;
  32534. /**
  32535. * Release all resources
  32536. */
  32537. dispose(): void;
  32538. /**
  32539. * Gets the name of the current physics plugin
  32540. * @returns the name of the plugin
  32541. */
  32542. getPhysicsPluginName(): string;
  32543. /**
  32544. * Adding a new impostor for the impostor tracking.
  32545. * This will be done by the impostor itself.
  32546. * @param impostor the impostor to add
  32547. */
  32548. addImpostor(impostor: PhysicsImpostor): void;
  32549. /**
  32550. * Remove an impostor from the engine.
  32551. * This impostor and its mesh will not longer be updated by the physics engine.
  32552. * @param impostor the impostor to remove
  32553. */
  32554. removeImpostor(impostor: PhysicsImpostor): void;
  32555. /**
  32556. * Add a joint to the physics engine
  32557. * @param mainImpostor defines the main impostor to which the joint is added.
  32558. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  32559. * @param joint defines the joint that will connect both impostors.
  32560. */
  32561. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  32562. /**
  32563. * Removes a joint from the simulation
  32564. * @param mainImpostor defines the impostor used with the joint
  32565. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  32566. * @param joint defines the joint to remove
  32567. */
  32568. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  32569. /**
  32570. * Gets the current plugin used to run the simulation
  32571. * @returns current plugin
  32572. */
  32573. getPhysicsPlugin(): IPhysicsEnginePlugin;
  32574. /**
  32575. * Gets the list of physic impostors
  32576. * @returns an array of PhysicsImpostor
  32577. */
  32578. getImpostors(): Array<PhysicsImpostor>;
  32579. /**
  32580. * Gets the impostor for a physics enabled object
  32581. * @param object defines the object impersonated by the impostor
  32582. * @returns the PhysicsImpostor or null if not found
  32583. */
  32584. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  32585. /**
  32586. * Gets the impostor for a physics body object
  32587. * @param body defines physics body used by the impostor
  32588. * @returns the PhysicsImpostor or null if not found
  32589. */
  32590. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  32591. /**
  32592. * Does a raycast in the physics world
  32593. * @param from when should the ray start?
  32594. * @param to when should the ray end?
  32595. * @returns PhysicsRaycastResult
  32596. */
  32597. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  32598. /**
  32599. * Called by the scene. No need to call it.
  32600. * @param delta defines the timespan between frames
  32601. */
  32602. _step(delta: number): void;
  32603. }
  32604. }
  32605. declare module BABYLON {
  32606. /**
  32607. * The interface for the physics imposter parameters
  32608. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  32609. */
  32610. export interface PhysicsImpostorParameters {
  32611. /**
  32612. * The mass of the physics imposter
  32613. */
  32614. mass: number;
  32615. /**
  32616. * The friction of the physics imposter
  32617. */
  32618. friction?: number;
  32619. /**
  32620. * The coefficient of restitution of the physics imposter
  32621. */
  32622. restitution?: number;
  32623. /**
  32624. * The native options of the physics imposter
  32625. */
  32626. nativeOptions?: any;
  32627. /**
  32628. * Specifies if the parent should be ignored
  32629. */
  32630. ignoreParent?: boolean;
  32631. /**
  32632. * Specifies if bi-directional transformations should be disabled
  32633. */
  32634. disableBidirectionalTransformation?: boolean;
  32635. /**
  32636. * The pressure inside the physics imposter, soft object only
  32637. */
  32638. pressure?: number;
  32639. /**
  32640. * The stiffness the physics imposter, soft object only
  32641. */
  32642. stiffness?: number;
  32643. /**
  32644. * The number of iterations used in maintaining consistent vertex velocities, soft object only
  32645. */
  32646. velocityIterations?: number;
  32647. /**
  32648. * The number of iterations used in maintaining consistent vertex positions, soft object only
  32649. */
  32650. positionIterations?: number;
  32651. /**
  32652. * The number used to fix points on a cloth (0, 1, 2, 4, 8) or rope (0, 1, 2) only
  32653. * 0 None, 1, back left or top, 2, back right or bottom, 4, front left, 8, front right
  32654. * Add to fix multiple points
  32655. */
  32656. fixedPoints?: number;
  32657. /**
  32658. * The collision margin around a soft object
  32659. */
  32660. margin?: number;
  32661. /**
  32662. * The collision margin around a soft object
  32663. */
  32664. damping?: number;
  32665. /**
  32666. * The path for a rope based on an extrusion
  32667. */
  32668. path?: any;
  32669. /**
  32670. * The shape of an extrusion used for a rope based on an extrusion
  32671. */
  32672. shape?: any;
  32673. }
  32674. /**
  32675. * Interface for a physics-enabled object
  32676. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  32677. */
  32678. export interface IPhysicsEnabledObject {
  32679. /**
  32680. * The position of the physics-enabled object
  32681. */
  32682. position: Vector3;
  32683. /**
  32684. * The rotation of the physics-enabled object
  32685. */
  32686. rotationQuaternion: Nullable<Quaternion>;
  32687. /**
  32688. * The scale of the physics-enabled object
  32689. */
  32690. scaling: Vector3;
  32691. /**
  32692. * The rotation of the physics-enabled object
  32693. */
  32694. rotation?: Vector3;
  32695. /**
  32696. * The parent of the physics-enabled object
  32697. */
  32698. parent?: any;
  32699. /**
  32700. * The bounding info of the physics-enabled object
  32701. * @returns The bounding info of the physics-enabled object
  32702. */
  32703. getBoundingInfo(): BoundingInfo;
  32704. /**
  32705. * Computes the world matrix
  32706. * @param force Specifies if the world matrix should be computed by force
  32707. * @returns A world matrix
  32708. */
  32709. computeWorldMatrix(force: boolean): Matrix;
  32710. /**
  32711. * Gets the world matrix
  32712. * @returns A world matrix
  32713. */
  32714. getWorldMatrix?(): Matrix;
  32715. /**
  32716. * Gets the child meshes
  32717. * @param directDescendantsOnly Specifies if only direct-descendants should be obtained
  32718. * @returns An array of abstract meshes
  32719. */
  32720. getChildMeshes?(directDescendantsOnly?: boolean): Array<AbstractMesh>;
  32721. /**
  32722. * Gets the vertex data
  32723. * @param kind The type of vertex data
  32724. * @returns A nullable array of numbers, or a float32 array
  32725. */
  32726. getVerticesData(kind: string): Nullable<Array<number> | Float32Array>;
  32727. /**
  32728. * Gets the indices from the mesh
  32729. * @returns A nullable array of index arrays
  32730. */
  32731. getIndices?(): Nullable<IndicesArray>;
  32732. /**
  32733. * Gets the scene from the mesh
  32734. * @returns the indices array or null
  32735. */
  32736. getScene?(): Scene;
  32737. /**
  32738. * Gets the absolute position from the mesh
  32739. * @returns the absolute position
  32740. */
  32741. getAbsolutePosition(): Vector3;
  32742. /**
  32743. * Gets the absolute pivot point from the mesh
  32744. * @returns the absolute pivot point
  32745. */
  32746. getAbsolutePivotPoint(): Vector3;
  32747. /**
  32748. * Rotates the mesh
  32749. * @param axis The axis of rotation
  32750. * @param amount The amount of rotation
  32751. * @param space The space of the rotation
  32752. * @returns The rotation transform node
  32753. */
  32754. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  32755. /**
  32756. * Translates the mesh
  32757. * @param axis The axis of translation
  32758. * @param distance The distance of translation
  32759. * @param space The space of the translation
  32760. * @returns The transform node
  32761. */
  32762. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  32763. /**
  32764. * Sets the absolute position of the mesh
  32765. * @param absolutePosition The absolute position of the mesh
  32766. * @returns The transform node
  32767. */
  32768. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  32769. /**
  32770. * Gets the class name of the mesh
  32771. * @returns The class name
  32772. */
  32773. getClassName(): string;
  32774. }
  32775. /**
  32776. * Represents a physics imposter
  32777. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  32778. */
  32779. export class PhysicsImpostor {
  32780. /**
  32781. * The physics-enabled object used as the physics imposter
  32782. */
  32783. object: IPhysicsEnabledObject;
  32784. /**
  32785. * The type of the physics imposter
  32786. */
  32787. type: number;
  32788. private _options;
  32789. private _scene?;
  32790. /**
  32791. * The default object size of the imposter
  32792. */
  32793. static DEFAULT_OBJECT_SIZE: Vector3;
  32794. /**
  32795. * The identity quaternion of the imposter
  32796. */
  32797. static IDENTITY_QUATERNION: Quaternion;
  32798. /** @hidden */
  32799. _pluginData: any;
  32800. private _physicsEngine;
  32801. private _physicsBody;
  32802. private _bodyUpdateRequired;
  32803. private _onBeforePhysicsStepCallbacks;
  32804. private _onAfterPhysicsStepCallbacks;
  32805. /** @hidden */
  32806. _onPhysicsCollideCallbacks: Array<{
  32807. callback: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor, point: Nullable<Vector3>) => void;
  32808. otherImpostors: Array<PhysicsImpostor>;
  32809. }>;
  32810. private _deltaPosition;
  32811. private _deltaRotation;
  32812. private _deltaRotationConjugated;
  32813. /** @hidden */
  32814. _isFromLine: boolean;
  32815. private _parent;
  32816. private _isDisposed;
  32817. private static _tmpVecs;
  32818. private static _tmpQuat;
  32819. /**
  32820. * Specifies if the physics imposter is disposed
  32821. */
  32822. get isDisposed(): boolean;
  32823. /**
  32824. * Gets the mass of the physics imposter
  32825. */
  32826. get mass(): number;
  32827. set mass(value: number);
  32828. /**
  32829. * Gets the coefficient of friction
  32830. */
  32831. get friction(): number;
  32832. /**
  32833. * Sets the coefficient of friction
  32834. */
  32835. set friction(value: number);
  32836. /**
  32837. * Gets the coefficient of restitution
  32838. */
  32839. get restitution(): number;
  32840. /**
  32841. * Sets the coefficient of restitution
  32842. */
  32843. set restitution(value: number);
  32844. /**
  32845. * Gets the pressure of a soft body; only supported by the AmmoJSPlugin
  32846. */
  32847. get pressure(): number;
  32848. /**
  32849. * Sets the pressure of a soft body; only supported by the AmmoJSPlugin
  32850. */
  32851. set pressure(value: number);
  32852. /**
  32853. * Gets the stiffness of a soft body; only supported by the AmmoJSPlugin
  32854. */
  32855. get stiffness(): number;
  32856. /**
  32857. * Sets the stiffness of a soft body; only supported by the AmmoJSPlugin
  32858. */
  32859. set stiffness(value: number);
  32860. /**
  32861. * Gets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  32862. */
  32863. get velocityIterations(): number;
  32864. /**
  32865. * Sets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  32866. */
  32867. set velocityIterations(value: number);
  32868. /**
  32869. * Gets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  32870. */
  32871. get positionIterations(): number;
  32872. /**
  32873. * Sets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  32874. */
  32875. set positionIterations(value: number);
  32876. /**
  32877. * The unique id of the physics imposter
  32878. * set by the physics engine when adding this impostor to the array
  32879. */
  32880. uniqueId: number;
  32881. /**
  32882. * @hidden
  32883. */
  32884. soft: boolean;
  32885. /**
  32886. * @hidden
  32887. */
  32888. segments: number;
  32889. private _joints;
  32890. /**
  32891. * Initializes the physics imposter
  32892. * @param object The physics-enabled object used as the physics imposter
  32893. * @param type The type of the physics imposter
  32894. * @param _options The options for the physics imposter
  32895. * @param _scene The Babylon scene
  32896. */
  32897. constructor(
  32898. /**
  32899. * The physics-enabled object used as the physics imposter
  32900. */
  32901. object: IPhysicsEnabledObject,
  32902. /**
  32903. * The type of the physics imposter
  32904. */
  32905. type: number, _options?: PhysicsImpostorParameters, _scene?: Scene | undefined);
  32906. /**
  32907. * This function will completely initialize this impostor.
  32908. * It will create a new body - but only if this mesh has no parent.
  32909. * If it has, this impostor will not be used other than to define the impostor
  32910. * of the child mesh.
  32911. * @hidden
  32912. */
  32913. _init(): void;
  32914. private _getPhysicsParent;
  32915. /**
  32916. * Should a new body be generated.
  32917. * @returns boolean specifying if body initialization is required
  32918. */
  32919. isBodyInitRequired(): boolean;
  32920. /**
  32921. * Sets the updated scaling
  32922. * @param updated Specifies if the scaling is updated
  32923. */
  32924. setScalingUpdated(): void;
  32925. /**
  32926. * Force a regeneration of this or the parent's impostor's body.
  32927. * Use under cautious - This will remove all joints already implemented.
  32928. */
  32929. forceUpdate(): void;
  32930. /**
  32931. * Gets the body that holds this impostor. Either its own, or its parent.
  32932. */
  32933. get physicsBody(): any;
  32934. /**
  32935. * Get the parent of the physics imposter
  32936. * @returns Physics imposter or null
  32937. */
  32938. get parent(): Nullable<PhysicsImpostor>;
  32939. /**
  32940. * Sets the parent of the physics imposter
  32941. */
  32942. set parent(value: Nullable<PhysicsImpostor>);
  32943. /**
  32944. * Set the physics body. Used mainly by the physics engine/plugin
  32945. */
  32946. set physicsBody(physicsBody: any);
  32947. /**
  32948. * Resets the update flags
  32949. */
  32950. resetUpdateFlags(): void;
  32951. /**
  32952. * Gets the object extend size
  32953. * @returns the object extend size
  32954. */
  32955. getObjectExtendSize(): Vector3;
  32956. /**
  32957. * Gets the object center
  32958. * @returns The object center
  32959. */
  32960. getObjectCenter(): Vector3;
  32961. /**
  32962. * Get a specific parameter from the options parameters
  32963. * @param paramName The object parameter name
  32964. * @returns The object parameter
  32965. */
  32966. getParam(paramName: string): any;
  32967. /**
  32968. * Sets a specific parameter in the options given to the physics plugin
  32969. * @param paramName The parameter name
  32970. * @param value The value of the parameter
  32971. */
  32972. setParam(paramName: string, value: number): void;
  32973. /**
  32974. * Specifically change the body's mass option. Won't recreate the physics body object
  32975. * @param mass The mass of the physics imposter
  32976. */
  32977. setMass(mass: number): void;
  32978. /**
  32979. * Gets the linear velocity
  32980. * @returns linear velocity or null
  32981. */
  32982. getLinearVelocity(): Nullable<Vector3>;
  32983. /**
  32984. * Sets the linear velocity
  32985. * @param velocity linear velocity or null
  32986. */
  32987. setLinearVelocity(velocity: Nullable<Vector3>): void;
  32988. /**
  32989. * Gets the angular velocity
  32990. * @returns angular velocity or null
  32991. */
  32992. getAngularVelocity(): Nullable<Vector3>;
  32993. /**
  32994. * Sets the angular velocity
  32995. * @param velocity The velocity or null
  32996. */
  32997. setAngularVelocity(velocity: Nullable<Vector3>): void;
  32998. /**
  32999. * Execute a function with the physics plugin native code
  33000. * Provide a function the will have two variables - the world object and the physics body object
  33001. * @param func The function to execute with the physics plugin native code
  33002. */
  33003. executeNativeFunction(func: (world: any, physicsBody: any) => void): void;
  33004. /**
  33005. * Register a function that will be executed before the physics world is stepping forward
  33006. * @param func The function to execute before the physics world is stepped forward
  33007. */
  33008. registerBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  33009. /**
  33010. * Unregister a function that will be executed before the physics world is stepping forward
  33011. * @param func The function to execute before the physics world is stepped forward
  33012. */
  33013. unregisterBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  33014. /**
  33015. * Register a function that will be executed after the physics step
  33016. * @param func The function to execute after physics step
  33017. */
  33018. registerAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  33019. /**
  33020. * Unregisters a function that will be executed after the physics step
  33021. * @param func The function to execute after physics step
  33022. */
  33023. unregisterAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  33024. /**
  33025. * register a function that will be executed when this impostor collides against a different body
  33026. * @param collideAgainst Physics imposter, or array of physics imposters to collide against
  33027. * @param func Callback that is executed on collision
  33028. */
  33029. registerOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void): void;
  33030. /**
  33031. * Unregisters the physics imposter on contact
  33032. * @param collideAgainst The physics object to collide against
  33033. * @param func Callback to execute on collision
  33034. */
  33035. unregisterOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor | Array<PhysicsImpostor>) => void): void;
  33036. private _tmpQuat;
  33037. private _tmpQuat2;
  33038. /**
  33039. * Get the parent rotation
  33040. * @returns The parent rotation
  33041. */
  33042. getParentsRotation(): Quaternion;
  33043. /**
  33044. * this function is executed by the physics engine.
  33045. */
  33046. beforeStep: () => void;
  33047. /**
  33048. * this function is executed by the physics engine
  33049. */
  33050. afterStep: () => void;
  33051. /**
  33052. * Legacy collision detection event support
  33053. */
  33054. onCollideEvent: Nullable<(collider: PhysicsImpostor, collidedWith: PhysicsImpostor) => void>;
  33055. /**
  33056. * event and body object due to cannon's event-based architecture.
  33057. */
  33058. onCollide: (e: {
  33059. body: any;
  33060. point: Nullable<Vector3>;
  33061. }) => void;
  33062. /**
  33063. * Apply a force
  33064. * @param force The force to apply
  33065. * @param contactPoint The contact point for the force
  33066. * @returns The physics imposter
  33067. */
  33068. applyForce(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  33069. /**
  33070. * Apply an impulse
  33071. * @param force The impulse force
  33072. * @param contactPoint The contact point for the impulse force
  33073. * @returns The physics imposter
  33074. */
  33075. applyImpulse(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  33076. /**
  33077. * A help function to create a joint
  33078. * @param otherImpostor A physics imposter used to create a joint
  33079. * @param jointType The type of joint
  33080. * @param jointData The data for the joint
  33081. * @returns The physics imposter
  33082. */
  33083. createJoint(otherImpostor: PhysicsImpostor, jointType: number, jointData: PhysicsJointData): PhysicsImpostor;
  33084. /**
  33085. * Add a joint to this impostor with a different impostor
  33086. * @param otherImpostor A physics imposter used to add a joint
  33087. * @param joint The joint to add
  33088. * @returns The physics imposter
  33089. */
  33090. addJoint(otherImpostor: PhysicsImpostor, joint: PhysicsJoint): PhysicsImpostor;
  33091. /**
  33092. * Add an anchor to a cloth impostor
  33093. * @param otherImpostor rigid impostor to anchor to
  33094. * @param width ratio across width from 0 to 1
  33095. * @param height ratio up height from 0 to 1
  33096. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little stretch
  33097. * @param noCollisionBetweenLinkedBodies when true collisions between cloth impostor and anchor are ignored; default false
  33098. * @returns impostor the soft imposter
  33099. */
  33100. addAnchor(otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  33101. /**
  33102. * Add a hook to a rope impostor
  33103. * @param otherImpostor rigid impostor to anchor to
  33104. * @param length ratio across rope from 0 to 1
  33105. * @param influence the elasticity between rope impostor and anchor from 0, very stretchy to 1, little stretch
  33106. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  33107. * @returns impostor the rope imposter
  33108. */
  33109. addHook(otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  33110. /**
  33111. * Will keep this body still, in a sleep mode.
  33112. * @returns the physics imposter
  33113. */
  33114. sleep(): PhysicsImpostor;
  33115. /**
  33116. * Wake the body up.
  33117. * @returns The physics imposter
  33118. */
  33119. wakeUp(): PhysicsImpostor;
  33120. /**
  33121. * Clones the physics imposter
  33122. * @param newObject The physics imposter clones to this physics-enabled object
  33123. * @returns A nullable physics imposter
  33124. */
  33125. clone(newObject: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  33126. /**
  33127. * Disposes the physics imposter
  33128. */
  33129. dispose(): void;
  33130. /**
  33131. * Sets the delta position
  33132. * @param position The delta position amount
  33133. */
  33134. setDeltaPosition(position: Vector3): void;
  33135. /**
  33136. * Sets the delta rotation
  33137. * @param rotation The delta rotation amount
  33138. */
  33139. setDeltaRotation(rotation: Quaternion): void;
  33140. /**
  33141. * Gets the box size of the physics imposter and stores the result in the input parameter
  33142. * @param result Stores the box size
  33143. * @returns The physics imposter
  33144. */
  33145. getBoxSizeToRef(result: Vector3): PhysicsImpostor;
  33146. /**
  33147. * Gets the radius of the physics imposter
  33148. * @returns Radius of the physics imposter
  33149. */
  33150. getRadius(): number;
  33151. /**
  33152. * Sync a bone with this impostor
  33153. * @param bone The bone to sync to the impostor.
  33154. * @param boneMesh The mesh that the bone is influencing.
  33155. * @param jointPivot The pivot of the joint / bone in local space.
  33156. * @param distToJoint Optional distance from the impostor to the joint.
  33157. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  33158. */
  33159. syncBoneWithImpostor(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion): void;
  33160. /**
  33161. * Sync impostor to a bone
  33162. * @param bone The bone that the impostor will be synced to.
  33163. * @param boneMesh The mesh that the bone is influencing.
  33164. * @param jointPivot The pivot of the joint / bone in local space.
  33165. * @param distToJoint Optional distance from the impostor to the joint.
  33166. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  33167. * @param boneAxis Optional vector3 axis the bone is aligned with
  33168. */
  33169. syncImpostorWithBone(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion, boneAxis?: Vector3): void;
  33170. /**
  33171. * No-Imposter type
  33172. */
  33173. static NoImpostor: number;
  33174. /**
  33175. * Sphere-Imposter type
  33176. */
  33177. static SphereImpostor: number;
  33178. /**
  33179. * Box-Imposter type
  33180. */
  33181. static BoxImpostor: number;
  33182. /**
  33183. * Plane-Imposter type
  33184. */
  33185. static PlaneImpostor: number;
  33186. /**
  33187. * Mesh-imposter type
  33188. */
  33189. static MeshImpostor: number;
  33190. /**
  33191. * Capsule-Impostor type (Ammo.js plugin only)
  33192. */
  33193. static CapsuleImpostor: number;
  33194. /**
  33195. * Cylinder-Imposter type
  33196. */
  33197. static CylinderImpostor: number;
  33198. /**
  33199. * Particle-Imposter type
  33200. */
  33201. static ParticleImpostor: number;
  33202. /**
  33203. * Heightmap-Imposter type
  33204. */
  33205. static HeightmapImpostor: number;
  33206. /**
  33207. * ConvexHull-Impostor type (Ammo.js plugin only)
  33208. */
  33209. static ConvexHullImpostor: number;
  33210. /**
  33211. * Custom-Imposter type (Ammo.js plugin only)
  33212. */
  33213. static CustomImpostor: number;
  33214. /**
  33215. * Rope-Imposter type
  33216. */
  33217. static RopeImpostor: number;
  33218. /**
  33219. * Cloth-Imposter type
  33220. */
  33221. static ClothImpostor: number;
  33222. /**
  33223. * Softbody-Imposter type
  33224. */
  33225. static SoftbodyImpostor: number;
  33226. }
  33227. }
  33228. declare module BABYLON {
  33229. /**
  33230. * @hidden
  33231. **/
  33232. export class _CreationDataStorage {
  33233. closePath?: boolean;
  33234. closeArray?: boolean;
  33235. idx: number[];
  33236. dashSize: number;
  33237. gapSize: number;
  33238. path3D: Path3D;
  33239. pathArray: Vector3[][];
  33240. arc: number;
  33241. radius: number;
  33242. cap: number;
  33243. tessellation: number;
  33244. }
  33245. /**
  33246. * @hidden
  33247. **/
  33248. class _InstanceDataStorage {
  33249. visibleInstances: any;
  33250. batchCache: _InstancesBatch;
  33251. instancesBufferSize: number;
  33252. instancesBuffer: Nullable<Buffer>;
  33253. instancesData: Float32Array;
  33254. overridenInstanceCount: number;
  33255. isFrozen: boolean;
  33256. previousBatch: Nullable<_InstancesBatch>;
  33257. hardwareInstancedRendering: boolean;
  33258. sideOrientation: number;
  33259. manualUpdate: boolean;
  33260. previousRenderId: number;
  33261. }
  33262. /**
  33263. * @hidden
  33264. **/
  33265. export class _InstancesBatch {
  33266. mustReturn: boolean;
  33267. visibleInstances: Nullable<InstancedMesh[]>[];
  33268. renderSelf: boolean[];
  33269. hardwareInstancedRendering: boolean[];
  33270. }
  33271. /**
  33272. * @hidden
  33273. **/
  33274. class _ThinInstanceDataStorage {
  33275. instancesCount: number;
  33276. matrixBuffer: Nullable<Buffer>;
  33277. matrixBufferSize: number;
  33278. matrixData: Nullable<Float32Array>;
  33279. boundingVectors: Array<Vector3>;
  33280. worldMatrices: Nullable<Matrix[]>;
  33281. }
  33282. /**
  33283. * Class used to represent renderable models
  33284. */
  33285. export class Mesh extends AbstractMesh implements IGetSetVerticesData {
  33286. /**
  33287. * Mesh side orientation : usually the external or front surface
  33288. */
  33289. static readonly FRONTSIDE: number;
  33290. /**
  33291. * Mesh side orientation : usually the internal or back surface
  33292. */
  33293. static readonly BACKSIDE: number;
  33294. /**
  33295. * Mesh side orientation : both internal and external or front and back surfaces
  33296. */
  33297. static readonly DOUBLESIDE: number;
  33298. /**
  33299. * Mesh side orientation : by default, `FRONTSIDE`
  33300. */
  33301. static readonly DEFAULTSIDE: number;
  33302. /**
  33303. * Mesh cap setting : no cap
  33304. */
  33305. static readonly NO_CAP: number;
  33306. /**
  33307. * Mesh cap setting : one cap at the beginning of the mesh
  33308. */
  33309. static readonly CAP_START: number;
  33310. /**
  33311. * Mesh cap setting : one cap at the end of the mesh
  33312. */
  33313. static readonly CAP_END: number;
  33314. /**
  33315. * Mesh cap setting : two caps, one at the beginning and one at the end of the mesh
  33316. */
  33317. static readonly CAP_ALL: number;
  33318. /**
  33319. * Mesh pattern setting : no flip or rotate
  33320. */
  33321. static readonly NO_FLIP: number;
  33322. /**
  33323. * Mesh pattern setting : flip (reflect in y axis) alternate tiles on each row or column
  33324. */
  33325. static readonly FLIP_TILE: number;
  33326. /**
  33327. * Mesh pattern setting : rotate (180degs) alternate tiles on each row or column
  33328. */
  33329. static readonly ROTATE_TILE: number;
  33330. /**
  33331. * Mesh pattern setting : flip (reflect in y axis) all tiles on alternate rows
  33332. */
  33333. static readonly FLIP_ROW: number;
  33334. /**
  33335. * Mesh pattern setting : rotate (180degs) all tiles on alternate rows
  33336. */
  33337. static readonly ROTATE_ROW: number;
  33338. /**
  33339. * Mesh pattern setting : flip and rotate alternate tiles on each row or column
  33340. */
  33341. static readonly FLIP_N_ROTATE_TILE: number;
  33342. /**
  33343. * Mesh pattern setting : rotate pattern and rotate
  33344. */
  33345. static readonly FLIP_N_ROTATE_ROW: number;
  33346. /**
  33347. * Mesh tile positioning : part tiles same on left/right or top/bottom
  33348. */
  33349. static readonly CENTER: number;
  33350. /**
  33351. * Mesh tile positioning : part tiles on left
  33352. */
  33353. static readonly LEFT: number;
  33354. /**
  33355. * Mesh tile positioning : part tiles on right
  33356. */
  33357. static readonly RIGHT: number;
  33358. /**
  33359. * Mesh tile positioning : part tiles on top
  33360. */
  33361. static readonly TOP: number;
  33362. /**
  33363. * Mesh tile positioning : part tiles on bottom
  33364. */
  33365. static readonly BOTTOM: number;
  33366. /**
  33367. * Gets the default side orientation.
  33368. * @param orientation the orientation to value to attempt to get
  33369. * @returns the default orientation
  33370. * @hidden
  33371. */
  33372. static _GetDefaultSideOrientation(orientation?: number): number;
  33373. private _internalMeshDataInfo;
  33374. get computeBonesUsingShaders(): boolean;
  33375. set computeBonesUsingShaders(value: boolean);
  33376. /**
  33377. * An event triggered before rendering the mesh
  33378. */
  33379. get onBeforeRenderObservable(): Observable<Mesh>;
  33380. /**
  33381. * An event triggered before binding the mesh
  33382. */
  33383. get onBeforeBindObservable(): Observable<Mesh>;
  33384. /**
  33385. * An event triggered after rendering the mesh
  33386. */
  33387. get onAfterRenderObservable(): Observable<Mesh>;
  33388. /**
  33389. * An event triggered before drawing the mesh
  33390. */
  33391. get onBeforeDrawObservable(): Observable<Mesh>;
  33392. private _onBeforeDrawObserver;
  33393. /**
  33394. * Sets a callback to call before drawing the mesh. It is recommended to use onBeforeDrawObservable instead
  33395. */
  33396. set onBeforeDraw(callback: () => void);
  33397. get hasInstances(): boolean;
  33398. get hasThinInstances(): boolean;
  33399. /**
  33400. * Gets the delay loading state of the mesh (when delay loading is turned on)
  33401. * @see https://doc.babylonjs.com/how_to/using_the_incremental_loading_system
  33402. */
  33403. delayLoadState: number;
  33404. /**
  33405. * Gets the list of instances created from this mesh
  33406. * it is not supposed to be modified manually.
  33407. * Note also that the order of the InstancedMesh wihin the array is not significant and might change.
  33408. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  33409. */
  33410. instances: InstancedMesh[];
  33411. /**
  33412. * Gets the file containing delay loading data for this mesh
  33413. */
  33414. delayLoadingFile: string;
  33415. /** @hidden */
  33416. _binaryInfo: any;
  33417. /**
  33418. * User defined function used to change how LOD level selection is done
  33419. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  33420. */
  33421. onLODLevelSelection: (distance: number, mesh: Mesh, selectedLevel: Nullable<Mesh>) => void;
  33422. /**
  33423. * Gets or sets the morph target manager
  33424. * @see https://doc.babylonjs.com/how_to/how_to_use_morphtargets
  33425. */
  33426. get morphTargetManager(): Nullable<MorphTargetManager>;
  33427. set morphTargetManager(value: Nullable<MorphTargetManager>);
  33428. /** @hidden */
  33429. _creationDataStorage: Nullable<_CreationDataStorage>;
  33430. /** @hidden */
  33431. _geometry: Nullable<Geometry>;
  33432. /** @hidden */
  33433. _delayInfo: Array<string>;
  33434. /** @hidden */
  33435. _delayLoadingFunction: (any: any, mesh: Mesh) => void;
  33436. /** @hidden */
  33437. _instanceDataStorage: _InstanceDataStorage;
  33438. /** @hidden */
  33439. _thinInstanceDataStorage: _ThinInstanceDataStorage;
  33440. private _effectiveMaterial;
  33441. /** @hidden */
  33442. _shouldGenerateFlatShading: boolean;
  33443. /** @hidden */
  33444. _originalBuilderSideOrientation: number;
  33445. /**
  33446. * Use this property to change the original side orientation defined at construction time
  33447. */
  33448. overrideMaterialSideOrientation: Nullable<number>;
  33449. /**
  33450. * Gets or sets a boolean indicating whether to render ignoring the active camera's max z setting. (false by default)
  33451. * Note this will reduce performance when set to true.
  33452. */
  33453. ignoreCameraMaxZ: boolean;
  33454. /**
  33455. * Gets the source mesh (the one used to clone this one from)
  33456. */
  33457. get source(): Nullable<Mesh>;
  33458. /**
  33459. * Gets the list of clones of this mesh
  33460. * The scene must have been constructed with useClonedMeshMap=true for this to work!
  33461. * Note that useClonedMeshMap=true is the default setting
  33462. */
  33463. get cloneMeshMap(): Nullable<{
  33464. [id: string]: Mesh | undefined;
  33465. }>;
  33466. /**
  33467. * Gets or sets a boolean indicating that this mesh does not use index buffer
  33468. */
  33469. get isUnIndexed(): boolean;
  33470. set isUnIndexed(value: boolean);
  33471. /** Gets the array buffer used to store the instanced buffer used for instances' world matrices */
  33472. get worldMatrixInstancedBuffer(): Float32Array;
  33473. /** Gets or sets a boolean indicating that the update of the instance buffer of the world matrices is manual */
  33474. get manualUpdateOfWorldMatrixInstancedBuffer(): boolean;
  33475. set manualUpdateOfWorldMatrixInstancedBuffer(value: boolean);
  33476. /**
  33477. * @constructor
  33478. * @param name The value used by scene.getMeshByName() to do a lookup.
  33479. * @param scene The scene to add this mesh to.
  33480. * @param parent The parent of this mesh, if it has one
  33481. * @param source An optional Mesh from which geometry is shared, cloned.
  33482. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  33483. * When false, achieved by calling a clone(), also passing False.
  33484. * This will make creation of children, recursive.
  33485. * @param clonePhysicsImpostor When cloning, include cloning mesh physics impostor, default True.
  33486. */
  33487. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<Mesh>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean);
  33488. instantiateHierarchy(newParent?: Nullable<TransformNode>, options?: {
  33489. doNotInstantiate: boolean;
  33490. }, onNewNodeCreated?: (source: TransformNode, clone: TransformNode) => void): Nullable<TransformNode>;
  33491. /**
  33492. * Gets the class name
  33493. * @returns the string "Mesh".
  33494. */
  33495. getClassName(): string;
  33496. /** @hidden */
  33497. get _isMesh(): boolean;
  33498. /**
  33499. * Returns a description of this mesh
  33500. * @param fullDetails define if full details about this mesh must be used
  33501. * @returns a descriptive string representing this mesh
  33502. */
  33503. toString(fullDetails?: boolean): string;
  33504. /** @hidden */
  33505. _unBindEffect(): void;
  33506. /**
  33507. * Gets a boolean indicating if this mesh has LOD
  33508. */
  33509. get hasLODLevels(): boolean;
  33510. /**
  33511. * Gets the list of MeshLODLevel associated with the current mesh
  33512. * @returns an array of MeshLODLevel
  33513. */
  33514. getLODLevels(): MeshLODLevel[];
  33515. private _sortLODLevels;
  33516. /**
  33517. * Add a mesh as LOD level triggered at the given distance.
  33518. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  33519. * @param distance The distance from the center of the object to show this level
  33520. * @param mesh The mesh to be added as LOD level (can be null)
  33521. * @return This mesh (for chaining)
  33522. */
  33523. addLODLevel(distance: number, mesh: Nullable<Mesh>): Mesh;
  33524. /**
  33525. * Returns the LOD level mesh at the passed distance or null if not found.
  33526. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  33527. * @param distance The distance from the center of the object to show this level
  33528. * @returns a Mesh or `null`
  33529. */
  33530. getLODLevelAtDistance(distance: number): Nullable<Mesh>;
  33531. /**
  33532. * Remove a mesh from the LOD array
  33533. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  33534. * @param mesh defines the mesh to be removed
  33535. * @return This mesh (for chaining)
  33536. */
  33537. removeLODLevel(mesh: Mesh): Mesh;
  33538. /**
  33539. * Returns the registered LOD mesh distant from the parameter `camera` position if any, else returns the current mesh.
  33540. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  33541. * @param camera defines the camera to use to compute distance
  33542. * @param boundingSphere defines a custom bounding sphere to use instead of the one from this mesh
  33543. * @return This mesh (for chaining)
  33544. */
  33545. getLOD(camera: Camera, boundingSphere?: BoundingSphere): Nullable<AbstractMesh>;
  33546. /**
  33547. * Gets the mesh internal Geometry object
  33548. */
  33549. get geometry(): Nullable<Geometry>;
  33550. /**
  33551. * Returns the total number of vertices within the mesh geometry or zero if the mesh has no geometry.
  33552. * @returns the total number of vertices
  33553. */
  33554. getTotalVertices(): number;
  33555. /**
  33556. * Returns the content of an associated vertex buffer
  33557. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  33558. * - VertexBuffer.PositionKind
  33559. * - VertexBuffer.UVKind
  33560. * - VertexBuffer.UV2Kind
  33561. * - VertexBuffer.UV3Kind
  33562. * - VertexBuffer.UV4Kind
  33563. * - VertexBuffer.UV5Kind
  33564. * - VertexBuffer.UV6Kind
  33565. * - VertexBuffer.ColorKind
  33566. * - VertexBuffer.MatricesIndicesKind
  33567. * - VertexBuffer.MatricesIndicesExtraKind
  33568. * - VertexBuffer.MatricesWeightsKind
  33569. * - VertexBuffer.MatricesWeightsExtraKind
  33570. * @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
  33571. * @param forceCopy defines a boolean forcing the copy of the buffer no matter what the value of copyWhenShared is
  33572. * @returns a FloatArray or null if the mesh has no geometry or no vertex buffer for this kind.
  33573. */
  33574. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  33575. /**
  33576. * Returns the mesh VertexBuffer object from the requested `kind`
  33577. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  33578. * - VertexBuffer.PositionKind
  33579. * - VertexBuffer.NormalKind
  33580. * - VertexBuffer.UVKind
  33581. * - VertexBuffer.UV2Kind
  33582. * - VertexBuffer.UV3Kind
  33583. * - VertexBuffer.UV4Kind
  33584. * - VertexBuffer.UV5Kind
  33585. * - VertexBuffer.UV6Kind
  33586. * - VertexBuffer.ColorKind
  33587. * - VertexBuffer.MatricesIndicesKind
  33588. * - VertexBuffer.MatricesIndicesExtraKind
  33589. * - VertexBuffer.MatricesWeightsKind
  33590. * - VertexBuffer.MatricesWeightsExtraKind
  33591. * @returns a FloatArray or null if the mesh has no vertex buffer for this kind.
  33592. */
  33593. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  33594. /**
  33595. * Tests if a specific vertex buffer is associated with this mesh
  33596. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  33597. * - VertexBuffer.PositionKind
  33598. * - VertexBuffer.NormalKind
  33599. * - VertexBuffer.UVKind
  33600. * - VertexBuffer.UV2Kind
  33601. * - VertexBuffer.UV3Kind
  33602. * - VertexBuffer.UV4Kind
  33603. * - VertexBuffer.UV5Kind
  33604. * - VertexBuffer.UV6Kind
  33605. * - VertexBuffer.ColorKind
  33606. * - VertexBuffer.MatricesIndicesKind
  33607. * - VertexBuffer.MatricesIndicesExtraKind
  33608. * - VertexBuffer.MatricesWeightsKind
  33609. * - VertexBuffer.MatricesWeightsExtraKind
  33610. * @returns a boolean
  33611. */
  33612. isVerticesDataPresent(kind: string): boolean;
  33613. /**
  33614. * Returns a boolean defining if the vertex data for the requested `kind` is updatable.
  33615. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  33616. * - VertexBuffer.PositionKind
  33617. * - VertexBuffer.UVKind
  33618. * - VertexBuffer.UV2Kind
  33619. * - VertexBuffer.UV3Kind
  33620. * - VertexBuffer.UV4Kind
  33621. * - VertexBuffer.UV5Kind
  33622. * - VertexBuffer.UV6Kind
  33623. * - VertexBuffer.ColorKind
  33624. * - VertexBuffer.MatricesIndicesKind
  33625. * - VertexBuffer.MatricesIndicesExtraKind
  33626. * - VertexBuffer.MatricesWeightsKind
  33627. * - VertexBuffer.MatricesWeightsExtraKind
  33628. * @returns a boolean
  33629. */
  33630. isVertexBufferUpdatable(kind: string): boolean;
  33631. /**
  33632. * Returns a string which contains the list of existing `kinds` of Vertex Data associated with this mesh.
  33633. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  33634. * - VertexBuffer.PositionKind
  33635. * - VertexBuffer.NormalKind
  33636. * - VertexBuffer.UVKind
  33637. * - VertexBuffer.UV2Kind
  33638. * - VertexBuffer.UV3Kind
  33639. * - VertexBuffer.UV4Kind
  33640. * - VertexBuffer.UV5Kind
  33641. * - VertexBuffer.UV6Kind
  33642. * - VertexBuffer.ColorKind
  33643. * - VertexBuffer.MatricesIndicesKind
  33644. * - VertexBuffer.MatricesIndicesExtraKind
  33645. * - VertexBuffer.MatricesWeightsKind
  33646. * - VertexBuffer.MatricesWeightsExtraKind
  33647. * @returns an array of strings
  33648. */
  33649. getVerticesDataKinds(): string[];
  33650. /**
  33651. * Returns a positive integer : the total number of indices in this mesh geometry.
  33652. * @returns the numner of indices or zero if the mesh has no geometry.
  33653. */
  33654. getTotalIndices(): number;
  33655. /**
  33656. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  33657. * @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.
  33658. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  33659. * @returns the indices array or an empty array if the mesh has no geometry
  33660. */
  33661. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  33662. get isBlocked(): boolean;
  33663. /**
  33664. * Determine if the current mesh is ready to be rendered
  33665. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  33666. * @param forceInstanceSupport will check if the mesh will be ready when used with instances (false by default)
  33667. * @returns true if all associated assets are ready (material, textures, shaders)
  33668. */
  33669. isReady(completeCheck?: boolean, forceInstanceSupport?: boolean): boolean;
  33670. /**
  33671. * 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.
  33672. */
  33673. get areNormalsFrozen(): boolean;
  33674. /**
  33675. * 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.
  33676. * @returns the current mesh
  33677. */
  33678. freezeNormals(): Mesh;
  33679. /**
  33680. * 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
  33681. * @returns the current mesh
  33682. */
  33683. unfreezeNormals(): Mesh;
  33684. /**
  33685. * Sets a value overriding the instance count. Only applicable when custom instanced InterleavedVertexBuffer are used rather than InstancedMeshs
  33686. */
  33687. set overridenInstanceCount(count: number);
  33688. /** @hidden */
  33689. _preActivate(): Mesh;
  33690. /** @hidden */
  33691. _preActivateForIntermediateRendering(renderId: number): Mesh;
  33692. /** @hidden */
  33693. _registerInstanceForRenderId(instance: InstancedMesh, renderId: number): Mesh;
  33694. protected _afterComputeWorldMatrix(): void;
  33695. /** @hidden */
  33696. _postActivate(): void;
  33697. /**
  33698. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  33699. * This means the mesh underlying bounding box and sphere are recomputed.
  33700. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  33701. * @returns the current mesh
  33702. */
  33703. refreshBoundingInfo(applySkeleton?: boolean): Mesh;
  33704. /** @hidden */
  33705. _createGlobalSubMesh(force: boolean): Nullable<SubMesh>;
  33706. /**
  33707. * This function will subdivide the mesh into multiple submeshes
  33708. * @param count defines the expected number of submeshes
  33709. */
  33710. subdivide(count: number): void;
  33711. /**
  33712. * Copy a FloatArray into a specific associated vertex buffer
  33713. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  33714. * - VertexBuffer.PositionKind
  33715. * - VertexBuffer.UVKind
  33716. * - VertexBuffer.UV2Kind
  33717. * - VertexBuffer.UV3Kind
  33718. * - VertexBuffer.UV4Kind
  33719. * - VertexBuffer.UV5Kind
  33720. * - VertexBuffer.UV6Kind
  33721. * - VertexBuffer.ColorKind
  33722. * - VertexBuffer.MatricesIndicesKind
  33723. * - VertexBuffer.MatricesIndicesExtraKind
  33724. * - VertexBuffer.MatricesWeightsKind
  33725. * - VertexBuffer.MatricesWeightsExtraKind
  33726. * @param data defines the data source
  33727. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  33728. * @param stride defines the data stride size (can be null)
  33729. * @returns the current mesh
  33730. */
  33731. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  33732. /**
  33733. * Delete a vertex buffer associated with this mesh
  33734. * @param kind defines which buffer to delete (positions, indices, normals, etc). Possible `kind` values :
  33735. * - VertexBuffer.PositionKind
  33736. * - VertexBuffer.UVKind
  33737. * - VertexBuffer.UV2Kind
  33738. * - VertexBuffer.UV3Kind
  33739. * - VertexBuffer.UV4Kind
  33740. * - VertexBuffer.UV5Kind
  33741. * - VertexBuffer.UV6Kind
  33742. * - VertexBuffer.ColorKind
  33743. * - VertexBuffer.MatricesIndicesKind
  33744. * - VertexBuffer.MatricesIndicesExtraKind
  33745. * - VertexBuffer.MatricesWeightsKind
  33746. * - VertexBuffer.MatricesWeightsExtraKind
  33747. */
  33748. removeVerticesData(kind: string): void;
  33749. /**
  33750. * Flags an associated vertex buffer as updatable
  33751. * @param kind defines which buffer to use (positions, indices, normals, etc). Possible `kind` values :
  33752. * - VertexBuffer.PositionKind
  33753. * - VertexBuffer.UVKind
  33754. * - VertexBuffer.UV2Kind
  33755. * - VertexBuffer.UV3Kind
  33756. * - VertexBuffer.UV4Kind
  33757. * - VertexBuffer.UV5Kind
  33758. * - VertexBuffer.UV6Kind
  33759. * - VertexBuffer.ColorKind
  33760. * - VertexBuffer.MatricesIndicesKind
  33761. * - VertexBuffer.MatricesIndicesExtraKind
  33762. * - VertexBuffer.MatricesWeightsKind
  33763. * - VertexBuffer.MatricesWeightsExtraKind
  33764. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  33765. */
  33766. markVerticesDataAsUpdatable(kind: string, updatable?: boolean): void;
  33767. /**
  33768. * Sets the mesh global Vertex Buffer
  33769. * @param buffer defines the buffer to use
  33770. * @returns the current mesh
  33771. */
  33772. setVerticesBuffer(buffer: VertexBuffer): Mesh;
  33773. /**
  33774. * Update a specific associated vertex buffer
  33775. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  33776. * - VertexBuffer.PositionKind
  33777. * - VertexBuffer.UVKind
  33778. * - VertexBuffer.UV2Kind
  33779. * - VertexBuffer.UV3Kind
  33780. * - VertexBuffer.UV4Kind
  33781. * - VertexBuffer.UV5Kind
  33782. * - VertexBuffer.UV6Kind
  33783. * - VertexBuffer.ColorKind
  33784. * - VertexBuffer.MatricesIndicesKind
  33785. * - VertexBuffer.MatricesIndicesExtraKind
  33786. * - VertexBuffer.MatricesWeightsKind
  33787. * - VertexBuffer.MatricesWeightsExtraKind
  33788. * @param data defines the data source
  33789. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  33790. * @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)
  33791. * @returns the current mesh
  33792. */
  33793. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  33794. /**
  33795. * This method updates the vertex positions of an updatable mesh according to the `positionFunction` returned values.
  33796. * @see https://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh#other-shapes-updatemeshpositions
  33797. * @param positionFunction is a simple JS function what is passed the mesh `positions` array. It doesn't need to return anything
  33798. * @param computeNormals is a boolean (default true) to enable/disable the mesh normal recomputation after the vertex position update
  33799. * @returns the current mesh
  33800. */
  33801. updateMeshPositions(positionFunction: (data: FloatArray) => void, computeNormals?: boolean): Mesh;
  33802. /**
  33803. * Creates a un-shared specific occurence of the geometry for the mesh.
  33804. * @returns the current mesh
  33805. */
  33806. makeGeometryUnique(): Mesh;
  33807. /**
  33808. * Set the index buffer of this mesh
  33809. * @param indices defines the source data
  33810. * @param totalVertices defines the total number of vertices referenced by this index data (can be null)
  33811. * @param updatable defines if the updated index buffer must be flagged as updatable (default is false)
  33812. * @returns the current mesh
  33813. */
  33814. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): AbstractMesh;
  33815. /**
  33816. * Update the current index buffer
  33817. * @param indices defines the source data
  33818. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  33819. * @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)
  33820. * @returns the current mesh
  33821. */
  33822. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  33823. /**
  33824. * Invert the geometry to move from a right handed system to a left handed one.
  33825. * @returns the current mesh
  33826. */
  33827. toLeftHanded(): Mesh;
  33828. /** @hidden */
  33829. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  33830. /** @hidden */
  33831. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): Mesh;
  33832. /**
  33833. * Registers for this mesh a javascript function called just before the rendering process
  33834. * @param func defines the function to call before rendering this mesh
  33835. * @returns the current mesh
  33836. */
  33837. registerBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  33838. /**
  33839. * Disposes a previously registered javascript function called before the rendering
  33840. * @param func defines the function to remove
  33841. * @returns the current mesh
  33842. */
  33843. unregisterBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  33844. /**
  33845. * Registers for this mesh a javascript function called just after the rendering is complete
  33846. * @param func defines the function to call after rendering this mesh
  33847. * @returns the current mesh
  33848. */
  33849. registerAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  33850. /**
  33851. * Disposes a previously registered javascript function called after the rendering.
  33852. * @param func defines the function to remove
  33853. * @returns the current mesh
  33854. */
  33855. unregisterAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  33856. /** @hidden */
  33857. _getInstancesRenderList(subMeshId: number, isReplacementMode?: boolean): _InstancesBatch;
  33858. /** @hidden */
  33859. _renderWithInstances(subMesh: SubMesh, fillMode: number, batch: _InstancesBatch, effect: Effect, engine: Engine): Mesh;
  33860. /** @hidden */
  33861. _renderWithThinInstances(subMesh: SubMesh, fillMode: number, effect: Effect, engine: Engine): void;
  33862. /** @hidden */
  33863. _processInstancedBuffers(visibleInstances: InstancedMesh[], renderSelf: boolean): void;
  33864. /** @hidden */
  33865. _processRendering(renderingMesh: AbstractMesh, subMesh: SubMesh, effect: Effect, fillMode: number, batch: _InstancesBatch, hardwareInstancedRendering: boolean, onBeforeDraw: (isInstance: boolean, world: Matrix, effectiveMaterial?: Material) => void, effectiveMaterial?: Material): Mesh;
  33866. /** @hidden */
  33867. _rebuild(): void;
  33868. /** @hidden */
  33869. _freeze(): void;
  33870. /** @hidden */
  33871. _unFreeze(): void;
  33872. /**
  33873. * 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
  33874. * @param subMesh defines the subMesh to render
  33875. * @param enableAlphaMode defines if alpha mode can be changed
  33876. * @param effectiveMeshReplacement defines an optional mesh used to provide info for the rendering
  33877. * @returns the current mesh
  33878. */
  33879. render(subMesh: SubMesh, enableAlphaMode: boolean, effectiveMeshReplacement?: AbstractMesh): Mesh;
  33880. private _onBeforeDraw;
  33881. /**
  33882. * Renormalize the mesh and patch it up if there are no weights
  33883. * Similar to normalization by adding the weights compute the reciprocal and multiply all elements, this wil ensure that everything adds to 1.
  33884. * However in the case of zero weights then we set just a single influence to 1.
  33885. * We check in the function for extra's present and if so we use the normalizeSkinWeightsWithExtras rather than the FourWeights version.
  33886. */
  33887. cleanMatrixWeights(): void;
  33888. private normalizeSkinFourWeights;
  33889. private normalizeSkinWeightsAndExtra;
  33890. /**
  33891. * ValidateSkinning is used to determine that a mesh has valid skinning data along with skin metrics, if missing weights,
  33892. * or not normalized it is returned as invalid mesh the string can be used for console logs, or on screen messages to let
  33893. * the user know there was an issue with importing the mesh
  33894. * @returns a validation object with skinned, valid and report string
  33895. */
  33896. validateSkinning(): {
  33897. skinned: boolean;
  33898. valid: boolean;
  33899. report: string;
  33900. };
  33901. /** @hidden */
  33902. _checkDelayState(): Mesh;
  33903. private _queueLoad;
  33904. /**
  33905. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  33906. * A mesh is in the frustum if its bounding box intersects the frustum
  33907. * @param frustumPlanes defines the frustum to test
  33908. * @returns true if the mesh is in the frustum planes
  33909. */
  33910. isInFrustum(frustumPlanes: Plane[]): boolean;
  33911. /**
  33912. * Sets the mesh material by the material or multiMaterial `id` property
  33913. * @param id is a string identifying the material or the multiMaterial
  33914. * @returns the current mesh
  33915. */
  33916. setMaterialByID(id: string): Mesh;
  33917. /**
  33918. * Returns as a new array populated with the mesh material and/or skeleton, if any.
  33919. * @returns an array of IAnimatable
  33920. */
  33921. getAnimatables(): IAnimatable[];
  33922. /**
  33923. * Modifies the mesh geometry according to the passed transformation matrix.
  33924. * This method returns nothing but it really modifies the mesh even if it's originally not set as updatable.
  33925. * The mesh normals are modified using the same transformation.
  33926. * Note that, under the hood, this method sets a new VertexBuffer each call.
  33927. * @param transform defines the transform matrix to use
  33928. * @see https://doc.babylonjs.com/resources/baking_transformations
  33929. * @returns the current mesh
  33930. */
  33931. bakeTransformIntoVertices(transform: Matrix): Mesh;
  33932. /**
  33933. * Modifies the mesh geometry according to its own current World Matrix.
  33934. * The mesh World Matrix is then reset.
  33935. * This method returns nothing but really modifies the mesh even if it's originally not set as updatable.
  33936. * Note that, under the hood, this method sets a new VertexBuffer each call.
  33937. * @see https://doc.babylonjs.com/resources/baking_transformations
  33938. * @param bakeIndependenlyOfChildren indicates whether to preserve all child nodes' World Matrix during baking
  33939. * @returns the current mesh
  33940. */
  33941. bakeCurrentTransformIntoVertices(bakeIndependenlyOfChildren?: boolean): Mesh;
  33942. /** @hidden */
  33943. get _positions(): Nullable<Vector3[]>;
  33944. /** @hidden */
  33945. _resetPointsArrayCache(): Mesh;
  33946. /** @hidden */
  33947. _generatePointsArray(): boolean;
  33948. /**
  33949. * Returns a new Mesh object generated from the current mesh properties.
  33950. * This method must not get confused with createInstance()
  33951. * @param name is a string, the name given to the new mesh
  33952. * @param newParent can be any Node object (default `null`)
  33953. * @param doNotCloneChildren allows/denies the recursive cloning of the original mesh children if any (default `false`)
  33954. * @param clonePhysicsImpostor allows/denies the cloning in the same time of the original mesh `body` used by the physics engine, if any (default `true`)
  33955. * @returns a new mesh
  33956. */
  33957. clone(name?: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean): Mesh;
  33958. /**
  33959. * Releases resources associated with this mesh.
  33960. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  33961. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  33962. */
  33963. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  33964. /** @hidden */
  33965. _disposeInstanceSpecificData(): void;
  33966. /** @hidden */
  33967. _disposeThinInstanceSpecificData(): void;
  33968. /**
  33969. * Modifies the mesh geometry according to a displacement map.
  33970. * 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.
  33971. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  33972. * @param url is a string, the URL from the image file is to be downloaded.
  33973. * @param minHeight is the lower limit of the displacement.
  33974. * @param maxHeight is the upper limit of the displacement.
  33975. * @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.
  33976. * @param uvOffset is an optional vector2 used to offset UV.
  33977. * @param uvScale is an optional vector2 used to scale UV.
  33978. * @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.
  33979. * @returns the Mesh.
  33980. */
  33981. applyDisplacementMap(url: string, minHeight: number, maxHeight: number, onSuccess?: (mesh: Mesh) => void, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  33982. /**
  33983. * Modifies the mesh geometry according to a displacementMap buffer.
  33984. * 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.
  33985. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  33986. * @param buffer is a `Uint8Array` buffer containing series of `Uint8` lower than 255, the red, green, blue and alpha values of each successive pixel.
  33987. * @param heightMapWidth is the width of the buffer image.
  33988. * @param heightMapHeight is the height of the buffer image.
  33989. * @param minHeight is the lower limit of the displacement.
  33990. * @param maxHeight is the upper limit of the displacement.
  33991. * @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.
  33992. * @param uvOffset is an optional vector2 used to offset UV.
  33993. * @param uvScale is an optional vector2 used to scale UV.
  33994. * @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.
  33995. * @returns the Mesh.
  33996. */
  33997. applyDisplacementMapFromBuffer(buffer: Uint8Array, heightMapWidth: number, heightMapHeight: number, minHeight: number, maxHeight: number, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  33998. /**
  33999. * Modify the mesh to get a flat shading rendering.
  34000. * This means each mesh facet will then have its own normals. Usually new vertices are added in the mesh geometry to get this result.
  34001. * Warning : the mesh is really modified even if not set originally as updatable and, under the hood, a new VertexBuffer is allocated.
  34002. * @returns current mesh
  34003. */
  34004. convertToFlatShadedMesh(): Mesh;
  34005. /**
  34006. * This method removes all the mesh indices and add new vertices (duplication) in order to unfold facets into buffers.
  34007. * In other words, more vertices, no more indices and a single bigger VBO.
  34008. * The mesh is really modified even if not set originally as updatable. Under the hood, a new VertexBuffer is allocated.
  34009. * @returns current mesh
  34010. */
  34011. convertToUnIndexedMesh(): Mesh;
  34012. /**
  34013. * Inverses facet orientations.
  34014. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  34015. * @param flipNormals will also inverts the normals
  34016. * @returns current mesh
  34017. */
  34018. flipFaces(flipNormals?: boolean): Mesh;
  34019. /**
  34020. * Increase the number of facets and hence vertices in a mesh
  34021. * Vertex normals are interpolated from existing vertex normals
  34022. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  34023. * @param numberPerEdge the number of new vertices to add to each edge of a facet, optional default 1
  34024. */
  34025. increaseVertices(numberPerEdge: number): void;
  34026. /**
  34027. * Force adjacent facets to share vertices and remove any facets that have all vertices in a line
  34028. * This will undo any application of covertToFlatShadedMesh
  34029. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  34030. */
  34031. forceSharedVertices(): void;
  34032. /** @hidden */
  34033. static _instancedMeshFactory(name: string, mesh: Mesh): InstancedMesh;
  34034. /** @hidden */
  34035. static _PhysicsImpostorParser(scene: Scene, physicObject: IPhysicsEnabledObject, jsonObject: any): PhysicsImpostor;
  34036. /**
  34037. * Creates a new InstancedMesh object from the mesh model.
  34038. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  34039. * @param name defines the name of the new instance
  34040. * @returns a new InstancedMesh
  34041. */
  34042. createInstance(name: string): InstancedMesh;
  34043. /**
  34044. * Synchronises all the mesh instance submeshes to the current mesh submeshes, if any.
  34045. * After this call, all the mesh instances have the same submeshes than the current mesh.
  34046. * @returns the current mesh
  34047. */
  34048. synchronizeInstances(): Mesh;
  34049. /**
  34050. * Optimization of the mesh's indices, in case a mesh has duplicated vertices.
  34051. * The function will only reorder the indices and will not remove unused vertices to avoid problems with submeshes.
  34052. * This should be used together with the simplification to avoid disappearing triangles.
  34053. * @param successCallback an optional success callback to be called after the optimization finished.
  34054. * @returns the current mesh
  34055. */
  34056. optimizeIndices(successCallback?: (mesh?: Mesh) => void): Mesh;
  34057. /**
  34058. * Serialize current mesh
  34059. * @param serializationObject defines the object which will receive the serialization data
  34060. */
  34061. serialize(serializationObject: any): void;
  34062. /** @hidden */
  34063. _syncGeometryWithMorphTargetManager(): void;
  34064. /** @hidden */
  34065. static _GroundMeshParser: (parsedMesh: any, scene: Scene) => Mesh;
  34066. /**
  34067. * Returns a new Mesh object parsed from the source provided.
  34068. * @param parsedMesh is the source
  34069. * @param scene defines the hosting scene
  34070. * @param rootUrl is the root URL to prefix the `delayLoadingFile` property with
  34071. * @returns a new Mesh
  34072. */
  34073. static Parse(parsedMesh: any, scene: Scene, rootUrl: string): Mesh;
  34074. /**
  34075. * Creates a ribbon mesh. Please consider using the same method from the MeshBuilder class instead
  34076. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  34077. * @param name defines the name of the mesh to create
  34078. * @param pathArray is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry.
  34079. * @param closeArray creates a seam between the first and the last paths of the path array (default is false)
  34080. * @param closePath creates a seam between the first and the last points of each path of the path array
  34081. * @param offset is taken in account only if the `pathArray` is containing a single path
  34082. * @param scene defines the hosting scene
  34083. * @param updatable defines if the mesh must be flagged as updatable
  34084. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  34085. * @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)
  34086. * @returns a new Mesh
  34087. */
  34088. static CreateRibbon(name: string, pathArray: Vector3[][], closeArray: boolean, closePath: boolean, offset: number, scene?: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  34089. /**
  34090. * Creates a plane polygonal mesh. By default, this is a disc. Please consider using the same method from the MeshBuilder class instead
  34091. * @param name defines the name of the mesh to create
  34092. * @param radius sets the radius size (float) of the polygon (default 0.5)
  34093. * @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
  34094. * @param scene defines the hosting scene
  34095. * @param updatable defines if the mesh must be flagged as updatable
  34096. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  34097. * @returns a new Mesh
  34098. */
  34099. static CreateDisc(name: string, radius: number, tessellation: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  34100. /**
  34101. * Creates a box mesh. Please consider using the same method from the MeshBuilder class instead
  34102. * @param name defines the name of the mesh to create
  34103. * @param size sets the size (float) of each box side (default 1)
  34104. * @param scene defines the hosting scene
  34105. * @param updatable defines if the mesh must be flagged as updatable
  34106. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  34107. * @returns a new Mesh
  34108. */
  34109. static CreateBox(name: string, size: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  34110. /**
  34111. * Creates a sphere mesh. Please consider using the same method from the MeshBuilder class instead
  34112. * @param name defines the name of the mesh to create
  34113. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  34114. * @param diameter sets the diameter size (float) of the sphere (default 1)
  34115. * @param scene defines the hosting scene
  34116. * @param updatable defines if the mesh must be flagged as updatable
  34117. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  34118. * @returns a new Mesh
  34119. */
  34120. static CreateSphere(name: string, segments: number, diameter: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  34121. /**
  34122. * Creates a hemisphere mesh. Please consider using the same method from the MeshBuilder class instead
  34123. * @param name defines the name of the mesh to create
  34124. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  34125. * @param diameter sets the diameter size (float) of the sphere (default 1)
  34126. * @param scene defines the hosting scene
  34127. * @returns a new Mesh
  34128. */
  34129. static CreateHemisphere(name: string, segments: number, diameter: number, scene?: Scene): Mesh;
  34130. /**
  34131. * Creates a cylinder or a cone mesh. Please consider using the same method from the MeshBuilder class instead
  34132. * @param name defines the name of the mesh to create
  34133. * @param height sets the height size (float) of the cylinder/cone (float, default 2)
  34134. * @param diameterTop set the top cap diameter (floats, default 1)
  34135. * @param diameterBottom set the bottom cap diameter (floats, default 1). This value can't be zero
  34136. * @param tessellation sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance
  34137. * @param subdivisions sets the number of rings along the cylinder height (positive integer, default 1)
  34138. * @param scene defines the hosting scene
  34139. * @param updatable defines if the mesh must be flagged as updatable
  34140. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  34141. * @returns a new Mesh
  34142. */
  34143. static CreateCylinder(name: string, height: number, diameterTop: number, diameterBottom: number, tessellation: number, subdivisions: any, scene?: Scene, updatable?: any, sideOrientation?: number): Mesh;
  34144. /**
  34145. * Creates a torus mesh. Please consider using the same method from the MeshBuilder class instead
  34146. * @param name defines the name of the mesh to create
  34147. * @param diameter sets the diameter size (float) of the torus (default 1)
  34148. * @param thickness sets the diameter size of the tube of the torus (float, default 0.5)
  34149. * @param tessellation sets the number of torus sides (positive integer, default 16)
  34150. * @param scene defines the hosting scene
  34151. * @param updatable defines if the mesh must be flagged as updatable
  34152. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  34153. * @returns a new Mesh
  34154. */
  34155. static CreateTorus(name: string, diameter: number, thickness: number, tessellation: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  34156. /**
  34157. * Creates a torus knot mesh. Please consider using the same method from the MeshBuilder class instead
  34158. * @param name defines the name of the mesh to create
  34159. * @param radius sets the global radius size (float) of the torus knot (default 2)
  34160. * @param tube sets the diameter size of the tube of the torus (float, default 0.5)
  34161. * @param radialSegments sets the number of sides on each tube segments (positive integer, default 32)
  34162. * @param tubularSegments sets the number of tubes to decompose the knot into (positive integer, default 32)
  34163. * @param p the number of windings on X axis (positive integers, default 2)
  34164. * @param q the number of windings on Y axis (positive integers, default 3)
  34165. * @param scene defines the hosting scene
  34166. * @param updatable defines if the mesh must be flagged as updatable
  34167. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  34168. * @returns a new Mesh
  34169. */
  34170. static CreateTorusKnot(name: string, radius: number, tube: number, radialSegments: number, tubularSegments: number, p: number, q: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  34171. /**
  34172. * Creates a line mesh. Please consider using the same method from the MeshBuilder class instead.
  34173. * @param name defines the name of the mesh to create
  34174. * @param points is an array successive Vector3
  34175. * @param scene defines the hosting scene
  34176. * @param updatable defines if the mesh must be flagged as updatable
  34177. * @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).
  34178. * @returns a new Mesh
  34179. */
  34180. static CreateLines(name: string, points: Vector3[], scene?: Nullable<Scene>, updatable?: boolean, instance?: Nullable<LinesMesh>): LinesMesh;
  34181. /**
  34182. * Creates a dashed line mesh. Please consider using the same method from the MeshBuilder class instead
  34183. * @param name defines the name of the mesh to create
  34184. * @param points is an array successive Vector3
  34185. * @param dashSize is the size of the dashes relatively the dash number (positive float, default 3)
  34186. * @param gapSize is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  34187. * @param dashNb is the intended total number of dashes (positive integer, default 200)
  34188. * @param scene defines the hosting scene
  34189. * @param updatable defines if the mesh must be flagged as updatable
  34190. * @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)
  34191. * @returns a new Mesh
  34192. */
  34193. static CreateDashedLines(name: string, points: Vector3[], dashSize: number, gapSize: number, dashNb: number, scene?: Nullable<Scene>, updatable?: boolean, instance?: LinesMesh): LinesMesh;
  34194. /**
  34195. * Creates a polygon mesh.Please consider using the same method from the MeshBuilder class instead
  34196. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh.
  34197. * 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.
  34198. * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  34199. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  34200. * Remember you can only change the shape positions, not their number when updating a polygon.
  34201. * @see https://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  34202. * @param name defines the name of the mesh to create
  34203. * @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
  34204. * @param scene defines the hosting scene
  34205. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  34206. * @param updatable defines if the mesh must be flagged as updatable
  34207. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  34208. * @param earcutInjection can be used to inject your own earcut reference
  34209. * @returns a new Mesh
  34210. */
  34211. static CreatePolygon(name: string, shape: Vector3[], scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  34212. /**
  34213. * Creates an extruded polygon mesh, with depth in the Y direction. Please consider using the same method from the MeshBuilder class instead.
  34214. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-non-regular-polygon
  34215. * @param name defines the name of the mesh to create
  34216. * @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
  34217. * @param depth defines the height of extrusion
  34218. * @param scene defines the hosting scene
  34219. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  34220. * @param updatable defines if the mesh must be flagged as updatable
  34221. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  34222. * @param earcutInjection can be used to inject your own earcut reference
  34223. * @returns a new Mesh
  34224. */
  34225. static ExtrudePolygon(name: string, shape: Vector3[], depth: number, scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  34226. /**
  34227. * Creates an extruded shape mesh.
  34228. * 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
  34229. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  34230. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  34231. * @param name defines the name of the mesh to create
  34232. * @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
  34233. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  34234. * @param scale is the value to scale the shape
  34235. * @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
  34236. * @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
  34237. * @param scene defines the hosting scene
  34238. * @param updatable defines if the mesh must be flagged as updatable
  34239. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  34240. * @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)
  34241. * @returns a new Mesh
  34242. */
  34243. static ExtrudeShape(name: string, shape: Vector3[], path: Vector3[], scale: number, rotation: number, cap: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  34244. /**
  34245. * Creates an custom extruded shape mesh.
  34246. * The custom extrusion is a parametric shape.
  34247. * It has no predefined shape. Its final shape will depend on the input parameters.
  34248. * Please consider using the same method from the MeshBuilder class instead
  34249. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  34250. * @param name defines the name of the mesh to create
  34251. * @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
  34252. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  34253. * @param scaleFunction is a custom Javascript function called on each path point
  34254. * @param rotationFunction is a custom Javascript function called on each path point
  34255. * @param ribbonCloseArray forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  34256. * @param ribbonClosePath forces the extrusion underlying ribbon to close its `pathArray`
  34257. * @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
  34258. * @param scene defines the hosting scene
  34259. * @param updatable defines if the mesh must be flagged as updatable
  34260. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  34261. * @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)
  34262. * @returns a new Mesh
  34263. */
  34264. 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;
  34265. /**
  34266. * Creates lathe mesh.
  34267. * The lathe is a shape with a symmetry axis : a 2D model shape is rotated around this axis to design the lathe.
  34268. * Please consider using the same method from the MeshBuilder class instead
  34269. * @param name defines the name of the mesh to create
  34270. * @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
  34271. * @param radius is the radius value of the lathe
  34272. * @param tessellation is the side number of the lathe.
  34273. * @param scene defines the hosting scene
  34274. * @param updatable defines if the mesh must be flagged as updatable
  34275. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  34276. * @returns a new Mesh
  34277. */
  34278. static CreateLathe(name: string, shape: Vector3[], radius: number, tessellation: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  34279. /**
  34280. * Creates a plane mesh. Please consider using the same method from the MeshBuilder class instead
  34281. * @param name defines the name of the mesh to create
  34282. * @param size sets the size (float) of both sides of the plane at once (default 1)
  34283. * @param scene defines the hosting scene
  34284. * @param updatable defines if the mesh must be flagged as updatable
  34285. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  34286. * @returns a new Mesh
  34287. */
  34288. static CreatePlane(name: string, size: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  34289. /**
  34290. * Creates a ground mesh.
  34291. * Please consider using the same method from the MeshBuilder class instead
  34292. * @param name defines the name of the mesh to create
  34293. * @param width set the width of the ground
  34294. * @param height set the height of the ground
  34295. * @param subdivisions sets the number of subdivisions per side
  34296. * @param scene defines the hosting scene
  34297. * @param updatable defines if the mesh must be flagged as updatable
  34298. * @returns a new Mesh
  34299. */
  34300. static CreateGround(name: string, width: number, height: number, subdivisions: number, scene?: Scene, updatable?: boolean): Mesh;
  34301. /**
  34302. * Creates a tiled ground mesh.
  34303. * Please consider using the same method from the MeshBuilder class instead
  34304. * @param name defines the name of the mesh to create
  34305. * @param xmin set the ground minimum X coordinate
  34306. * @param zmin set the ground minimum Y coordinate
  34307. * @param xmax set the ground maximum X coordinate
  34308. * @param zmax set the ground maximum Z coordinate
  34309. * @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
  34310. * @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
  34311. * @param scene defines the hosting scene
  34312. * @param updatable defines if the mesh must be flagged as updatable
  34313. * @returns a new Mesh
  34314. */
  34315. static CreateTiledGround(name: string, xmin: number, zmin: number, xmax: number, zmax: number, subdivisions: {
  34316. w: number;
  34317. h: number;
  34318. }, precision: {
  34319. w: number;
  34320. h: number;
  34321. }, scene: Scene, updatable?: boolean): Mesh;
  34322. /**
  34323. * Creates a ground mesh from a height map.
  34324. * Please consider using the same method from the MeshBuilder class instead
  34325. * @see https://doc.babylonjs.com/babylon101/height_map
  34326. * @param name defines the name of the mesh to create
  34327. * @param url sets the URL of the height map image resource
  34328. * @param width set the ground width size
  34329. * @param height set the ground height size
  34330. * @param subdivisions sets the number of subdivision per side
  34331. * @param minHeight is the minimum altitude on the ground
  34332. * @param maxHeight is the maximum altitude on the ground
  34333. * @param scene defines the hosting scene
  34334. * @param updatable defines if the mesh must be flagged as updatable
  34335. * @param onReady is a callback function that will be called once the mesh is built (the height map download can last some time)
  34336. * @param alphaFilter will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  34337. * @returns a new Mesh
  34338. */
  34339. 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;
  34340. /**
  34341. * Creates a tube mesh.
  34342. * The tube is a parametric shape.
  34343. * It has no predefined shape. Its final shape will depend on the input parameters.
  34344. * Please consider using the same method from the MeshBuilder class instead
  34345. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  34346. * @param name defines the name of the mesh to create
  34347. * @param path is a required array of successive Vector3. It is the curve used as the axis of the tube
  34348. * @param radius sets the tube radius size
  34349. * @param tessellation is the number of sides on the tubular surface
  34350. * @param radiusFunction is a custom function. If it is not null, it overrides the parameter `radius`. This function is called on each point of the tube path and is passed the index `i` of the i-th point and the distance of this point from the first point of the path
  34351. * @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
  34352. * @param scene defines the hosting scene
  34353. * @param updatable defines if the mesh must be flagged as updatable
  34354. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  34355. * @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)
  34356. * @returns a new Mesh
  34357. */
  34358. static CreateTube(name: string, path: Vector3[], radius: number, tessellation: number, radiusFunction: {
  34359. (i: number, distance: number): number;
  34360. }, cap: number, scene: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  34361. /**
  34362. * Creates a polyhedron mesh.
  34363. * Please consider using the same method from the MeshBuilder class instead.
  34364. * * The parameter `type` (positive integer, max 14, default 0) sets the polyhedron type to build among the 15 embedded types. Please refer to the type sheet in the tutorial to choose the wanted type
  34365. * * The parameter `size` (positive float, default 1) sets the polygon size
  34366. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  34367. * * 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`
  34368. * * 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
  34369. * * 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)`)
  34370. * * 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
  34371. * * 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
  34372. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  34373. * * 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
  34374. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  34375. * @param name defines the name of the mesh to create
  34376. * @param options defines the options used to create the mesh
  34377. * @param scene defines the hosting scene
  34378. * @returns a new Mesh
  34379. */
  34380. static CreatePolyhedron(name: string, options: {
  34381. type?: number;
  34382. size?: number;
  34383. sizeX?: number;
  34384. sizeY?: number;
  34385. sizeZ?: number;
  34386. custom?: any;
  34387. faceUV?: Vector4[];
  34388. faceColors?: Color4[];
  34389. updatable?: boolean;
  34390. sideOrientation?: number;
  34391. }, scene: Scene): Mesh;
  34392. /**
  34393. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  34394. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  34395. * * 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`)
  34396. * * The parameter `subdivisions` sets the number of subdivisions (positive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  34397. * * 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
  34398. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  34399. * * 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
  34400. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  34401. * @param name defines the name of the mesh
  34402. * @param options defines the options used to create the mesh
  34403. * @param scene defines the hosting scene
  34404. * @returns a new Mesh
  34405. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  34406. */
  34407. static CreateIcoSphere(name: string, options: {
  34408. radius?: number;
  34409. flat?: boolean;
  34410. subdivisions?: number;
  34411. sideOrientation?: number;
  34412. updatable?: boolean;
  34413. }, scene: Scene): Mesh;
  34414. /**
  34415. * Creates a decal mesh.
  34416. * Please consider using the same method from the MeshBuilder class instead.
  34417. * A decal is a mesh usually applied as a model onto the surface of another mesh
  34418. * @param name defines the name of the mesh
  34419. * @param sourceMesh defines the mesh receiving the decal
  34420. * @param position sets the position of the decal in world coordinates
  34421. * @param normal sets the normal of the mesh where the decal is applied onto in world coordinates
  34422. * @param size sets the decal scaling
  34423. * @param angle sets the angle to rotate the decal
  34424. * @returns a new Mesh
  34425. */
  34426. static CreateDecal(name: string, sourceMesh: AbstractMesh, position: Vector3, normal: Vector3, size: Vector3, angle: number): Mesh;
  34427. /** Creates a Capsule Mesh
  34428. * @param name defines the name of the mesh.
  34429. * @param options the constructors options used to shape the mesh.
  34430. * @param scene defines the scene the mesh is scoped to.
  34431. * @returns the capsule mesh
  34432. * @see https://doc.babylonjs.com/how_to/capsule_shape
  34433. */
  34434. static CreateCapsule(name: string, options: ICreateCapsuleOptions, scene: Scene): Mesh;
  34435. /**
  34436. * Prepare internal position array for software CPU skinning
  34437. * @returns original positions used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh
  34438. */
  34439. setPositionsForCPUSkinning(): Float32Array;
  34440. /**
  34441. * Prepare internal normal array for software CPU skinning
  34442. * @returns original normals used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh.
  34443. */
  34444. setNormalsForCPUSkinning(): Float32Array;
  34445. /**
  34446. * Updates the vertex buffer by applying transformation from the bones
  34447. * @param skeleton defines the skeleton to apply to current mesh
  34448. * @returns the current mesh
  34449. */
  34450. applySkeleton(skeleton: Skeleton): Mesh;
  34451. /**
  34452. * 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
  34453. * @param meshes defines the list of meshes to scan
  34454. * @returns an object `{min:` Vector3`, max:` Vector3`}`
  34455. */
  34456. static MinMax(meshes: AbstractMesh[]): {
  34457. min: Vector3;
  34458. max: Vector3;
  34459. };
  34460. /**
  34461. * Returns the center of the `{min:` Vector3`, max:` Vector3`}` or the center of MinMax vector3 computed from a mesh array
  34462. * @param meshesOrMinMaxVector could be an array of meshes or a `{min:` Vector3`, max:` Vector3`}` object
  34463. * @returns a vector3
  34464. */
  34465. static Center(meshesOrMinMaxVector: {
  34466. min: Vector3;
  34467. max: Vector3;
  34468. } | AbstractMesh[]): Vector3;
  34469. /**
  34470. * Merge the array of meshes into a single mesh for performance reasons.
  34471. * @param meshes defines he vertices source. They should all be of the same material. Entries can empty
  34472. * @param disposeSource when true (default), dispose of the vertices from the source meshes
  34473. * @param allow32BitsIndices when the sum of the vertices > 64k, this must be set to true
  34474. * @param meshSubclass when set, vertices inserted into this Mesh. Meshes can then be merged into a Mesh sub-class.
  34475. * @param subdivideWithSubMeshes when true (false default), subdivide mesh to his subMesh array with meshes source.
  34476. * @param multiMultiMaterials when true (false default), subdivide mesh and accept multiple multi materials, ignores subdivideWithSubMeshes.
  34477. * @returns a new mesh
  34478. */
  34479. static MergeMeshes(meshes: Array<Mesh>, disposeSource?: boolean, allow32BitsIndices?: boolean, meshSubclass?: Mesh, subdivideWithSubMeshes?: boolean, multiMultiMaterials?: boolean): Nullable<Mesh>;
  34480. /** @hidden */
  34481. addInstance(instance: InstancedMesh): void;
  34482. /** @hidden */
  34483. removeInstance(instance: InstancedMesh): void;
  34484. }
  34485. }
  34486. declare module BABYLON {
  34487. /**
  34488. * The options Interface for creating a Capsule Mesh
  34489. */
  34490. export interface ICreateCapsuleOptions {
  34491. /** The Orientation of the capsule. Default : Vector3.Up() */
  34492. orientation?: Vector3;
  34493. /** Number of sub segments on the tube section of the capsule running parallel to orientation. */
  34494. subdivisions: number;
  34495. /** Number of cylindrical segments on the capsule. */
  34496. tessellation: number;
  34497. /** Height or Length of the capsule. */
  34498. height: number;
  34499. /** Radius of the capsule. */
  34500. radius: number;
  34501. /** Number of sub segments on the cap sections of the capsule running parallel to orientation. */
  34502. capSubdivisions: number;
  34503. /** Overwrite for the top radius. */
  34504. radiusTop?: number;
  34505. /** Overwrite for the bottom radius. */
  34506. radiusBottom?: number;
  34507. /** Overwrite for the top capSubdivisions. */
  34508. topCapSubdivisions?: number;
  34509. /** Overwrite for the bottom capSubdivisions. */
  34510. bottomCapSubdivisions?: number;
  34511. }
  34512. /**
  34513. * Class containing static functions to help procedurally build meshes
  34514. */
  34515. export class CapsuleBuilder {
  34516. /**
  34517. * Creates a capsule or a pill mesh
  34518. * @param name defines the name of the mesh
  34519. * @param options The constructors options.
  34520. * @param scene The scene the mesh is scoped to.
  34521. * @returns Capsule Mesh
  34522. */
  34523. static CreateCapsule(name: string, options: ICreateCapsuleOptions | undefined, scene: any): Mesh;
  34524. }
  34525. }
  34526. declare module BABYLON {
  34527. /**
  34528. * Define an interface for all classes that will get and set the data on vertices
  34529. */
  34530. export interface IGetSetVerticesData {
  34531. /**
  34532. * Gets a boolean indicating if specific vertex data is present
  34533. * @param kind defines the vertex data kind to use
  34534. * @returns true is data kind is present
  34535. */
  34536. isVerticesDataPresent(kind: string): boolean;
  34537. /**
  34538. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  34539. * @param kind defines the data kind (Position, normal, etc...)
  34540. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  34541. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  34542. * @returns a float array containing vertex data
  34543. */
  34544. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  34545. /**
  34546. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  34547. * @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.
  34548. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  34549. * @returns the indices array or an empty array if the mesh has no geometry
  34550. */
  34551. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  34552. /**
  34553. * Set specific vertex data
  34554. * @param kind defines the data kind (Position, normal, etc...)
  34555. * @param data defines the vertex data to use
  34556. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  34557. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  34558. */
  34559. setVerticesData(kind: string, data: FloatArray, updatable: boolean): void;
  34560. /**
  34561. * Update a specific associated vertex buffer
  34562. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  34563. * - VertexBuffer.PositionKind
  34564. * - VertexBuffer.UVKind
  34565. * - VertexBuffer.UV2Kind
  34566. * - VertexBuffer.UV3Kind
  34567. * - VertexBuffer.UV4Kind
  34568. * - VertexBuffer.UV5Kind
  34569. * - VertexBuffer.UV6Kind
  34570. * - VertexBuffer.ColorKind
  34571. * - VertexBuffer.MatricesIndicesKind
  34572. * - VertexBuffer.MatricesIndicesExtraKind
  34573. * - VertexBuffer.MatricesWeightsKind
  34574. * - VertexBuffer.MatricesWeightsExtraKind
  34575. * @param data defines the data source
  34576. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  34577. * @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)
  34578. */
  34579. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): void;
  34580. /**
  34581. * Creates a new index buffer
  34582. * @param indices defines the indices to store in the index buffer
  34583. * @param totalVertices defines the total number of vertices (could be null)
  34584. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  34585. */
  34586. setIndices(indices: IndicesArray, totalVertices: Nullable<number>, updatable?: boolean): void;
  34587. }
  34588. /**
  34589. * This class contains the various kinds of data on every vertex of a mesh used in determining its shape and appearance
  34590. */
  34591. export class VertexData {
  34592. /**
  34593. * Mesh side orientation : usually the external or front surface
  34594. */
  34595. static readonly FRONTSIDE: number;
  34596. /**
  34597. * Mesh side orientation : usually the internal or back surface
  34598. */
  34599. static readonly BACKSIDE: number;
  34600. /**
  34601. * Mesh side orientation : both internal and external or front and back surfaces
  34602. */
  34603. static readonly DOUBLESIDE: number;
  34604. /**
  34605. * Mesh side orientation : by default, `FRONTSIDE`
  34606. */
  34607. static readonly DEFAULTSIDE: number;
  34608. /**
  34609. * An array of the x, y, z position of each vertex [...., x, y, z, .....]
  34610. */
  34611. positions: Nullable<FloatArray>;
  34612. /**
  34613. * An array of the x, y, z normal vector of each vertex [...., x, y, z, .....]
  34614. */
  34615. normals: Nullable<FloatArray>;
  34616. /**
  34617. * An array of the x, y, z tangent vector of each vertex [...., x, y, z, .....]
  34618. */
  34619. tangents: Nullable<FloatArray>;
  34620. /**
  34621. * An array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  34622. */
  34623. uvs: Nullable<FloatArray>;
  34624. /**
  34625. * A second array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  34626. */
  34627. uvs2: Nullable<FloatArray>;
  34628. /**
  34629. * A third array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  34630. */
  34631. uvs3: Nullable<FloatArray>;
  34632. /**
  34633. * A fourth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  34634. */
  34635. uvs4: Nullable<FloatArray>;
  34636. /**
  34637. * A fifth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  34638. */
  34639. uvs5: Nullable<FloatArray>;
  34640. /**
  34641. * A sixth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  34642. */
  34643. uvs6: Nullable<FloatArray>;
  34644. /**
  34645. * An array of the r, g, b, a, color of each vertex [...., r, g, b, a, .....]
  34646. */
  34647. colors: Nullable<FloatArray>;
  34648. /**
  34649. * 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).
  34650. */
  34651. matricesIndices: Nullable<FloatArray>;
  34652. /**
  34653. * An array containing the list of weights defining the weight of each indexed matrix in the final computation
  34654. */
  34655. matricesWeights: Nullable<FloatArray>;
  34656. /**
  34657. * An array extending the number of possible indices
  34658. */
  34659. matricesIndicesExtra: Nullable<FloatArray>;
  34660. /**
  34661. * An array extending the number of possible weights when the number of indices is extended
  34662. */
  34663. matricesWeightsExtra: Nullable<FloatArray>;
  34664. /**
  34665. * An array of i, j, k the three vertex indices required for each triangular facet [...., i, j, k .....]
  34666. */
  34667. indices: Nullable<IndicesArray>;
  34668. /**
  34669. * Uses the passed data array to set the set the values for the specified kind of data
  34670. * @param data a linear array of floating numbers
  34671. * @param kind the type of data that is being set, eg positions, colors etc
  34672. */
  34673. set(data: FloatArray, kind: string): void;
  34674. /**
  34675. * Associates the vertexData to the passed Mesh.
  34676. * Sets it as updatable or not (default `false`)
  34677. * @param mesh the mesh the vertexData is applied to
  34678. * @param updatable when used and having the value true allows new data to update the vertexData
  34679. * @returns the VertexData
  34680. */
  34681. applyToMesh(mesh: Mesh, updatable?: boolean): VertexData;
  34682. /**
  34683. * Associates the vertexData to the passed Geometry.
  34684. * Sets it as updatable or not (default `false`)
  34685. * @param geometry the geometry the vertexData is applied to
  34686. * @param updatable when used and having the value true allows new data to update the vertexData
  34687. * @returns VertexData
  34688. */
  34689. applyToGeometry(geometry: Geometry, updatable?: boolean): VertexData;
  34690. /**
  34691. * Updates the associated mesh
  34692. * @param mesh the mesh to be updated
  34693. * @param updateExtends when true the mesh BoundingInfo will be renewed when and if position kind is updated, optional with default false
  34694. * @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
  34695. * @returns VertexData
  34696. */
  34697. updateMesh(mesh: Mesh): VertexData;
  34698. /**
  34699. * Updates the associated geometry
  34700. * @param geometry the geometry to be updated
  34701. * @param updateExtends when true BoundingInfo will be renewed when and if position kind is updated, optional with default false
  34702. * @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
  34703. * @returns VertexData.
  34704. */
  34705. updateGeometry(geometry: Geometry): VertexData;
  34706. private _applyTo;
  34707. private _update;
  34708. /**
  34709. * Transforms each position and each normal of the vertexData according to the passed Matrix
  34710. * @param matrix the transforming matrix
  34711. * @returns the VertexData
  34712. */
  34713. transform(matrix: Matrix): VertexData;
  34714. /**
  34715. * Merges the passed VertexData into the current one
  34716. * @param other the VertexData to be merged into the current one
  34717. * @param use32BitsIndices defines a boolean indicating if indices must be store in a 32 bits array
  34718. * @returns the modified VertexData
  34719. */
  34720. merge(other: VertexData, use32BitsIndices?: boolean): VertexData;
  34721. private _mergeElement;
  34722. private _validate;
  34723. /**
  34724. * Serializes the VertexData
  34725. * @returns a serialized object
  34726. */
  34727. serialize(): any;
  34728. /**
  34729. * Extracts the vertexData from a mesh
  34730. * @param mesh the mesh from which to extract the VertexData
  34731. * @param copyWhenShared defines if the VertexData must be cloned when shared between multiple meshes, optional, default false
  34732. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  34733. * @returns the object VertexData associated to the passed mesh
  34734. */
  34735. static ExtractFromMesh(mesh: Mesh, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  34736. /**
  34737. * Extracts the vertexData from the geometry
  34738. * @param geometry the geometry from which to extract the VertexData
  34739. * @param copyWhenShared defines if the VertexData must be cloned when the geometry is shared between multiple meshes, optional, default false
  34740. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  34741. * @returns the object VertexData associated to the passed mesh
  34742. */
  34743. static ExtractFromGeometry(geometry: Geometry, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  34744. private static _ExtractFrom;
  34745. /**
  34746. * Creates the VertexData for a Ribbon
  34747. * @param options an object used to set the following optional parameters for the ribbon, required but can be empty
  34748. * * pathArray array of paths, each of which an array of successive Vector3
  34749. * * closeArray creates a seam between the first and the last paths of the pathArray, optional, default false
  34750. * * closePath creates a seam between the first and the last points of each path of the path array, optional, default false
  34751. * * 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
  34752. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  34753. * * 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)
  34754. * * 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)
  34755. * * invertUV swaps in the U and V coordinates when applying a texture, optional, default false
  34756. * * uvs a linear array, of length 2 * number of vertices, of custom UV values, optional
  34757. * * colors a linear array, of length 4 * number of vertices, of custom color values, optional
  34758. * @returns the VertexData of the ribbon
  34759. */
  34760. static CreateRibbon(options: {
  34761. pathArray: Vector3[][];
  34762. closeArray?: boolean;
  34763. closePath?: boolean;
  34764. offset?: number;
  34765. sideOrientation?: number;
  34766. frontUVs?: Vector4;
  34767. backUVs?: Vector4;
  34768. invertUV?: boolean;
  34769. uvs?: Vector2[];
  34770. colors?: Color4[];
  34771. }): VertexData;
  34772. /**
  34773. * Creates the VertexData for a box
  34774. * @param options an object used to set the following optional parameters for the box, required but can be empty
  34775. * * size sets the width, height and depth of the box to the value of size, optional default 1
  34776. * * width sets the width (x direction) of the box, overwrites the width set by size, optional, default size
  34777. * * height sets the height (y direction) of the box, overwrites the height set by size, optional, default size
  34778. * * depth sets the depth (z direction) of the box, overwrites the depth set by size, optional, default size
  34779. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  34780. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  34781. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  34782. * * 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)
  34783. * * 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)
  34784. * @returns the VertexData of the box
  34785. */
  34786. static CreateBox(options: {
  34787. size?: number;
  34788. width?: number;
  34789. height?: number;
  34790. depth?: number;
  34791. faceUV?: Vector4[];
  34792. faceColors?: Color4[];
  34793. sideOrientation?: number;
  34794. frontUVs?: Vector4;
  34795. backUVs?: Vector4;
  34796. }): VertexData;
  34797. /**
  34798. * Creates the VertexData for a tiled box
  34799. * @param options an object used to set the following optional parameters for the box, required but can be empty
  34800. * * faceTiles sets the pattern, tile size and number of tiles for a face
  34801. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  34802. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  34803. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  34804. * @returns the VertexData of the box
  34805. */
  34806. static CreateTiledBox(options: {
  34807. pattern?: number;
  34808. width?: number;
  34809. height?: number;
  34810. depth?: number;
  34811. tileSize?: number;
  34812. tileWidth?: number;
  34813. tileHeight?: number;
  34814. alignHorizontal?: number;
  34815. alignVertical?: number;
  34816. faceUV?: Vector4[];
  34817. faceColors?: Color4[];
  34818. sideOrientation?: number;
  34819. }): VertexData;
  34820. /**
  34821. * Creates the VertexData for a tiled plane
  34822. * @param options an object used to set the following optional parameters for the box, required but can be empty
  34823. * * pattern a limited pattern arrangement depending on the number
  34824. * * tileSize sets the width, height and depth of the tile to the value of size, optional default 1
  34825. * * tileWidth sets the width (x direction) of the tile, overwrites the width set by size, optional, default size
  34826. * * tileHeight sets the height (y direction) of the tile, overwrites the height set by size, optional, default size
  34827. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  34828. * * 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)
  34829. * * 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)
  34830. * @returns the VertexData of the tiled plane
  34831. */
  34832. static CreateTiledPlane(options: {
  34833. pattern?: number;
  34834. tileSize?: number;
  34835. tileWidth?: number;
  34836. tileHeight?: number;
  34837. size?: number;
  34838. width?: number;
  34839. height?: number;
  34840. alignHorizontal?: number;
  34841. alignVertical?: number;
  34842. sideOrientation?: number;
  34843. frontUVs?: Vector4;
  34844. backUVs?: Vector4;
  34845. }): VertexData;
  34846. /**
  34847. * Creates the VertexData for an ellipsoid, defaults to a sphere
  34848. * @param options an object used to set the following optional parameters for the box, required but can be empty
  34849. * * segments sets the number of horizontal strips optional, default 32
  34850. * * diameter sets the axes dimensions, diameterX, diameterY and diameterZ to the value of diameter, optional default 1
  34851. * * diameterX sets the diameterX (x direction) of the ellipsoid, overwrites the diameterX set by diameter, optional, default diameter
  34852. * * diameterY sets the diameterY (y direction) of the ellipsoid, overwrites the diameterY set by diameter, optional, default diameter
  34853. * * diameterZ sets the diameterZ (z direction) of the ellipsoid, overwrites the diameterZ set by diameter, optional, default diameter
  34854. * * 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
  34855. * * 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
  34856. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  34857. * * 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)
  34858. * * 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)
  34859. * @returns the VertexData of the ellipsoid
  34860. */
  34861. static CreateSphere(options: {
  34862. segments?: number;
  34863. diameter?: number;
  34864. diameterX?: number;
  34865. diameterY?: number;
  34866. diameterZ?: number;
  34867. arc?: number;
  34868. slice?: number;
  34869. sideOrientation?: number;
  34870. frontUVs?: Vector4;
  34871. backUVs?: Vector4;
  34872. }): VertexData;
  34873. /**
  34874. * Creates the VertexData for a cylinder, cone or prism
  34875. * @param options an object used to set the following optional parameters for the box, required but can be empty
  34876. * * height sets the height (y direction) of the cylinder, optional, default 2
  34877. * * diameterTop sets the diameter of the top of the cone, overwrites diameter, optional, default diameter
  34878. * * diameterBottom sets the diameter of the bottom of the cone, overwrites diameter, optional, default diameter
  34879. * * diameter sets the diameter of the top and bottom of the cone, optional default 1
  34880. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  34881. * * subdivisions` the number of rings along the cylinder height, optional, default 1
  34882. * * 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
  34883. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  34884. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  34885. * * hasRings when true makes each subdivision independantly treated as a face for faceUV and faceColors, optional, default false
  34886. * * enclose when true closes an open cylinder by adding extra flat faces between the height axis and vertical edges, think cut cake
  34887. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  34888. * * 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)
  34889. * * 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)
  34890. * @returns the VertexData of the cylinder, cone or prism
  34891. */
  34892. static CreateCylinder(options: {
  34893. height?: number;
  34894. diameterTop?: number;
  34895. diameterBottom?: number;
  34896. diameter?: number;
  34897. tessellation?: number;
  34898. subdivisions?: number;
  34899. arc?: number;
  34900. faceColors?: Color4[];
  34901. faceUV?: Vector4[];
  34902. hasRings?: boolean;
  34903. enclose?: boolean;
  34904. sideOrientation?: number;
  34905. frontUVs?: Vector4;
  34906. backUVs?: Vector4;
  34907. }): VertexData;
  34908. /**
  34909. * Creates the VertexData for a torus
  34910. * @param options an object used to set the following optional parameters for the box, required but can be empty
  34911. * * diameter the diameter of the torus, optional default 1
  34912. * * thickness the diameter of the tube forming the torus, optional default 0.5
  34913. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  34914. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  34915. * * 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)
  34916. * * 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)
  34917. * @returns the VertexData of the torus
  34918. */
  34919. static CreateTorus(options: {
  34920. diameter?: number;
  34921. thickness?: number;
  34922. tessellation?: number;
  34923. sideOrientation?: number;
  34924. frontUVs?: Vector4;
  34925. backUVs?: Vector4;
  34926. }): VertexData;
  34927. /**
  34928. * Creates the VertexData of the LineSystem
  34929. * @param options an object used to set the following optional parameters for the LineSystem, required but can be empty
  34930. * - lines an array of lines, each line being an array of successive Vector3
  34931. * - colors an array of line colors, each of the line colors being an array of successive Color4, one per line point
  34932. * @returns the VertexData of the LineSystem
  34933. */
  34934. static CreateLineSystem(options: {
  34935. lines: Vector3[][];
  34936. colors?: Nullable<Color4[][]>;
  34937. }): VertexData;
  34938. /**
  34939. * Create the VertexData for a DashedLines
  34940. * @param options an object used to set the following optional parameters for the DashedLines, required but can be empty
  34941. * - points an array successive Vector3
  34942. * - dashSize the size of the dashes relative to the dash number, optional, default 3
  34943. * - gapSize the size of the gap between two successive dashes relative to the dash number, optional, default 1
  34944. * - dashNb the intended total number of dashes, optional, default 200
  34945. * @returns the VertexData for the DashedLines
  34946. */
  34947. static CreateDashedLines(options: {
  34948. points: Vector3[];
  34949. dashSize?: number;
  34950. gapSize?: number;
  34951. dashNb?: number;
  34952. }): VertexData;
  34953. /**
  34954. * Creates the VertexData for a Ground
  34955. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  34956. * - width the width (x direction) of the ground, optional, default 1
  34957. * - height the height (z direction) of the ground, optional, default 1
  34958. * - subdivisions the number of subdivisions per side, optional, default 1
  34959. * @returns the VertexData of the Ground
  34960. */
  34961. static CreateGround(options: {
  34962. width?: number;
  34963. height?: number;
  34964. subdivisions?: number;
  34965. subdivisionsX?: number;
  34966. subdivisionsY?: number;
  34967. }): VertexData;
  34968. /**
  34969. * Creates the VertexData for a TiledGround by subdividing the ground into tiles
  34970. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  34971. * * xmin the ground minimum X coordinate, optional, default -1
  34972. * * zmin the ground minimum Z coordinate, optional, default -1
  34973. * * xmax the ground maximum X coordinate, optional, default 1
  34974. * * zmax the ground maximum Z coordinate, optional, default 1
  34975. * * 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}
  34976. * * 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}
  34977. * @returns the VertexData of the TiledGround
  34978. */
  34979. static CreateTiledGround(options: {
  34980. xmin: number;
  34981. zmin: number;
  34982. xmax: number;
  34983. zmax: number;
  34984. subdivisions?: {
  34985. w: number;
  34986. h: number;
  34987. };
  34988. precision?: {
  34989. w: number;
  34990. h: number;
  34991. };
  34992. }): VertexData;
  34993. /**
  34994. * Creates the VertexData of the Ground designed from a heightmap
  34995. * @param options an object used to set the following parameters for the Ground, required and provided by MeshBuilder.CreateGroundFromHeightMap
  34996. * * width the width (x direction) of the ground
  34997. * * height the height (z direction) of the ground
  34998. * * subdivisions the number of subdivisions per side
  34999. * * minHeight the minimum altitude on the ground, optional, default 0
  35000. * * maxHeight the maximum altitude on the ground, optional default 1
  35001. * * colorFilter the filter to apply to the image pixel colors to compute the height, optional Color3, default (0.3, 0.59, 0.11)
  35002. * * buffer the array holding the image color data
  35003. * * bufferWidth the width of image
  35004. * * bufferHeight the height of image
  35005. * * alphaFilter Remove any data where the alpha channel is below this value, defaults 0 (all data visible)
  35006. * @returns the VertexData of the Ground designed from a heightmap
  35007. */
  35008. static CreateGroundFromHeightMap(options: {
  35009. width: number;
  35010. height: number;
  35011. subdivisions: number;
  35012. minHeight: number;
  35013. maxHeight: number;
  35014. colorFilter: Color3;
  35015. buffer: Uint8Array;
  35016. bufferWidth: number;
  35017. bufferHeight: number;
  35018. alphaFilter: number;
  35019. }): VertexData;
  35020. /**
  35021. * Creates the VertexData for a Plane
  35022. * @param options an object used to set the following optional parameters for the plane, required but can be empty
  35023. * * size sets the width and height of the plane to the value of size, optional default 1
  35024. * * width sets the width (x direction) of the plane, overwrites the width set by size, optional, default size
  35025. * * height sets the height (y direction) of the plane, overwrites the height set by size, optional, default size
  35026. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  35027. * * 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)
  35028. * * 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)
  35029. * @returns the VertexData of the box
  35030. */
  35031. static CreatePlane(options: {
  35032. size?: number;
  35033. width?: number;
  35034. height?: number;
  35035. sideOrientation?: number;
  35036. frontUVs?: Vector4;
  35037. backUVs?: Vector4;
  35038. }): VertexData;
  35039. /**
  35040. * Creates the VertexData of the Disc or regular Polygon
  35041. * @param options an object used to set the following optional parameters for the disc, required but can be empty
  35042. * * radius the radius of the disc, optional default 0.5
  35043. * * tessellation the number of polygon sides, optional, default 64
  35044. * * 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
  35045. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  35046. * * 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)
  35047. * * 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)
  35048. * @returns the VertexData of the box
  35049. */
  35050. static CreateDisc(options: {
  35051. radius?: number;
  35052. tessellation?: number;
  35053. arc?: number;
  35054. sideOrientation?: number;
  35055. frontUVs?: Vector4;
  35056. backUVs?: Vector4;
  35057. }): VertexData;
  35058. /**
  35059. * Creates the VertexData for an irregular Polygon in the XoZ plane using a mesh built by polygonTriangulation.build()
  35060. * All parameters are provided by MeshBuilder.CreatePolygon as needed
  35061. * @param polygon a mesh built from polygonTriangulation.build()
  35062. * @param sideOrientation takes the values Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  35063. * @param fUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  35064. * @param fColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  35065. * @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)
  35066. * @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)
  35067. * @param wrap a boolean, default false, when true and fUVs used texture is wrapped around all sides, when false texture is applied side
  35068. * @returns the VertexData of the Polygon
  35069. */
  35070. static CreatePolygon(polygon: Mesh, sideOrientation: number, fUV?: Vector4[], fColors?: Color4[], frontUVs?: Vector4, backUVs?: Vector4, wrap?: boolean): VertexData;
  35071. /**
  35072. * Creates the VertexData of the IcoSphere
  35073. * @param options an object used to set the following optional parameters for the IcoSphere, required but can be empty
  35074. * * radius the radius of the IcoSphere, optional default 1
  35075. * * radiusX allows stretching in the x direction, optional, default radius
  35076. * * radiusY allows stretching in the y direction, optional, default radius
  35077. * * radiusZ allows stretching in the z direction, optional, default radius
  35078. * * flat when true creates a flat shaded mesh, optional, default true
  35079. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  35080. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  35081. * * 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)
  35082. * * 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)
  35083. * @returns the VertexData of the IcoSphere
  35084. */
  35085. static CreateIcoSphere(options: {
  35086. radius?: number;
  35087. radiusX?: number;
  35088. radiusY?: number;
  35089. radiusZ?: number;
  35090. flat?: boolean;
  35091. subdivisions?: number;
  35092. sideOrientation?: number;
  35093. frontUVs?: Vector4;
  35094. backUVs?: Vector4;
  35095. }): VertexData;
  35096. /**
  35097. * Creates the VertexData for a Polyhedron
  35098. * @param options an object used to set the following optional parameters for the polyhedron, required but can be empty
  35099. * * type provided types are:
  35100. * * 0 : Tetrahedron, 1 : Octahedron, 2 : Dodecahedron, 3 : Icosahedron, 4 : Rhombicuboctahedron, 5 : Triangular Prism, 6 : Pentagonal Prism, 7 : Hexagonal Prism, 8 : Square Pyramid (J1)
  35101. * * 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)
  35102. * * size the size of the IcoSphere, optional default 1
  35103. * * sizeX allows stretching in the x direction, optional, default size
  35104. * * sizeY allows stretching in the y direction, optional, default size
  35105. * * sizeZ allows stretching in the z direction, optional, default size
  35106. * * 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
  35107. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  35108. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  35109. * * flat when true creates a flat shaded mesh, optional, default true
  35110. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  35111. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  35112. * * 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)
  35113. * * 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)
  35114. * @returns the VertexData of the Polyhedron
  35115. */
  35116. static CreatePolyhedron(options: {
  35117. type?: number;
  35118. size?: number;
  35119. sizeX?: number;
  35120. sizeY?: number;
  35121. sizeZ?: number;
  35122. custom?: any;
  35123. faceUV?: Vector4[];
  35124. faceColors?: Color4[];
  35125. flat?: boolean;
  35126. sideOrientation?: number;
  35127. frontUVs?: Vector4;
  35128. backUVs?: Vector4;
  35129. }): VertexData;
  35130. /**
  35131. * Creates the VertexData for a Capsule, inspired from https://github.com/maximeq/three-js-capsule-geometry/blob/master/src/CapsuleBufferGeometry.js
  35132. * @param options an object used to set the following optional parameters for the capsule, required but can be empty
  35133. * @returns the VertexData of the Capsule
  35134. */
  35135. static CreateCapsule(options?: ICreateCapsuleOptions): VertexData;
  35136. /**
  35137. * Creates the VertexData for a TorusKnot
  35138. * @param options an object used to set the following optional parameters for the TorusKnot, required but can be empty
  35139. * * radius the radius of the torus knot, optional, default 2
  35140. * * tube the thickness of the tube, optional, default 0.5
  35141. * * radialSegments the number of sides on each tube segments, optional, default 32
  35142. * * tubularSegments the number of tubes to decompose the knot into, optional, default 32
  35143. * * p the number of windings around the z axis, optional, default 2
  35144. * * q the number of windings around the x axis, optional, default 3
  35145. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  35146. * * frontUvs only usable when you create a double-sided mesh, used to choose what parts of the texture image to crop and apply on the front side, optional, default vector4 (0, 0, 1, 1)
  35147. * * backUVs only usable when you create a double-sided mesh, used to choose what parts of the texture image to crop and apply on the back side, optional, default vector4 (0, 0, 1, 1)
  35148. * @returns the VertexData of the Torus Knot
  35149. */
  35150. static CreateTorusKnot(options: {
  35151. radius?: number;
  35152. tube?: number;
  35153. radialSegments?: number;
  35154. tubularSegments?: number;
  35155. p?: number;
  35156. q?: number;
  35157. sideOrientation?: number;
  35158. frontUVs?: Vector4;
  35159. backUVs?: Vector4;
  35160. }): VertexData;
  35161. /**
  35162. * Compute normals for given positions and indices
  35163. * @param positions an array of vertex positions, [...., x, y, z, ......]
  35164. * @param indices an array of indices in groups of three for each triangular facet, [...., i, j, k, ......]
  35165. * @param normals an array of vertex normals, [...., x, y, z, ......]
  35166. * @param options an object used to set the following optional parameters for the TorusKnot, optional
  35167. * * facetNormals : optional array of facet normals (vector3)
  35168. * * facetPositions : optional array of facet positions (vector3)
  35169. * * facetPartitioning : optional partitioning array. facetPositions is required for facetPartitioning computation
  35170. * * ratio : optional partitioning ratio / bounding box, required for facetPartitioning computation
  35171. * * bInfo : optional bounding info, required for facetPartitioning computation
  35172. * * bbSize : optional bounding box size data, required for facetPartitioning computation
  35173. * * subDiv : optional partitioning data about subdivisions on each axis (int), required for facetPartitioning computation
  35174. * * useRightHandedSystem: optional boolean to for right handed system computation
  35175. * * depthSort : optional boolean to enable the facet depth sort computation
  35176. * * distanceTo : optional Vector3 to compute the facet depth from this location
  35177. * * depthSortedFacets : optional array of depthSortedFacets to store the facet distances from the reference location
  35178. */
  35179. static ComputeNormals(positions: any, indices: any, normals: any, options?: {
  35180. facetNormals?: any;
  35181. facetPositions?: any;
  35182. facetPartitioning?: any;
  35183. ratio?: number;
  35184. bInfo?: any;
  35185. bbSize?: Vector3;
  35186. subDiv?: any;
  35187. useRightHandedSystem?: boolean;
  35188. depthSort?: boolean;
  35189. distanceTo?: Vector3;
  35190. depthSortedFacets?: any;
  35191. }): void;
  35192. /** @hidden */
  35193. static _ComputeSides(sideOrientation: number, positions: FloatArray, indices: FloatArray, normals: FloatArray, uvs: FloatArray, frontUVs?: Vector4, backUVs?: Vector4): void;
  35194. /**
  35195. * Applies VertexData created from the imported parameters to the geometry
  35196. * @param parsedVertexData the parsed data from an imported file
  35197. * @param geometry the geometry to apply the VertexData to
  35198. */
  35199. static ImportVertexData(parsedVertexData: any, geometry: Geometry): void;
  35200. }
  35201. }
  35202. declare module BABYLON {
  35203. /**
  35204. * Class containing static functions to help procedurally build meshes
  35205. */
  35206. export class DiscBuilder {
  35207. /**
  35208. * Creates a plane polygonal mesh. By default, this is a disc
  35209. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  35210. * * 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
  35211. * * 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
  35212. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  35213. * * 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
  35214. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  35215. * @param name defines the name of the mesh
  35216. * @param options defines the options used to create the mesh
  35217. * @param scene defines the hosting scene
  35218. * @returns the plane polygonal mesh
  35219. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  35220. */
  35221. static CreateDisc(name: string, options: {
  35222. radius?: number;
  35223. tessellation?: number;
  35224. arc?: number;
  35225. updatable?: boolean;
  35226. sideOrientation?: number;
  35227. frontUVs?: Vector4;
  35228. backUVs?: Vector4;
  35229. }, scene?: Nullable<Scene>): Mesh;
  35230. }
  35231. }
  35232. declare module BABYLON {
  35233. /**
  35234. * The SPS is a single updatable mesh. The solid particles are simply separate parts or faces fo this big mesh.
  35235. *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.
  35236. * The SPS is also a particle system. It provides some methods to manage the particles.
  35237. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  35238. *
  35239. * Full documentation here : https://doc.babylonjs.com/how_to/Solid_Particle_System
  35240. */
  35241. export class SolidParticleSystem implements IDisposable {
  35242. /**
  35243. * The SPS array of Solid Particle objects. Just access each particle as with any classic array.
  35244. * Example : var p = SPS.particles[i];
  35245. */
  35246. particles: SolidParticle[];
  35247. /**
  35248. * The SPS total number of particles. Read only. Use SPS.counter instead if you need to set your own value.
  35249. */
  35250. nbParticles: number;
  35251. /**
  35252. * If the particles must ever face the camera (default false). Useful for planar particles.
  35253. */
  35254. billboard: boolean;
  35255. /**
  35256. * Recompute normals when adding a shape
  35257. */
  35258. recomputeNormals: boolean;
  35259. /**
  35260. * This a counter ofr your own usage. It's not set by any SPS functions.
  35261. */
  35262. counter: number;
  35263. /**
  35264. * The SPS name. This name is also given to the underlying mesh.
  35265. */
  35266. name: string;
  35267. /**
  35268. * The SPS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are available.
  35269. */
  35270. mesh: Mesh;
  35271. /**
  35272. * This empty object is intended to store some SPS specific or temporary values in order to lower the Garbage Collector activity.
  35273. * Please read : https://doc.babylonjs.com/how_to/Solid_Particle_System#garbage-collector-concerns
  35274. */
  35275. vars: any;
  35276. /**
  35277. * This array is populated when the SPS is set as 'pickable'.
  35278. * Each key of this array is a `faceId` value that you can get from a pickResult object.
  35279. * Each element of this array is an object `{idx: int, faceId: int}`.
  35280. * `idx` is the picked particle index in the `SPS.particles` array
  35281. * `faceId` is the picked face index counted within this particle.
  35282. * This array is the first element of the pickedBySubMesh array : sps.pickBySubMesh[0].
  35283. * It's not pertinent to use it when using a SPS with the support for MultiMaterial enabled.
  35284. * Use the method SPS.pickedParticle(pickingInfo) instead.
  35285. * Please read : https://doc.babylonjs.com/how_to/Solid_Particle_System#pickable-particles
  35286. */
  35287. pickedParticles: {
  35288. idx: number;
  35289. faceId: number;
  35290. }[];
  35291. /**
  35292. * This array is populated when the SPS is set as 'pickable'
  35293. * Each key of this array is a submesh index.
  35294. * Each element of this array is a second array defined like this :
  35295. * Each key of this second array is a `faceId` value that you can get from a pickResult object.
  35296. * Each element of this second array is an object `{idx: int, faceId: int}`.
  35297. * `idx` is the picked particle index in the `SPS.particles` array
  35298. * `faceId` is the picked face index counted within this particle.
  35299. * It's better to use the method SPS.pickedParticle(pickingInfo) rather than using directly this array.
  35300. * Please read : https://doc.babylonjs.com/how_to/Solid_Particle_System#pickable-particles
  35301. */
  35302. pickedBySubMesh: {
  35303. idx: number;
  35304. faceId: number;
  35305. }[][];
  35306. /**
  35307. * This array is populated when `enableDepthSort` is set to true.
  35308. * Each element of this array is an instance of the class DepthSortedParticle.
  35309. */
  35310. depthSortedParticles: DepthSortedParticle[];
  35311. /**
  35312. * If the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster). (Internal use only)
  35313. * @hidden
  35314. */
  35315. _bSphereOnly: boolean;
  35316. /**
  35317. * A number to multiply the bounding sphere radius by in order to reduce it for instance. (Internal use only)
  35318. * @hidden
  35319. */
  35320. _bSphereRadiusFactor: number;
  35321. private _scene;
  35322. private _positions;
  35323. private _indices;
  35324. private _normals;
  35325. private _colors;
  35326. private _uvs;
  35327. private _indices32;
  35328. private _positions32;
  35329. private _normals32;
  35330. private _fixedNormal32;
  35331. private _colors32;
  35332. private _uvs32;
  35333. private _index;
  35334. private _updatable;
  35335. private _pickable;
  35336. private _isVisibilityBoxLocked;
  35337. private _alwaysVisible;
  35338. private _depthSort;
  35339. private _expandable;
  35340. private _shapeCounter;
  35341. private _copy;
  35342. private _color;
  35343. private _computeParticleColor;
  35344. private _computeParticleTexture;
  35345. private _computeParticleRotation;
  35346. private _computeParticleVertex;
  35347. private _computeBoundingBox;
  35348. private _depthSortParticles;
  35349. private _camera;
  35350. private _mustUnrotateFixedNormals;
  35351. private _particlesIntersect;
  35352. private _needs32Bits;
  35353. private _isNotBuilt;
  35354. private _lastParticleId;
  35355. private _idxOfId;
  35356. private _multimaterialEnabled;
  35357. private _useModelMaterial;
  35358. private _indicesByMaterial;
  35359. private _materialIndexes;
  35360. private _depthSortFunction;
  35361. private _materialSortFunction;
  35362. private _materials;
  35363. private _multimaterial;
  35364. private _materialIndexesById;
  35365. private _defaultMaterial;
  35366. private _autoUpdateSubMeshes;
  35367. private _tmpVertex;
  35368. /**
  35369. * Creates a SPS (Solid Particle System) object.
  35370. * @param name (String) is the SPS name, this will be the underlying mesh name.
  35371. * @param scene (Scene) is the scene in which the SPS is added.
  35372. * @param options defines the options of the sps e.g.
  35373. * * updatable (optional boolean, default true) : if the SPS must be updatable or immutable.
  35374. * * isPickable (optional boolean, default false) : if the solid particles must be pickable.
  35375. * * enableDepthSort (optional boolean, default false) : if the solid particles must be sorted in the geometry according to their distance to the camera.
  35376. * * useModelMaterial (optional boolean, default false) : if the model materials must be used to create the SPS multimaterial. This enables the multimaterial supports of the SPS.
  35377. * * enableMultiMaterial (optional boolean, default false) : if the solid particles can be given different materials.
  35378. * * expandable (optional boolean, default false) : if particles can still be added after the initial SPS mesh creation.
  35379. * * particleIntersection (optional boolean, default false) : if the solid particle intersections must be computed.
  35380. * * boundingSphereOnly (optional boolean, default false) : if the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster).
  35381. * * bSphereRadiusFactor (optional float, default 1.0) : a number to multiply the bounding sphere radius by in order to reduce it for instance.
  35382. * @example bSphereRadiusFactor = 1.0 / Math.sqrt(3.0) => the bounding sphere exactly matches a spherical mesh.
  35383. */
  35384. constructor(name: string, scene: Scene, options?: {
  35385. updatable?: boolean;
  35386. isPickable?: boolean;
  35387. enableDepthSort?: boolean;
  35388. particleIntersection?: boolean;
  35389. boundingSphereOnly?: boolean;
  35390. bSphereRadiusFactor?: number;
  35391. expandable?: boolean;
  35392. useModelMaterial?: boolean;
  35393. enableMultiMaterial?: boolean;
  35394. });
  35395. /**
  35396. * Builds the SPS underlying mesh. Returns a standard Mesh.
  35397. * If no model shape was added to the SPS, the returned mesh is just a single triangular plane.
  35398. * @returns the created mesh
  35399. */
  35400. buildMesh(): Mesh;
  35401. /**
  35402. * Digests the mesh and generates as many solid particles in the system as wanted. Returns the SPS.
  35403. * These particles will have the same geometry than the mesh parts and will be positioned at the same localisation than the mesh original places.
  35404. * Thus the particles generated from `digest()` have their property `position` set yet.
  35405. * @param mesh ( Mesh ) is the mesh to be digested
  35406. * @param options {facetNb} (optional integer, default 1) is the number of mesh facets per particle, this parameter is overridden by the parameter `number` if any
  35407. * {delta} (optional integer, default 0) is the random extra number of facets per particle , each particle will have between `facetNb` and `facetNb + delta` facets
  35408. * {number} (optional positive integer) is the wanted number of particles : each particle is built with `mesh_total_facets / number` facets
  35409. * {storage} (optional existing array) is an array where the particles will be stored for a further use instead of being inserted in the SPS.
  35410. * @returns the current SPS
  35411. */
  35412. digest(mesh: Mesh, options?: {
  35413. facetNb?: number;
  35414. number?: number;
  35415. delta?: number;
  35416. storage?: [];
  35417. }): SolidParticleSystem;
  35418. /**
  35419. * Unrotate the fixed normals in case the mesh was built with pre-rotated particles, ex : use of positionFunction in addShape()
  35420. * @hidden
  35421. */
  35422. private _unrotateFixedNormals;
  35423. /**
  35424. * Resets the temporary working copy particle
  35425. * @hidden
  35426. */
  35427. private _resetCopy;
  35428. /**
  35429. * Inserts the shape model geometry in the global SPS mesh by updating the positions, indices, normals, colors, uvs arrays
  35430. * @param p the current index in the positions array to be updated
  35431. * @param ind the current index in the indices array
  35432. * @param shape a Vector3 array, the shape geometry
  35433. * @param positions the positions array to be updated
  35434. * @param meshInd the shape indices array
  35435. * @param indices the indices array to be updated
  35436. * @param meshUV the shape uv array
  35437. * @param uvs the uv array to be updated
  35438. * @param meshCol the shape color array
  35439. * @param colors the color array to be updated
  35440. * @param meshNor the shape normals array
  35441. * @param normals the normals array to be updated
  35442. * @param idx the particle index
  35443. * @param idxInShape the particle index in its shape
  35444. * @param options the addShape() method passed options
  35445. * @model the particle model
  35446. * @hidden
  35447. */
  35448. private _meshBuilder;
  35449. /**
  35450. * Returns a shape Vector3 array from positions float array
  35451. * @param positions float array
  35452. * @returns a vector3 array
  35453. * @hidden
  35454. */
  35455. private _posToShape;
  35456. /**
  35457. * Returns a shapeUV array from a float uvs (array deep copy)
  35458. * @param uvs as a float array
  35459. * @returns a shapeUV array
  35460. * @hidden
  35461. */
  35462. private _uvsToShapeUV;
  35463. /**
  35464. * Adds a new particle object in the particles array
  35465. * @param idx particle index in particles array
  35466. * @param id particle id
  35467. * @param idxpos positionIndex : the starting index of the particle vertices in the SPS "positions" array
  35468. * @param idxind indiceIndex : he starting index of the particle indices in the SPS "indices" array
  35469. * @param model particle ModelShape object
  35470. * @param shapeId model shape identifier
  35471. * @param idxInShape index of the particle in the current model
  35472. * @param bInfo model bounding info object
  35473. * @param storage target storage array, if any
  35474. * @hidden
  35475. */
  35476. private _addParticle;
  35477. /**
  35478. * Adds some particles to the SPS from the model shape. Returns the shape id.
  35479. * Please read the doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#create-an-immutable-sps
  35480. * @param mesh is any Mesh object that will be used as a model for the solid particles.
  35481. * @param nb (positive integer) the number of particles to be created from this model
  35482. * @param options {positionFunction} is an optional javascript function to called for each particle on SPS creation.
  35483. * {vertexFunction} is an optional javascript function to called for each vertex of each particle on SPS creation
  35484. * {storage} (optional existing array) is an array where the particles will be stored for a further use instead of being inserted in the SPS.
  35485. * @returns the number of shapes in the system
  35486. */
  35487. addShape(mesh: Mesh, nb: number, options?: {
  35488. positionFunction?: any;
  35489. vertexFunction?: any;
  35490. storage?: [];
  35491. }): number;
  35492. /**
  35493. * Rebuilds a particle back to its just built status : if needed, recomputes the custom positions and vertices
  35494. * @hidden
  35495. */
  35496. private _rebuildParticle;
  35497. /**
  35498. * Rebuilds the whole mesh and updates the VBO : custom positions and vertices are recomputed if needed.
  35499. * @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.
  35500. * @returns the SPS.
  35501. */
  35502. rebuildMesh(reset?: boolean): SolidParticleSystem;
  35503. /** Removes the particles from the start-th to the end-th included from an expandable SPS (required).
  35504. * Returns an array with the removed particles.
  35505. * 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.
  35506. * The SPS can't be empty so at least one particle needs to remain in place.
  35507. * Under the hood, the VertexData array, so the VBO buffer, is recreated each call.
  35508. * @param start index of the first particle to remove
  35509. * @param end index of the last particle to remove (included)
  35510. * @returns an array populated with the removed particles
  35511. */
  35512. removeParticles(start: number, end: number): SolidParticle[];
  35513. /**
  35514. * Inserts some pre-created particles in the solid particle system so that they can be managed by setParticles().
  35515. * @param solidParticleArray an array populated with Solid Particles objects
  35516. * @returns the SPS
  35517. */
  35518. insertParticlesFromArray(solidParticleArray: SolidParticle[]): SolidParticleSystem;
  35519. /**
  35520. * Creates a new particle and modifies the SPS mesh geometry :
  35521. * - calls _meshBuilder() to increase the SPS mesh geometry step by step
  35522. * - calls _addParticle() to populate the particle array
  35523. * factorized code from addShape() and insertParticlesFromArray()
  35524. * @param idx particle index in the particles array
  35525. * @param i particle index in its shape
  35526. * @param modelShape particle ModelShape object
  35527. * @param shape shape vertex array
  35528. * @param meshInd shape indices array
  35529. * @param meshUV shape uv array
  35530. * @param meshCol shape color array
  35531. * @param meshNor shape normals array
  35532. * @param bbInfo shape bounding info
  35533. * @param storage target particle storage
  35534. * @options addShape() passed options
  35535. * @hidden
  35536. */
  35537. private _insertNewParticle;
  35538. /**
  35539. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  35540. * This method calls `updateParticle()` for each particle of the SPS.
  35541. * For an animated SPS, it is usually called within the render loop.
  35542. * 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.
  35543. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  35544. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  35545. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  35546. * @returns the SPS.
  35547. */
  35548. setParticles(start?: number, end?: number, update?: boolean): SolidParticleSystem;
  35549. /**
  35550. * Disposes the SPS.
  35551. */
  35552. dispose(): void;
  35553. /** Returns an object {idx: number faceId: number} for the picked particle from the passed pickingInfo object.
  35554. * idx is the particle index in the SPS
  35555. * faceId is the picked face index counted within this particle.
  35556. * Returns null if the pickInfo can't identify a picked particle.
  35557. * @param pickingInfo (PickingInfo object)
  35558. * @returns {idx: number, faceId: number} or null
  35559. */
  35560. pickedParticle(pickingInfo: PickingInfo): Nullable<{
  35561. idx: number;
  35562. faceId: number;
  35563. }>;
  35564. /**
  35565. * Returns a SolidParticle object from its identifier : particle.id
  35566. * @param id (integer) the particle Id
  35567. * @returns the searched particle or null if not found in the SPS.
  35568. */
  35569. getParticleById(id: number): Nullable<SolidParticle>;
  35570. /**
  35571. * Returns a new array populated with the particles having the passed shapeId.
  35572. * @param shapeId (integer) the shape identifier
  35573. * @returns a new solid particle array
  35574. */
  35575. getParticlesByShapeId(shapeId: number): SolidParticle[];
  35576. /**
  35577. * Populates the passed array "ref" with the particles having the passed shapeId.
  35578. * @param shapeId the shape identifier
  35579. * @returns the SPS
  35580. * @param ref
  35581. */
  35582. getParticlesByShapeIdToRef(shapeId: number, ref: SolidParticle[]): SolidParticleSystem;
  35583. /**
  35584. * Computes the required SubMeshes according the materials assigned to the particles.
  35585. * @returns the solid particle system.
  35586. * Does nothing if called before the SPS mesh is built.
  35587. */
  35588. computeSubMeshes(): SolidParticleSystem;
  35589. /**
  35590. * Sorts the solid particles by material when MultiMaterial is enabled.
  35591. * Updates the indices32 array.
  35592. * Updates the indicesByMaterial array.
  35593. * Updates the mesh indices array.
  35594. * @returns the SPS
  35595. * @hidden
  35596. */
  35597. private _sortParticlesByMaterial;
  35598. /**
  35599. * Sets the material indexes by id materialIndexesById[id] = materialIndex
  35600. * @hidden
  35601. */
  35602. private _setMaterialIndexesById;
  35603. /**
  35604. * Returns an array with unique values of Materials from the passed array
  35605. * @param array the material array to be checked and filtered
  35606. * @hidden
  35607. */
  35608. private _filterUniqueMaterialId;
  35609. /**
  35610. * Sets a new Standard Material as _defaultMaterial if not already set.
  35611. * @hidden
  35612. */
  35613. private _setDefaultMaterial;
  35614. /**
  35615. * Visibility helper : Recomputes the visible size according to the mesh bounding box
  35616. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  35617. * @returns the SPS.
  35618. */
  35619. refreshVisibleSize(): SolidParticleSystem;
  35620. /**
  35621. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  35622. * @param size the size (float) of the visibility box
  35623. * note : this doesn't lock the SPS mesh bounding box.
  35624. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  35625. */
  35626. setVisibilityBox(size: number): void;
  35627. /**
  35628. * Gets whether the SPS as always visible or not
  35629. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  35630. */
  35631. get isAlwaysVisible(): boolean;
  35632. /**
  35633. * Sets the SPS as always visible or not
  35634. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  35635. */
  35636. set isAlwaysVisible(val: boolean);
  35637. /**
  35638. * Sets the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  35639. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  35640. */
  35641. set isVisibilityBoxLocked(val: boolean);
  35642. /**
  35643. * Gets if the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  35644. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  35645. */
  35646. get isVisibilityBoxLocked(): boolean;
  35647. /**
  35648. * Tells to `setParticles()` to compute the particle rotations or not.
  35649. * Default value : true. The SPS is faster when it's set to false.
  35650. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  35651. */
  35652. set computeParticleRotation(val: boolean);
  35653. /**
  35654. * Tells to `setParticles()` to compute the particle colors or not.
  35655. * Default value : true. The SPS is faster when it's set to false.
  35656. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  35657. */
  35658. set computeParticleColor(val: boolean);
  35659. set computeParticleTexture(val: boolean);
  35660. /**
  35661. * Tells to `setParticles()` to call the vertex function for each vertex of each particle, or not.
  35662. * Default value : false. The SPS is faster when it's set to false.
  35663. * Note : the particle custom vertex positions aren't stored values.
  35664. */
  35665. set computeParticleVertex(val: boolean);
  35666. /**
  35667. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  35668. */
  35669. set computeBoundingBox(val: boolean);
  35670. /**
  35671. * Tells to `setParticles()` to sort or not the distance between each particle and the camera.
  35672. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  35673. * Default : `true`
  35674. */
  35675. set depthSortParticles(val: boolean);
  35676. /**
  35677. * Gets if `setParticles()` computes the particle rotations or not.
  35678. * Default value : true. The SPS is faster when it's set to false.
  35679. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  35680. */
  35681. get computeParticleRotation(): boolean;
  35682. /**
  35683. * Gets if `setParticles()` computes the particle colors or not.
  35684. * Default value : true. The SPS is faster when it's set to false.
  35685. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  35686. */
  35687. get computeParticleColor(): boolean;
  35688. /**
  35689. * Gets if `setParticles()` computes the particle textures or not.
  35690. * Default value : true. The SPS is faster when it's set to false.
  35691. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  35692. */
  35693. get computeParticleTexture(): boolean;
  35694. /**
  35695. * Gets if `setParticles()` calls the vertex function for each vertex of each particle, or not.
  35696. * Default value : false. The SPS is faster when it's set to false.
  35697. * Note : the particle custom vertex positions aren't stored values.
  35698. */
  35699. get computeParticleVertex(): boolean;
  35700. /**
  35701. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  35702. */
  35703. get computeBoundingBox(): boolean;
  35704. /**
  35705. * Gets if `setParticles()` sorts or not the distance between each particle and the camera.
  35706. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  35707. * Default : `true`
  35708. */
  35709. get depthSortParticles(): boolean;
  35710. /**
  35711. * Gets if the SPS is created as expandable at construction time.
  35712. * Default : `false`
  35713. */
  35714. get expandable(): boolean;
  35715. /**
  35716. * Gets if the SPS supports the Multi Materials
  35717. */
  35718. get multimaterialEnabled(): boolean;
  35719. /**
  35720. * Gets if the SPS uses the model materials for its own multimaterial.
  35721. */
  35722. get useModelMaterial(): boolean;
  35723. /**
  35724. * The SPS used material array.
  35725. */
  35726. get materials(): Material[];
  35727. /**
  35728. * Sets the SPS MultiMaterial from the passed materials.
  35729. * Note : the passed array is internally copied and not used then by reference.
  35730. * @param materials an array of material objects. This array indexes are the materialIndex values of the particles.
  35731. */
  35732. setMultiMaterial(materials: Material[]): void;
  35733. /**
  35734. * The SPS computed multimaterial object
  35735. */
  35736. get multimaterial(): MultiMaterial;
  35737. set multimaterial(mm: MultiMaterial);
  35738. /**
  35739. * If the subMeshes must be updated on the next call to setParticles()
  35740. */
  35741. get autoUpdateSubMeshes(): boolean;
  35742. set autoUpdateSubMeshes(val: boolean);
  35743. /**
  35744. * This function does nothing. It may be overwritten to set all the particle first values.
  35745. * The SPS doesn't call this function, you may have to call it by your own.
  35746. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  35747. */
  35748. initParticles(): void;
  35749. /**
  35750. * This function does nothing. It may be overwritten to recycle a particle.
  35751. * The SPS doesn't call this function, you may have to call it by your own.
  35752. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  35753. * @param particle The particle to recycle
  35754. * @returns the recycled particle
  35755. */
  35756. recycleParticle(particle: SolidParticle): SolidParticle;
  35757. /**
  35758. * Updates a particle : this function should be overwritten by the user.
  35759. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  35760. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  35761. * @example : just set a particle position or velocity and recycle conditions
  35762. * @param particle The particle to update
  35763. * @returns the updated particle
  35764. */
  35765. updateParticle(particle: SolidParticle): SolidParticle;
  35766. /**
  35767. * Updates a vertex of a particle : it can be overwritten by the user.
  35768. * This will be called on each vertex particle by `setParticles()` if `computeParticleVertex` is set to true only.
  35769. * @param particle the current particle
  35770. * @param vertex the current vertex of the current particle : a SolidParticleVertex object
  35771. * @param pt the index of the current vertex in the particle shape
  35772. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#update-each-particle-shape
  35773. * @example : just set a vertex particle position or color
  35774. * @returns the sps
  35775. */
  35776. updateParticleVertex(particle: SolidParticle, vertex: SolidParticleVertex, pt: number): SolidParticleSystem;
  35777. /**
  35778. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  35779. * This does nothing and may be overwritten by the user.
  35780. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  35781. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  35782. * @param update the boolean update value actually passed to setParticles()
  35783. */
  35784. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  35785. /**
  35786. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  35787. * This will be passed three parameters.
  35788. * This does nothing and may be overwritten by the user.
  35789. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  35790. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  35791. * @param update the boolean update value actually passed to setParticles()
  35792. */
  35793. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  35794. }
  35795. }
  35796. declare module BABYLON {
  35797. /**
  35798. * Represents one particle of a solid particle system.
  35799. */
  35800. export class SolidParticle {
  35801. /**
  35802. * particle global index
  35803. */
  35804. idx: number;
  35805. /**
  35806. * particle identifier
  35807. */
  35808. id: number;
  35809. /**
  35810. * The color of the particle
  35811. */
  35812. color: Nullable<Color4>;
  35813. /**
  35814. * The world space position of the particle.
  35815. */
  35816. position: Vector3;
  35817. /**
  35818. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  35819. */
  35820. rotation: Vector3;
  35821. /**
  35822. * The world space rotation quaternion of the particle.
  35823. */
  35824. rotationQuaternion: Nullable<Quaternion>;
  35825. /**
  35826. * The scaling of the particle.
  35827. */
  35828. scaling: Vector3;
  35829. /**
  35830. * The uvs of the particle.
  35831. */
  35832. uvs: Vector4;
  35833. /**
  35834. * The current speed of the particle.
  35835. */
  35836. velocity: Vector3;
  35837. /**
  35838. * The pivot point in the particle local space.
  35839. */
  35840. pivot: Vector3;
  35841. /**
  35842. * Must the particle be translated from its pivot point in its local space ?
  35843. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  35844. * Default : false
  35845. */
  35846. translateFromPivot: boolean;
  35847. /**
  35848. * Is the particle active or not ?
  35849. */
  35850. alive: boolean;
  35851. /**
  35852. * Is the particle visible or not ?
  35853. */
  35854. isVisible: boolean;
  35855. /**
  35856. * Index of this particle in the global "positions" array (Internal use)
  35857. * @hidden
  35858. */
  35859. _pos: number;
  35860. /**
  35861. * @hidden Index of this particle in the global "indices" array (Internal use)
  35862. */
  35863. _ind: number;
  35864. /**
  35865. * @hidden ModelShape of this particle (Internal use)
  35866. */
  35867. _model: ModelShape;
  35868. /**
  35869. * ModelShape id of this particle
  35870. */
  35871. shapeId: number;
  35872. /**
  35873. * Index of the particle in its shape id
  35874. */
  35875. idxInShape: number;
  35876. /**
  35877. * @hidden Reference to the shape model BoundingInfo object (Internal use)
  35878. */
  35879. _modelBoundingInfo: BoundingInfo;
  35880. /**
  35881. * @hidden Particle BoundingInfo object (Internal use)
  35882. */
  35883. _boundingInfo: BoundingInfo;
  35884. /**
  35885. * @hidden Reference to the SPS what the particle belongs to (Internal use)
  35886. */
  35887. _sps: SolidParticleSystem;
  35888. /**
  35889. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  35890. */
  35891. _stillInvisible: boolean;
  35892. /**
  35893. * @hidden Last computed particle rotation matrix
  35894. */
  35895. _rotationMatrix: number[];
  35896. /**
  35897. * Parent particle Id, if any.
  35898. * Default null.
  35899. */
  35900. parentId: Nullable<number>;
  35901. /**
  35902. * The particle material identifier (integer) when MultiMaterials are enabled in the SPS.
  35903. */
  35904. materialIndex: Nullable<number>;
  35905. /**
  35906. * Custom object or properties.
  35907. */
  35908. props: Nullable<any>;
  35909. /**
  35910. * The culling strategy to use to check whether the solid particle must be culled or not when using isInFrustum().
  35911. * The possible values are :
  35912. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  35913. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  35914. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  35915. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  35916. * The default value for solid particles is AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  35917. * Please read each static variable documentation in the class AbstractMesh to get details about the culling process.
  35918. * */
  35919. cullingStrategy: number;
  35920. /**
  35921. * @hidden Internal global position in the SPS.
  35922. */
  35923. _globalPosition: Vector3;
  35924. /**
  35925. * Creates a Solid Particle object.
  35926. * Don't create particles manually, use instead the Solid Particle System internal tools like _addParticle()
  35927. * @param particleIndex (integer) is the particle index in the Solid Particle System pool.
  35928. * @param particleId (integer) is the particle identifier. Unless some particles are removed from the SPS, it's the same value than the particle idx.
  35929. * @param positionIndex (integer) is the starting index of the particle vertices in the SPS "positions" array.
  35930. * @param indiceIndex (integer) is the starting index of the particle indices in the SPS "indices" array.
  35931. * @param model (ModelShape) is a reference to the model shape on what the particle is designed.
  35932. * @param shapeId (integer) is the model shape identifier in the SPS.
  35933. * @param idxInShape (integer) is the index of the particle in the current model (ex: the 10th box of addShape(box, 30))
  35934. * @param sps defines the sps it is associated to
  35935. * @param modelBoundingInfo is the reference to the model BoundingInfo used for intersection computations.
  35936. * @param materialIndex is the particle material identifier (integer) when the MultiMaterials are enabled in the SPS.
  35937. */
  35938. constructor(particleIndex: number, particleId: number, positionIndex: number, indiceIndex: number, model: Nullable<ModelShape>, shapeId: number, idxInShape: number, sps: SolidParticleSystem, modelBoundingInfo?: Nullable<BoundingInfo>, materialIndex?: Nullable<number>);
  35939. /**
  35940. * Copies the particle property values into the existing target : position, rotation, scaling, uvs, colors, pivot, parent, visibility, alive
  35941. * @param target the particle target
  35942. * @returns the current particle
  35943. */
  35944. copyToRef(target: SolidParticle): SolidParticle;
  35945. /**
  35946. * Legacy support, changed scale to scaling
  35947. */
  35948. get scale(): Vector3;
  35949. /**
  35950. * Legacy support, changed scale to scaling
  35951. */
  35952. set scale(scale: Vector3);
  35953. /**
  35954. * Legacy support, changed quaternion to rotationQuaternion
  35955. */
  35956. get quaternion(): Nullable<Quaternion>;
  35957. /**
  35958. * Legacy support, changed quaternion to rotationQuaternion
  35959. */
  35960. set quaternion(q: Nullable<Quaternion>);
  35961. /**
  35962. * Returns a boolean. True if the particle intersects another particle or another mesh, else false.
  35963. * The intersection is computed on the particle bounding sphere and Axis Aligned Bounding Box (AABB)
  35964. * @param target is the object (solid particle or mesh) what the intersection is computed against.
  35965. * @returns true if it intersects
  35966. */
  35967. intersectsMesh(target: Mesh | SolidParticle): boolean;
  35968. /**
  35969. * Returns `true` if the solid particle is within the frustum defined by the passed array of planes.
  35970. * A particle is in the frustum if its bounding box intersects the frustum
  35971. * @param frustumPlanes defines the frustum to test
  35972. * @returns true if the particle is in the frustum planes
  35973. */
  35974. isInFrustum(frustumPlanes: Plane[]): boolean;
  35975. /**
  35976. * get the rotation matrix of the particle
  35977. * @hidden
  35978. */
  35979. getRotationMatrix(m: Matrix): void;
  35980. }
  35981. /**
  35982. * Represents the shape of the model used by one particle of a solid particle system.
  35983. * SPS internal tool, don't use it manually.
  35984. */
  35985. export class ModelShape {
  35986. /**
  35987. * The shape id
  35988. * @hidden
  35989. */
  35990. shapeID: number;
  35991. /**
  35992. * flat array of model positions (internal use)
  35993. * @hidden
  35994. */
  35995. _shape: Vector3[];
  35996. /**
  35997. * flat array of model UVs (internal use)
  35998. * @hidden
  35999. */
  36000. _shapeUV: number[];
  36001. /**
  36002. * color array of the model
  36003. * @hidden
  36004. */
  36005. _shapeColors: number[];
  36006. /**
  36007. * indices array of the model
  36008. * @hidden
  36009. */
  36010. _indices: number[];
  36011. /**
  36012. * normals array of the model
  36013. * @hidden
  36014. */
  36015. _normals: number[];
  36016. /**
  36017. * length of the shape in the model indices array (internal use)
  36018. * @hidden
  36019. */
  36020. _indicesLength: number;
  36021. /**
  36022. * Custom position function (internal use)
  36023. * @hidden
  36024. */
  36025. _positionFunction: Nullable<(particle: SolidParticle, i: number, s: number) => void>;
  36026. /**
  36027. * Custom vertex function (internal use)
  36028. * @hidden
  36029. */
  36030. _vertexFunction: Nullable<(particle: SolidParticle, vertex: Vector3, i: number) => void>;
  36031. /**
  36032. * Model material (internal use)
  36033. * @hidden
  36034. */
  36035. _material: Nullable<Material>;
  36036. /**
  36037. * 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.
  36038. * SPS internal tool, don't use it manually.
  36039. * @hidden
  36040. */
  36041. 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>);
  36042. }
  36043. /**
  36044. * Represents a Depth Sorted Particle in the solid particle system.
  36045. * @hidden
  36046. */
  36047. export class DepthSortedParticle {
  36048. /**
  36049. * Particle index
  36050. */
  36051. idx: number;
  36052. /**
  36053. * Index of the particle in the "indices" array
  36054. */
  36055. ind: number;
  36056. /**
  36057. * Length of the particle shape in the "indices" array
  36058. */
  36059. indicesLength: number;
  36060. /**
  36061. * Squared distance from the particle to the camera
  36062. */
  36063. sqDistance: number;
  36064. /**
  36065. * Material index when used with MultiMaterials
  36066. */
  36067. materialIndex: number;
  36068. /**
  36069. * Creates a new sorted particle
  36070. * @param materialIndex
  36071. */
  36072. constructor(idx: number, ind: number, indLength: number, materialIndex: number);
  36073. }
  36074. /**
  36075. * Represents a solid particle vertex
  36076. */
  36077. export class SolidParticleVertex {
  36078. /**
  36079. * Vertex position
  36080. */
  36081. position: Vector3;
  36082. /**
  36083. * Vertex color
  36084. */
  36085. color: Color4;
  36086. /**
  36087. * Vertex UV
  36088. */
  36089. uv: Vector2;
  36090. /**
  36091. * Creates a new solid particle vertex
  36092. */
  36093. constructor();
  36094. /** Vertex x coordinate */
  36095. get x(): number;
  36096. set x(val: number);
  36097. /** Vertex y coordinate */
  36098. get y(): number;
  36099. set y(val: number);
  36100. /** Vertex z coordinate */
  36101. get z(): number;
  36102. set z(val: number);
  36103. }
  36104. }
  36105. declare module BABYLON {
  36106. /**
  36107. * @hidden
  36108. */
  36109. export class _MeshCollisionData {
  36110. _checkCollisions: boolean;
  36111. _collisionMask: number;
  36112. _collisionGroup: number;
  36113. _surroundingMeshes: Nullable<AbstractMesh[]>;
  36114. _collider: Nullable<Collider>;
  36115. _oldPositionForCollisions: Vector3;
  36116. _diffPositionForCollisions: Vector3;
  36117. _onCollideObserver: Nullable<Observer<AbstractMesh>>;
  36118. _onCollisionPositionChangeObserver: Nullable<Observer<Vector3>>;
  36119. _collisionResponse: boolean;
  36120. }
  36121. }
  36122. declare module BABYLON {
  36123. /** @hidden */
  36124. class _FacetDataStorage {
  36125. facetPositions: Vector3[];
  36126. facetNormals: Vector3[];
  36127. facetPartitioning: number[][];
  36128. facetNb: number;
  36129. partitioningSubdivisions: number;
  36130. partitioningBBoxRatio: number;
  36131. facetDataEnabled: boolean;
  36132. facetParameters: any;
  36133. bbSize: Vector3;
  36134. subDiv: {
  36135. max: number;
  36136. X: number;
  36137. Y: number;
  36138. Z: number;
  36139. };
  36140. facetDepthSort: boolean;
  36141. facetDepthSortEnabled: boolean;
  36142. depthSortedIndices: IndicesArray;
  36143. depthSortedFacets: {
  36144. ind: number;
  36145. sqDistance: number;
  36146. }[];
  36147. facetDepthSortFunction: (f1: {
  36148. ind: number;
  36149. sqDistance: number;
  36150. }, f2: {
  36151. ind: number;
  36152. sqDistance: number;
  36153. }) => number;
  36154. facetDepthSortFrom: Vector3;
  36155. facetDepthSortOrigin: Vector3;
  36156. invertedMatrix: Matrix;
  36157. }
  36158. /**
  36159. * @hidden
  36160. **/
  36161. class _InternalAbstractMeshDataInfo {
  36162. _hasVertexAlpha: boolean;
  36163. _useVertexColors: boolean;
  36164. _numBoneInfluencers: number;
  36165. _applyFog: boolean;
  36166. _receiveShadows: boolean;
  36167. _facetData: _FacetDataStorage;
  36168. _visibility: number;
  36169. _skeleton: Nullable<Skeleton>;
  36170. _layerMask: number;
  36171. _computeBonesUsingShaders: boolean;
  36172. _isActive: boolean;
  36173. _onlyForInstances: boolean;
  36174. _isActiveIntermediate: boolean;
  36175. _onlyForInstancesIntermediate: boolean;
  36176. _actAsRegularMesh: boolean;
  36177. _currentLOD: Nullable<AbstractMesh>;
  36178. _currentLODIsUpToDate: boolean;
  36179. }
  36180. /**
  36181. * Class used to store all common mesh properties
  36182. */
  36183. export class AbstractMesh extends TransformNode implements IDisposable, ICullable, IGetSetVerticesData {
  36184. /** No occlusion */
  36185. static OCCLUSION_TYPE_NONE: number;
  36186. /** Occlusion set to optimistic */
  36187. static OCCLUSION_TYPE_OPTIMISTIC: number;
  36188. /** Occlusion set to strict */
  36189. static OCCLUSION_TYPE_STRICT: number;
  36190. /** Use an accurate occlusion algorithm */
  36191. static OCCLUSION_ALGORITHM_TYPE_ACCURATE: number;
  36192. /** Use a conservative occlusion algorithm */
  36193. static OCCLUSION_ALGORITHM_TYPE_CONSERVATIVE: number;
  36194. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  36195. * Test order :
  36196. * Is the bounding sphere outside the frustum ?
  36197. * If not, are the bounding box vertices outside the frustum ?
  36198. * It not, then the cullable object is in the frustum.
  36199. */
  36200. static readonly CULLINGSTRATEGY_STANDARD: number;
  36201. /** Culling strategy : Bounding Sphere Only.
  36202. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  36203. * It's also less accurate than the standard because some not visible objects can still be selected.
  36204. * Test : is the bounding sphere outside the frustum ?
  36205. * If not, then the cullable object is in the frustum.
  36206. */
  36207. static readonly CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  36208. /** Culling strategy : Optimistic Inclusion.
  36209. * This in an inclusion test first, then the standard exclusion test.
  36210. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  36211. * 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.
  36212. * Anyway, it's as accurate as the standard strategy.
  36213. * Test :
  36214. * Is the cullable object bounding sphere center in the frustum ?
  36215. * If not, apply the default culling strategy.
  36216. */
  36217. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  36218. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  36219. * This in an inclusion test first, then the bounding sphere only exclusion test.
  36220. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  36221. * 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.
  36222. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  36223. * Test :
  36224. * Is the cullable object bounding sphere center in the frustum ?
  36225. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  36226. */
  36227. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  36228. /**
  36229. * No billboard
  36230. */
  36231. static get BILLBOARDMODE_NONE(): number;
  36232. /** Billboard on X axis */
  36233. static get BILLBOARDMODE_X(): number;
  36234. /** Billboard on Y axis */
  36235. static get BILLBOARDMODE_Y(): number;
  36236. /** Billboard on Z axis */
  36237. static get BILLBOARDMODE_Z(): number;
  36238. /** Billboard on all axes */
  36239. static get BILLBOARDMODE_ALL(): number;
  36240. /** Billboard on using position instead of orientation */
  36241. static get BILLBOARDMODE_USE_POSITION(): number;
  36242. /** @hidden */
  36243. _internalAbstractMeshDataInfo: _InternalAbstractMeshDataInfo;
  36244. /**
  36245. * The culling strategy to use to check whether the mesh must be rendered or not.
  36246. * This value can be changed at any time and will be used on the next render mesh selection.
  36247. * The possible values are :
  36248. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  36249. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  36250. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  36251. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  36252. * Please read each static variable documentation to get details about the culling process.
  36253. * */
  36254. cullingStrategy: number;
  36255. /**
  36256. * Gets the number of facets in the mesh
  36257. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  36258. */
  36259. get facetNb(): number;
  36260. /**
  36261. * Gets or set the number (integer) of subdivisions per axis in the partitioning space
  36262. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  36263. */
  36264. get partitioningSubdivisions(): number;
  36265. set partitioningSubdivisions(nb: number);
  36266. /**
  36267. * The ratio (float) to apply to the bounding box size to set to the partitioning space.
  36268. * Ex : 1.01 (default) the partitioning space is 1% bigger than the bounding box
  36269. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  36270. */
  36271. get partitioningBBoxRatio(): number;
  36272. set partitioningBBoxRatio(ratio: number);
  36273. /**
  36274. * Gets or sets a boolean indicating that the facets must be depth sorted on next call to `updateFacetData()`.
  36275. * Works only for updatable meshes.
  36276. * Doesn't work with multi-materials
  36277. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  36278. */
  36279. get mustDepthSortFacets(): boolean;
  36280. set mustDepthSortFacets(sort: boolean);
  36281. /**
  36282. * The location (Vector3) where the facet depth sort must be computed from.
  36283. * By default, the active camera position.
  36284. * Used only when facet depth sort is enabled
  36285. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  36286. */
  36287. get facetDepthSortFrom(): Vector3;
  36288. set facetDepthSortFrom(location: Vector3);
  36289. /**
  36290. * gets a boolean indicating if facetData is enabled
  36291. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  36292. */
  36293. get isFacetDataEnabled(): boolean;
  36294. /** @hidden */
  36295. _updateNonUniformScalingState(value: boolean): boolean;
  36296. /**
  36297. * An event triggered when this mesh collides with another one
  36298. */
  36299. onCollideObservable: Observable<AbstractMesh>;
  36300. /** Set a function to call when this mesh collides with another one */
  36301. set onCollide(callback: () => void);
  36302. /**
  36303. * An event triggered when the collision's position changes
  36304. */
  36305. onCollisionPositionChangeObservable: Observable<Vector3>;
  36306. /** Set a function to call when the collision's position changes */
  36307. set onCollisionPositionChange(callback: () => void);
  36308. /**
  36309. * An event triggered when material is changed
  36310. */
  36311. onMaterialChangedObservable: Observable<AbstractMesh>;
  36312. /**
  36313. * Gets or sets the orientation for POV movement & rotation
  36314. */
  36315. definedFacingForward: boolean;
  36316. /** @hidden */
  36317. _occlusionQuery: Nullable<WebGLQuery>;
  36318. /** @hidden */
  36319. _renderingGroup: Nullable<RenderingGroup>;
  36320. /**
  36321. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  36322. */
  36323. get visibility(): number;
  36324. /**
  36325. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  36326. */
  36327. set visibility(value: number);
  36328. /** Gets or sets the alpha index used to sort transparent meshes
  36329. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#alpha-index
  36330. */
  36331. alphaIndex: number;
  36332. /**
  36333. * Gets or sets a boolean indicating if the mesh is visible (renderable). Default is true
  36334. */
  36335. isVisible: boolean;
  36336. /**
  36337. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  36338. */
  36339. isPickable: boolean;
  36340. /** Gets or sets a boolean indicating that bounding boxes of subMeshes must be rendered as well (false by default) */
  36341. showSubMeshesBoundingBox: boolean;
  36342. /** Gets or sets a boolean indicating if the mesh must be considered as a ray blocker for lens flares (false by default)
  36343. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  36344. */
  36345. isBlocker: boolean;
  36346. /**
  36347. * Gets or sets a boolean indicating that pointer move events must be supported on this mesh (false by default)
  36348. */
  36349. enablePointerMoveEvents: boolean;
  36350. private _renderingGroupId;
  36351. /**
  36352. * Specifies the rendering group id for this mesh (0 by default)
  36353. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  36354. */
  36355. get renderingGroupId(): number;
  36356. set renderingGroupId(value: number);
  36357. private _material;
  36358. /** Gets or sets current material */
  36359. get material(): Nullable<Material>;
  36360. set material(value: Nullable<Material>);
  36361. /**
  36362. * Gets or sets a boolean indicating that this mesh can receive realtime shadows
  36363. * @see https://doc.babylonjs.com/babylon101/shadows
  36364. */
  36365. get receiveShadows(): boolean;
  36366. set receiveShadows(value: boolean);
  36367. /** Defines color to use when rendering outline */
  36368. outlineColor: Color3;
  36369. /** Define width to use when rendering outline */
  36370. outlineWidth: number;
  36371. /** Defines color to use when rendering overlay */
  36372. overlayColor: Color3;
  36373. /** Defines alpha to use when rendering overlay */
  36374. overlayAlpha: number;
  36375. /** Gets or sets a boolean indicating that this mesh contains vertex color data with alpha values */
  36376. get hasVertexAlpha(): boolean;
  36377. set hasVertexAlpha(value: boolean);
  36378. /** 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) */
  36379. get useVertexColors(): boolean;
  36380. set useVertexColors(value: boolean);
  36381. /**
  36382. * Gets or sets a boolean indicating that bone animations must be computed by the CPU (false by default)
  36383. */
  36384. get computeBonesUsingShaders(): boolean;
  36385. set computeBonesUsingShaders(value: boolean);
  36386. /** Gets or sets the number of allowed bone influences per vertex (4 by default) */
  36387. get numBoneInfluencers(): number;
  36388. set numBoneInfluencers(value: number);
  36389. /** Gets or sets a boolean indicating that this mesh will allow fog to be rendered on it (true by default) */
  36390. get applyFog(): boolean;
  36391. set applyFog(value: boolean);
  36392. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes selection (true by default) */
  36393. useOctreeForRenderingSelection: boolean;
  36394. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes picking (true by default) */
  36395. useOctreeForPicking: boolean;
  36396. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes collision (true by default) */
  36397. useOctreeForCollisions: boolean;
  36398. /**
  36399. * Gets or sets the current layer mask (default is 0x0FFFFFFF)
  36400. * @see https://doc.babylonjs.com/how_to/layermasks_and_multi-cam_textures
  36401. */
  36402. get layerMask(): number;
  36403. set layerMask(value: number);
  36404. /**
  36405. * True if the mesh must be rendered in any case (this will shortcut the frustum clipping phase)
  36406. */
  36407. alwaysSelectAsActiveMesh: boolean;
  36408. /**
  36409. * Gets or sets a boolean indicating that the bounding info does not need to be kept in sync (for performance reason)
  36410. */
  36411. doNotSyncBoundingInfo: boolean;
  36412. /**
  36413. * Gets or sets the current action manager
  36414. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  36415. */
  36416. actionManager: Nullable<AbstractActionManager>;
  36417. private _meshCollisionData;
  36418. /**
  36419. * Gets or sets the ellipsoid used to impersonate this mesh when using collision engine (default is (0.5, 1, 0.5))
  36420. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  36421. */
  36422. ellipsoid: Vector3;
  36423. /**
  36424. * Gets or sets the ellipsoid offset used to impersonate this mesh when using collision engine (default is (0, 0, 0))
  36425. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  36426. */
  36427. ellipsoidOffset: Vector3;
  36428. /**
  36429. * Gets or sets a collision mask used to mask collisions (default is -1).
  36430. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  36431. */
  36432. get collisionMask(): number;
  36433. set collisionMask(mask: number);
  36434. /**
  36435. * Gets or sets a collision response flag (default is true).
  36436. * when collisionResponse is false, events are still triggered but colliding entity has no response
  36437. * This helps creating trigger volume when user wants collision feedback events but not position/velocity
  36438. * to respond to the collision.
  36439. */
  36440. get collisionResponse(): boolean;
  36441. set collisionResponse(response: boolean);
  36442. /**
  36443. * Gets or sets the current collision group mask (-1 by default).
  36444. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  36445. */
  36446. get collisionGroup(): number;
  36447. set collisionGroup(mask: number);
  36448. /**
  36449. * Gets or sets current surrounding meshes (null by default).
  36450. *
  36451. * By default collision detection is tested against every mesh in the scene.
  36452. * It is possible to set surroundingMeshes to a defined list of meshes and then only these specified
  36453. * meshes will be tested for the collision.
  36454. *
  36455. * Note: if set to an empty array no collision will happen when this mesh is moved.
  36456. */
  36457. get surroundingMeshes(): Nullable<AbstractMesh[]>;
  36458. set surroundingMeshes(meshes: Nullable<AbstractMesh[]>);
  36459. /**
  36460. * Defines edge width used when edgesRenderer is enabled
  36461. * @see https://www.babylonjs-playground.com/#10OJSG#13
  36462. */
  36463. edgesWidth: number;
  36464. /**
  36465. * Defines edge color used when edgesRenderer is enabled
  36466. * @see https://www.babylonjs-playground.com/#10OJSG#13
  36467. */
  36468. edgesColor: Color4;
  36469. /** @hidden */
  36470. _edgesRenderer: Nullable<IEdgesRenderer>;
  36471. /** @hidden */
  36472. _masterMesh: Nullable<AbstractMesh>;
  36473. /** @hidden */
  36474. _boundingInfo: Nullable<BoundingInfo>;
  36475. /** @hidden */
  36476. _renderId: number;
  36477. /**
  36478. * Gets or sets the list of subMeshes
  36479. * @see https://doc.babylonjs.com/how_to/multi_materials
  36480. */
  36481. subMeshes: SubMesh[];
  36482. /** @hidden */
  36483. _intersectionsInProgress: AbstractMesh[];
  36484. /** @hidden */
  36485. _unIndexed: boolean;
  36486. /** @hidden */
  36487. _lightSources: Light[];
  36488. /** Gets the list of lights affecting that mesh */
  36489. get lightSources(): Light[];
  36490. /** @hidden */
  36491. get _positions(): Nullable<Vector3[]>;
  36492. /** @hidden */
  36493. _waitingData: {
  36494. lods: Nullable<any>;
  36495. actions: Nullable<any>;
  36496. freezeWorldMatrix: Nullable<boolean>;
  36497. };
  36498. /** @hidden */
  36499. _bonesTransformMatrices: Nullable<Float32Array>;
  36500. /** @hidden */
  36501. _transformMatrixTexture: Nullable<RawTexture>;
  36502. /**
  36503. * Gets or sets a skeleton to apply skinning transformations
  36504. * @see https://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  36505. */
  36506. set skeleton(value: Nullable<Skeleton>);
  36507. get skeleton(): Nullable<Skeleton>;
  36508. /**
  36509. * An event triggered when the mesh is rebuilt.
  36510. */
  36511. onRebuildObservable: Observable<AbstractMesh>;
  36512. /**
  36513. * The current mesh uniform buffer.
  36514. * @hidden Internal use only.
  36515. */
  36516. _uniformBuffer: UniformBuffer;
  36517. /**
  36518. * Creates a new AbstractMesh
  36519. * @param name defines the name of the mesh
  36520. * @param scene defines the hosting scene
  36521. */
  36522. constructor(name: string, scene?: Nullable<Scene>);
  36523. protected _buildUniformLayout(): void;
  36524. /**
  36525. * Transfer the mesh values to its UBO.
  36526. * @param world The world matrix associated with the mesh
  36527. */
  36528. transferToEffect(world: Matrix): void;
  36529. /**
  36530. * Gets the mesh uniform buffer.
  36531. * @return the uniform buffer of the mesh.
  36532. */
  36533. getMeshUniformBuffer(): UniformBuffer;
  36534. /**
  36535. * Returns the string "AbstractMesh"
  36536. * @returns "AbstractMesh"
  36537. */
  36538. getClassName(): string;
  36539. /**
  36540. * Gets a string representation of the current mesh
  36541. * @param fullDetails defines a boolean indicating if full details must be included
  36542. * @returns a string representation of the current mesh
  36543. */
  36544. toString(fullDetails?: boolean): string;
  36545. /**
  36546. * @hidden
  36547. */
  36548. protected _getEffectiveParent(): Nullable<Node>;
  36549. /** @hidden */
  36550. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  36551. /** @hidden */
  36552. _rebuild(): void;
  36553. /** @hidden */
  36554. _resyncLightSources(): void;
  36555. /** @hidden */
  36556. _resyncLightSource(light: Light): void;
  36557. /** @hidden */
  36558. _unBindEffect(): void;
  36559. /** @hidden */
  36560. _removeLightSource(light: Light, dispose: boolean): void;
  36561. private _markSubMeshesAsDirty;
  36562. /** @hidden */
  36563. _markSubMeshesAsLightDirty(dispose?: boolean): void;
  36564. /** @hidden */
  36565. _markSubMeshesAsAttributesDirty(): void;
  36566. /** @hidden */
  36567. _markSubMeshesAsMiscDirty(): void;
  36568. /**
  36569. * Gets or sets a Vector3 depicting the mesh scaling along each local axis X, Y, Z. Default is (1.0, 1.0, 1.0)
  36570. */
  36571. get scaling(): Vector3;
  36572. set scaling(newScaling: Vector3);
  36573. /**
  36574. * Returns true if the mesh is blocked. Implemented by child classes
  36575. */
  36576. get isBlocked(): boolean;
  36577. /**
  36578. * Returns the mesh itself by default. Implemented by child classes
  36579. * @param camera defines the camera to use to pick the right LOD level
  36580. * @returns the currentAbstractMesh
  36581. */
  36582. getLOD(camera: Camera): Nullable<AbstractMesh>;
  36583. /**
  36584. * Returns 0 by default. Implemented by child classes
  36585. * @returns an integer
  36586. */
  36587. getTotalVertices(): number;
  36588. /**
  36589. * Returns a positive integer : the total number of indices in this mesh geometry.
  36590. * @returns the number of indices or zero if the mesh has no geometry.
  36591. */
  36592. getTotalIndices(): number;
  36593. /**
  36594. * Returns null by default. Implemented by child classes
  36595. * @returns null
  36596. */
  36597. getIndices(): Nullable<IndicesArray>;
  36598. /**
  36599. * Returns the array of the requested vertex data kind. Implemented by child classes
  36600. * @param kind defines the vertex data kind to use
  36601. * @returns null
  36602. */
  36603. getVerticesData(kind: string): Nullable<FloatArray>;
  36604. /**
  36605. * Sets the vertex data of the mesh geometry for the requested `kind`.
  36606. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  36607. * Note that a new underlying VertexBuffer object is created each call.
  36608. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  36609. * @param kind defines vertex data kind:
  36610. * * VertexBuffer.PositionKind
  36611. * * VertexBuffer.UVKind
  36612. * * VertexBuffer.UV2Kind
  36613. * * VertexBuffer.UV3Kind
  36614. * * VertexBuffer.UV4Kind
  36615. * * VertexBuffer.UV5Kind
  36616. * * VertexBuffer.UV6Kind
  36617. * * VertexBuffer.ColorKind
  36618. * * VertexBuffer.MatricesIndicesKind
  36619. * * VertexBuffer.MatricesIndicesExtraKind
  36620. * * VertexBuffer.MatricesWeightsKind
  36621. * * VertexBuffer.MatricesWeightsExtraKind
  36622. * @param data defines the data source
  36623. * @param updatable defines if the data must be flagged as updatable (or static)
  36624. * @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
  36625. * @returns the current mesh
  36626. */
  36627. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  36628. /**
  36629. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  36630. * If the mesh has no geometry, it is simply returned as it is.
  36631. * @param kind defines vertex data kind:
  36632. * * VertexBuffer.PositionKind
  36633. * * VertexBuffer.UVKind
  36634. * * VertexBuffer.UV2Kind
  36635. * * VertexBuffer.UV3Kind
  36636. * * VertexBuffer.UV4Kind
  36637. * * VertexBuffer.UV5Kind
  36638. * * VertexBuffer.UV6Kind
  36639. * * VertexBuffer.ColorKind
  36640. * * VertexBuffer.MatricesIndicesKind
  36641. * * VertexBuffer.MatricesIndicesExtraKind
  36642. * * VertexBuffer.MatricesWeightsKind
  36643. * * VertexBuffer.MatricesWeightsExtraKind
  36644. * @param data defines the data source
  36645. * @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
  36646. * @param makeItUnique If true, a new global geometry is created from this data and is set to the mesh
  36647. * @returns the current mesh
  36648. */
  36649. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  36650. /**
  36651. * Sets the mesh indices,
  36652. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  36653. * @param indices Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array)
  36654. * @param totalVertices Defines the total number of vertices
  36655. * @returns the current mesh
  36656. */
  36657. setIndices(indices: IndicesArray, totalVertices: Nullable<number>): AbstractMesh;
  36658. /**
  36659. * Gets a boolean indicating if specific vertex data is present
  36660. * @param kind defines the vertex data kind to use
  36661. * @returns true is data kind is present
  36662. */
  36663. isVerticesDataPresent(kind: string): boolean;
  36664. /**
  36665. * Returns the mesh BoundingInfo object or creates a new one and returns if it was undefined.
  36666. * Note that it returns a shallow bounding of the mesh (i.e. it does not include children).
  36667. * To get the full bounding of all children, call `getHierarchyBoundingVectors` instead.
  36668. * @returns a BoundingInfo
  36669. */
  36670. getBoundingInfo(): BoundingInfo;
  36671. /**
  36672. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  36673. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  36674. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  36675. * @param predicate predicate that is passed in to getHierarchyBoundingVectors when selecting which object should be included when scaling
  36676. * @returns the current mesh
  36677. */
  36678. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean, predicate?: Nullable<(node: AbstractMesh) => boolean>): AbstractMesh;
  36679. /**
  36680. * Overwrite the current bounding info
  36681. * @param boundingInfo defines the new bounding info
  36682. * @returns the current mesh
  36683. */
  36684. setBoundingInfo(boundingInfo: BoundingInfo): AbstractMesh;
  36685. /** Gets a boolean indicating if this mesh has skinning data and an attached skeleton */
  36686. get useBones(): boolean;
  36687. /** @hidden */
  36688. _preActivate(): void;
  36689. /** @hidden */
  36690. _preActivateForIntermediateRendering(renderId: number): void;
  36691. /** @hidden */
  36692. _activate(renderId: number, intermediateRendering: boolean): boolean;
  36693. /** @hidden */
  36694. _postActivate(): void;
  36695. /** @hidden */
  36696. _freeze(): void;
  36697. /** @hidden */
  36698. _unFreeze(): void;
  36699. /**
  36700. * Gets the current world matrix
  36701. * @returns a Matrix
  36702. */
  36703. getWorldMatrix(): Matrix;
  36704. /** @hidden */
  36705. _getWorldMatrixDeterminant(): number;
  36706. /**
  36707. * Gets a boolean indicating if this mesh is an instance or a regular mesh
  36708. */
  36709. get isAnInstance(): boolean;
  36710. /**
  36711. * Gets a boolean indicating if this mesh has instances
  36712. */
  36713. get hasInstances(): boolean;
  36714. /**
  36715. * Gets a boolean indicating if this mesh has thin instances
  36716. */
  36717. get hasThinInstances(): boolean;
  36718. /**
  36719. * Perform relative position change from the point of view of behind the front of the mesh.
  36720. * This is performed taking into account the meshes current rotation, so you do not have to care.
  36721. * Supports definition of mesh facing forward or backward
  36722. * @param amountRight defines the distance on the right axis
  36723. * @param amountUp defines the distance on the up axis
  36724. * @param amountForward defines the distance on the forward axis
  36725. * @returns the current mesh
  36726. */
  36727. movePOV(amountRight: number, amountUp: number, amountForward: number): AbstractMesh;
  36728. /**
  36729. * Calculate relative position change from the point of view of behind the front of the mesh.
  36730. * This is performed taking into account the meshes current rotation, so you do not have to care.
  36731. * Supports definition of mesh facing forward or backward
  36732. * @param amountRight defines the distance on the right axis
  36733. * @param amountUp defines the distance on the up axis
  36734. * @param amountForward defines the distance on the forward axis
  36735. * @returns the new displacement vector
  36736. */
  36737. calcMovePOV(amountRight: number, amountUp: number, amountForward: number): Vector3;
  36738. /**
  36739. * Perform relative rotation change from the point of view of behind the front of the mesh.
  36740. * Supports definition of mesh facing forward or backward
  36741. * @param flipBack defines the flip
  36742. * @param twirlClockwise defines the twirl
  36743. * @param tiltRight defines the tilt
  36744. * @returns the current mesh
  36745. */
  36746. rotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): AbstractMesh;
  36747. /**
  36748. * Calculate relative rotation change from the point of view of behind the front of the mesh.
  36749. * Supports definition of mesh facing forward or backward.
  36750. * @param flipBack defines the flip
  36751. * @param twirlClockwise defines the twirl
  36752. * @param tiltRight defines the tilt
  36753. * @returns the new rotation vector
  36754. */
  36755. calcRotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): Vector3;
  36756. /**
  36757. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  36758. * This means the mesh underlying bounding box and sphere are recomputed.
  36759. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  36760. * @returns the current mesh
  36761. */
  36762. refreshBoundingInfo(applySkeleton?: boolean): AbstractMesh;
  36763. /** @hidden */
  36764. _refreshBoundingInfo(data: Nullable<FloatArray>, bias: Nullable<Vector2>): void;
  36765. /** @hidden */
  36766. _getPositionData(applySkeleton: boolean): Nullable<FloatArray>;
  36767. /** @hidden */
  36768. _updateBoundingInfo(): AbstractMesh;
  36769. /** @hidden */
  36770. _updateSubMeshesBoundingInfo(matrix: DeepImmutable<Matrix>): AbstractMesh;
  36771. /** @hidden */
  36772. protected _afterComputeWorldMatrix(): void;
  36773. /** @hidden */
  36774. get _effectiveMesh(): AbstractMesh;
  36775. /**
  36776. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  36777. * A mesh is in the frustum if its bounding box intersects the frustum
  36778. * @param frustumPlanes defines the frustum to test
  36779. * @returns true if the mesh is in the frustum planes
  36780. */
  36781. isInFrustum(frustumPlanes: Plane[]): boolean;
  36782. /**
  36783. * Returns `true` if the mesh is completely in the frustum defined be the passed array of planes.
  36784. * A mesh is completely in the frustum if its bounding box it completely inside the frustum.
  36785. * @param frustumPlanes defines the frustum to test
  36786. * @returns true if the mesh is completely in the frustum planes
  36787. */
  36788. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  36789. /**
  36790. * True if the mesh intersects another mesh or a SolidParticle object
  36791. * @param mesh defines a target mesh or SolidParticle to test
  36792. * @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)
  36793. * @param includeDescendants Can be set to true to test if the mesh defined in parameters intersects with the current mesh or any child meshes
  36794. * @returns true if there is an intersection
  36795. */
  36796. intersectsMesh(mesh: AbstractMesh | SolidParticle, precise?: boolean, includeDescendants?: boolean): boolean;
  36797. /**
  36798. * Returns true if the passed point (Vector3) is inside the mesh bounding box
  36799. * @param point defines the point to test
  36800. * @returns true if there is an intersection
  36801. */
  36802. intersectsPoint(point: Vector3): boolean;
  36803. /**
  36804. * Gets or sets a boolean indicating that this mesh can be used in the collision engine
  36805. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  36806. */
  36807. get checkCollisions(): boolean;
  36808. set checkCollisions(collisionEnabled: boolean);
  36809. /**
  36810. * Gets Collider object used to compute collisions (not physics)
  36811. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  36812. */
  36813. get collider(): Nullable<Collider>;
  36814. /**
  36815. * Move the mesh using collision engine
  36816. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  36817. * @param displacement defines the requested displacement vector
  36818. * @returns the current mesh
  36819. */
  36820. moveWithCollisions(displacement: Vector3): AbstractMesh;
  36821. private _onCollisionPositionChange;
  36822. /** @hidden */
  36823. _collideForSubMesh(subMesh: SubMesh, transformMatrix: Matrix, collider: Collider): AbstractMesh;
  36824. /** @hidden */
  36825. _processCollisionsForSubMeshes(collider: Collider, transformMatrix: Matrix): AbstractMesh;
  36826. /** @hidden */
  36827. _checkCollision(collider: Collider): AbstractMesh;
  36828. /** @hidden */
  36829. _generatePointsArray(): boolean;
  36830. /**
  36831. * Checks if the passed Ray intersects with the mesh
  36832. * @param ray defines the ray to use
  36833. * @param fastCheck defines if fast mode (but less precise) must be used (false by default)
  36834. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  36835. * @param onlyBoundingInfo defines a boolean indicating if picking should only happen using bounding info (false by default)
  36836. * @param worldToUse defines the world matrix to use to get the world coordinate of the intersection point
  36837. * @param skipBoundingInfo a boolean indicating if we should skip the bounding info check
  36838. * @returns the picking info
  36839. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  36840. */
  36841. intersects(ray: Ray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate, onlyBoundingInfo?: boolean, worldToUse?: Matrix, skipBoundingInfo?: boolean): PickingInfo;
  36842. /**
  36843. * Clones the current mesh
  36844. * @param name defines the mesh name
  36845. * @param newParent defines the new mesh parent
  36846. * @param doNotCloneChildren defines a boolean indicating that children must not be cloned (false by default)
  36847. * @returns the new mesh
  36848. */
  36849. clone(name: string, newParent: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<AbstractMesh>;
  36850. /**
  36851. * Disposes all the submeshes of the current meshnp
  36852. * @returns the current mesh
  36853. */
  36854. releaseSubMeshes(): AbstractMesh;
  36855. /**
  36856. * Releases resources associated with this abstract mesh.
  36857. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  36858. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  36859. */
  36860. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  36861. /**
  36862. * Adds the passed mesh as a child to the current mesh
  36863. * @param mesh defines the child mesh
  36864. * @returns the current mesh
  36865. */
  36866. addChild(mesh: AbstractMesh): AbstractMesh;
  36867. /**
  36868. * Removes the passed mesh from the current mesh children list
  36869. * @param mesh defines the child mesh
  36870. * @returns the current mesh
  36871. */
  36872. removeChild(mesh: AbstractMesh): AbstractMesh;
  36873. /** @hidden */
  36874. private _initFacetData;
  36875. /**
  36876. * Updates the mesh facetData arrays and the internal partitioning when the mesh is morphed or updated.
  36877. * This method can be called within the render loop.
  36878. * 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
  36879. * @returns the current mesh
  36880. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  36881. */
  36882. updateFacetData(): AbstractMesh;
  36883. /**
  36884. * Returns the facetLocalNormals array.
  36885. * The normals are expressed in the mesh local spac
  36886. * @returns an array of Vector3
  36887. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  36888. */
  36889. getFacetLocalNormals(): Vector3[];
  36890. /**
  36891. * Returns the facetLocalPositions array.
  36892. * The facet positions are expressed in the mesh local space
  36893. * @returns an array of Vector3
  36894. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  36895. */
  36896. getFacetLocalPositions(): Vector3[];
  36897. /**
  36898. * Returns the facetLocalPartitioning array
  36899. * @returns an array of array of numbers
  36900. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  36901. */
  36902. getFacetLocalPartitioning(): number[][];
  36903. /**
  36904. * Returns the i-th facet position in the world system.
  36905. * This method allocates a new Vector3 per call
  36906. * @param i defines the facet index
  36907. * @returns a new Vector3
  36908. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  36909. */
  36910. getFacetPosition(i: number): Vector3;
  36911. /**
  36912. * Sets the reference Vector3 with the i-th facet position in the world system
  36913. * @param i defines the facet index
  36914. * @param ref defines the target vector
  36915. * @returns the current mesh
  36916. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  36917. */
  36918. getFacetPositionToRef(i: number, ref: Vector3): AbstractMesh;
  36919. /**
  36920. * Returns the i-th facet normal in the world system.
  36921. * This method allocates a new Vector3 per call
  36922. * @param i defines the facet index
  36923. * @returns a new Vector3
  36924. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  36925. */
  36926. getFacetNormal(i: number): Vector3;
  36927. /**
  36928. * Sets the reference Vector3 with the i-th facet normal in the world system
  36929. * @param i defines the facet index
  36930. * @param ref defines the target vector
  36931. * @returns the current mesh
  36932. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  36933. */
  36934. getFacetNormalToRef(i: number, ref: Vector3): this;
  36935. /**
  36936. * 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)
  36937. * @param x defines x coordinate
  36938. * @param y defines y coordinate
  36939. * @param z defines z coordinate
  36940. * @returns the array of facet indexes
  36941. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  36942. */
  36943. getFacetsAtLocalCoordinates(x: number, y: number, z: number): Nullable<number[]>;
  36944. /**
  36945. * Returns the closest mesh facet index at (x,y,z) World coordinates, null if not found
  36946. * @param projected sets as the (x,y,z) world projection on the facet
  36947. * @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
  36948. * @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
  36949. * @param x defines x coordinate
  36950. * @param y defines y coordinate
  36951. * @param z defines z coordinate
  36952. * @returns the face index if found (or null instead)
  36953. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  36954. */
  36955. getClosestFacetAtCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  36956. /**
  36957. * Returns the closest mesh facet index at (x,y,z) local coordinates, null if not found
  36958. * @param projected sets as the (x,y,z) local projection on the facet
  36959. * @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
  36960. * @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
  36961. * @param x defines x coordinate
  36962. * @param y defines y coordinate
  36963. * @param z defines z coordinate
  36964. * @returns the face index if found (or null instead)
  36965. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  36966. */
  36967. getClosestFacetAtLocalCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  36968. /**
  36969. * Returns the object "parameter" set with all the expected parameters for facetData computation by ComputeNormals()
  36970. * @returns the parameters
  36971. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  36972. */
  36973. getFacetDataParameters(): any;
  36974. /**
  36975. * Disables the feature FacetData and frees the related memory
  36976. * @returns the current mesh
  36977. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  36978. */
  36979. disableFacetData(): AbstractMesh;
  36980. /**
  36981. * Updates the AbstractMesh indices array
  36982. * @param indices defines the data source
  36983. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  36984. * @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)
  36985. * @returns the current mesh
  36986. */
  36987. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  36988. /**
  36989. * Creates new normals data for the mesh
  36990. * @param updatable defines if the normal vertex buffer must be flagged as updatable
  36991. * @returns the current mesh
  36992. */
  36993. createNormals(updatable: boolean): AbstractMesh;
  36994. /**
  36995. * Align the mesh with a normal
  36996. * @param normal defines the normal to use
  36997. * @param upDirection can be used to redefined the up vector to use (will use the (0, 1, 0) by default)
  36998. * @returns the current mesh
  36999. */
  37000. alignWithNormal(normal: Vector3, upDirection?: Vector3): AbstractMesh;
  37001. /** @hidden */
  37002. _checkOcclusionQuery(): boolean;
  37003. /**
  37004. * Disables the mesh edge rendering mode
  37005. * @returns the currentAbstractMesh
  37006. */
  37007. disableEdgesRendering(): AbstractMesh;
  37008. /**
  37009. * Enables the edge rendering mode on the mesh.
  37010. * This mode makes the mesh edges visible
  37011. * @param epsilon defines the maximal distance between two angles to detect a face
  37012. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  37013. * @param options options to the edge renderer
  37014. * @returns the currentAbstractMesh
  37015. * @see https://www.babylonjs-playground.com/#19O9TU#0
  37016. */
  37017. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean, options?: IEdgesRendererOptions): AbstractMesh;
  37018. /**
  37019. * This function returns all of the particle systems in the scene that use the mesh as an emitter.
  37020. * @returns an array of particle systems in the scene that use the mesh as an emitter
  37021. */
  37022. getConnectedParticleSystems(): IParticleSystem[];
  37023. }
  37024. }
  37025. declare module BABYLON {
  37026. /**
  37027. * Interface used to define ActionEvent
  37028. */
  37029. export interface IActionEvent {
  37030. /** The mesh or sprite that triggered the action */
  37031. source: any;
  37032. /** The X mouse cursor position at the time of the event */
  37033. pointerX: number;
  37034. /** The Y mouse cursor position at the time of the event */
  37035. pointerY: number;
  37036. /** The mesh that is currently pointed at (can be null) */
  37037. meshUnderPointer: Nullable<AbstractMesh>;
  37038. /** the original (browser) event that triggered the ActionEvent */
  37039. sourceEvent?: any;
  37040. /** additional data for the event */
  37041. additionalData?: any;
  37042. }
  37043. /**
  37044. * ActionEvent is the event being sent when an action is triggered.
  37045. */
  37046. export class ActionEvent implements IActionEvent {
  37047. /** The mesh or sprite that triggered the action */
  37048. source: any;
  37049. /** The X mouse cursor position at the time of the event */
  37050. pointerX: number;
  37051. /** The Y mouse cursor position at the time of the event */
  37052. pointerY: number;
  37053. /** The mesh that is currently pointed at (can be null) */
  37054. meshUnderPointer: Nullable<AbstractMesh>;
  37055. /** the original (browser) event that triggered the ActionEvent */
  37056. sourceEvent?: any;
  37057. /** additional data for the event */
  37058. additionalData?: any;
  37059. /**
  37060. * Creates a new ActionEvent
  37061. * @param source The mesh or sprite that triggered the action
  37062. * @param pointerX The X mouse cursor position at the time of the event
  37063. * @param pointerY The Y mouse cursor position at the time of the event
  37064. * @param meshUnderPointer The mesh that is currently pointed at (can be null)
  37065. * @param sourceEvent the original (browser) event that triggered the ActionEvent
  37066. * @param additionalData additional data for the event
  37067. */
  37068. constructor(
  37069. /** The mesh or sprite that triggered the action */
  37070. source: any,
  37071. /** The X mouse cursor position at the time of the event */
  37072. pointerX: number,
  37073. /** The Y mouse cursor position at the time of the event */
  37074. pointerY: number,
  37075. /** The mesh that is currently pointed at (can be null) */
  37076. meshUnderPointer: Nullable<AbstractMesh>,
  37077. /** the original (browser) event that triggered the ActionEvent */
  37078. sourceEvent?: any,
  37079. /** additional data for the event */
  37080. additionalData?: any);
  37081. /**
  37082. * Helper function to auto-create an ActionEvent from a source mesh.
  37083. * @param source The source mesh that triggered the event
  37084. * @param evt The original (browser) event
  37085. * @param additionalData additional data for the event
  37086. * @returns the new ActionEvent
  37087. */
  37088. static CreateNew(source: AbstractMesh, evt?: Event, additionalData?: any): ActionEvent;
  37089. /**
  37090. * Helper function to auto-create an ActionEvent from a source sprite
  37091. * @param source The source sprite that triggered the event
  37092. * @param scene Scene associated with the sprite
  37093. * @param evt The original (browser) event
  37094. * @param additionalData additional data for the event
  37095. * @returns the new ActionEvent
  37096. */
  37097. static CreateNewFromSprite(source: Sprite, scene: Scene, evt?: Event, additionalData?: any): ActionEvent;
  37098. /**
  37099. * Helper function to auto-create an ActionEvent from a scene. If triggered by a mesh use ActionEvent.CreateNew
  37100. * @param scene the scene where the event occurred
  37101. * @param evt The original (browser) event
  37102. * @returns the new ActionEvent
  37103. */
  37104. static CreateNewFromScene(scene: Scene, evt: Event): ActionEvent;
  37105. /**
  37106. * Helper function to auto-create an ActionEvent from a primitive
  37107. * @param prim defines the target primitive
  37108. * @param pointerPos defines the pointer position
  37109. * @param evt The original (browser) event
  37110. * @param additionalData additional data for the event
  37111. * @returns the new ActionEvent
  37112. */
  37113. static CreateNewFromPrimitive(prim: any, pointerPos: Vector2, evt?: Event, additionalData?: any): ActionEvent;
  37114. }
  37115. }
  37116. declare module BABYLON {
  37117. /**
  37118. * Abstract class used to decouple action Manager from scene and meshes.
  37119. * Do not instantiate.
  37120. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  37121. */
  37122. export abstract class AbstractActionManager implements IDisposable {
  37123. /** Gets the list of active triggers */
  37124. static Triggers: {
  37125. [key: string]: number;
  37126. };
  37127. /** Gets the cursor to use when hovering items */
  37128. hoverCursor: string;
  37129. /** Gets the list of actions */
  37130. actions: IAction[];
  37131. /**
  37132. * Gets or sets a boolean indicating that the manager is recursive meaning that it can trigger action from children
  37133. */
  37134. isRecursive: boolean;
  37135. /**
  37136. * Releases all associated resources
  37137. */
  37138. abstract dispose(): void;
  37139. /**
  37140. * Does this action manager has pointer triggers
  37141. */
  37142. abstract get hasPointerTriggers(): boolean;
  37143. /**
  37144. * Does this action manager has pick triggers
  37145. */
  37146. abstract get hasPickTriggers(): boolean;
  37147. /**
  37148. * Process a specific trigger
  37149. * @param trigger defines the trigger to process
  37150. * @param evt defines the event details to be processed
  37151. */
  37152. abstract processTrigger(trigger: number, evt?: IActionEvent): void;
  37153. /**
  37154. * Does this action manager handles actions of any of the given triggers
  37155. * @param triggers defines the triggers to be tested
  37156. * @return a boolean indicating whether one (or more) of the triggers is handled
  37157. */
  37158. abstract hasSpecificTriggers(triggers: number[]): boolean;
  37159. /**
  37160. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  37161. * speed.
  37162. * @param triggerA defines the trigger to be tested
  37163. * @param triggerB defines the trigger to be tested
  37164. * @return a boolean indicating whether one (or more) of the triggers is handled
  37165. */
  37166. abstract hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  37167. /**
  37168. * Does this action manager handles actions of a given trigger
  37169. * @param trigger defines the trigger to be tested
  37170. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  37171. * @return whether the trigger is handled
  37172. */
  37173. abstract hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  37174. /**
  37175. * Serialize this manager to a JSON object
  37176. * @param name defines the property name to store this manager
  37177. * @returns a JSON representation of this manager
  37178. */
  37179. abstract serialize(name: string): any;
  37180. /**
  37181. * Registers an action to this action manager
  37182. * @param action defines the action to be registered
  37183. * @return the action amended (prepared) after registration
  37184. */
  37185. abstract registerAction(action: IAction): Nullable<IAction>;
  37186. /**
  37187. * Unregisters an action to this action manager
  37188. * @param action defines the action to be unregistered
  37189. * @return a boolean indicating whether the action has been unregistered
  37190. */
  37191. abstract unregisterAction(action: IAction): Boolean;
  37192. /**
  37193. * Does exist one action manager with at least one trigger
  37194. **/
  37195. static get HasTriggers(): boolean;
  37196. /**
  37197. * Does exist one action manager with at least one pick trigger
  37198. **/
  37199. static get HasPickTriggers(): boolean;
  37200. /**
  37201. * Does exist one action manager that handles actions of a given trigger
  37202. * @param trigger defines the trigger to be tested
  37203. * @return a boolean indicating whether the trigger is handled by at least one action manager
  37204. **/
  37205. static HasSpecificTrigger(trigger: number): boolean;
  37206. }
  37207. }
  37208. declare module BABYLON {
  37209. /**
  37210. * Defines how a node can be built from a string name.
  37211. */
  37212. export type NodeConstructor = (name: string, scene: Scene, options?: any) => () => Node;
  37213. /**
  37214. * Node is the basic class for all scene objects (Mesh, Light, Camera.)
  37215. */
  37216. export class Node implements IBehaviorAware<Node> {
  37217. /** @hidden */
  37218. static _AnimationRangeFactory: (name: string, from: number, to: number) => AnimationRange;
  37219. private static _NodeConstructors;
  37220. /**
  37221. * Add a new node constructor
  37222. * @param type defines the type name of the node to construct
  37223. * @param constructorFunc defines the constructor function
  37224. */
  37225. static AddNodeConstructor(type: string, constructorFunc: NodeConstructor): void;
  37226. /**
  37227. * Returns a node constructor based on type name
  37228. * @param type defines the type name
  37229. * @param name defines the new node name
  37230. * @param scene defines the hosting scene
  37231. * @param options defines optional options to transmit to constructors
  37232. * @returns the new constructor or null
  37233. */
  37234. static Construct(type: string, name: string, scene: Scene, options?: any): Nullable<() => Node>;
  37235. /**
  37236. * Gets or sets the name of the node
  37237. */
  37238. name: string;
  37239. /**
  37240. * Gets or sets the id of the node
  37241. */
  37242. id: string;
  37243. /**
  37244. * Gets or sets the unique id of the node
  37245. */
  37246. uniqueId: number;
  37247. /**
  37248. * Gets or sets a string used to store user defined state for the node
  37249. */
  37250. state: string;
  37251. /**
  37252. * Gets or sets an object used to store user defined information for the node
  37253. */
  37254. metadata: any;
  37255. /**
  37256. * For internal use only. Please do not use.
  37257. */
  37258. reservedDataStore: any;
  37259. /**
  37260. * List of inspectable custom properties (used by the Inspector)
  37261. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  37262. */
  37263. inspectableCustomProperties: IInspectable[];
  37264. private _doNotSerialize;
  37265. /**
  37266. * Gets or sets a boolean used to define if the node must be serialized
  37267. */
  37268. get doNotSerialize(): boolean;
  37269. set doNotSerialize(value: boolean);
  37270. /** @hidden */
  37271. _isDisposed: boolean;
  37272. /**
  37273. * Gets a list of Animations associated with the node
  37274. */
  37275. animations: Animation[];
  37276. protected _ranges: {
  37277. [name: string]: Nullable<AnimationRange>;
  37278. };
  37279. /**
  37280. * Callback raised when the node is ready to be used
  37281. */
  37282. onReady: Nullable<(node: Node) => void>;
  37283. private _isEnabled;
  37284. private _isParentEnabled;
  37285. private _isReady;
  37286. /** @hidden */
  37287. _currentRenderId: number;
  37288. private _parentUpdateId;
  37289. /** @hidden */
  37290. _childUpdateId: number;
  37291. /** @hidden */
  37292. _waitingParentId: Nullable<string>;
  37293. /** @hidden */
  37294. _scene: Scene;
  37295. /** @hidden */
  37296. _cache: any;
  37297. private _parentNode;
  37298. private _children;
  37299. /** @hidden */
  37300. _worldMatrix: Matrix;
  37301. /** @hidden */
  37302. _worldMatrixDeterminant: number;
  37303. /** @hidden */
  37304. _worldMatrixDeterminantIsDirty: boolean;
  37305. /** @hidden */
  37306. private _sceneRootNodesIndex;
  37307. /**
  37308. * Gets a boolean indicating if the node has been disposed
  37309. * @returns true if the node was disposed
  37310. */
  37311. isDisposed(): boolean;
  37312. /**
  37313. * Gets or sets the parent of the node (without keeping the current position in the scene)
  37314. * @see https://doc.babylonjs.com/how_to/parenting
  37315. */
  37316. set parent(parent: Nullable<Node>);
  37317. get parent(): Nullable<Node>;
  37318. /** @hidden */
  37319. _addToSceneRootNodes(): void;
  37320. /** @hidden */
  37321. _removeFromSceneRootNodes(): void;
  37322. private _animationPropertiesOverride;
  37323. /**
  37324. * Gets or sets the animation properties override
  37325. */
  37326. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  37327. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  37328. /**
  37329. * Gets a string identifying the name of the class
  37330. * @returns "Node" string
  37331. */
  37332. getClassName(): string;
  37333. /** @hidden */
  37334. readonly _isNode: boolean;
  37335. /**
  37336. * An event triggered when the mesh is disposed
  37337. */
  37338. onDisposeObservable: Observable<Node>;
  37339. private _onDisposeObserver;
  37340. /**
  37341. * Sets a callback that will be raised when the node will be disposed
  37342. */
  37343. set onDispose(callback: () => void);
  37344. /**
  37345. * Creates a new Node
  37346. * @param name the name and id to be given to this node
  37347. * @param scene the scene this node will be added to
  37348. */
  37349. constructor(name: string, scene?: Nullable<Scene>);
  37350. /**
  37351. * Gets the scene of the node
  37352. * @returns a scene
  37353. */
  37354. getScene(): Scene;
  37355. /**
  37356. * Gets the engine of the node
  37357. * @returns a Engine
  37358. */
  37359. getEngine(): Engine;
  37360. private _behaviors;
  37361. /**
  37362. * Attach a behavior to the node
  37363. * @see https://doc.babylonjs.com/features/behaviour
  37364. * @param behavior defines the behavior to attach
  37365. * @param attachImmediately defines that the behavior must be attached even if the scene is still loading
  37366. * @returns the current Node
  37367. */
  37368. addBehavior(behavior: Behavior<Node>, attachImmediately?: boolean): Node;
  37369. /**
  37370. * Remove an attached behavior
  37371. * @see https://doc.babylonjs.com/features/behaviour
  37372. * @param behavior defines the behavior to attach
  37373. * @returns the current Node
  37374. */
  37375. removeBehavior(behavior: Behavior<Node>): Node;
  37376. /**
  37377. * Gets the list of attached behaviors
  37378. * @see https://doc.babylonjs.com/features/behaviour
  37379. */
  37380. get behaviors(): Behavior<Node>[];
  37381. /**
  37382. * Gets an attached behavior by name
  37383. * @param name defines the name of the behavior to look for
  37384. * @see https://doc.babylonjs.com/features/behaviour
  37385. * @returns null if behavior was not found else the requested behavior
  37386. */
  37387. getBehaviorByName(name: string): Nullable<Behavior<Node>>;
  37388. /**
  37389. * Returns the latest update of the World matrix
  37390. * @returns a Matrix
  37391. */
  37392. getWorldMatrix(): Matrix;
  37393. /** @hidden */
  37394. _getWorldMatrixDeterminant(): number;
  37395. /**
  37396. * Returns directly the latest state of the mesh World matrix.
  37397. * A Matrix is returned.
  37398. */
  37399. get worldMatrixFromCache(): Matrix;
  37400. /** @hidden */
  37401. _initCache(): void;
  37402. /** @hidden */
  37403. updateCache(force?: boolean): void;
  37404. /** @hidden */
  37405. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  37406. /** @hidden */
  37407. _updateCache(ignoreParentClass?: boolean): void;
  37408. /** @hidden */
  37409. _isSynchronized(): boolean;
  37410. /** @hidden */
  37411. _markSyncedWithParent(): void;
  37412. /** @hidden */
  37413. isSynchronizedWithParent(): boolean;
  37414. /** @hidden */
  37415. isSynchronized(): boolean;
  37416. /**
  37417. * Is this node ready to be used/rendered
  37418. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  37419. * @return true if the node is ready
  37420. */
  37421. isReady(completeCheck?: boolean): boolean;
  37422. /**
  37423. * Is this node enabled?
  37424. * 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
  37425. * @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
  37426. * @return whether this node (and its parent) is enabled
  37427. */
  37428. isEnabled(checkAncestors?: boolean): boolean;
  37429. /** @hidden */
  37430. protected _syncParentEnabledState(): void;
  37431. /**
  37432. * Set the enabled state of this node
  37433. * @param value defines the new enabled state
  37434. */
  37435. setEnabled(value: boolean): void;
  37436. /**
  37437. * Is this node a descendant of the given node?
  37438. * The function will iterate up the hierarchy until the ancestor was found or no more parents defined
  37439. * @param ancestor defines the parent node to inspect
  37440. * @returns a boolean indicating if this node is a descendant of the given node
  37441. */
  37442. isDescendantOf(ancestor: Node): boolean;
  37443. /** @hidden */
  37444. _getDescendants(results: Node[], directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): void;
  37445. /**
  37446. * Will return all nodes that have this node as ascendant
  37447. * @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
  37448. * @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
  37449. * @return all children nodes of all types
  37450. */
  37451. getDescendants(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): Node[];
  37452. /**
  37453. * Get all child-meshes of this node
  37454. * @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)
  37455. * @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
  37456. * @returns an array of AbstractMesh
  37457. */
  37458. getChildMeshes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): AbstractMesh[];
  37459. /**
  37460. * Get all direct children of this node
  37461. * @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
  37462. * @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)
  37463. * @returns an array of Node
  37464. */
  37465. getChildren(predicate?: (node: Node) => boolean, directDescendantsOnly?: boolean): Node[];
  37466. /** @hidden */
  37467. _setReady(state: boolean): void;
  37468. /**
  37469. * Get an animation by name
  37470. * @param name defines the name of the animation to look for
  37471. * @returns null if not found else the requested animation
  37472. */
  37473. getAnimationByName(name: string): Nullable<Animation>;
  37474. /**
  37475. * Creates an animation range for this node
  37476. * @param name defines the name of the range
  37477. * @param from defines the starting key
  37478. * @param to defines the end key
  37479. */
  37480. createAnimationRange(name: string, from: number, to: number): void;
  37481. /**
  37482. * Delete a specific animation range
  37483. * @param name defines the name of the range to delete
  37484. * @param deleteFrames defines if animation frames from the range must be deleted as well
  37485. */
  37486. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  37487. /**
  37488. * Get an animation range by name
  37489. * @param name defines the name of the animation range to look for
  37490. * @returns null if not found else the requested animation range
  37491. */
  37492. getAnimationRange(name: string): Nullable<AnimationRange>;
  37493. /**
  37494. * Gets the list of all animation ranges defined on this node
  37495. * @returns an array
  37496. */
  37497. getAnimationRanges(): Nullable<AnimationRange>[];
  37498. /**
  37499. * Will start the animation sequence
  37500. * @param name defines the range frames for animation sequence
  37501. * @param loop defines if the animation should loop (false by default)
  37502. * @param speedRatio defines the speed factor in which to run the animation (1 by default)
  37503. * @param onAnimationEnd defines a function to be executed when the animation ended (undefined by default)
  37504. * @returns the object created for this animation. If range does not exist, it will return null
  37505. */
  37506. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  37507. /**
  37508. * Serialize animation ranges into a JSON compatible object
  37509. * @returns serialization object
  37510. */
  37511. serializeAnimationRanges(): any;
  37512. /**
  37513. * Computes the world matrix of the node
  37514. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  37515. * @returns the world matrix
  37516. */
  37517. computeWorldMatrix(force?: boolean): Matrix;
  37518. /**
  37519. * Releases resources associated with this node.
  37520. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  37521. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  37522. */
  37523. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  37524. /**
  37525. * Parse animation range data from a serialization object and store them into a given node
  37526. * @param node defines where to store the animation ranges
  37527. * @param parsedNode defines the serialization object to read data from
  37528. * @param scene defines the hosting scene
  37529. */
  37530. static ParseAnimationRanges(node: Node, parsedNode: any, scene: Scene): void;
  37531. /**
  37532. * Return the minimum and maximum world vectors of the entire hierarchy under current node
  37533. * @param includeDescendants Include bounding info from descendants as well (true by default)
  37534. * @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
  37535. * @returns the new bounding vectors
  37536. */
  37537. getHierarchyBoundingVectors(includeDescendants?: boolean, predicate?: Nullable<(abstractMesh: AbstractMesh) => boolean>): {
  37538. min: Vector3;
  37539. max: Vector3;
  37540. };
  37541. }
  37542. }
  37543. declare module BABYLON {
  37544. /**
  37545. * @hidden
  37546. */
  37547. export class _IAnimationState {
  37548. key: number;
  37549. repeatCount: number;
  37550. workValue?: any;
  37551. loopMode?: number;
  37552. offsetValue?: any;
  37553. highLimitValue?: any;
  37554. }
  37555. /**
  37556. * Class used to store any kind of animation
  37557. */
  37558. export class Animation {
  37559. /**Name of the animation */
  37560. name: string;
  37561. /**Property to animate */
  37562. targetProperty: string;
  37563. /**The frames per second of the animation */
  37564. framePerSecond: number;
  37565. /**The data type of the animation */
  37566. dataType: number;
  37567. /**The loop mode of the animation */
  37568. loopMode?: number | undefined;
  37569. /**Specifies if blending should be enabled */
  37570. enableBlending?: boolean | undefined;
  37571. /**
  37572. * Use matrix interpolation instead of using direct key value when animating matrices
  37573. */
  37574. static AllowMatricesInterpolation: boolean;
  37575. /**
  37576. * When matrix interpolation is enabled, this boolean forces the system to use Matrix.DecomposeLerp instead of Matrix.Lerp. Interpolation is more precise but slower
  37577. */
  37578. static AllowMatrixDecomposeForInterpolation: boolean;
  37579. /** Define the Url to load snippets */
  37580. static SnippetUrl: string;
  37581. /** Snippet ID if the animation was created from the snippet server */
  37582. snippetId: string;
  37583. /**
  37584. * Stores the key frames of the animation
  37585. */
  37586. private _keys;
  37587. /**
  37588. * Stores the easing function of the animation
  37589. */
  37590. private _easingFunction;
  37591. /**
  37592. * @hidden Internal use only
  37593. */
  37594. _runtimeAnimations: RuntimeAnimation[];
  37595. /**
  37596. * The set of event that will be linked to this animation
  37597. */
  37598. private _events;
  37599. /**
  37600. * Stores an array of target property paths
  37601. */
  37602. targetPropertyPath: string[];
  37603. /**
  37604. * Stores the blending speed of the animation
  37605. */
  37606. blendingSpeed: number;
  37607. /**
  37608. * Stores the animation ranges for the animation
  37609. */
  37610. private _ranges;
  37611. /**
  37612. * @hidden Internal use
  37613. */
  37614. static _PrepareAnimation(name: string, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction): Nullable<Animation>;
  37615. /**
  37616. * Sets up an animation
  37617. * @param property The property to animate
  37618. * @param animationType The animation type to apply
  37619. * @param framePerSecond The frames per second of the animation
  37620. * @param easingFunction The easing function used in the animation
  37621. * @returns The created animation
  37622. */
  37623. static CreateAnimation(property: string, animationType: number, framePerSecond: number, easingFunction: EasingFunction): Animation;
  37624. /**
  37625. * Create and start an animation on a node
  37626. * @param name defines the name of the global animation that will be run on all nodes
  37627. * @param node defines the root node where the animation will take place
  37628. * @param targetProperty defines property to animate
  37629. * @param framePerSecond defines the number of frame per second yo use
  37630. * @param totalFrame defines the number of frames in total
  37631. * @param from defines the initial value
  37632. * @param to defines the final value
  37633. * @param loopMode defines which loop mode you want to use (off by default)
  37634. * @param easingFunction defines the easing function to use (linear by default)
  37635. * @param onAnimationEnd defines the callback to call when animation end
  37636. * @returns the animatable created for this animation
  37637. */
  37638. static CreateAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  37639. /**
  37640. * Create and start an animation on a node and its descendants
  37641. * @param name defines the name of the global animation that will be run on all nodes
  37642. * @param node defines the root node where the animation will take place
  37643. * @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
  37644. * @param targetProperty defines property to animate
  37645. * @param framePerSecond defines the number of frame per second to use
  37646. * @param totalFrame defines the number of frames in total
  37647. * @param from defines the initial value
  37648. * @param to defines the final value
  37649. * @param loopMode defines which loop mode you want to use (off by default)
  37650. * @param easingFunction defines the easing function to use (linear by default)
  37651. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  37652. * @returns the list of animatables created for all nodes
  37653. * @example https://www.babylonjs-playground.com/#MH0VLI
  37654. */
  37655. 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[]>;
  37656. /**
  37657. * Creates a new animation, merges it with the existing animations and starts it
  37658. * @param name Name of the animation
  37659. * @param node Node which contains the scene that begins the animations
  37660. * @param targetProperty Specifies which property to animate
  37661. * @param framePerSecond The frames per second of the animation
  37662. * @param totalFrame The total number of frames
  37663. * @param from The frame at the beginning of the animation
  37664. * @param to The frame at the end of the animation
  37665. * @param loopMode Specifies the loop mode of the animation
  37666. * @param easingFunction (Optional) The easing function of the animation, which allow custom mathematical formulas for animations
  37667. * @param onAnimationEnd Callback to run once the animation is complete
  37668. * @returns Nullable animation
  37669. */
  37670. static CreateMergeAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  37671. /**
  37672. * Convert the keyframes for all animations belonging to the group to be relative to a given reference frame.
  37673. * @param sourceAnimation defines the Animation containing keyframes to convert
  37674. * @param referenceFrame defines the frame that keyframes in the range will be relative to
  37675. * @param range defines the name of the AnimationRange belonging to the Animation to convert
  37676. * @param cloneOriginal defines whether or not to clone the animation and convert the clone or convert the original animation (default is false)
  37677. * @param clonedName defines the name of the resulting cloned Animation if cloneOriginal is true
  37678. * @returns a new Animation if cloneOriginal is true or the original Animation if cloneOriginal is false
  37679. */
  37680. static MakeAnimationAdditive(sourceAnimation: Animation, referenceFrame?: number, range?: string, cloneOriginal?: boolean, clonedName?: string): Animation;
  37681. /**
  37682. * Transition property of an host to the target Value
  37683. * @param property The property to transition
  37684. * @param targetValue The target Value of the property
  37685. * @param host The object where the property to animate belongs
  37686. * @param scene Scene used to run the animation
  37687. * @param frameRate Framerate (in frame/s) to use
  37688. * @param transition The transition type we want to use
  37689. * @param duration The duration of the animation, in milliseconds
  37690. * @param onAnimationEnd Callback trigger at the end of the animation
  37691. * @returns Nullable animation
  37692. */
  37693. static TransitionTo(property: string, targetValue: any, host: any, scene: Scene, frameRate: number, transition: Animation, duration: number, onAnimationEnd?: Nullable<() => void>): Nullable<Animatable>;
  37694. /**
  37695. * Return the array of runtime animations currently using this animation
  37696. */
  37697. get runtimeAnimations(): RuntimeAnimation[];
  37698. /**
  37699. * Specifies if any of the runtime animations are currently running
  37700. */
  37701. get hasRunningRuntimeAnimations(): boolean;
  37702. /**
  37703. * Initializes the animation
  37704. * @param name Name of the animation
  37705. * @param targetProperty Property to animate
  37706. * @param framePerSecond The frames per second of the animation
  37707. * @param dataType The data type of the animation
  37708. * @param loopMode The loop mode of the animation
  37709. * @param enableBlending Specifies if blending should be enabled
  37710. */
  37711. constructor(
  37712. /**Name of the animation */
  37713. name: string,
  37714. /**Property to animate */
  37715. targetProperty: string,
  37716. /**The frames per second of the animation */
  37717. framePerSecond: number,
  37718. /**The data type of the animation */
  37719. dataType: number,
  37720. /**The loop mode of the animation */
  37721. loopMode?: number | undefined,
  37722. /**Specifies if blending should be enabled */
  37723. enableBlending?: boolean | undefined);
  37724. /**
  37725. * Converts the animation to a string
  37726. * @param fullDetails support for multiple levels of logging within scene loading
  37727. * @returns String form of the animation
  37728. */
  37729. toString(fullDetails?: boolean): string;
  37730. /**
  37731. * Add an event to this animation
  37732. * @param event Event to add
  37733. */
  37734. addEvent(event: AnimationEvent): void;
  37735. /**
  37736. * Remove all events found at the given frame
  37737. * @param frame The frame to remove events from
  37738. */
  37739. removeEvents(frame: number): void;
  37740. /**
  37741. * Retrieves all the events from the animation
  37742. * @returns Events from the animation
  37743. */
  37744. getEvents(): AnimationEvent[];
  37745. /**
  37746. * Creates an animation range
  37747. * @param name Name of the animation range
  37748. * @param from Starting frame of the animation range
  37749. * @param to Ending frame of the animation
  37750. */
  37751. createRange(name: string, from: number, to: number): void;
  37752. /**
  37753. * Deletes an animation range by name
  37754. * @param name Name of the animation range to delete
  37755. * @param deleteFrames Specifies if the key frames for the range should also be deleted (true) or not (false)
  37756. */
  37757. deleteRange(name: string, deleteFrames?: boolean): void;
  37758. /**
  37759. * Gets the animation range by name, or null if not defined
  37760. * @param name Name of the animation range
  37761. * @returns Nullable animation range
  37762. */
  37763. getRange(name: string): Nullable<AnimationRange>;
  37764. /**
  37765. * Gets the key frames from the animation
  37766. * @returns The key frames of the animation
  37767. */
  37768. getKeys(): Array<IAnimationKey>;
  37769. /**
  37770. * Gets the highest frame rate of the animation
  37771. * @returns Highest frame rate of the animation
  37772. */
  37773. getHighestFrame(): number;
  37774. /**
  37775. * Gets the easing function of the animation
  37776. * @returns Easing function of the animation
  37777. */
  37778. getEasingFunction(): IEasingFunction;
  37779. /**
  37780. * Sets the easing function of the animation
  37781. * @param easingFunction A custom mathematical formula for animation
  37782. */
  37783. setEasingFunction(easingFunction: EasingFunction): void;
  37784. /**
  37785. * Interpolates a scalar linearly
  37786. * @param startValue Start value of the animation curve
  37787. * @param endValue End value of the animation curve
  37788. * @param gradient Scalar amount to interpolate
  37789. * @returns Interpolated scalar value
  37790. */
  37791. floatInterpolateFunction(startValue: number, endValue: number, gradient: number): number;
  37792. /**
  37793. * Interpolates a scalar cubically
  37794. * @param startValue Start value of the animation curve
  37795. * @param outTangent End tangent of the animation
  37796. * @param endValue End value of the animation curve
  37797. * @param inTangent Start tangent of the animation curve
  37798. * @param gradient Scalar amount to interpolate
  37799. * @returns Interpolated scalar value
  37800. */
  37801. floatInterpolateFunctionWithTangents(startValue: number, outTangent: number, endValue: number, inTangent: number, gradient: number): number;
  37802. /**
  37803. * Interpolates a quaternion using a spherical linear interpolation
  37804. * @param startValue Start value of the animation curve
  37805. * @param endValue End value of the animation curve
  37806. * @param gradient Scalar amount to interpolate
  37807. * @returns Interpolated quaternion value
  37808. */
  37809. quaternionInterpolateFunction(startValue: Quaternion, endValue: Quaternion, gradient: number): Quaternion;
  37810. /**
  37811. * Interpolates a quaternion cubically
  37812. * @param startValue Start value of the animation curve
  37813. * @param outTangent End tangent of the animation curve
  37814. * @param endValue End value of the animation curve
  37815. * @param inTangent Start tangent of the animation curve
  37816. * @param gradient Scalar amount to interpolate
  37817. * @returns Interpolated quaternion value
  37818. */
  37819. quaternionInterpolateFunctionWithTangents(startValue: Quaternion, outTangent: Quaternion, endValue: Quaternion, inTangent: Quaternion, gradient: number): Quaternion;
  37820. /**
  37821. * Interpolates a Vector3 linearly
  37822. * @param startValue Start value of the animation curve
  37823. * @param endValue End value of the animation curve
  37824. * @param gradient Scalar amount to interpolate
  37825. * @returns Interpolated scalar value
  37826. */
  37827. vector3InterpolateFunction(startValue: Vector3, endValue: Vector3, gradient: number): Vector3;
  37828. /**
  37829. * Interpolates a Vector3 cubically
  37830. * @param startValue Start value of the animation curve
  37831. * @param outTangent End tangent of the animation
  37832. * @param endValue End value of the animation curve
  37833. * @param inTangent Start tangent of the animation curve
  37834. * @param gradient Scalar amount to interpolate
  37835. * @returns InterpolatedVector3 value
  37836. */
  37837. vector3InterpolateFunctionWithTangents(startValue: Vector3, outTangent: Vector3, endValue: Vector3, inTangent: Vector3, gradient: number): Vector3;
  37838. /**
  37839. * Interpolates a Vector2 linearly
  37840. * @param startValue Start value of the animation curve
  37841. * @param endValue End value of the animation curve
  37842. * @param gradient Scalar amount to interpolate
  37843. * @returns Interpolated Vector2 value
  37844. */
  37845. vector2InterpolateFunction(startValue: Vector2, endValue: Vector2, gradient: number): Vector2;
  37846. /**
  37847. * Interpolates a Vector2 cubically
  37848. * @param startValue Start value of the animation curve
  37849. * @param outTangent End tangent of the animation
  37850. * @param endValue End value of the animation curve
  37851. * @param inTangent Start tangent of the animation curve
  37852. * @param gradient Scalar amount to interpolate
  37853. * @returns Interpolated Vector2 value
  37854. */
  37855. vector2InterpolateFunctionWithTangents(startValue: Vector2, outTangent: Vector2, endValue: Vector2, inTangent: Vector2, gradient: number): Vector2;
  37856. /**
  37857. * Interpolates a size linearly
  37858. * @param startValue Start value of the animation curve
  37859. * @param endValue End value of the animation curve
  37860. * @param gradient Scalar amount to interpolate
  37861. * @returns Interpolated Size value
  37862. */
  37863. sizeInterpolateFunction(startValue: Size, endValue: Size, gradient: number): Size;
  37864. /**
  37865. * Interpolates a Color3 linearly
  37866. * @param startValue Start value of the animation curve
  37867. * @param endValue End value of the animation curve
  37868. * @param gradient Scalar amount to interpolate
  37869. * @returns Interpolated Color3 value
  37870. */
  37871. color3InterpolateFunction(startValue: Color3, endValue: Color3, gradient: number): Color3;
  37872. /**
  37873. * Interpolates a Color4 linearly
  37874. * @param startValue Start value of the animation curve
  37875. * @param endValue End value of the animation curve
  37876. * @param gradient Scalar amount to interpolate
  37877. * @returns Interpolated Color3 value
  37878. */
  37879. color4InterpolateFunction(startValue: Color4, endValue: Color4, gradient: number): Color4;
  37880. /**
  37881. * @hidden Internal use only
  37882. */
  37883. _getKeyValue(value: any): any;
  37884. /**
  37885. * @hidden Internal use only
  37886. */
  37887. _interpolate(currentFrame: number, state: _IAnimationState): any;
  37888. /**
  37889. * Defines the function to use to interpolate matrices
  37890. * @param startValue defines the start matrix
  37891. * @param endValue defines the end matrix
  37892. * @param gradient defines the gradient between both matrices
  37893. * @param result defines an optional target matrix where to store the interpolation
  37894. * @returns the interpolated matrix
  37895. */
  37896. matrixInterpolateFunction(startValue: Matrix, endValue: Matrix, gradient: number, result?: Matrix): Matrix;
  37897. /**
  37898. * Makes a copy of the animation
  37899. * @returns Cloned animation
  37900. */
  37901. clone(): Animation;
  37902. /**
  37903. * Sets the key frames of the animation
  37904. * @param values The animation key frames to set
  37905. */
  37906. setKeys(values: Array<IAnimationKey>): void;
  37907. /**
  37908. * Serializes the animation to an object
  37909. * @returns Serialized object
  37910. */
  37911. serialize(): any;
  37912. /**
  37913. * Float animation type
  37914. */
  37915. static readonly ANIMATIONTYPE_FLOAT: number;
  37916. /**
  37917. * Vector3 animation type
  37918. */
  37919. static readonly ANIMATIONTYPE_VECTOR3: number;
  37920. /**
  37921. * Quaternion animation type
  37922. */
  37923. static readonly ANIMATIONTYPE_QUATERNION: number;
  37924. /**
  37925. * Matrix animation type
  37926. */
  37927. static readonly ANIMATIONTYPE_MATRIX: number;
  37928. /**
  37929. * Color3 animation type
  37930. */
  37931. static readonly ANIMATIONTYPE_COLOR3: number;
  37932. /**
  37933. * Color3 animation type
  37934. */
  37935. static readonly ANIMATIONTYPE_COLOR4: number;
  37936. /**
  37937. * Vector2 animation type
  37938. */
  37939. static readonly ANIMATIONTYPE_VECTOR2: number;
  37940. /**
  37941. * Size animation type
  37942. */
  37943. static readonly ANIMATIONTYPE_SIZE: number;
  37944. /**
  37945. * Relative Loop Mode
  37946. */
  37947. static readonly ANIMATIONLOOPMODE_RELATIVE: number;
  37948. /**
  37949. * Cycle Loop Mode
  37950. */
  37951. static readonly ANIMATIONLOOPMODE_CYCLE: number;
  37952. /**
  37953. * Constant Loop Mode
  37954. */
  37955. static readonly ANIMATIONLOOPMODE_CONSTANT: number;
  37956. /** @hidden */
  37957. static _UniversalLerp(left: any, right: any, amount: number): any;
  37958. /**
  37959. * Parses an animation object and creates an animation
  37960. * @param parsedAnimation Parsed animation object
  37961. * @returns Animation object
  37962. */
  37963. static Parse(parsedAnimation: any): Animation;
  37964. /**
  37965. * Appends the serialized animations from the source animations
  37966. * @param source Source containing the animations
  37967. * @param destination Target to store the animations
  37968. */
  37969. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  37970. /**
  37971. * Creates a new animation or an array of animations from a snippet saved in a remote file
  37972. * @param name defines the name of the animation to create (can be null or empty to use the one from the json data)
  37973. * @param url defines the url to load from
  37974. * @returns a promise that will resolve to the new animation or an array of animations
  37975. */
  37976. static ParseFromFileAsync(name: Nullable<string>, url: string): Promise<Animation | Array<Animation>>;
  37977. /**
  37978. * Creates an animation or an array of animations from a snippet saved by the Inspector
  37979. * @param snippetId defines the snippet to load
  37980. * @returns a promise that will resolve to the new animation or a new array of animations
  37981. */
  37982. static CreateFromSnippetAsync(snippetId: string): Promise<Animation | Array<Animation>>;
  37983. }
  37984. }
  37985. declare module BABYLON {
  37986. /**
  37987. * Interface containing an array of animations
  37988. */
  37989. export interface IAnimatable {
  37990. /**
  37991. * Array of animations
  37992. */
  37993. animations: Nullable<Array<Animation>>;
  37994. }
  37995. }
  37996. declare module BABYLON {
  37997. export function expandToProperty(callback: string, targetKey?: Nullable<string>): (target: any, propertyKey: string) => void;
  37998. export function serialize(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  37999. export function serializeAsTexture(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  38000. export function serializeAsColor3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  38001. export function serializeAsFresnelParameters(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  38002. export function serializeAsVector2(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  38003. export function serializeAsVector3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  38004. export function serializeAsMeshReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  38005. export function serializeAsColorCurves(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  38006. export function serializeAsColor4(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  38007. export function serializeAsImageProcessingConfiguration(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  38008. export function serializeAsQuaternion(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  38009. export function serializeAsMatrix(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  38010. /**
  38011. * Decorator used to define property that can be serialized as reference to a camera
  38012. * @param sourceName defines the name of the property to decorate
  38013. */
  38014. export function serializeAsCameraReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  38015. /**
  38016. * Class used to help serialization objects
  38017. */
  38018. export class SerializationHelper {
  38019. /** @hidden */
  38020. static _ImageProcessingConfigurationParser: (sourceProperty: any) => ImageProcessingConfiguration;
  38021. /** @hidden */
  38022. static _FresnelParametersParser: (sourceProperty: any) => FresnelParameters;
  38023. /** @hidden */
  38024. static _ColorCurvesParser: (sourceProperty: any) => ColorCurves;
  38025. /** @hidden */
  38026. static _TextureParser: (sourceProperty: any, scene: Scene, rootUrl: string) => Nullable<BaseTexture>;
  38027. /**
  38028. * Appends the serialized animations from the source animations
  38029. * @param source Source containing the animations
  38030. * @param destination Target to store the animations
  38031. */
  38032. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  38033. /**
  38034. * Static function used to serialized a specific entity
  38035. * @param entity defines the entity to serialize
  38036. * @param serializationObject defines the optional target object where serialization data will be stored
  38037. * @returns a JSON compatible object representing the serialization of the entity
  38038. */
  38039. static Serialize<T>(entity: T, serializationObject?: any): any;
  38040. /**
  38041. * Creates a new entity from a serialization data object
  38042. * @param creationFunction defines a function used to instanciated the new entity
  38043. * @param source defines the source serialization data
  38044. * @param scene defines the hosting scene
  38045. * @param rootUrl defines the root url for resources
  38046. * @returns a new entity
  38047. */
  38048. static Parse<T>(creationFunction: () => T, source: any, scene: Nullable<Scene>, rootUrl?: Nullable<string>): T;
  38049. /**
  38050. * Clones an object
  38051. * @param creationFunction defines the function used to instanciate the new object
  38052. * @param source defines the source object
  38053. * @returns the cloned object
  38054. */
  38055. static Clone<T>(creationFunction: () => T, source: T): T;
  38056. /**
  38057. * Instanciates a new object based on a source one (some data will be shared between both object)
  38058. * @param creationFunction defines the function used to instanciate the new object
  38059. * @param source defines the source object
  38060. * @returns the new object
  38061. */
  38062. static Instanciate<T>(creationFunction: () => T, source: T): T;
  38063. }
  38064. }
  38065. declare module BABYLON {
  38066. /**
  38067. * This is the base class of all the camera used in the application.
  38068. * @see https://doc.babylonjs.com/features/cameras
  38069. */
  38070. export class Camera extends Node {
  38071. /** @hidden */
  38072. static _createDefaultParsedCamera: (name: string, scene: Scene) => Camera;
  38073. /**
  38074. * This is the default projection mode used by the cameras.
  38075. * It helps recreating a feeling of perspective and better appreciate depth.
  38076. * This is the best way to simulate real life cameras.
  38077. */
  38078. static readonly PERSPECTIVE_CAMERA: number;
  38079. /**
  38080. * This helps creating camera with an orthographic mode.
  38081. * 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.
  38082. */
  38083. static readonly ORTHOGRAPHIC_CAMERA: number;
  38084. /**
  38085. * This is the default FOV mode for perspective cameras.
  38086. * This setting aligns the upper and lower bounds of the viewport to the upper and lower bounds of the camera frustum.
  38087. */
  38088. static readonly FOVMODE_VERTICAL_FIXED: number;
  38089. /**
  38090. * This setting aligns the left and right bounds of the viewport to the left and right bounds of the camera frustum.
  38091. */
  38092. static readonly FOVMODE_HORIZONTAL_FIXED: number;
  38093. /**
  38094. * This specifies there is no need for a camera rig.
  38095. * Basically only one eye is rendered corresponding to the camera.
  38096. */
  38097. static readonly RIG_MODE_NONE: number;
  38098. /**
  38099. * Simulates a camera Rig with one blue eye and one red eye.
  38100. * This can be use with 3d blue and red glasses.
  38101. */
  38102. static readonly RIG_MODE_STEREOSCOPIC_ANAGLYPH: number;
  38103. /**
  38104. * Defines that both eyes of the camera will be rendered side by side with a parallel target.
  38105. */
  38106. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL: number;
  38107. /**
  38108. * Defines that both eyes of the camera will be rendered side by side with a none parallel target.
  38109. */
  38110. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED: number;
  38111. /**
  38112. * Defines that both eyes of the camera will be rendered over under each other.
  38113. */
  38114. static readonly RIG_MODE_STEREOSCOPIC_OVERUNDER: number;
  38115. /**
  38116. * Defines that both eyes of the camera will be rendered on successive lines interlaced for passive 3d monitors.
  38117. */
  38118. static readonly RIG_MODE_STEREOSCOPIC_INTERLACED: number;
  38119. /**
  38120. * Defines that both eyes of the camera should be renderered in a VR mode (carbox).
  38121. */
  38122. static readonly RIG_MODE_VR: number;
  38123. /**
  38124. * Defines that both eyes of the camera should be renderered in a VR mode (webVR).
  38125. */
  38126. static readonly RIG_MODE_WEBVR: number;
  38127. /**
  38128. * Custom rig mode allowing rig cameras to be populated manually with any number of cameras
  38129. */
  38130. static readonly RIG_MODE_CUSTOM: number;
  38131. /**
  38132. * Defines if by default attaching controls should prevent the default javascript event to continue.
  38133. */
  38134. static ForceAttachControlToAlwaysPreventDefault: boolean;
  38135. /**
  38136. * Define the input manager associated with the camera.
  38137. */
  38138. inputs: CameraInputsManager<Camera>;
  38139. /** @hidden */
  38140. _position: Vector3;
  38141. /**
  38142. * Define the current local position of the camera in the scene
  38143. */
  38144. get position(): Vector3;
  38145. set position(newPosition: Vector3);
  38146. protected _upVector: Vector3;
  38147. /**
  38148. * The vector the camera should consider as up.
  38149. * (default is Vector3(0, 1, 0) aka Vector3.Up())
  38150. */
  38151. set upVector(vec: Vector3);
  38152. get upVector(): Vector3;
  38153. /**
  38154. * Define the current limit on the left side for an orthographic camera
  38155. * In scene unit
  38156. */
  38157. orthoLeft: Nullable<number>;
  38158. /**
  38159. * Define the current limit on the right side for an orthographic camera
  38160. * In scene unit
  38161. */
  38162. orthoRight: Nullable<number>;
  38163. /**
  38164. * Define the current limit on the bottom side for an orthographic camera
  38165. * In scene unit
  38166. */
  38167. orthoBottom: Nullable<number>;
  38168. /**
  38169. * Define the current limit on the top side for an orthographic camera
  38170. * In scene unit
  38171. */
  38172. orthoTop: Nullable<number>;
  38173. /**
  38174. * Field Of View is set in Radians. (default is 0.8)
  38175. */
  38176. fov: number;
  38177. /**
  38178. * Define the minimum distance the camera can see from.
  38179. * This is important to note that the depth buffer are not infinite and the closer it starts
  38180. * the more your scene might encounter depth fighting issue.
  38181. */
  38182. minZ: number;
  38183. /**
  38184. * Define the maximum distance the camera can see to.
  38185. * This is important to note that the depth buffer are not infinite and the further it end
  38186. * the more your scene might encounter depth fighting issue.
  38187. */
  38188. maxZ: number;
  38189. /**
  38190. * Define the default inertia of the camera.
  38191. * This helps giving a smooth feeling to the camera movement.
  38192. */
  38193. inertia: number;
  38194. /**
  38195. * Define the mode of the camera (Camera.PERSPECTIVE_CAMERA or Camera.ORTHOGRAPHIC_CAMERA)
  38196. */
  38197. mode: number;
  38198. /**
  38199. * Define whether the camera is intermediate.
  38200. * This is useful to not present the output directly to the screen in case of rig without post process for instance
  38201. */
  38202. isIntermediate: boolean;
  38203. /**
  38204. * Define the viewport of the camera.
  38205. * This correspond to the portion of the screen the camera will render to in normalized 0 to 1 unit.
  38206. */
  38207. viewport: Viewport;
  38208. /**
  38209. * Restricts the camera to viewing objects with the same layerMask.
  38210. * A camera with a layerMask of 1 will render mesh.layerMask & camera.layerMask!== 0
  38211. */
  38212. layerMask: number;
  38213. /**
  38214. * fovMode sets the camera frustum bounds to the viewport bounds. (default is FOVMODE_VERTICAL_FIXED)
  38215. */
  38216. fovMode: number;
  38217. /**
  38218. * Rig mode of the camera.
  38219. * This is useful to create the camera with two "eyes" instead of one to create VR or stereoscopic scenes.
  38220. * This is normally controlled byt the camera themselves as internal use.
  38221. */
  38222. cameraRigMode: number;
  38223. /**
  38224. * Defines the distance between both "eyes" in case of a RIG
  38225. */
  38226. interaxialDistance: number;
  38227. /**
  38228. * Defines if stereoscopic rendering is done side by side or over under.
  38229. */
  38230. isStereoscopicSideBySide: boolean;
  38231. /**
  38232. * 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
  38233. * This is pretty helpful if you wish to make a camera render to a texture you could reuse somewhere
  38234. * else in the scene. (Eg. security camera)
  38235. *
  38236. * To change the final output target of the camera, camera.outputRenderTarget should be used instead (eg. webXR renders to a render target corresponding to an HMD)
  38237. */
  38238. customRenderTargets: RenderTargetTexture[];
  38239. /**
  38240. * When set, the camera will render to this render target instead of the default canvas
  38241. *
  38242. * If the desire is to use the output of a camera as a texture in the scene consider using camera.customRenderTargets instead
  38243. */
  38244. outputRenderTarget: Nullable<RenderTargetTexture>;
  38245. /**
  38246. * Observable triggered when the camera view matrix has changed.
  38247. */
  38248. onViewMatrixChangedObservable: Observable<Camera>;
  38249. /**
  38250. * Observable triggered when the camera Projection matrix has changed.
  38251. */
  38252. onProjectionMatrixChangedObservable: Observable<Camera>;
  38253. /**
  38254. * Observable triggered when the inputs have been processed.
  38255. */
  38256. onAfterCheckInputsObservable: Observable<Camera>;
  38257. /**
  38258. * Observable triggered when reset has been called and applied to the camera.
  38259. */
  38260. onRestoreStateObservable: Observable<Camera>;
  38261. /**
  38262. * Is this camera a part of a rig system?
  38263. */
  38264. isRigCamera: boolean;
  38265. /**
  38266. * If isRigCamera set to true this will be set with the parent camera.
  38267. * The parent camera is not (!) necessarily the .parent of this camera (like in the case of XR)
  38268. */
  38269. rigParent?: Camera;
  38270. /** @hidden */
  38271. _cameraRigParams: any;
  38272. /** @hidden */
  38273. _rigCameras: Camera[];
  38274. /** @hidden */
  38275. _rigPostProcess: Nullable<PostProcess>;
  38276. protected _webvrViewMatrix: Matrix;
  38277. /** @hidden */
  38278. _skipRendering: boolean;
  38279. /** @hidden */
  38280. _projectionMatrix: Matrix;
  38281. /** @hidden */
  38282. _postProcesses: Nullable<PostProcess>[];
  38283. /** @hidden */
  38284. _activeMeshes: SmartArray<AbstractMesh>;
  38285. protected _globalPosition: Vector3;
  38286. /** @hidden */
  38287. _computedViewMatrix: Matrix;
  38288. private _doNotComputeProjectionMatrix;
  38289. private _transformMatrix;
  38290. private _frustumPlanes;
  38291. private _refreshFrustumPlanes;
  38292. private _storedFov;
  38293. private _stateStored;
  38294. /**
  38295. * Instantiates a new camera object.
  38296. * This should not be used directly but through the inherited cameras: ArcRotate, Free...
  38297. * @see https://doc.babylonjs.com/features/cameras
  38298. * @param name Defines the name of the camera in the scene
  38299. * @param position Defines the position of the camera
  38300. * @param scene Defines the scene the camera belongs too
  38301. * @param setActiveOnSceneIfNoneActive Defines if the camera should be set as active after creation if no other camera have been defined in the scene
  38302. */
  38303. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  38304. /**
  38305. * Store current camera state (fov, position, etc..)
  38306. * @returns the camera
  38307. */
  38308. storeState(): Camera;
  38309. /**
  38310. * Restores the camera state values if it has been stored. You must call storeState() first
  38311. */
  38312. protected _restoreStateValues(): boolean;
  38313. /**
  38314. * Restored camera state. You must call storeState() first.
  38315. * @returns true if restored and false otherwise
  38316. */
  38317. restoreState(): boolean;
  38318. /**
  38319. * Gets the class name of the camera.
  38320. * @returns the class name
  38321. */
  38322. getClassName(): string;
  38323. /** @hidden */
  38324. readonly _isCamera: boolean;
  38325. /**
  38326. * Gets a string representation of the camera useful for debug purpose.
  38327. * @param fullDetails Defines that a more verboe level of logging is required
  38328. * @returns the string representation
  38329. */
  38330. toString(fullDetails?: boolean): string;
  38331. /**
  38332. * Gets the current world space position of the camera.
  38333. */
  38334. get globalPosition(): Vector3;
  38335. /**
  38336. * Gets the list of active meshes this frame (meshes no culled or excluded by lod s in the frame)
  38337. * @returns the active meshe list
  38338. */
  38339. getActiveMeshes(): SmartArray<AbstractMesh>;
  38340. /**
  38341. * Check whether a mesh is part of the current active mesh list of the camera
  38342. * @param mesh Defines the mesh to check
  38343. * @returns true if active, false otherwise
  38344. */
  38345. isActiveMesh(mesh: Mesh): boolean;
  38346. /**
  38347. * Is this camera ready to be used/rendered
  38348. * @param completeCheck defines if a complete check (including post processes) has to be done (false by default)
  38349. * @return true if the camera is ready
  38350. */
  38351. isReady(completeCheck?: boolean): boolean;
  38352. /** @hidden */
  38353. _initCache(): void;
  38354. /** @hidden */
  38355. _updateCache(ignoreParentClass?: boolean): void;
  38356. /** @hidden */
  38357. _isSynchronized(): boolean;
  38358. /** @hidden */
  38359. _isSynchronizedViewMatrix(): boolean;
  38360. /** @hidden */
  38361. _isSynchronizedProjectionMatrix(): boolean;
  38362. /**
  38363. * Attach the input controls to a specific dom element to get the input from.
  38364. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  38365. */
  38366. attachControl(noPreventDefault?: boolean): void;
  38367. /**
  38368. * Attach the input controls to a specific dom element to get the input from.
  38369. * @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
  38370. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  38371. * BACK COMPAT SIGNATURE ONLY.
  38372. */
  38373. attachControl(ignored: any, noPreventDefault?: boolean): void;
  38374. /**
  38375. * Detach the current controls from the specified dom element.
  38376. */
  38377. detachControl(): void;
  38378. /**
  38379. * Detach the current controls from the specified dom element.
  38380. * @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
  38381. */
  38382. detachControl(ignored: any): void;
  38383. /**
  38384. * Update the camera state according to the different inputs gathered during the frame.
  38385. */
  38386. update(): void;
  38387. /** @hidden */
  38388. _checkInputs(): void;
  38389. /** @hidden */
  38390. get rigCameras(): Camera[];
  38391. /**
  38392. * Gets the post process used by the rig cameras
  38393. */
  38394. get rigPostProcess(): Nullable<PostProcess>;
  38395. /**
  38396. * Internal, gets the first post process.
  38397. * @returns the first post process to be run on this camera.
  38398. */
  38399. _getFirstPostProcess(): Nullable<PostProcess>;
  38400. private _cascadePostProcessesToRigCams;
  38401. /**
  38402. * Attach a post process to the camera.
  38403. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  38404. * @param postProcess The post process to attach to the camera
  38405. * @param insertAt The position of the post process in case several of them are in use in the scene
  38406. * @returns the position the post process has been inserted at
  38407. */
  38408. attachPostProcess(postProcess: PostProcess, insertAt?: Nullable<number>): number;
  38409. /**
  38410. * Detach a post process to the camera.
  38411. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  38412. * @param postProcess The post process to detach from the camera
  38413. */
  38414. detachPostProcess(postProcess: PostProcess): void;
  38415. /**
  38416. * Gets the current world matrix of the camera
  38417. */
  38418. getWorldMatrix(): Matrix;
  38419. /** @hidden */
  38420. _getViewMatrix(): Matrix;
  38421. /**
  38422. * Gets the current view matrix of the camera.
  38423. * @param force forces the camera to recompute the matrix without looking at the cached state
  38424. * @returns the view matrix
  38425. */
  38426. getViewMatrix(force?: boolean): Matrix;
  38427. /**
  38428. * Freeze the projection matrix.
  38429. * It will prevent the cache check of the camera projection compute and can speed up perf
  38430. * if no parameter of the camera are meant to change
  38431. * @param projection Defines manually a projection if necessary
  38432. */
  38433. freezeProjectionMatrix(projection?: Matrix): void;
  38434. /**
  38435. * Unfreeze the projection matrix if it has previously been freezed by freezeProjectionMatrix.
  38436. */
  38437. unfreezeProjectionMatrix(): void;
  38438. /**
  38439. * Gets the current projection matrix of the camera.
  38440. * @param force forces the camera to recompute the matrix without looking at the cached state
  38441. * @returns the projection matrix
  38442. */
  38443. getProjectionMatrix(force?: boolean): Matrix;
  38444. /**
  38445. * Gets the transformation matrix (ie. the multiplication of view by projection matrices)
  38446. * @returns a Matrix
  38447. */
  38448. getTransformationMatrix(): Matrix;
  38449. private _updateFrustumPlanes;
  38450. /**
  38451. * Checks if a cullable object (mesh...) is in the camera frustum
  38452. * This checks the bounding box center. See isCompletelyInFrustum for a full bounding check
  38453. * @param target The object to check
  38454. * @param checkRigCameras If the rig cameras should be checked (eg. with webVR camera both eyes should be checked) (Default: false)
  38455. * @returns true if the object is in frustum otherwise false
  38456. */
  38457. isInFrustum(target: ICullable, checkRigCameras?: boolean): boolean;
  38458. /**
  38459. * Checks if a cullable object (mesh...) is in the camera frustum
  38460. * Unlike isInFrustum this checks the full bounding box
  38461. * @param target The object to check
  38462. * @returns true if the object is in frustum otherwise false
  38463. */
  38464. isCompletelyInFrustum(target: ICullable): boolean;
  38465. /**
  38466. * Gets a ray in the forward direction from the camera.
  38467. * @param length Defines the length of the ray to create
  38468. * @param transform Defines the transform to apply to the ray, by default the world matrix is used to create a workd space ray
  38469. * @param origin Defines the start point of the ray which defaults to the camera position
  38470. * @returns the forward ray
  38471. */
  38472. getForwardRay(length?: number, transform?: Matrix, origin?: Vector3): Ray;
  38473. /**
  38474. * Gets a ray in the forward direction from the camera.
  38475. * @param refRay the ray to (re)use when setting the values
  38476. * @param length Defines the length of the ray to create
  38477. * @param transform Defines the transform to apply to the ray, by default the world matrx is used to create a workd space ray
  38478. * @param origin Defines the start point of the ray which defaults to the camera position
  38479. * @returns the forward ray
  38480. */
  38481. getForwardRayToRef(refRay: Ray, length?: number, transform?: Matrix, origin?: Vector3): Ray;
  38482. /**
  38483. * Releases resources associated with this node.
  38484. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  38485. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  38486. */
  38487. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  38488. /** @hidden */
  38489. _isLeftCamera: boolean;
  38490. /**
  38491. * Gets the left camera of a rig setup in case of Rigged Camera
  38492. */
  38493. get isLeftCamera(): boolean;
  38494. /** @hidden */
  38495. _isRightCamera: boolean;
  38496. /**
  38497. * Gets the right camera of a rig setup in case of Rigged Camera
  38498. */
  38499. get isRightCamera(): boolean;
  38500. /**
  38501. * Gets the left camera of a rig setup in case of Rigged Camera
  38502. */
  38503. get leftCamera(): Nullable<FreeCamera>;
  38504. /**
  38505. * Gets the right camera of a rig setup in case of Rigged Camera
  38506. */
  38507. get rightCamera(): Nullable<FreeCamera>;
  38508. /**
  38509. * Gets the left camera target of a rig setup in case of Rigged Camera
  38510. * @returns the target position
  38511. */
  38512. getLeftTarget(): Nullable<Vector3>;
  38513. /**
  38514. * Gets the right camera target of a rig setup in case of Rigged Camera
  38515. * @returns the target position
  38516. */
  38517. getRightTarget(): Nullable<Vector3>;
  38518. /**
  38519. * @hidden
  38520. */
  38521. setCameraRigMode(mode: number, rigParams: any): void;
  38522. /** @hidden */
  38523. static _setStereoscopicRigMode(camera: Camera): void;
  38524. /** @hidden */
  38525. static _setStereoscopicAnaglyphRigMode(camera: Camera): void;
  38526. /** @hidden */
  38527. static _setVRRigMode(camera: Camera, rigParams: any): void;
  38528. /** @hidden */
  38529. static _setWebVRRigMode(camera: Camera, rigParams: any): void;
  38530. /** @hidden */
  38531. _getVRProjectionMatrix(): Matrix;
  38532. protected _updateCameraRotationMatrix(): void;
  38533. protected _updateWebVRCameraRotationMatrix(): void;
  38534. /**
  38535. * This function MUST be overwritten by the different WebVR cameras available.
  38536. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  38537. * @hidden
  38538. */
  38539. _getWebVRProjectionMatrix(): Matrix;
  38540. /**
  38541. * This function MUST be overwritten by the different WebVR cameras available.
  38542. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  38543. * @hidden
  38544. */
  38545. _getWebVRViewMatrix(): Matrix;
  38546. /** @hidden */
  38547. setCameraRigParameter(name: string, value: any): void;
  38548. /**
  38549. * needs to be overridden by children so sub has required properties to be copied
  38550. * @hidden
  38551. */
  38552. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  38553. /**
  38554. * May need to be overridden by children
  38555. * @hidden
  38556. */
  38557. _updateRigCameras(): void;
  38558. /** @hidden */
  38559. _setupInputs(): void;
  38560. /**
  38561. * Serialiaze the camera setup to a json representation
  38562. * @returns the JSON representation
  38563. */
  38564. serialize(): any;
  38565. /**
  38566. * Clones the current camera.
  38567. * @param name The cloned camera name
  38568. * @returns the cloned camera
  38569. */
  38570. clone(name: string): Camera;
  38571. /**
  38572. * Gets the direction of the camera relative to a given local axis.
  38573. * @param localAxis Defines the reference axis to provide a relative direction.
  38574. * @return the direction
  38575. */
  38576. getDirection(localAxis: Vector3): Vector3;
  38577. /**
  38578. * Returns the current camera absolute rotation
  38579. */
  38580. get absoluteRotation(): Quaternion;
  38581. /**
  38582. * Gets the direction of the camera relative to a given local axis into a passed vector.
  38583. * @param localAxis Defines the reference axis to provide a relative direction.
  38584. * @param result Defines the vector to store the result in
  38585. */
  38586. getDirectionToRef(localAxis: Vector3, result: Vector3): void;
  38587. /**
  38588. * Gets a camera constructor for a given camera type
  38589. * @param type The type of the camera to construct (should be equal to one of the camera class name)
  38590. * @param name The name of the camera the result will be able to instantiate
  38591. * @param scene The scene the result will construct the camera in
  38592. * @param interaxial_distance In case of stereoscopic setup, the distance between both eyes
  38593. * @param isStereoscopicSideBySide In case of stereoscopic setup, should the sereo be side b side
  38594. * @returns a factory method to construct the camera
  38595. */
  38596. static GetConstructorFromName(type: string, name: string, scene: Scene, interaxial_distance?: number, isStereoscopicSideBySide?: boolean): () => Camera;
  38597. /**
  38598. * Compute the world matrix of the camera.
  38599. * @returns the camera world matrix
  38600. */
  38601. computeWorldMatrix(): Matrix;
  38602. /**
  38603. * Parse a JSON and creates the camera from the parsed information
  38604. * @param parsedCamera The JSON to parse
  38605. * @param scene The scene to instantiate the camera in
  38606. * @returns the newly constructed camera
  38607. */
  38608. static Parse(parsedCamera: any, scene: Scene): Camera;
  38609. }
  38610. }
  38611. declare module BABYLON {
  38612. /**
  38613. * PostProcessManager is used to manage one or more post processes or post process pipelines
  38614. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  38615. */
  38616. export class PostProcessManager {
  38617. private _scene;
  38618. private _indexBuffer;
  38619. private _vertexBuffers;
  38620. /**
  38621. * Creates a new instance PostProcess
  38622. * @param scene The scene that the post process is associated with.
  38623. */
  38624. constructor(scene: Scene);
  38625. private _prepareBuffers;
  38626. private _buildIndexBuffer;
  38627. /**
  38628. * Rebuilds the vertex buffers of the manager.
  38629. * @hidden
  38630. */
  38631. _rebuild(): void;
  38632. /**
  38633. * Prepares a frame to be run through a post process.
  38634. * @param sourceTexture The input texture to the post procesess. (default: null)
  38635. * @param postProcesses An array of post processes to be run. (default: null)
  38636. * @returns True if the post processes were able to be run.
  38637. * @hidden
  38638. */
  38639. _prepareFrame(sourceTexture?: Nullable<InternalTexture>, postProcesses?: Nullable<PostProcess[]>): boolean;
  38640. /**
  38641. * Manually render a set of post processes to a texture.
  38642. * Please note, the frame buffer won't be unbound after the call in case you have more render to do.
  38643. * @param postProcesses An array of post processes to be run.
  38644. * @param targetTexture The target texture to render to.
  38645. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight
  38646. * @param faceIndex defines the face to render to if a cubemap is defined as the target
  38647. * @param lodLevel defines which lod of the texture to render to
  38648. * @param doNotBindFrambuffer If set to true, assumes that the framebuffer has been bound previously
  38649. */
  38650. directRender(postProcesses: PostProcess[], targetTexture?: Nullable<InternalTexture>, forceFullscreenViewport?: boolean, faceIndex?: number, lodLevel?: number, doNotBindFrambuffer?: boolean): void;
  38651. /**
  38652. * Finalize the result of the output of the postprocesses.
  38653. * @param doNotPresent If true the result will not be displayed to the screen.
  38654. * @param targetTexture The target texture to render to.
  38655. * @param faceIndex The index of the face to bind the target texture to.
  38656. * @param postProcesses The array of post processes to render.
  38657. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight (default: false)
  38658. * @hidden
  38659. */
  38660. _finalizeFrame(doNotPresent?: boolean, targetTexture?: InternalTexture, faceIndex?: number, postProcesses?: Array<PostProcess>, forceFullscreenViewport?: boolean): void;
  38661. /**
  38662. * Disposes of the post process manager.
  38663. */
  38664. dispose(): void;
  38665. }
  38666. }
  38667. declare module BABYLON {
  38668. /**
  38669. * This Helps creating a texture that will be created from a camera in your scene.
  38670. * It is basically a dynamic texture that could be used to create special effects for instance.
  38671. * Actually, It is the base of lot of effects in the framework like post process, shadows, effect layers and rendering pipelines...
  38672. */
  38673. export class RenderTargetTexture extends Texture {
  38674. /**
  38675. * The texture will only be rendered once which can be useful to improve performance if everything in your render is static for instance.
  38676. */
  38677. static readonly REFRESHRATE_RENDER_ONCE: number;
  38678. /**
  38679. * The texture will only be rendered rendered every frame and is recommended for dynamic contents.
  38680. */
  38681. static readonly REFRESHRATE_RENDER_ONEVERYFRAME: number;
  38682. /**
  38683. * The texture will be rendered every 2 frames which could be enough if your dynamic objects are not
  38684. * the central point of your effect and can save a lot of performances.
  38685. */
  38686. static readonly REFRESHRATE_RENDER_ONEVERYTWOFRAMES: number;
  38687. /**
  38688. * Use this predicate to dynamically define the list of mesh you want to render.
  38689. * If set, the renderList property will be overwritten.
  38690. */
  38691. renderListPredicate: (AbstractMesh: AbstractMesh) => boolean;
  38692. private _renderList;
  38693. /**
  38694. * Use this list to define the list of mesh you want to render.
  38695. */
  38696. get renderList(): Nullable<Array<AbstractMesh>>;
  38697. set renderList(value: Nullable<Array<AbstractMesh>>);
  38698. /**
  38699. * Use this function to overload the renderList array at rendering time.
  38700. * Return null to render with the current renderList, else return the list of meshes to use for rendering.
  38701. * For 2DArray RTT, layerOrFace is the index of the layer that is going to be rendered, else it is the faceIndex of
  38702. * the cube (if the RTT is a cube, else layerOrFace=0).
  38703. * The renderList passed to the function is the current render list (the one that will be used if the function returns null).
  38704. * The length of this list is passed through renderListLength: don't use renderList.length directly because the array can
  38705. * hold dummy elements!
  38706. */
  38707. getCustomRenderList: (layerOrFace: number, renderList: Nullable<Immutable<Array<AbstractMesh>>>, renderListLength: number) => Nullable<Array<AbstractMesh>>;
  38708. private _hookArray;
  38709. /**
  38710. * Define if particles should be rendered in your texture.
  38711. */
  38712. renderParticles: boolean;
  38713. /**
  38714. * Define if sprites should be rendered in your texture.
  38715. */
  38716. renderSprites: boolean;
  38717. /**
  38718. * Define the camera used to render the texture.
  38719. */
  38720. activeCamera: Nullable<Camera>;
  38721. /**
  38722. * Override the mesh isReady function with your own one.
  38723. */
  38724. customIsReadyFunction: (mesh: AbstractMesh, refreshRate: number) => boolean;
  38725. /**
  38726. * Override the render function of the texture with your own one.
  38727. */
  38728. customRenderFunction: (opaqueSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>, beforeTransparents?: () => void) => void;
  38729. /**
  38730. * Define if camera post processes should be use while rendering the texture.
  38731. */
  38732. useCameraPostProcesses: boolean;
  38733. /**
  38734. * Define if the camera viewport should be respected while rendering the texture or if the render should be done to the entire texture.
  38735. */
  38736. ignoreCameraViewport: boolean;
  38737. private _postProcessManager;
  38738. /**
  38739. * Post-processes for this render target
  38740. */
  38741. get postProcesses(): PostProcess[];
  38742. private _postProcesses;
  38743. private _resizeObserver;
  38744. private get _prePassEnabled();
  38745. /**
  38746. * An event triggered when the texture is unbind.
  38747. */
  38748. onBeforeBindObservable: Observable<RenderTargetTexture>;
  38749. /**
  38750. * An event triggered when the texture is unbind.
  38751. */
  38752. onAfterUnbindObservable: Observable<RenderTargetTexture>;
  38753. private _onAfterUnbindObserver;
  38754. /**
  38755. * Set a after unbind callback in the texture.
  38756. * This has been kept for backward compatibility and use of onAfterUnbindObservable is recommended.
  38757. */
  38758. set onAfterUnbind(callback: () => void);
  38759. /**
  38760. * An event triggered before rendering the texture
  38761. */
  38762. onBeforeRenderObservable: Observable<number>;
  38763. private _onBeforeRenderObserver;
  38764. /**
  38765. * Set a before render callback in the texture.
  38766. * This has been kept for backward compatibility and use of onBeforeRenderObservable is recommended.
  38767. */
  38768. set onBeforeRender(callback: (faceIndex: number) => void);
  38769. /**
  38770. * An event triggered after rendering the texture
  38771. */
  38772. onAfterRenderObservable: Observable<number>;
  38773. private _onAfterRenderObserver;
  38774. /**
  38775. * Set a after render callback in the texture.
  38776. * This has been kept for backward compatibility and use of onAfterRenderObservable is recommended.
  38777. */
  38778. set onAfterRender(callback: (faceIndex: number) => void);
  38779. /**
  38780. * An event triggered after the texture clear
  38781. */
  38782. onClearObservable: Observable<Engine>;
  38783. private _onClearObserver;
  38784. /**
  38785. * Set a clear callback in the texture.
  38786. * This has been kept for backward compatibility and use of onClearObservable is recommended.
  38787. */
  38788. set onClear(callback: (Engine: Engine) => void);
  38789. /**
  38790. * An event triggered when the texture is resized.
  38791. */
  38792. onResizeObservable: Observable<RenderTargetTexture>;
  38793. /**
  38794. * Define the clear color of the Render Target if it should be different from the scene.
  38795. */
  38796. clearColor: Color4;
  38797. protected _size: number | {
  38798. width: number;
  38799. height: number;
  38800. layers?: number;
  38801. };
  38802. protected _initialSizeParameter: number | {
  38803. width: number;
  38804. height: number;
  38805. } | {
  38806. ratio: number;
  38807. };
  38808. protected _sizeRatio: Nullable<number>;
  38809. /** @hidden */
  38810. _generateMipMaps: boolean;
  38811. protected _renderingManager: RenderingManager;
  38812. /** @hidden */
  38813. _waitingRenderList?: string[];
  38814. protected _doNotChangeAspectRatio: boolean;
  38815. protected _currentRefreshId: number;
  38816. protected _refreshRate: number;
  38817. protected _textureMatrix: Matrix;
  38818. protected _samples: number;
  38819. protected _renderTargetOptions: RenderTargetCreationOptions;
  38820. /**
  38821. * Gets render target creation options that were used.
  38822. */
  38823. get renderTargetOptions(): RenderTargetCreationOptions;
  38824. protected _onRatioRescale(): void;
  38825. /**
  38826. * Gets or sets the center of the bounding box associated with the texture (when in cube mode)
  38827. * It must define where the camera used to render the texture is set
  38828. */
  38829. boundingBoxPosition: Vector3;
  38830. private _boundingBoxSize;
  38831. /**
  38832. * Gets or sets the size of the bounding box associated with the texture (when in cube mode)
  38833. * When defined, the cubemap will switch to local mode
  38834. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  38835. * @example https://www.babylonjs-playground.com/#RNASML
  38836. */
  38837. set boundingBoxSize(value: Vector3);
  38838. get boundingBoxSize(): Vector3;
  38839. /**
  38840. * In case the RTT has been created with a depth texture, get the associated
  38841. * depth texture.
  38842. * Otherwise, return null.
  38843. */
  38844. get depthStencilTexture(): Nullable<InternalTexture>;
  38845. /**
  38846. * Instantiate a render target texture. This is mainly used to render of screen the scene to for instance apply post process
  38847. * or used a shadow, depth texture...
  38848. * @param name The friendly name of the texture
  38849. * @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)
  38850. * @param scene The scene the RTT belongs to. The latest created scene will be used if not precised.
  38851. * @param generateMipMaps True if mip maps need to be generated after render.
  38852. * @param doNotChangeAspectRatio True to not change the aspect ratio of the scene in the RTT
  38853. * @param type The type of the buffer in the RTT (int, half float, float...)
  38854. * @param isCube True if a cube texture needs to be created
  38855. * @param samplingMode The sampling mode to be usedwith the render target (Linear, Nearest...)
  38856. * @param generateDepthBuffer True to generate a depth buffer
  38857. * @param generateStencilBuffer True to generate a stencil buffer
  38858. * @param isMulti True if multiple textures need to be created (Draw Buffers)
  38859. * @param format The internal format of the buffer in the RTT (RED, RG, RGB, RGBA, ALPHA...)
  38860. * @param delayAllocation if the texture allocation should be delayed (default: false)
  38861. * @param samples sample count to use when creating the RTT
  38862. */
  38863. constructor(name: string, size: number | {
  38864. width: number;
  38865. height: number;
  38866. layers?: number;
  38867. } | {
  38868. ratio: number;
  38869. }, 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);
  38870. /**
  38871. * Creates a depth stencil texture.
  38872. * This is only available in WebGL 2 or with the depth texture extension available.
  38873. * @param comparisonFunction Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode
  38874. * @param bilinearFiltering Specifies whether or not bilinear filtering is enable on the texture
  38875. * @param generateStencil Specifies whether or not a stencil should be allocated in the texture
  38876. * @param samples sample count of the depth/stencil texture
  38877. */
  38878. createDepthStencilTexture(comparisonFunction?: number, bilinearFiltering?: boolean, generateStencil?: boolean, samples?: number): void;
  38879. private _processSizeParameter;
  38880. /**
  38881. * Define the number of samples to use in case of MSAA.
  38882. * It defaults to one meaning no MSAA has been enabled.
  38883. */
  38884. get samples(): number;
  38885. set samples(value: number);
  38886. /**
  38887. * Resets the refresh counter of the texture and start bak from scratch.
  38888. * Could be useful to regenerate the texture if it is setup to render only once.
  38889. */
  38890. resetRefreshCounter(): void;
  38891. /**
  38892. * Define the refresh rate of the texture or the rendering frequency.
  38893. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  38894. */
  38895. get refreshRate(): number;
  38896. set refreshRate(value: number);
  38897. /**
  38898. * Adds a post process to the render target rendering passes.
  38899. * @param postProcess define the post process to add
  38900. */
  38901. addPostProcess(postProcess: PostProcess): void;
  38902. /**
  38903. * Clear all the post processes attached to the render target
  38904. * @param dispose define if the cleared post processes should also be disposed (false by default)
  38905. */
  38906. clearPostProcesses(dispose?: boolean): void;
  38907. /**
  38908. * Remove one of the post process from the list of attached post processes to the texture
  38909. * @param postProcess define the post process to remove from the list
  38910. */
  38911. removePostProcess(postProcess: PostProcess): void;
  38912. /** @hidden */
  38913. _shouldRender(): boolean;
  38914. /**
  38915. * Gets the actual render size of the texture.
  38916. * @returns the width of the render size
  38917. */
  38918. getRenderSize(): number;
  38919. /**
  38920. * Gets the actual render width of the texture.
  38921. * @returns the width of the render size
  38922. */
  38923. getRenderWidth(): number;
  38924. /**
  38925. * Gets the actual render height of the texture.
  38926. * @returns the height of the render size
  38927. */
  38928. getRenderHeight(): number;
  38929. /**
  38930. * Gets the actual number of layers of the texture.
  38931. * @returns the number of layers
  38932. */
  38933. getRenderLayers(): number;
  38934. /**
  38935. * Get if the texture can be rescaled or not.
  38936. */
  38937. get canRescale(): boolean;
  38938. /**
  38939. * Resize the texture using a ratio.
  38940. * @param ratio the ratio to apply to the texture size in order to compute the new target size
  38941. */
  38942. scale(ratio: number): void;
  38943. /**
  38944. * Get the texture reflection matrix used to rotate/transform the reflection.
  38945. * @returns the reflection matrix
  38946. */
  38947. getReflectionTextureMatrix(): Matrix;
  38948. /**
  38949. * Resize the texture to a new desired size.
  38950. * Be careful as it will recreate all the data in the new texture.
  38951. * @param size Define the new size. It can be:
  38952. * - a number for squared texture,
  38953. * - an object containing { width: number, height: number }
  38954. * - or an object containing a ratio { ratio: number }
  38955. */
  38956. resize(size: number | {
  38957. width: number;
  38958. height: number;
  38959. } | {
  38960. ratio: number;
  38961. }): void;
  38962. private _defaultRenderListPrepared;
  38963. /**
  38964. * Renders all the objects from the render list into the texture.
  38965. * @param useCameraPostProcess Define if camera post processes should be used during the rendering
  38966. * @param dumpForDebug Define if the rendering result should be dumped (copied) for debugging purpose
  38967. */
  38968. render(useCameraPostProcess?: boolean, dumpForDebug?: boolean): void;
  38969. private _bestReflectionRenderTargetDimension;
  38970. private _prepareRenderingManager;
  38971. /**
  38972. * @hidden
  38973. * @param faceIndex face index to bind to if this is a cubetexture
  38974. * @param layer defines the index of the texture to bind in the array
  38975. */
  38976. _bindFrameBuffer(faceIndex?: number, layer?: number): void;
  38977. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  38978. /**
  38979. * @hidden
  38980. */
  38981. _prepareFrame(scene: Scene, faceIndex?: number, layer?: number, useCameraPostProcess?: boolean): void;
  38982. private renderToTarget;
  38983. /**
  38984. * Overrides the default sort function applied in the rendering group to prepare the meshes.
  38985. * This allowed control for front to back rendering or reversely depending of the special needs.
  38986. *
  38987. * @param renderingGroupId The rendering group id corresponding to its index
  38988. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  38989. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  38990. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  38991. */
  38992. 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;
  38993. /**
  38994. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  38995. *
  38996. * @param renderingGroupId The rendering group id corresponding to its index
  38997. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  38998. */
  38999. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  39000. /**
  39001. * Clones the texture.
  39002. * @returns the cloned texture
  39003. */
  39004. clone(): RenderTargetTexture;
  39005. /**
  39006. * Serialize the texture to a JSON representation we can easily use in the respective Parse function.
  39007. * @returns The JSON representation of the texture
  39008. */
  39009. serialize(): any;
  39010. /**
  39011. * This will remove the attached framebuffer objects. The texture will not be able to be used as render target anymore
  39012. */
  39013. disposeFramebufferObjects(): void;
  39014. /**
  39015. * Dispose the texture and release its associated resources.
  39016. */
  39017. dispose(): void;
  39018. /** @hidden */
  39019. _rebuild(): void;
  39020. /**
  39021. * Clear the info related to rendering groups preventing retention point in material dispose.
  39022. */
  39023. freeRenderingGroups(): void;
  39024. /**
  39025. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  39026. * @returns the view count
  39027. */
  39028. getViewCount(): number;
  39029. }
  39030. }
  39031. declare module BABYLON {
  39032. /**
  39033. * Options to be used when creating an effect.
  39034. */
  39035. export interface IEffectCreationOptions {
  39036. /**
  39037. * Attributes that will be used in the shader.
  39038. */
  39039. attributes: string[];
  39040. /**
  39041. * Uniform variable names that will be set in the shader.
  39042. */
  39043. uniformsNames: string[];
  39044. /**
  39045. * Uniform buffer variable names that will be set in the shader.
  39046. */
  39047. uniformBuffersNames: string[];
  39048. /**
  39049. * Sampler texture variable names that will be set in the shader.
  39050. */
  39051. samplers: string[];
  39052. /**
  39053. * Define statements that will be set in the shader.
  39054. */
  39055. defines: any;
  39056. /**
  39057. * Possible fallbacks for this effect to improve performance when needed.
  39058. */
  39059. fallbacks: Nullable<IEffectFallbacks>;
  39060. /**
  39061. * Callback that will be called when the shader is compiled.
  39062. */
  39063. onCompiled: Nullable<(effect: Effect) => void>;
  39064. /**
  39065. * Callback that will be called if an error occurs during shader compilation.
  39066. */
  39067. onError: Nullable<(effect: Effect, errors: string) => void>;
  39068. /**
  39069. * Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  39070. */
  39071. indexParameters?: any;
  39072. /**
  39073. * Max number of lights that can be used in the shader.
  39074. */
  39075. maxSimultaneousLights?: number;
  39076. /**
  39077. * See https://developer.mozilla.org/en-US/docs/Web/API/WebGL2RenderingContext/transformFeedbackVaryings
  39078. */
  39079. transformFeedbackVaryings?: Nullable<string[]>;
  39080. /**
  39081. * 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
  39082. */
  39083. processFinalCode?: Nullable<(shaderType: string, code: string) => string>;
  39084. /**
  39085. * Is this effect rendering to several color attachments ?
  39086. */
  39087. multiTarget?: boolean;
  39088. }
  39089. /**
  39090. * Effect containing vertex and fragment shader that can be executed on an object.
  39091. */
  39092. export class Effect implements IDisposable {
  39093. /**
  39094. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  39095. */
  39096. static ShadersRepository: string;
  39097. /**
  39098. * Enable logging of the shader code when a compilation error occurs
  39099. */
  39100. static LogShaderCodeOnCompilationError: boolean;
  39101. /**
  39102. * Name of the effect.
  39103. */
  39104. name: any;
  39105. /**
  39106. * String container all the define statements that should be set on the shader.
  39107. */
  39108. defines: string;
  39109. /**
  39110. * Callback that will be called when the shader is compiled.
  39111. */
  39112. onCompiled: Nullable<(effect: Effect) => void>;
  39113. /**
  39114. * Callback that will be called if an error occurs during shader compilation.
  39115. */
  39116. onError: Nullable<(effect: Effect, errors: string) => void>;
  39117. /**
  39118. * Callback that will be called when effect is bound.
  39119. */
  39120. onBind: Nullable<(effect: Effect) => void>;
  39121. /**
  39122. * Unique ID of the effect.
  39123. */
  39124. uniqueId: number;
  39125. /**
  39126. * Observable that will be called when the shader is compiled.
  39127. * It is recommended to use executeWhenCompile() or to make sure that scene.isReady() is called to get this observable raised.
  39128. */
  39129. onCompileObservable: Observable<Effect>;
  39130. /**
  39131. * Observable that will be called if an error occurs during shader compilation.
  39132. */
  39133. onErrorObservable: Observable<Effect>;
  39134. /** @hidden */
  39135. _onBindObservable: Nullable<Observable<Effect>>;
  39136. /**
  39137. * @hidden
  39138. * Specifies if the effect was previously ready
  39139. */
  39140. _wasPreviouslyReady: boolean;
  39141. /**
  39142. * Observable that will be called when effect is bound.
  39143. */
  39144. get onBindObservable(): Observable<Effect>;
  39145. /** @hidden */
  39146. _bonesComputationForcedToCPU: boolean;
  39147. /** @hidden */
  39148. _uniformBuffersNames: {
  39149. [key: string]: number;
  39150. };
  39151. /** @hidden */
  39152. _samplerList: string[];
  39153. /** @hidden */
  39154. _multiTarget: boolean;
  39155. private static _uniqueIdSeed;
  39156. private _engine;
  39157. private _uniformBuffersNamesList;
  39158. private _uniformsNames;
  39159. private _samplers;
  39160. private _isReady;
  39161. private _compilationError;
  39162. private _allFallbacksProcessed;
  39163. private _attributesNames;
  39164. private _attributes;
  39165. private _attributeLocationByName;
  39166. private _uniforms;
  39167. /**
  39168. * Key for the effect.
  39169. * @hidden
  39170. */
  39171. _key: string;
  39172. private _indexParameters;
  39173. private _fallbacks;
  39174. private _vertexSourceCodeOverride;
  39175. private _fragmentSourceCodeOverride;
  39176. private _transformFeedbackVaryings;
  39177. /**
  39178. * Compiled shader to webGL program.
  39179. * @hidden
  39180. */
  39181. _pipelineContext: Nullable<IPipelineContext>;
  39182. /** @hidden */
  39183. _vertexSourceCode: string;
  39184. /** @hidden */
  39185. _fragmentSourceCode: string;
  39186. /** @hidden */
  39187. private _rawVertexSourceCode;
  39188. /** @hidden */
  39189. private _rawFragmentSourceCode;
  39190. private static _baseCache;
  39191. private _processingContext;
  39192. /**
  39193. * Instantiates an effect.
  39194. * An effect can be used to create/manage/execute vertex and fragment shaders.
  39195. * @param baseName Name of the effect.
  39196. * @param attributesNamesOrOptions List of attribute names that will be passed to the shader or set of all options to create the effect.
  39197. * @param uniformsNamesOrEngine List of uniform variable names that will be passed to the shader or the engine that will be used to render effect.
  39198. * @param samplers List of sampler variables that will be passed to the shader.
  39199. * @param engine Engine to be used to render the effect
  39200. * @param defines Define statements to be added to the shader.
  39201. * @param fallbacks Possible fallbacks for this effect to improve performance when needed.
  39202. * @param onCompiled Callback that will be called when the shader is compiled.
  39203. * @param onError Callback that will be called if an error occurs during shader compilation.
  39204. * @param indexParameters Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  39205. * @param key Effect Key identifying uniquely compiled shader variants
  39206. */
  39207. 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);
  39208. private _useFinalCode;
  39209. /**
  39210. * Unique key for this effect
  39211. */
  39212. get key(): string;
  39213. /**
  39214. * If the effect has been compiled and prepared.
  39215. * @returns if the effect is compiled and prepared.
  39216. */
  39217. isReady(): boolean;
  39218. private _isReadyInternal;
  39219. /**
  39220. * The engine the effect was initialized with.
  39221. * @returns the engine.
  39222. */
  39223. getEngine(): Engine;
  39224. /**
  39225. * The pipeline context for this effect
  39226. * @returns the associated pipeline context
  39227. */
  39228. getPipelineContext(): Nullable<IPipelineContext>;
  39229. /**
  39230. * The set of names of attribute variables for the shader.
  39231. * @returns An array of attribute names.
  39232. */
  39233. getAttributesNames(): string[];
  39234. /**
  39235. * Returns the attribute at the given index.
  39236. * @param index The index of the attribute.
  39237. * @returns The location of the attribute.
  39238. */
  39239. getAttributeLocation(index: number): number;
  39240. /**
  39241. * Returns the attribute based on the name of the variable.
  39242. * @param name of the attribute to look up.
  39243. * @returns the attribute location.
  39244. */
  39245. getAttributeLocationByName(name: string): number;
  39246. /**
  39247. * The number of attributes.
  39248. * @returns the number of attributes.
  39249. */
  39250. getAttributesCount(): number;
  39251. /**
  39252. * Gets the index of a uniform variable.
  39253. * @param uniformName of the uniform to look up.
  39254. * @returns the index.
  39255. */
  39256. getUniformIndex(uniformName: string): number;
  39257. /**
  39258. * Returns the attribute based on the name of the variable.
  39259. * @param uniformName of the uniform to look up.
  39260. * @returns the location of the uniform.
  39261. */
  39262. getUniform(uniformName: string): Nullable<WebGLUniformLocation>;
  39263. /**
  39264. * Returns an array of sampler variable names
  39265. * @returns The array of sampler variable names.
  39266. */
  39267. getSamplers(): string[];
  39268. /**
  39269. * Returns an array of uniform variable names
  39270. * @returns The array of uniform variable names.
  39271. */
  39272. getUniformNames(): string[];
  39273. /**
  39274. * Returns an array of uniform buffer variable names
  39275. * @returns The array of uniform buffer variable names.
  39276. */
  39277. getUniformBuffersNames(): string[];
  39278. /**
  39279. * Returns the index parameters used to create the effect
  39280. * @returns The index parameters object
  39281. */
  39282. getIndexParameters(): any;
  39283. /**
  39284. * The error from the last compilation.
  39285. * @returns the error string.
  39286. */
  39287. getCompilationError(): string;
  39288. /**
  39289. * Gets a boolean indicating that all fallbacks were used during compilation
  39290. * @returns true if all fallbacks were used
  39291. */
  39292. allFallbacksProcessed(): boolean;
  39293. /**
  39294. * Adds a callback to the onCompiled observable and call the callback immediately if already ready.
  39295. * @param func The callback to be used.
  39296. */
  39297. executeWhenCompiled(func: (effect: Effect) => void): void;
  39298. private _checkIsReady;
  39299. private _loadShader;
  39300. /**
  39301. * Gets the vertex shader source code of this effect
  39302. */
  39303. get vertexSourceCode(): string;
  39304. /**
  39305. * Gets the fragment shader source code of this effect
  39306. */
  39307. get fragmentSourceCode(): string;
  39308. /**
  39309. * Gets the vertex shader source code before it has been processed by the preprocessor
  39310. */
  39311. get rawVertexSourceCode(): string;
  39312. /**
  39313. * Gets the fragment shader source code before it has been processed by the preprocessor
  39314. */
  39315. get rawFragmentSourceCode(): string;
  39316. /**
  39317. * Recompiles the webGL program
  39318. * @param vertexSourceCode The source code for the vertex shader.
  39319. * @param fragmentSourceCode The source code for the fragment shader.
  39320. * @param onCompiled Callback called when completed.
  39321. * @param onError Callback called on error.
  39322. * @hidden
  39323. */
  39324. _rebuildProgram(vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (pipelineContext: IPipelineContext) => void, onError: (message: string) => void): void;
  39325. /**
  39326. * Prepares the effect
  39327. * @hidden
  39328. */
  39329. _prepareEffect(): void;
  39330. private _getShaderCodeAndErrorLine;
  39331. private _processCompilationErrors;
  39332. /**
  39333. * Checks if the effect is supported. (Must be called after compilation)
  39334. */
  39335. get isSupported(): boolean;
  39336. /**
  39337. * Binds a texture to the engine to be used as output of the shader.
  39338. * @param channel Name of the output variable.
  39339. * @param texture Texture to bind.
  39340. * @hidden
  39341. */
  39342. _bindTexture(channel: string, texture: Nullable<InternalTexture>): void;
  39343. /**
  39344. * Sets a texture on the engine to be used in the shader.
  39345. * @param channel Name of the sampler variable.
  39346. * @param texture Texture to set.
  39347. */
  39348. setTexture(channel: string, texture: Nullable<ThinTexture>): void;
  39349. /**
  39350. * Sets a depth stencil texture from a render target on the engine to be used in the shader.
  39351. * @param channel Name of the sampler variable.
  39352. * @param texture Texture to set.
  39353. */
  39354. setDepthStencilTexture(channel: string, texture: Nullable<RenderTargetTexture>): void;
  39355. /**
  39356. * Sets an array of textures on the engine to be used in the shader.
  39357. * @param channel Name of the variable.
  39358. * @param textures Textures to set.
  39359. */
  39360. setTextureArray(channel: string, textures: ThinTexture[]): void;
  39361. /**
  39362. * 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)
  39363. * @param channel Name of the sampler variable.
  39364. * @param postProcess Post process to get the input texture from.
  39365. */
  39366. setTextureFromPostProcess(channel: string, postProcess: Nullable<PostProcess>): void;
  39367. /**
  39368. * (Warning! setTextureFromPostProcessOutput may be desired instead)
  39369. * 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)
  39370. * @param channel Name of the sampler variable.
  39371. * @param postProcess Post process to get the output texture from.
  39372. */
  39373. setTextureFromPostProcessOutput(channel: string, postProcess: Nullable<PostProcess>): void;
  39374. /**
  39375. * Binds a buffer to a uniform.
  39376. * @param buffer Buffer to bind.
  39377. * @param name Name of the uniform variable to bind to.
  39378. */
  39379. bindUniformBuffer(buffer: DataBuffer, name: string): void;
  39380. /**
  39381. * Binds block to a uniform.
  39382. * @param blockName Name of the block to bind.
  39383. * @param index Index to bind.
  39384. */
  39385. bindUniformBlock(blockName: string, index: number): void;
  39386. /**
  39387. * Sets an integer value on a uniform variable.
  39388. * @param uniformName Name of the variable.
  39389. * @param value Value to be set.
  39390. * @returns this effect.
  39391. */
  39392. setInt(uniformName: string, value: number): Effect;
  39393. /**
  39394. * Sets an int2 value on a uniform variable.
  39395. * @param uniformName Name of the variable.
  39396. * @param x First int in int2.
  39397. * @param y Second int in int2.
  39398. * @returns this effect.
  39399. */
  39400. setInt2(uniformName: string, x: number, y: number): Effect;
  39401. /**
  39402. * Sets an int3 value on a uniform variable.
  39403. * @param uniformName Name of the variable.
  39404. * @param x First int in int3.
  39405. * @param y Second int in int3.
  39406. * @param z Third int in int3.
  39407. * @returns this effect.
  39408. */
  39409. setInt3(uniformName: string, x: number, y: number, z: number): Effect;
  39410. /**
  39411. * Sets an int4 value on a uniform variable.
  39412. * @param uniformName Name of the variable.
  39413. * @param x First int in int4.
  39414. * @param y Second int in int4.
  39415. * @param z Third int in int4.
  39416. * @param w Fourth int in int4.
  39417. * @returns this effect.
  39418. */
  39419. setInt4(uniformName: string, x: number, y: number, z: number, w: number): Effect;
  39420. /**
  39421. * Sets an int array on a uniform variable.
  39422. * @param uniformName Name of the variable.
  39423. * @param array array to be set.
  39424. * @returns this effect.
  39425. */
  39426. setIntArray(uniformName: string, array: Int32Array): Effect;
  39427. /**
  39428. * 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)
  39429. * @param uniformName Name of the variable.
  39430. * @param array array to be set.
  39431. * @returns this effect.
  39432. */
  39433. setIntArray2(uniformName: string, array: Int32Array): Effect;
  39434. /**
  39435. * 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)
  39436. * @param uniformName Name of the variable.
  39437. * @param array array to be set.
  39438. * @returns this effect.
  39439. */
  39440. setIntArray3(uniformName: string, array: Int32Array): Effect;
  39441. /**
  39442. * 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)
  39443. * @param uniformName Name of the variable.
  39444. * @param array array to be set.
  39445. * @returns this effect.
  39446. */
  39447. setIntArray4(uniformName: string, array: Int32Array): Effect;
  39448. /**
  39449. * Sets an float array on a uniform variable.
  39450. * @param uniformName Name of the variable.
  39451. * @param array array to be set.
  39452. * @returns this effect.
  39453. */
  39454. setFloatArray(uniformName: string, array: FloatArray): Effect;
  39455. /**
  39456. * 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)
  39457. * @param uniformName Name of the variable.
  39458. * @param array array to be set.
  39459. * @returns this effect.
  39460. */
  39461. setFloatArray2(uniformName: string, array: FloatArray): Effect;
  39462. /**
  39463. * 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)
  39464. * @param uniformName Name of the variable.
  39465. * @param array array to be set.
  39466. * @returns this effect.
  39467. */
  39468. setFloatArray3(uniformName: string, array: FloatArray): Effect;
  39469. /**
  39470. * 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)
  39471. * @param uniformName Name of the variable.
  39472. * @param array array to be set.
  39473. * @returns this effect.
  39474. */
  39475. setFloatArray4(uniformName: string, array: FloatArray): Effect;
  39476. /**
  39477. * Sets an array on a uniform variable.
  39478. * @param uniformName Name of the variable.
  39479. * @param array array to be set.
  39480. * @returns this effect.
  39481. */
  39482. setArray(uniformName: string, array: number[]): Effect;
  39483. /**
  39484. * 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)
  39485. * @param uniformName Name of the variable.
  39486. * @param array array to be set.
  39487. * @returns this effect.
  39488. */
  39489. setArray2(uniformName: string, array: number[]): Effect;
  39490. /**
  39491. * 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)
  39492. * @param uniformName Name of the variable.
  39493. * @param array array to be set.
  39494. * @returns this effect.
  39495. */
  39496. setArray3(uniformName: string, array: number[]): Effect;
  39497. /**
  39498. * 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)
  39499. * @param uniformName Name of the variable.
  39500. * @param array array to be set.
  39501. * @returns this effect.
  39502. */
  39503. setArray4(uniformName: string, array: number[]): Effect;
  39504. /**
  39505. * Sets matrices on a uniform variable.
  39506. * @param uniformName Name of the variable.
  39507. * @param matrices matrices to be set.
  39508. * @returns this effect.
  39509. */
  39510. setMatrices(uniformName: string, matrices: Float32Array | Array<number>): Effect;
  39511. /**
  39512. * Sets matrix on a uniform variable.
  39513. * @param uniformName Name of the variable.
  39514. * @param matrix matrix to be set.
  39515. * @returns this effect.
  39516. */
  39517. setMatrix(uniformName: string, matrix: IMatrixLike): Effect;
  39518. /**
  39519. * Sets a 3x3 matrix on a uniform variable. (Specified as [1,2,3,4,5,6,7,8,9] will result in [1,2,3][4,5,6][7,8,9] matrix)
  39520. * @param uniformName Name of the variable.
  39521. * @param matrix matrix to be set.
  39522. * @returns this effect.
  39523. */
  39524. setMatrix3x3(uniformName: string, matrix: Float32Array | Array<number>): Effect;
  39525. /**
  39526. * Sets a 2x2 matrix on a uniform variable. (Specified as [1,2,3,4] will result in [1,2][3,4] matrix)
  39527. * @param uniformName Name of the variable.
  39528. * @param matrix matrix to be set.
  39529. * @returns this effect.
  39530. */
  39531. setMatrix2x2(uniformName: string, matrix: Float32Array | Array<number>): Effect;
  39532. /**
  39533. * Sets a float on a uniform variable.
  39534. * @param uniformName Name of the variable.
  39535. * @param value value to be set.
  39536. * @returns this effect.
  39537. */
  39538. setFloat(uniformName: string, value: number): Effect;
  39539. /**
  39540. * Sets a boolean on a uniform variable.
  39541. * @param uniformName Name of the variable.
  39542. * @param bool value to be set.
  39543. * @returns this effect.
  39544. */
  39545. setBool(uniformName: string, bool: boolean): Effect;
  39546. /**
  39547. * Sets a Vector2 on a uniform variable.
  39548. * @param uniformName Name of the variable.
  39549. * @param vector2 vector2 to be set.
  39550. * @returns this effect.
  39551. */
  39552. setVector2(uniformName: string, vector2: IVector2Like): Effect;
  39553. /**
  39554. * Sets a float2 on a uniform variable.
  39555. * @param uniformName Name of the variable.
  39556. * @param x First float in float2.
  39557. * @param y Second float in float2.
  39558. * @returns this effect.
  39559. */
  39560. setFloat2(uniformName: string, x: number, y: number): Effect;
  39561. /**
  39562. * Sets a Vector3 on a uniform variable.
  39563. * @param uniformName Name of the variable.
  39564. * @param vector3 Value to be set.
  39565. * @returns this effect.
  39566. */
  39567. setVector3(uniformName: string, vector3: IVector3Like): Effect;
  39568. /**
  39569. * Sets a float3 on a uniform variable.
  39570. * @param uniformName Name of the variable.
  39571. * @param x First float in float3.
  39572. * @param y Second float in float3.
  39573. * @param z Third float in float3.
  39574. * @returns this effect.
  39575. */
  39576. setFloat3(uniformName: string, x: number, y: number, z: number): Effect;
  39577. /**
  39578. * Sets a Vector4 on a uniform variable.
  39579. * @param uniformName Name of the variable.
  39580. * @param vector4 Value to be set.
  39581. * @returns this effect.
  39582. */
  39583. setVector4(uniformName: string, vector4: IVector4Like): Effect;
  39584. /**
  39585. * Sets a float4 on a uniform variable.
  39586. * @param uniformName Name of the variable.
  39587. * @param x First float in float4.
  39588. * @param y Second float in float4.
  39589. * @param z Third float in float4.
  39590. * @param w Fourth float in float4.
  39591. * @returns this effect.
  39592. */
  39593. setFloat4(uniformName: string, x: number, y: number, z: number, w: number): Effect;
  39594. /**
  39595. * Sets a Color3 on a uniform variable.
  39596. * @param uniformName Name of the variable.
  39597. * @param color3 Value to be set.
  39598. * @returns this effect.
  39599. */
  39600. setColor3(uniformName: string, color3: IColor3Like): Effect;
  39601. /**
  39602. * Sets a Color4 on a uniform variable.
  39603. * @param uniformName Name of the variable.
  39604. * @param color3 Value to be set.
  39605. * @param alpha Alpha value to be set.
  39606. * @returns this effect.
  39607. */
  39608. setColor4(uniformName: string, color3: IColor3Like, alpha: number): Effect;
  39609. /**
  39610. * Sets a Color4 on a uniform variable
  39611. * @param uniformName defines the name of the variable
  39612. * @param color4 defines the value to be set
  39613. * @returns this effect.
  39614. */
  39615. setDirectColor4(uniformName: string, color4: IColor4Like): Effect;
  39616. /**
  39617. * Release all associated resources.
  39618. **/
  39619. dispose(): void;
  39620. /**
  39621. * This function will add a new shader to the shader store
  39622. * @param name the name of the shader
  39623. * @param pixelShader optional pixel shader content
  39624. * @param vertexShader optional vertex shader content
  39625. */
  39626. static RegisterShader(name: string, pixelShader?: string, vertexShader?: string): void;
  39627. /**
  39628. * Store of each shader (The can be looked up using effect.key)
  39629. */
  39630. static ShadersStore: {
  39631. [key: string]: string;
  39632. };
  39633. /**
  39634. * Store of each included file for a shader (The can be looked up using effect.key)
  39635. */
  39636. static IncludesShadersStore: {
  39637. [key: string]: string;
  39638. };
  39639. /**
  39640. * Resets the cache of effects.
  39641. */
  39642. static ResetCache(): void;
  39643. }
  39644. }
  39645. declare module BABYLON {
  39646. /**
  39647. * Interface used to describe the capabilities of the engine relatively to the current browser
  39648. */
  39649. export interface EngineCapabilities {
  39650. /** Maximum textures units per fragment shader */
  39651. maxTexturesImageUnits: number;
  39652. /** Maximum texture units per vertex shader */
  39653. maxVertexTextureImageUnits: number;
  39654. /** Maximum textures units in the entire pipeline */
  39655. maxCombinedTexturesImageUnits: number;
  39656. /** Maximum texture size */
  39657. maxTextureSize: number;
  39658. /** Maximum texture samples */
  39659. maxSamples?: number;
  39660. /** Maximum cube texture size */
  39661. maxCubemapTextureSize: number;
  39662. /** Maximum render texture size */
  39663. maxRenderTextureSize: number;
  39664. /** Maximum number of vertex attributes */
  39665. maxVertexAttribs: number;
  39666. /** Maximum number of varyings */
  39667. maxVaryingVectors: number;
  39668. /** Maximum number of uniforms per vertex shader */
  39669. maxVertexUniformVectors: number;
  39670. /** Maximum number of uniforms per fragment shader */
  39671. maxFragmentUniformVectors: number;
  39672. /** Defines if standard derivatives (dx/dy) are supported */
  39673. standardDerivatives: boolean;
  39674. /** Defines if s3tc texture compression is supported */
  39675. s3tc?: WEBGL_compressed_texture_s3tc;
  39676. /** Defines if pvrtc texture compression is supported */
  39677. pvrtc: any;
  39678. /** Defines if etc1 texture compression is supported */
  39679. etc1: any;
  39680. /** Defines if etc2 texture compression is supported */
  39681. etc2: any;
  39682. /** Defines if astc texture compression is supported */
  39683. astc: any;
  39684. /** Defines if bptc texture compression is supported */
  39685. bptc: any;
  39686. /** Defines if float textures are supported */
  39687. textureFloat: boolean;
  39688. /** Defines if vertex array objects are supported */
  39689. vertexArrayObject: boolean;
  39690. /** Gets the webgl extension for anisotropic filtering (null if not supported) */
  39691. textureAnisotropicFilterExtension?: EXT_texture_filter_anisotropic;
  39692. /** Gets the maximum level of anisotropy supported */
  39693. maxAnisotropy: number;
  39694. /** Defines if instancing is supported */
  39695. instancedArrays: boolean;
  39696. /** Defines if 32 bits indices are supported */
  39697. uintIndices: boolean;
  39698. /** Defines if high precision shaders are supported */
  39699. highPrecisionShaderSupported: boolean;
  39700. /** Defines if depth reading in the fragment shader is supported */
  39701. fragmentDepthSupported: boolean;
  39702. /** Defines if float texture linear filtering is supported*/
  39703. textureFloatLinearFiltering: boolean;
  39704. /** Defines if rendering to float textures is supported */
  39705. textureFloatRender: boolean;
  39706. /** Defines if half float textures are supported*/
  39707. textureHalfFloat: boolean;
  39708. /** Defines if half float texture linear filtering is supported*/
  39709. textureHalfFloatLinearFiltering: boolean;
  39710. /** Defines if rendering to half float textures is supported */
  39711. textureHalfFloatRender: boolean;
  39712. /** Defines if textureLOD shader command is supported */
  39713. textureLOD: boolean;
  39714. /** Defines if draw buffers extension is supported */
  39715. drawBuffersExtension: boolean;
  39716. /** Defines if depth textures are supported */
  39717. depthTextureExtension: boolean;
  39718. /** Defines if float color buffer are supported */
  39719. colorBufferFloat: boolean;
  39720. /** Gets disjoint timer query extension (null if not supported) */
  39721. timerQuery?: EXT_disjoint_timer_query;
  39722. /** Defines if timestamp can be used with timer query */
  39723. canUseTimestampForTimerQuery: boolean;
  39724. /** Defines if multiview is supported (https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/) */
  39725. multiview?: any;
  39726. /** Defines if oculus multiview is supported (https://developer.oculus.com/documentation/oculus-browser/latest/concepts/browser-multiview/) */
  39727. oculusMultiview?: any;
  39728. /** Function used to let the system compiles shaders in background */
  39729. parallelShaderCompile?: {
  39730. COMPLETION_STATUS_KHR: number;
  39731. };
  39732. /** Max number of texture samples for MSAA */
  39733. maxMSAASamples: number;
  39734. /** Defines if the blend min max extension is supported */
  39735. blendMinMax: boolean;
  39736. /** 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 */
  39737. canUseGLInstanceID: boolean;
  39738. }
  39739. }
  39740. declare module BABYLON {
  39741. /**
  39742. * @hidden
  39743. **/
  39744. export class DepthCullingState {
  39745. private _isDepthTestDirty;
  39746. private _isDepthMaskDirty;
  39747. private _isDepthFuncDirty;
  39748. private _isCullFaceDirty;
  39749. private _isCullDirty;
  39750. private _isZOffsetDirty;
  39751. private _isFrontFaceDirty;
  39752. private _depthTest;
  39753. private _depthMask;
  39754. private _depthFunc;
  39755. private _cull;
  39756. private _cullFace;
  39757. private _zOffset;
  39758. private _frontFace;
  39759. /**
  39760. * Initializes the state.
  39761. */
  39762. constructor();
  39763. get isDirty(): boolean;
  39764. get zOffset(): number;
  39765. set zOffset(value: number);
  39766. get cullFace(): Nullable<number>;
  39767. set cullFace(value: Nullable<number>);
  39768. get cull(): Nullable<boolean>;
  39769. set cull(value: Nullable<boolean>);
  39770. get depthFunc(): Nullable<number>;
  39771. set depthFunc(value: Nullable<number>);
  39772. get depthMask(): boolean;
  39773. set depthMask(value: boolean);
  39774. get depthTest(): boolean;
  39775. set depthTest(value: boolean);
  39776. get frontFace(): Nullable<number>;
  39777. set frontFace(value: Nullable<number>);
  39778. reset(): void;
  39779. apply(gl: WebGLRenderingContext): void;
  39780. }
  39781. }
  39782. declare module BABYLON {
  39783. /**
  39784. * @hidden
  39785. **/
  39786. export class StencilState {
  39787. /** 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 */
  39788. static readonly ALWAYS: number;
  39789. /** Passed to stencilOperation to specify that stencil value must be kept */
  39790. static readonly KEEP: number;
  39791. /** Passed to stencilOperation to specify that stencil value must be replaced */
  39792. static readonly REPLACE: number;
  39793. private _isStencilTestDirty;
  39794. private _isStencilMaskDirty;
  39795. private _isStencilFuncDirty;
  39796. private _isStencilOpDirty;
  39797. private _stencilTest;
  39798. private _stencilMask;
  39799. private _stencilFunc;
  39800. private _stencilFuncRef;
  39801. private _stencilFuncMask;
  39802. private _stencilOpStencilFail;
  39803. private _stencilOpDepthFail;
  39804. private _stencilOpStencilDepthPass;
  39805. get isDirty(): boolean;
  39806. get stencilFunc(): number;
  39807. set stencilFunc(value: number);
  39808. get stencilFuncRef(): number;
  39809. set stencilFuncRef(value: number);
  39810. get stencilFuncMask(): number;
  39811. set stencilFuncMask(value: number);
  39812. get stencilOpStencilFail(): number;
  39813. set stencilOpStencilFail(value: number);
  39814. get stencilOpDepthFail(): number;
  39815. set stencilOpDepthFail(value: number);
  39816. get stencilOpStencilDepthPass(): number;
  39817. set stencilOpStencilDepthPass(value: number);
  39818. get stencilMask(): number;
  39819. set stencilMask(value: number);
  39820. get stencilTest(): boolean;
  39821. set stencilTest(value: boolean);
  39822. constructor();
  39823. reset(): void;
  39824. apply(gl: WebGLRenderingContext): void;
  39825. }
  39826. }
  39827. declare module BABYLON {
  39828. /**
  39829. * @hidden
  39830. **/
  39831. export class AlphaState {
  39832. _blendFunctionParameters: Nullable<number>[];
  39833. _blendEquationParameters: Nullable<number>[];
  39834. _blendConstants: Nullable<number>[];
  39835. _isBlendConstantsDirty: boolean;
  39836. private _alphaBlend;
  39837. private _isAlphaBlendDirty;
  39838. private _isBlendFunctionParametersDirty;
  39839. private _isBlendEquationParametersDirty;
  39840. /**
  39841. * Initializes the state.
  39842. */
  39843. constructor();
  39844. get isDirty(): boolean;
  39845. get alphaBlend(): boolean;
  39846. set alphaBlend(value: boolean);
  39847. setAlphaBlendConstants(r: number, g: number, b: number, a: number): void;
  39848. setAlphaBlendFunctionParameters(value0: number, value1: number, value2: number, value3: number): void;
  39849. setAlphaEquationParameters(rgb: number, alpha: number): void;
  39850. reset(): void;
  39851. apply(gl: WebGLRenderingContext): void;
  39852. }
  39853. }
  39854. declare module BABYLON {
  39855. /** @hidden */
  39856. export class WebGLShaderProcessor implements IShaderProcessor {
  39857. postProcessor(code: string, defines: string[], isFragment: boolean, processingContext: Nullable<ShaderProcessingContext>, engine: ThinEngine): string;
  39858. }
  39859. }
  39860. declare module BABYLON {
  39861. /** @hidden */
  39862. export class WebGL2ShaderProcessor implements IShaderProcessor {
  39863. attributeProcessor(attribute: string): string;
  39864. varyingProcessor(varying: string, isFragment: boolean): string;
  39865. postProcessor(code: string, defines: string[], isFragment: boolean, processingContext: Nullable<ShaderProcessingContext>, engine: ThinEngine): string;
  39866. }
  39867. }
  39868. declare module BABYLON {
  39869. /**
  39870. * Interface for attribute information associated with buffer instantiation
  39871. */
  39872. export interface InstancingAttributeInfo {
  39873. /**
  39874. * Name of the GLSL attribute
  39875. * if attribute index is not specified, this is used to retrieve the index from the effect
  39876. */
  39877. attributeName: string;
  39878. /**
  39879. * Index/offset of the attribute in the vertex shader
  39880. * if not specified, this will be computes from the name.
  39881. */
  39882. index?: number;
  39883. /**
  39884. * size of the attribute, 1, 2, 3 or 4
  39885. */
  39886. attributeSize: number;
  39887. /**
  39888. * Offset of the data in the Vertex Buffer acting as the instancing buffer
  39889. */
  39890. offset: number;
  39891. /**
  39892. * Modifies the rate at which generic vertex attributes advance when rendering multiple instances
  39893. * default to 1
  39894. */
  39895. divisor?: number;
  39896. /**
  39897. * type of the attribute, gl.BYTE, gl.UNSIGNED_BYTE, gl.SHORT, gl.UNSIGNED_SHORT, gl.FIXED, gl.FLOAT.
  39898. * default is FLOAT
  39899. */
  39900. attributeType?: number;
  39901. /**
  39902. * normalization of fixed-point data. behavior unclear, use FALSE, default is FALSE
  39903. */
  39904. normalized?: boolean;
  39905. }
  39906. }
  39907. declare module BABYLON {
  39908. /** @hidden */
  39909. export interface EngineFeatures {
  39910. /** Force using Bitmap when Bitmap or HTMLImageElement can be used */
  39911. forceBitmapOverHTMLImageElement: boolean;
  39912. /** Indicates that the engine support rendering to as well as copying to lod float textures */
  39913. supportRenderAndCopyToLodForFloatTextures: boolean;
  39914. /** Indicates that the engine support handling depth/stencil textures */
  39915. supportDepthStencilTexture: boolean;
  39916. /** Indicates that the engine support shadow samplers */
  39917. supportShadowSamplers: boolean;
  39918. /** 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 */
  39919. uniformBufferHardCheckMatrix: boolean;
  39920. /** Indicates that prefiltered mipmaps can be generated in some processes (for eg when loading an HDR cube texture) */
  39921. allowTexturePrefiltering: boolean;
  39922. /** Indicates to track the usage of ubos and to create new ones as necessary during a frame duration */
  39923. trackUbosInFrame: boolean;
  39924. /** Indicates that the Cascaded Shadow Map technic is supported */
  39925. supportCSM: boolean;
  39926. /** Indicates that the textures transcoded by the basis transcoder must have power of 2 width and height */
  39927. basisNeedsPOT: boolean;
  39928. /** Indicates that the engine supports 3D textures */
  39929. support3DTextures: boolean;
  39930. /** Indicates that constants need a type suffix in shaders (used by realtime filtering...) */
  39931. needTypeSuffixInShaderConstants: boolean;
  39932. /** Indicates that MSAA is supported */
  39933. supportMSAA: boolean;
  39934. /** Indicates that SSAO2 is supported */
  39935. supportSSAO2: boolean;
  39936. /** Indicates that some additional texture formats are supported (like TEXTUREFORMAT_R for eg) */
  39937. supportExtendedTextureFormats: boolean;
  39938. /** Indicates that the switch/case construct is supported in shaders */
  39939. supportSwitchCaseInShader: boolean;
  39940. /** Indicates that synchronous texture reading is supported */
  39941. supportSyncTextureRead: boolean;
  39942. /** @hidden */
  39943. _collectUbosUpdatedInFrame: boolean;
  39944. }
  39945. }
  39946. declare module BABYLON {
  39947. /** @hidden */
  39948. export class WebGLHardwareTexture implements HardwareTextureWrapper {
  39949. private _webGLTexture;
  39950. private _context;
  39951. get underlyingResource(): Nullable<WebGLTexture>;
  39952. constructor(existingTexture: WebGLTexture | null | undefined, context: WebGLRenderingContext);
  39953. setUsage(textureSource: number, generateMipMaps: boolean, isCube: boolean, width: number, height: number): void;
  39954. set(hardwareTexture: WebGLTexture): void;
  39955. reset(): void;
  39956. release(): void;
  39957. }
  39958. }
  39959. declare module BABYLON {
  39960. interface ThinEngine {
  39961. /**
  39962. * Update a video texture
  39963. * @param texture defines the texture to update
  39964. * @param video defines the video element to use
  39965. * @param invertY defines if data must be stored with Y axis inverted
  39966. */
  39967. updateVideoTexture(texture: Nullable<InternalTexture>, video: HTMLVideoElement, invertY: boolean): void;
  39968. }
  39969. }
  39970. declare module BABYLON {
  39971. interface ThinEngine {
  39972. /**
  39973. * Creates a dynamic texture
  39974. * @param width defines the width of the texture
  39975. * @param height defines the height of the texture
  39976. * @param generateMipMaps defines if the engine should generate the mip levels
  39977. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  39978. * @returns the dynamic texture inside an InternalTexture
  39979. */
  39980. createDynamicTexture(width: number, height: number, generateMipMaps: boolean, samplingMode: number): InternalTexture;
  39981. /**
  39982. * Update the content of a dynamic texture
  39983. * @param texture defines the texture to update
  39984. * @param source defines the source containing the data
  39985. * @param invertY defines if data must be stored with Y axis inverted
  39986. * @param premulAlpha defines if alpha is stored as premultiplied
  39987. * @param format defines the format of the data
  39988. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  39989. */
  39990. updateDynamicTexture(texture: Nullable<InternalTexture>, source: ImageBitmap | ImageData | HTMLImageElement | HTMLCanvasElement | HTMLVideoElement | OffscreenCanvas, invertY?: boolean, premulAlpha?: boolean, format?: number, forceBindTexture?: boolean): void;
  39991. }
  39992. }
  39993. declare module BABYLON {
  39994. /**
  39995. * Settings for finer control over video usage
  39996. */
  39997. export interface VideoTextureSettings {
  39998. /**
  39999. * Applies `autoplay` to video, if specified
  40000. */
  40001. autoPlay?: boolean;
  40002. /**
  40003. * Applies `muted` to video, if specified
  40004. */
  40005. muted?: boolean;
  40006. /**
  40007. * Applies `loop` to video, if specified
  40008. */
  40009. loop?: boolean;
  40010. /**
  40011. * Automatically updates internal texture from video at every frame in the render loop
  40012. */
  40013. autoUpdateTexture: boolean;
  40014. /**
  40015. * Image src displayed during the video loading or until the user interacts with the video.
  40016. */
  40017. poster?: string;
  40018. }
  40019. /**
  40020. * If you want to display a video in your scene, this is the special texture for that.
  40021. * This special texture works similar to other textures, with the exception of a few parameters.
  40022. * @see https://doc.babylonjs.com/how_to/video_texture
  40023. */
  40024. export class VideoTexture extends Texture {
  40025. /**
  40026. * Tells whether textures will be updated automatically or user is required to call `updateTexture` manually
  40027. */
  40028. readonly autoUpdateTexture: boolean;
  40029. /**
  40030. * The video instance used by the texture internally
  40031. */
  40032. readonly video: HTMLVideoElement;
  40033. private _onUserActionRequestedObservable;
  40034. /**
  40035. * Event triggered when a dom action is required by the user to play the video.
  40036. * This happens due to recent changes in browser policies preventing video to auto start.
  40037. */
  40038. get onUserActionRequestedObservable(): Observable<Texture>;
  40039. private _generateMipMaps;
  40040. private _stillImageCaptured;
  40041. private _displayingPosterTexture;
  40042. private _settings;
  40043. private _createInternalTextureOnEvent;
  40044. private _frameId;
  40045. private _currentSrc;
  40046. /**
  40047. * Creates a video texture.
  40048. * If you want to display a video in your scene, this is the special texture for that.
  40049. * This special texture works similar to other textures, with the exception of a few parameters.
  40050. * @see https://doc.babylonjs.com/how_to/video_texture
  40051. * @param name optional name, will detect from video source, if not defined
  40052. * @param src can be used to provide an url, array of urls or an already setup HTML video element.
  40053. * @param scene is obviously the current scene.
  40054. * @param generateMipMaps can be used to turn on mipmaps (Can be expensive for videoTextures because they are often updated).
  40055. * @param invertY is false by default but can be used to invert video on Y axis
  40056. * @param samplingMode controls the sampling method and is set to TRILINEAR_SAMPLINGMODE by default
  40057. * @param settings allows finer control over video usage
  40058. */
  40059. constructor(name: Nullable<string>, src: string | string[] | HTMLVideoElement, scene: Nullable<Scene>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, settings?: VideoTextureSettings);
  40060. private _getName;
  40061. private _getVideo;
  40062. private _createInternalTexture;
  40063. private reset;
  40064. /**
  40065. * @hidden Internal method to initiate `update`.
  40066. */
  40067. _rebuild(): void;
  40068. /**
  40069. * Update Texture in the `auto` mode. Does not do anything if `settings.autoUpdateTexture` is false.
  40070. */
  40071. update(): void;
  40072. /**
  40073. * Update Texture in `manual` mode. Does not do anything if not visible or paused.
  40074. * @param isVisible Visibility state, detected by user using `scene.getActiveMeshes()` or otherwise.
  40075. */
  40076. updateTexture(isVisible: boolean): void;
  40077. protected _updateInternalTexture: () => void;
  40078. /**
  40079. * Change video content. Changing video instance or setting multiple urls (as in constructor) is not supported.
  40080. * @param url New url.
  40081. */
  40082. updateURL(url: string): void;
  40083. /**
  40084. * Clones the texture.
  40085. * @returns the cloned texture
  40086. */
  40087. clone(): VideoTexture;
  40088. /**
  40089. * Dispose the texture and release its associated resources.
  40090. */
  40091. dispose(): void;
  40092. /**
  40093. * Creates a video texture straight from a stream.
  40094. * @param scene Define the scene the texture should be created in
  40095. * @param stream Define the stream the texture should be created from
  40096. * @returns The created video texture as a promise
  40097. */
  40098. static CreateFromStreamAsync(scene: Scene, stream: MediaStream): Promise<VideoTexture>;
  40099. /**
  40100. * Creates a video texture straight from your WebCam video feed.
  40101. * @param scene Define the scene the texture should be created in
  40102. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  40103. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  40104. * @returns The created video texture as a promise
  40105. */
  40106. static CreateFromWebCamAsync(scene: Scene, constraints: {
  40107. minWidth: number;
  40108. maxWidth: number;
  40109. minHeight: number;
  40110. maxHeight: number;
  40111. deviceId: string;
  40112. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): Promise<VideoTexture>;
  40113. /**
  40114. * Creates a video texture straight from your WebCam video feed.
  40115. * @param scene Define the scene the texture should be created in
  40116. * @param onReady Define a callback to triggered once the texture will be ready
  40117. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  40118. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  40119. */
  40120. static CreateFromWebCam(scene: Scene, onReady: (videoTexture: VideoTexture) => void, constraints: {
  40121. minWidth: number;
  40122. maxWidth: number;
  40123. minHeight: number;
  40124. maxHeight: number;
  40125. deviceId: string;
  40126. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): void;
  40127. }
  40128. }
  40129. declare module BABYLON {
  40130. /**
  40131. * Defines the interface used by objects working like Scene
  40132. * @hidden
  40133. */
  40134. export interface ISceneLike {
  40135. _addPendingData(data: any): void;
  40136. _removePendingData(data: any): void;
  40137. offlineProvider: IOfflineProvider;
  40138. }
  40139. /**
  40140. * Information about the current host
  40141. */
  40142. export interface HostInformation {
  40143. /**
  40144. * Defines if the current host is a mobile
  40145. */
  40146. isMobile: boolean;
  40147. }
  40148. /** Interface defining initialization parameters for Engine class */
  40149. export interface EngineOptions extends WebGLContextAttributes {
  40150. /**
  40151. * Defines if the engine should no exceed a specified device ratio
  40152. * @see https://developer.mozilla.org/en-US/docs/Web/API/Window/devicePixelRatio
  40153. */
  40154. limitDeviceRatio?: number;
  40155. /**
  40156. * Defines if webvr should be enabled automatically
  40157. * @see https://doc.babylonjs.com/how_to/webvr_camera
  40158. */
  40159. autoEnableWebVR?: boolean;
  40160. /**
  40161. * Defines if webgl2 should be turned off even if supported
  40162. * @see https://doc.babylonjs.com/features/webgl2
  40163. */
  40164. disableWebGL2Support?: boolean;
  40165. /**
  40166. * Defines if webaudio should be initialized as well
  40167. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  40168. */
  40169. audioEngine?: boolean;
  40170. /**
  40171. * Defines if animations should run using a deterministic lock step
  40172. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  40173. */
  40174. deterministicLockstep?: boolean;
  40175. /** Defines the maximum steps to use with deterministic lock step mode */
  40176. lockstepMaxSteps?: number;
  40177. /** Defines the seconds between each deterministic lock step */
  40178. timeStep?: number;
  40179. /**
  40180. * Defines that engine should ignore context lost events
  40181. * If this event happens when this parameter is true, you will have to reload the page to restore rendering
  40182. */
  40183. doNotHandleContextLost?: boolean;
  40184. /**
  40185. * Defines that engine should ignore modifying touch action attribute and style
  40186. * If not handle, you might need to set it up on your side for expected touch devices behavior.
  40187. */
  40188. doNotHandleTouchAction?: boolean;
  40189. /**
  40190. * Defines that engine should compile shaders with high precision floats (if supported). True by default
  40191. */
  40192. useHighPrecisionFloats?: boolean;
  40193. /**
  40194. * Make the canvas XR Compatible for XR sessions
  40195. */
  40196. xrCompatible?: boolean;
  40197. /**
  40198. * Make the matrix computations to be performed in 64 bits instead of 32 bits. False by default
  40199. */
  40200. useHighPrecisionMatrix?: boolean;
  40201. /**
  40202. * Will prevent the system from falling back to software implementation if a hardware device cannot be created
  40203. */
  40204. failIfMajorPerformanceCaveat?: boolean;
  40205. /**
  40206. * Defines whether to adapt to the device's viewport characteristics (default: false)
  40207. */
  40208. adaptToDeviceRatio?: boolean;
  40209. }
  40210. /**
  40211. * The base engine class (root of all engines)
  40212. */
  40213. export class ThinEngine {
  40214. /** Use this array to turn off some WebGL2 features on known buggy browsers version */
  40215. static ExceptionList: ({
  40216. key: string;
  40217. capture: string;
  40218. captureConstraint: number;
  40219. targets: string[];
  40220. } | {
  40221. key: string;
  40222. capture: null;
  40223. captureConstraint: null;
  40224. targets: string[];
  40225. })[];
  40226. /** @hidden */
  40227. static _TextureLoaders: IInternalTextureLoader[];
  40228. /**
  40229. * Returns the current npm package of the sdk
  40230. */
  40231. static get NpmPackage(): string;
  40232. /**
  40233. * Returns the current version of the framework
  40234. */
  40235. static get Version(): string;
  40236. /**
  40237. * Returns a string describing the current engine
  40238. */
  40239. get description(): string;
  40240. /**
  40241. * Returns the name of the engine
  40242. */
  40243. get name(): string;
  40244. /**
  40245. * Returns the version of the engine
  40246. */
  40247. get version(): number;
  40248. /**
  40249. * Gets or sets the epsilon value used by collision engine
  40250. */
  40251. static CollisionsEpsilon: number;
  40252. /**
  40253. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  40254. */
  40255. static get ShadersRepository(): string;
  40256. static set ShadersRepository(value: string);
  40257. /** @hidden */
  40258. _shaderProcessor: Nullable<IShaderProcessor>;
  40259. /**
  40260. * Gets or sets a boolean that indicates if textures must be forced to power of 2 size even if not required
  40261. */
  40262. forcePOTTextures: boolean;
  40263. /**
  40264. * Gets a boolean indicating if the engine is currently rendering in fullscreen mode
  40265. */
  40266. isFullscreen: boolean;
  40267. /**
  40268. * Gets or sets a boolean indicating if back faces must be culled (true by default)
  40269. */
  40270. cullBackFaces: boolean;
  40271. /**
  40272. * Gets or sets a boolean indicating if the engine must keep rendering even if the window is not in foregroun
  40273. */
  40274. renderEvenInBackground: boolean;
  40275. /**
  40276. * Gets or sets a boolean indicating that cache can be kept between frames
  40277. */
  40278. preventCacheWipeBetweenFrames: boolean;
  40279. /** Gets or sets a boolean indicating if the engine should validate programs after compilation */
  40280. validateShaderPrograms: boolean;
  40281. /**
  40282. * Gets or sets a boolean indicating if depth buffer should be reverse, going from far to near.
  40283. * This can provide greater z depth for distant objects.
  40284. */
  40285. useReverseDepthBuffer: boolean;
  40286. /**
  40287. * Gets or sets a boolean indicating that uniform buffers must be disabled even if they are supported
  40288. */
  40289. disableUniformBuffers: boolean;
  40290. private _frameId;
  40291. /**
  40292. * Gets the current frame id
  40293. */
  40294. get frameId(): number;
  40295. /** @hidden */
  40296. _uniformBuffers: UniformBuffer[];
  40297. /**
  40298. * Gets a boolean indicating that the engine supports uniform buffers
  40299. * @see https://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  40300. */
  40301. get supportsUniformBuffers(): boolean;
  40302. /** @hidden */
  40303. _gl: WebGLRenderingContext;
  40304. /** @hidden */
  40305. _webGLVersion: number;
  40306. protected _renderingCanvas: Nullable<HTMLCanvasElement>;
  40307. protected _windowIsBackground: boolean;
  40308. protected _creationOptions: EngineOptions;
  40309. protected _highPrecisionShadersAllowed: boolean;
  40310. /** @hidden */
  40311. get _shouldUseHighPrecisionShader(): boolean;
  40312. /**
  40313. * Gets a boolean indicating that only power of 2 textures are supported
  40314. * Please note that you can still use non power of 2 textures but in this case the engine will forcefully convert them
  40315. */
  40316. get needPOTTextures(): boolean;
  40317. /** @hidden */
  40318. _badOS: boolean;
  40319. /** @hidden */
  40320. _badDesktopOS: boolean;
  40321. protected _hardwareScalingLevel: number;
  40322. /** @hidden */
  40323. _caps: EngineCapabilities;
  40324. /** @hidden */
  40325. _features: EngineFeatures;
  40326. protected _isStencilEnable: boolean;
  40327. private _glVersion;
  40328. private _glRenderer;
  40329. private _glVendor;
  40330. /** @hidden */
  40331. _videoTextureSupported: boolean;
  40332. protected _renderingQueueLaunched: boolean;
  40333. protected _activeRenderLoops: (() => void)[];
  40334. /**
  40335. * Observable signaled when a context lost event is raised
  40336. */
  40337. onContextLostObservable: Observable<ThinEngine>;
  40338. /**
  40339. * Observable signaled when a context restored event is raised
  40340. */
  40341. onContextRestoredObservable: Observable<ThinEngine>;
  40342. private _onContextLost;
  40343. private _onContextRestored;
  40344. protected _contextWasLost: boolean;
  40345. /** @hidden */
  40346. _doNotHandleContextLost: boolean;
  40347. /**
  40348. * Gets or sets a boolean indicating if resources should be retained to be able to handle context lost events
  40349. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#handling-webgl-context-lost
  40350. */
  40351. get doNotHandleContextLost(): boolean;
  40352. set doNotHandleContextLost(value: boolean);
  40353. /**
  40354. * Gets or sets a boolean indicating that vertex array object must be disabled even if they are supported
  40355. */
  40356. disableVertexArrayObjects: boolean;
  40357. /** @hidden */
  40358. protected _colorWrite: boolean;
  40359. /** @hidden */
  40360. protected _colorWriteChanged: boolean;
  40361. /** @hidden */
  40362. protected _depthCullingState: DepthCullingState;
  40363. /** @hidden */
  40364. protected _stencilState: StencilState;
  40365. /** @hidden */
  40366. _alphaState: AlphaState;
  40367. /** @hidden */
  40368. _alphaMode: number;
  40369. /** @hidden */
  40370. _alphaEquation: number;
  40371. /** @hidden */
  40372. _internalTexturesCache: InternalTexture[];
  40373. /** @hidden */
  40374. protected _activeChannel: number;
  40375. private _currentTextureChannel;
  40376. /** @hidden */
  40377. protected _boundTexturesCache: {
  40378. [key: string]: Nullable<InternalTexture>;
  40379. };
  40380. /** @hidden */
  40381. protected _currentEffect: Nullable<Effect>;
  40382. /** @hidden */
  40383. protected _currentProgram: Nullable<WebGLProgram>;
  40384. protected _compiledEffects: {
  40385. [key: string]: Effect;
  40386. };
  40387. private _vertexAttribArraysEnabled;
  40388. /** @hidden */
  40389. protected _cachedViewport: Nullable<IViewportLike>;
  40390. private _cachedVertexArrayObject;
  40391. /** @hidden */
  40392. protected _cachedVertexBuffers: any;
  40393. /** @hidden */
  40394. protected _cachedIndexBuffer: Nullable<DataBuffer>;
  40395. /** @hidden */
  40396. protected _cachedEffectForVertexBuffers: Nullable<Effect>;
  40397. /** @hidden */
  40398. _currentRenderTarget: Nullable<InternalTexture>;
  40399. private _uintIndicesCurrentlySet;
  40400. protected _currentBoundBuffer: Nullable<WebGLBuffer>[];
  40401. /** @hidden */
  40402. _currentFramebuffer: Nullable<WebGLFramebuffer>;
  40403. /** @hidden */
  40404. _dummyFramebuffer: Nullable<WebGLFramebuffer>;
  40405. private _currentBufferPointers;
  40406. private _currentInstanceLocations;
  40407. private _currentInstanceBuffers;
  40408. private _textureUnits;
  40409. /** @hidden */
  40410. _workingCanvas: Nullable<HTMLCanvasElement | OffscreenCanvas>;
  40411. /** @hidden */
  40412. _workingContext: Nullable<CanvasRenderingContext2D | OffscreenCanvasRenderingContext2D>;
  40413. /** @hidden */
  40414. _boundRenderFunction: any;
  40415. private _vaoRecordInProgress;
  40416. private _mustWipeVertexAttributes;
  40417. private _emptyTexture;
  40418. private _emptyCubeTexture;
  40419. private _emptyTexture3D;
  40420. private _emptyTexture2DArray;
  40421. /** @hidden */
  40422. _frameHandler: number;
  40423. private _nextFreeTextureSlots;
  40424. private _maxSimultaneousTextures;
  40425. private _activeRequests;
  40426. /** @hidden */
  40427. _transformTextureUrl: Nullable<(url: string) => string>;
  40428. /**
  40429. * Gets information about the current host
  40430. */
  40431. hostInformation: HostInformation;
  40432. protected get _supportsHardwareTextureRescaling(): boolean;
  40433. private _framebufferDimensionsObject;
  40434. /**
  40435. * sets the object from which width and height will be taken from when getting render width and height
  40436. * Will fallback to the gl object
  40437. * @param dimensions the framebuffer width and height that will be used.
  40438. */
  40439. set framebufferDimensionsObject(dimensions: Nullable<{
  40440. framebufferWidth: number;
  40441. framebufferHeight: number;
  40442. }>);
  40443. /**
  40444. * Gets the current viewport
  40445. */
  40446. get currentViewport(): Nullable<IViewportLike>;
  40447. /**
  40448. * Gets the default empty texture
  40449. */
  40450. get emptyTexture(): InternalTexture;
  40451. /**
  40452. * Gets the default empty 3D texture
  40453. */
  40454. get emptyTexture3D(): InternalTexture;
  40455. /**
  40456. * Gets the default empty 2D array texture
  40457. */
  40458. get emptyTexture2DArray(): InternalTexture;
  40459. /**
  40460. * Gets the default empty cube texture
  40461. */
  40462. get emptyCubeTexture(): InternalTexture;
  40463. /**
  40464. * Defines whether the engine has been created with the premultipliedAlpha option on or not.
  40465. */
  40466. premultipliedAlpha: boolean;
  40467. /**
  40468. * Observable event triggered before each texture is initialized
  40469. */
  40470. onBeforeTextureInitObservable: Observable<Texture>;
  40471. /** @hidden */
  40472. protected _isWebGPU: boolean;
  40473. /**
  40474. * Gets a boolean indicating if the engine runs in WebGPU or not.
  40475. */
  40476. get isWebGPU(): boolean;
  40477. /** @hidden */
  40478. protected _shaderPlatformName: string;
  40479. /**
  40480. * Gets the shader platfrom name used by the effects.
  40481. */
  40482. get shaderPlatformName(): string;
  40483. /**
  40484. * Creates a new engine
  40485. * @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
  40486. * @param antialias defines enable antialiasing (default: false)
  40487. * @param options defines further options to be sent to the getContext() function
  40488. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  40489. */
  40490. constructor(canvasOrContext: Nullable<HTMLCanvasElement | OffscreenCanvas | WebGLRenderingContext | WebGL2RenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  40491. /**
  40492. * @hidden
  40493. */
  40494. _debugPushGroup(groupName: string, targetObject?: number): void;
  40495. /**
  40496. * @hidden
  40497. */
  40498. _debugPopGroup(targetObject?: number): void;
  40499. /**
  40500. * @hidden
  40501. */
  40502. _debugInsertMarker(text: string, targetObject?: number): void;
  40503. /**
  40504. * Shared initialization across engines types.
  40505. * @param canvas The canvas associated with this instance of the engine.
  40506. * @param doNotHandleTouchAction Defines that engine should ignore modifying touch action attribute and style
  40507. * @param audioEngine Defines if an audio engine should be created by default
  40508. */
  40509. protected _sharedInit(canvas: HTMLCanvasElement, doNotHandleTouchAction: boolean, audioEngine: boolean): void;
  40510. /**
  40511. * Gets a shader processor implementation fitting with the current engine type.
  40512. * @returns The shader processor implementation.
  40513. */
  40514. protected _getShaderProcessor(): Nullable<IShaderProcessor>;
  40515. /** @hidden */
  40516. _getShaderProcessingContext(): Nullable<ShaderProcessingContext>;
  40517. private _rebuildInternalTextures;
  40518. private _rebuildEffects;
  40519. /**
  40520. * Gets a boolean indicating if all created effects are ready
  40521. * @returns true if all effects are ready
  40522. */
  40523. areAllEffectsReady(): boolean;
  40524. protected _rebuildBuffers(): void;
  40525. protected _initGLContext(): void;
  40526. protected _initFeatures(): void;
  40527. /**
  40528. * Gets version of the current webGL context
  40529. * Keep it for back compat - use version instead
  40530. */
  40531. get webGLVersion(): number;
  40532. /**
  40533. * Gets a string identifying the name of the class
  40534. * @returns "Engine" string
  40535. */
  40536. getClassName(): string;
  40537. /**
  40538. * Returns true if the stencil buffer has been enabled through the creation option of the context.
  40539. */
  40540. get isStencilEnable(): boolean;
  40541. /** @hidden */
  40542. _prepareWorkingCanvas(): void;
  40543. /**
  40544. * Reset the texture cache to empty state
  40545. */
  40546. resetTextureCache(): void;
  40547. /**
  40548. * Gets an object containing information about the current webGL context
  40549. * @returns an object containing the vendor, the renderer and the version of the current webGL context
  40550. */
  40551. getGlInfo(): {
  40552. vendor: string;
  40553. renderer: string;
  40554. version: string;
  40555. };
  40556. /**
  40557. * Defines the hardware scaling level.
  40558. * By default the hardware scaling level is computed from the window device ratio.
  40559. * 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.
  40560. * @param level defines the level to use
  40561. */
  40562. setHardwareScalingLevel(level: number): void;
  40563. /**
  40564. * Gets the current hardware scaling level.
  40565. * By default the hardware scaling level is computed from the window device ratio.
  40566. * 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.
  40567. * @returns a number indicating the current hardware scaling level
  40568. */
  40569. getHardwareScalingLevel(): number;
  40570. /**
  40571. * Gets the list of loaded textures
  40572. * @returns an array containing all loaded textures
  40573. */
  40574. getLoadedTexturesCache(): InternalTexture[];
  40575. /**
  40576. * Gets the object containing all engine capabilities
  40577. * @returns the EngineCapabilities object
  40578. */
  40579. getCaps(): EngineCapabilities;
  40580. /**
  40581. * stop executing a render loop function and remove it from the execution array
  40582. * @param renderFunction defines the function to be removed. If not provided all functions will be removed.
  40583. */
  40584. stopRenderLoop(renderFunction?: () => void): void;
  40585. /** @hidden */
  40586. _renderLoop(): void;
  40587. /**
  40588. * Gets the HTML canvas attached with the current webGL context
  40589. * @returns a HTML canvas
  40590. */
  40591. getRenderingCanvas(): Nullable<HTMLCanvasElement>;
  40592. /**
  40593. * Gets host window
  40594. * @returns the host window object
  40595. */
  40596. getHostWindow(): Nullable<Window>;
  40597. /**
  40598. * Gets the current render width
  40599. * @param useScreen defines if screen size must be used (or the current render target if any)
  40600. * @returns a number defining the current render width
  40601. */
  40602. getRenderWidth(useScreen?: boolean): number;
  40603. /**
  40604. * Gets the current render height
  40605. * @param useScreen defines if screen size must be used (or the current render target if any)
  40606. * @returns a number defining the current render height
  40607. */
  40608. getRenderHeight(useScreen?: boolean): number;
  40609. /**
  40610. * Can be used to override the current requestAnimationFrame requester.
  40611. * @hidden
  40612. */
  40613. protected _queueNewFrame(bindedRenderFunction: any, requester?: any): number;
  40614. /**
  40615. * Register and execute a render loop. The engine can have more than one render function
  40616. * @param renderFunction defines the function to continuously execute
  40617. */
  40618. runRenderLoop(renderFunction: () => void): void;
  40619. /**
  40620. * Clear the current render buffer or the current render target (if any is set up)
  40621. * @param color defines the color to use
  40622. * @param backBuffer defines if the back buffer must be cleared
  40623. * @param depth defines if the depth buffer must be cleared
  40624. * @param stencil defines if the stencil buffer must be cleared
  40625. */
  40626. clear(color: Nullable<IColor4Like>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  40627. protected _viewportCached: {
  40628. x: number;
  40629. y: number;
  40630. z: number;
  40631. w: number;
  40632. };
  40633. /** @hidden */
  40634. _viewport(x: number, y: number, width: number, height: number): void;
  40635. /**
  40636. * Set the WebGL's viewport
  40637. * @param viewport defines the viewport element to be used
  40638. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  40639. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  40640. */
  40641. setViewport(viewport: IViewportLike, requiredWidth?: number, requiredHeight?: number): void;
  40642. /**
  40643. * Begin a new frame
  40644. */
  40645. beginFrame(): void;
  40646. /**
  40647. * Enf the current frame
  40648. */
  40649. endFrame(): void;
  40650. /**
  40651. * Resize the view according to the canvas' size
  40652. * @param forceSetSize true to force setting the sizes of the underlying canvas
  40653. */
  40654. resize(forceSetSize?: boolean): void;
  40655. /**
  40656. * Force a specific size of the canvas
  40657. * @param width defines the new canvas' width
  40658. * @param height defines the new canvas' height
  40659. * @param forceSetSize true to force setting the sizes of the underlying canvas
  40660. * @returns true if the size was changed
  40661. */
  40662. setSize(width: number, height: number, forceSetSize?: boolean): boolean;
  40663. /**
  40664. * Binds the frame buffer to the specified texture.
  40665. * @param texture The texture to render to or null for the default canvas
  40666. * @param faceIndex The face of the texture to render to in case of cube texture
  40667. * @param requiredWidth The width of the target to render to
  40668. * @param requiredHeight The height of the target to render to
  40669. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  40670. * @param lodLevel defines the lod level to bind to the frame buffer
  40671. * @param layer defines the 2d array index to bind to frame buffer to
  40672. */
  40673. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean, lodLevel?: number, layer?: number): void;
  40674. /** @hidden */
  40675. _bindUnboundFramebuffer(framebuffer: Nullable<WebGLFramebuffer>): void;
  40676. /**
  40677. * Unbind the current render target texture from the webGL context
  40678. * @param texture defines the render target texture to unbind
  40679. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  40680. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  40681. */
  40682. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  40683. /**
  40684. * Force a webGL flush (ie. a flush of all waiting webGL commands)
  40685. */
  40686. flushFramebuffer(): void;
  40687. /**
  40688. * Unbind the current render target and bind the default framebuffer
  40689. */
  40690. restoreDefaultFramebuffer(): void;
  40691. /** @hidden */
  40692. protected _resetVertexBufferBinding(): void;
  40693. /**
  40694. * Creates a vertex buffer
  40695. * @param data the data for the vertex buffer
  40696. * @returns the new WebGL static buffer
  40697. */
  40698. createVertexBuffer(data: DataArray): DataBuffer;
  40699. private _createVertexBuffer;
  40700. /**
  40701. * Creates a dynamic vertex buffer
  40702. * @param data the data for the dynamic vertex buffer
  40703. * @returns the new WebGL dynamic buffer
  40704. */
  40705. createDynamicVertexBuffer(data: DataArray): DataBuffer;
  40706. protected _resetIndexBufferBinding(): void;
  40707. /**
  40708. * Creates a new index buffer
  40709. * @param indices defines the content of the index buffer
  40710. * @param updatable defines if the index buffer must be updatable
  40711. * @returns a new webGL buffer
  40712. */
  40713. createIndexBuffer(indices: IndicesArray, updatable?: boolean): DataBuffer;
  40714. protected _normalizeIndexData(indices: IndicesArray): Uint16Array | Uint32Array;
  40715. /**
  40716. * Bind a webGL buffer to the webGL context
  40717. * @param buffer defines the buffer to bind
  40718. */
  40719. bindArrayBuffer(buffer: Nullable<DataBuffer>): void;
  40720. protected bindIndexBuffer(buffer: Nullable<DataBuffer>): void;
  40721. private bindBuffer;
  40722. /**
  40723. * update the bound buffer with the given data
  40724. * @param data defines the data to update
  40725. */
  40726. updateArrayBuffer(data: Float32Array): void;
  40727. private _vertexAttribPointer;
  40728. /** @hidden */
  40729. _bindIndexBufferWithCache(indexBuffer: Nullable<DataBuffer>): void;
  40730. private _bindVertexBuffersAttributes;
  40731. /**
  40732. * Records a vertex array object
  40733. * @see https://doc.babylonjs.com/features/webgl2#vertex-array-objects
  40734. * @param vertexBuffers defines the list of vertex buffers to store
  40735. * @param indexBuffer defines the index buffer to store
  40736. * @param effect defines the effect to store
  40737. * @param overrideVertexBuffers defines optional list of avertex buffers that overrides the entries in vertexBuffers
  40738. * @returns the new vertex array object
  40739. */
  40740. recordVertexArrayObject(vertexBuffers: {
  40741. [key: string]: VertexBuffer;
  40742. }, indexBuffer: Nullable<DataBuffer>, effect: Effect, overrideVertexBuffers?: {
  40743. [kind: string]: Nullable<VertexBuffer>;
  40744. }): WebGLVertexArrayObject;
  40745. /**
  40746. * Bind a specific vertex array object
  40747. * @see https://doc.babylonjs.com/features/webgl2#vertex-array-objects
  40748. * @param vertexArrayObject defines the vertex array object to bind
  40749. * @param indexBuffer defines the index buffer to bind
  40750. */
  40751. bindVertexArrayObject(vertexArrayObject: WebGLVertexArrayObject, indexBuffer: Nullable<DataBuffer>): void;
  40752. /**
  40753. * Bind webGl buffers directly to the webGL context
  40754. * @param vertexBuffer defines the vertex buffer to bind
  40755. * @param indexBuffer defines the index buffer to bind
  40756. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  40757. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  40758. * @param effect defines the effect associated with the vertex buffer
  40759. */
  40760. bindBuffersDirectly(vertexBuffer: DataBuffer, indexBuffer: DataBuffer, vertexDeclaration: number[], vertexStrideSize: number, effect: Effect): void;
  40761. private _unbindVertexArrayObject;
  40762. /**
  40763. * Bind a list of vertex buffers to the webGL context
  40764. * @param vertexBuffers defines the list of vertex buffers to bind
  40765. * @param indexBuffer defines the index buffer to bind
  40766. * @param effect defines the effect associated with the vertex buffers
  40767. * @param overrideVertexBuffers defines optional list of avertex buffers that overrides the entries in vertexBuffers
  40768. */
  40769. bindBuffers(vertexBuffers: {
  40770. [key: string]: Nullable<VertexBuffer>;
  40771. }, indexBuffer: Nullable<DataBuffer>, effect: Effect, overrideVertexBuffers?: {
  40772. [kind: string]: Nullable<VertexBuffer>;
  40773. }): void;
  40774. /**
  40775. * Unbind all instance attributes
  40776. */
  40777. unbindInstanceAttributes(): void;
  40778. /**
  40779. * Release and free the memory of a vertex array object
  40780. * @param vao defines the vertex array object to delete
  40781. */
  40782. releaseVertexArrayObject(vao: WebGLVertexArrayObject): void;
  40783. /** @hidden */
  40784. _releaseBuffer(buffer: DataBuffer): boolean;
  40785. protected _deleteBuffer(buffer: DataBuffer): void;
  40786. /**
  40787. * Update the content of a webGL buffer used with instantiation and bind it to the webGL context
  40788. * @param instancesBuffer defines the webGL buffer to update and bind
  40789. * @param data defines the data to store in the buffer
  40790. * @param offsetLocations defines the offsets or attributes information used to determine where data must be stored in the buffer
  40791. */
  40792. updateAndBindInstancesBuffer(instancesBuffer: DataBuffer, data: Float32Array, offsetLocations: number[] | InstancingAttributeInfo[]): void;
  40793. /**
  40794. * Bind the content of a webGL buffer used with instantiation
  40795. * @param instancesBuffer defines the webGL buffer to bind
  40796. * @param attributesInfo defines the offsets or attributes information used to determine where data must be stored in the buffer
  40797. * @param computeStride defines Whether to compute the strides from the info or use the default 0
  40798. */
  40799. bindInstancesBuffer(instancesBuffer: DataBuffer, attributesInfo: InstancingAttributeInfo[], computeStride?: boolean): void;
  40800. /**
  40801. * Disable the instance attribute corresponding to the name in parameter
  40802. * @param name defines the name of the attribute to disable
  40803. */
  40804. disableInstanceAttributeByName(name: string): void;
  40805. /**
  40806. * Disable the instance attribute corresponding to the location in parameter
  40807. * @param attributeLocation defines the attribute location of the attribute to disable
  40808. */
  40809. disableInstanceAttribute(attributeLocation: number): void;
  40810. /**
  40811. * Disable the attribute corresponding to the location in parameter
  40812. * @param attributeLocation defines the attribute location of the attribute to disable
  40813. */
  40814. disableAttributeByIndex(attributeLocation: number): void;
  40815. /**
  40816. * Send a draw order
  40817. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  40818. * @param indexStart defines the starting index
  40819. * @param indexCount defines the number of index to draw
  40820. * @param instancesCount defines the number of instances to draw (if instantiation is enabled)
  40821. */
  40822. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  40823. /**
  40824. * Draw a list of points
  40825. * @param verticesStart defines the index of first vertex to draw
  40826. * @param verticesCount defines the count of vertices to draw
  40827. * @param instancesCount defines the number of instances to draw (if instantiation is enabled)
  40828. */
  40829. drawPointClouds(verticesStart: number, verticesCount: number, instancesCount?: number): void;
  40830. /**
  40831. * Draw a list of unindexed primitives
  40832. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  40833. * @param verticesStart defines the index of first vertex to draw
  40834. * @param verticesCount defines the count of vertices to draw
  40835. * @param instancesCount defines the number of instances to draw (if instantiation is enabled)
  40836. */
  40837. drawUnIndexed(useTriangles: boolean, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  40838. /**
  40839. * Draw a list of indexed primitives
  40840. * @param fillMode defines the primitive to use
  40841. * @param indexStart defines the starting index
  40842. * @param indexCount defines the number of index to draw
  40843. * @param instancesCount defines the number of instances to draw (if instantiation is enabled)
  40844. */
  40845. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  40846. /**
  40847. * Draw a list of unindexed primitives
  40848. * @param fillMode defines the primitive to use
  40849. * @param verticesStart defines the index of first vertex to draw
  40850. * @param verticesCount defines the count of vertices to draw
  40851. * @param instancesCount defines the number of instances to draw (if instantiation is enabled)
  40852. */
  40853. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  40854. private _drawMode;
  40855. /** @hidden */
  40856. protected _reportDrawCall(): void;
  40857. /** @hidden */
  40858. _releaseEffect(effect: Effect): void;
  40859. /** @hidden */
  40860. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  40861. /**
  40862. * Create a new effect (used to store vertex/fragment shaders)
  40863. * @param baseName defines the base name of the effect (The name of file without .fragment.fx or .vertex.fx)
  40864. * @param attributesNamesOrOptions defines either a list of attribute names or an IEffectCreationOptions object
  40865. * @param uniformsNamesOrEngine defines either a list of uniform names or the engine to use
  40866. * @param samplers defines an array of string used to represent textures
  40867. * @param defines defines the string containing the defines to use to compile the shaders
  40868. * @param fallbacks defines the list of potential fallbacks to use if shader compilation fails
  40869. * @param onCompiled defines a function to call when the effect creation is successful
  40870. * @param onError defines a function to call when the effect creation has failed
  40871. * @param indexParameters defines an object containing the index values to use to compile shaders (like the maximum number of simultaneous lights)
  40872. * @returns the new Effect
  40873. */
  40874. 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;
  40875. protected static _ConcatenateShader(source: string, defines: Nullable<string>, shaderVersion?: string): string;
  40876. private _compileShader;
  40877. private _compileRawShader;
  40878. /** @hidden */
  40879. _getShaderSource(shader: WebGLShader): Nullable<string>;
  40880. /**
  40881. * Directly creates a webGL program
  40882. * @param pipelineContext defines the pipeline context to attach to
  40883. * @param vertexCode defines the vertex shader code to use
  40884. * @param fragmentCode defines the fragment shader code to use
  40885. * @param context defines the webGL context to use (if not set, the current one will be used)
  40886. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  40887. * @returns the new webGL program
  40888. */
  40889. createRawShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  40890. /**
  40891. * Creates a webGL program
  40892. * @param pipelineContext defines the pipeline context to attach to
  40893. * @param vertexCode defines the vertex shader code to use
  40894. * @param fragmentCode defines the fragment shader code to use
  40895. * @param defines defines the string containing the defines to use to compile the shaders
  40896. * @param context defines the webGL context to use (if not set, the current one will be used)
  40897. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  40898. * @returns the new webGL program
  40899. */
  40900. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  40901. /**
  40902. * Creates a new pipeline context
  40903. * @param shaderProcessingContext defines the shader processing context used during the processing if available
  40904. * @returns the new pipeline
  40905. */
  40906. createPipelineContext(shaderProcessingContext: Nullable<ShaderProcessingContext>): IPipelineContext;
  40907. protected _createShaderProgram(pipelineContext: WebGLPipelineContext, vertexShader: WebGLShader, fragmentShader: WebGLShader, context: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  40908. protected _finalizePipelineContext(pipelineContext: WebGLPipelineContext): void;
  40909. /** @hidden */
  40910. _preparePipelineContext(pipelineContext: IPipelineContext, vertexSourceCode: string, fragmentSourceCode: string, createAsRaw: boolean, rawVertexSourceCode: string, rawFragmentSourceCode: string, rebuildRebind: any, defines: Nullable<string>, transformFeedbackVaryings: Nullable<string[]>, key: string): void;
  40911. /** @hidden */
  40912. _isRenderingStateCompiled(pipelineContext: IPipelineContext): boolean;
  40913. /** @hidden */
  40914. _executeWhenRenderingStateIsCompiled(pipelineContext: IPipelineContext, action: () => void): void;
  40915. /**
  40916. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  40917. * @param pipelineContext defines the pipeline context to use
  40918. * @param uniformsNames defines the list of uniform names
  40919. * @returns an array of webGL uniform locations
  40920. */
  40921. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  40922. /**
  40923. * Gets the list of active attributes for a given webGL program
  40924. * @param pipelineContext defines the pipeline context to use
  40925. * @param attributesNames defines the list of attribute names to get
  40926. * @returns an array of indices indicating the offset of each attribute
  40927. */
  40928. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  40929. /**
  40930. * Activates an effect, making it the current one (ie. the one used for rendering)
  40931. * @param effect defines the effect to activate
  40932. */
  40933. enableEffect(effect: Nullable<Effect>): void;
  40934. /**
  40935. * Set the value of an uniform to a number (int)
  40936. * @param uniform defines the webGL uniform location where to store the value
  40937. * @param value defines the int number to store
  40938. * @returns true if the value was set
  40939. */
  40940. setInt(uniform: Nullable<WebGLUniformLocation>, value: number): boolean;
  40941. /**
  40942. * Set the value of an uniform to a int2
  40943. * @param uniform defines the webGL uniform location where to store the value
  40944. * @param x defines the 1st component of the value
  40945. * @param y defines the 2nd component of the value
  40946. * @returns true if the value was set
  40947. */
  40948. setInt2(uniform: Nullable<WebGLUniformLocation>, x: number, y: number): boolean;
  40949. /**
  40950. * Set the value of an uniform to a int3
  40951. * @param uniform defines the webGL uniform location where to store the value
  40952. * @param x defines the 1st component of the value
  40953. * @param y defines the 2nd component of the value
  40954. * @param z defines the 3rd component of the value
  40955. * @returns true if the value was set
  40956. */
  40957. setInt3(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number): boolean;
  40958. /**
  40959. * Set the value of an uniform to a int4
  40960. * @param uniform defines the webGL uniform location where to store the value
  40961. * @param x defines the 1st component of the value
  40962. * @param y defines the 2nd component of the value
  40963. * @param z defines the 3rd component of the value
  40964. * @param w defines the 4th component of the value
  40965. * @returns true if the value was set
  40966. */
  40967. setInt4(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number, w: number): boolean;
  40968. /**
  40969. * Set the value of an uniform to an array of int32
  40970. * @param uniform defines the webGL uniform location where to store the value
  40971. * @param array defines the array of int32 to store
  40972. * @returns true if the value was set
  40973. */
  40974. setIntArray(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): boolean;
  40975. /**
  40976. * Set the value of an uniform to an array of int32 (stored as vec2)
  40977. * @param uniform defines the webGL uniform location where to store the value
  40978. * @param array defines the array of int32 to store
  40979. * @returns true if the value was set
  40980. */
  40981. setIntArray2(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): boolean;
  40982. /**
  40983. * Set the value of an uniform to an array of int32 (stored as vec3)
  40984. * @param uniform defines the webGL uniform location where to store the value
  40985. * @param array defines the array of int32 to store
  40986. * @returns true if the value was set
  40987. */
  40988. setIntArray3(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): boolean;
  40989. /**
  40990. * Set the value of an uniform to an array of int32 (stored as vec4)
  40991. * @param uniform defines the webGL uniform location where to store the value
  40992. * @param array defines the array of int32 to store
  40993. * @returns true if the value was set
  40994. */
  40995. setIntArray4(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): boolean;
  40996. /**
  40997. * Set the value of an uniform to an array of number
  40998. * @param uniform defines the webGL uniform location where to store the value
  40999. * @param array defines the array of number to store
  41000. * @returns true if the value was set
  41001. */
  41002. setArray(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): boolean;
  41003. /**
  41004. * Set the value of an uniform to an array of number (stored as vec2)
  41005. * @param uniform defines the webGL uniform location where to store the value
  41006. * @param array defines the array of number to store
  41007. * @returns true if the value was set
  41008. */
  41009. setArray2(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): boolean;
  41010. /**
  41011. * Set the value of an uniform to an array of number (stored as vec3)
  41012. * @param uniform defines the webGL uniform location where to store the value
  41013. * @param array defines the array of number to store
  41014. * @returns true if the value was set
  41015. */
  41016. setArray3(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): boolean;
  41017. /**
  41018. * Set the value of an uniform to an array of number (stored as vec4)
  41019. * @param uniform defines the webGL uniform location where to store the value
  41020. * @param array defines the array of number to store
  41021. * @returns true if the value was set
  41022. */
  41023. setArray4(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): boolean;
  41024. /**
  41025. * Set the value of an uniform to an array of float32 (stored as matrices)
  41026. * @param uniform defines the webGL uniform location where to store the value
  41027. * @param matrices defines the array of float32 to store
  41028. * @returns true if the value was set
  41029. */
  41030. setMatrices(uniform: Nullable<WebGLUniformLocation>, matrices: Float32Array): boolean;
  41031. /**
  41032. * Set the value of an uniform to a matrix (3x3)
  41033. * @param uniform defines the webGL uniform location where to store the value
  41034. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  41035. * @returns true if the value was set
  41036. */
  41037. setMatrix3x3(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): boolean;
  41038. /**
  41039. * Set the value of an uniform to a matrix (2x2)
  41040. * @param uniform defines the webGL uniform location where to store the value
  41041. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  41042. * @returns true if the value was set
  41043. */
  41044. setMatrix2x2(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): boolean;
  41045. /**
  41046. * Set the value of an uniform to a number (float)
  41047. * @param uniform defines the webGL uniform location where to store the value
  41048. * @param value defines the float number to store
  41049. * @returns true if the value was transferred
  41050. */
  41051. setFloat(uniform: Nullable<WebGLUniformLocation>, value: number): boolean;
  41052. /**
  41053. * Set the value of an uniform to a vec2
  41054. * @param uniform defines the webGL uniform location where to store the value
  41055. * @param x defines the 1st component of the value
  41056. * @param y defines the 2nd component of the value
  41057. * @returns true if the value was set
  41058. */
  41059. setFloat2(uniform: Nullable<WebGLUniformLocation>, x: number, y: number): boolean;
  41060. /**
  41061. * Set the value of an uniform to a vec3
  41062. * @param uniform defines the webGL uniform location where to store the value
  41063. * @param x defines the 1st component of the value
  41064. * @param y defines the 2nd component of the value
  41065. * @param z defines the 3rd component of the value
  41066. * @returns true if the value was set
  41067. */
  41068. setFloat3(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number): boolean;
  41069. /**
  41070. * Set the value of an uniform to a vec4
  41071. * @param uniform defines the webGL uniform location where to store the value
  41072. * @param x defines the 1st component of the value
  41073. * @param y defines the 2nd component of the value
  41074. * @param z defines the 3rd component of the value
  41075. * @param w defines the 4th component of the value
  41076. * @returns true if the value was set
  41077. */
  41078. setFloat4(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number, w: number): boolean;
  41079. /**
  41080. * Apply all cached states (depth, culling, stencil and alpha)
  41081. */
  41082. applyStates(): void;
  41083. /**
  41084. * Enable or disable color writing
  41085. * @param enable defines the state to set
  41086. */
  41087. setColorWrite(enable: boolean): void;
  41088. /**
  41089. * Gets a boolean indicating if color writing is enabled
  41090. * @returns the current color writing state
  41091. */
  41092. getColorWrite(): boolean;
  41093. /**
  41094. * Gets the depth culling state manager
  41095. */
  41096. get depthCullingState(): DepthCullingState;
  41097. /**
  41098. * Gets the alpha state manager
  41099. */
  41100. get alphaState(): AlphaState;
  41101. /**
  41102. * Gets the stencil state manager
  41103. */
  41104. get stencilState(): StencilState;
  41105. /**
  41106. * Clears the list of texture accessible through engine.
  41107. * This can help preventing texture load conflict due to name collision.
  41108. */
  41109. clearInternalTexturesCache(): void;
  41110. /**
  41111. * Force the entire cache to be cleared
  41112. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  41113. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  41114. */
  41115. wipeCaches(bruteForce?: boolean): void;
  41116. /** @hidden */
  41117. _getSamplingParameters(samplingMode: number, generateMipMaps: boolean): {
  41118. min: number;
  41119. mag: number;
  41120. };
  41121. /** @hidden */
  41122. protected _createTexture(): WebGLTexture;
  41123. /** @hidden */
  41124. _createHardwareTexture(): HardwareTextureWrapper;
  41125. 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 | {
  41126. width: number;
  41127. height: number;
  41128. }, invertY: boolean, noMipmap: boolean, isCompressed: boolean, processFunction: (width: number, height: number, img: HTMLImageElement | ImageBitmap | {
  41129. width: number;
  41130. height: number;
  41131. }, extension: string, texture: InternalTexture, continuationCallback: () => void) => boolean, samplingMode: number) => void, prepareTextureProcessFunction: (width: number, height: number, img: HTMLImageElement | ImageBitmap | {
  41132. width: number;
  41133. height: number;
  41134. }, 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;
  41135. /**
  41136. * Usually called from Texture.ts.
  41137. * Passed information to create a WebGLTexture
  41138. * @param url defines a value which contains one of the following:
  41139. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  41140. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  41141. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  41142. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  41143. * @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)
  41144. * @param scene needed for loading to the correct scene
  41145. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  41146. * @param onLoad optional callback to be called upon successful completion
  41147. * @param onError optional callback to be called upon failure
  41148. * @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
  41149. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  41150. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  41151. * @param forcedExtension defines the extension to use to pick the right loader
  41152. * @param mimeType defines an optional mime type
  41153. * @param loaderOptions options to be passed to the loader
  41154. * @returns a InternalTexture for assignment back into BABYLON.Texture
  41155. */
  41156. 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;
  41157. /**
  41158. * Loads an image as an HTMLImageElement.
  41159. * @param input url string, ArrayBuffer, or Blob to load
  41160. * @param onLoad callback called when the image successfully loads
  41161. * @param onError callback called when the image fails to load
  41162. * @param offlineProvider offline provider for caching
  41163. * @param mimeType optional mime type
  41164. * @returns the HTMLImageElement of the loaded image
  41165. * @hidden
  41166. */
  41167. 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>;
  41168. /**
  41169. * @hidden
  41170. */
  41171. _rescaleTexture(source: InternalTexture, destination: InternalTexture, scene: Nullable<any>, internalFormat: number, onComplete: () => void): void;
  41172. private _unpackFlipYCached;
  41173. /**
  41174. * In case you are sharing the context with other applications, it might
  41175. * be interested to not cache the unpack flip y state to ensure a consistent
  41176. * value would be set.
  41177. */
  41178. enableUnpackFlipYCached: boolean;
  41179. /** @hidden */
  41180. _unpackFlipY(value: boolean): void;
  41181. /** @hidden */
  41182. _getUnpackAlignement(): number;
  41183. private _getTextureTarget;
  41184. /**
  41185. * Update the sampling mode of a given texture
  41186. * @param samplingMode defines the required sampling mode
  41187. * @param texture defines the texture to update
  41188. * @param generateMipMaps defines whether to generate mipmaps for the texture
  41189. */
  41190. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture, generateMipMaps?: boolean): void;
  41191. /**
  41192. * Update the dimensions of a texture
  41193. * @param texture texture to update
  41194. * @param width new width of the texture
  41195. * @param height new height of the texture
  41196. * @param depth new depth of the texture
  41197. */
  41198. updateTextureDimensions(texture: InternalTexture, width: number, height: number, depth?: number): void;
  41199. /**
  41200. * Update the sampling mode of a given texture
  41201. * @param texture defines the texture to update
  41202. * @param wrapU defines the texture wrap mode of the u coordinates
  41203. * @param wrapV defines the texture wrap mode of the v coordinates
  41204. * @param wrapR defines the texture wrap mode of the r coordinates
  41205. */
  41206. updateTextureWrappingMode(texture: InternalTexture, wrapU: Nullable<number>, wrapV?: Nullable<number>, wrapR?: Nullable<number>): void;
  41207. /** @hidden */
  41208. _setupDepthStencilTexture(internalTexture: InternalTexture, size: number | {
  41209. width: number;
  41210. height: number;
  41211. layers?: number;
  41212. }, generateStencil: boolean, bilinearFiltering: boolean, comparisonFunction: number, samples?: number): void;
  41213. /** @hidden */
  41214. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  41215. /** @hidden */
  41216. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number, babylonInternalFormat?: number, useTextureWidthAndHeight?: boolean): void;
  41217. /**
  41218. * Update a portion of an internal texture
  41219. * @param texture defines the texture to update
  41220. * @param imageData defines the data to store into the texture
  41221. * @param xOffset defines the x coordinates of the update rectangle
  41222. * @param yOffset defines the y coordinates of the update rectangle
  41223. * @param width defines the width of the update rectangle
  41224. * @param height defines the height of the update rectangle
  41225. * @param faceIndex defines the face index if texture is a cube (0 by default)
  41226. * @param lod defines the lod level to update (0 by default)
  41227. */
  41228. updateTextureData(texture: InternalTexture, imageData: ArrayBufferView, xOffset: number, yOffset: number, width: number, height: number, faceIndex?: number, lod?: number): void;
  41229. /** @hidden */
  41230. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  41231. protected _prepareWebGLTextureContinuation(texture: InternalTexture, scene: Nullable<ISceneLike>, noMipmap: boolean, isCompressed: boolean, samplingMode: number): void;
  41232. private _prepareWebGLTexture;
  41233. /** @hidden */
  41234. _setupFramebufferDepthAttachments(generateStencilBuffer: boolean, generateDepthBuffer: boolean, width: number, height: number, samples?: number): Nullable<WebGLRenderbuffer>;
  41235. private _getDepthStencilBuffer;
  41236. /** @hidden */
  41237. _releaseFramebufferObjects(texture: InternalTexture): void;
  41238. /** @hidden */
  41239. _releaseTexture(texture: InternalTexture): void;
  41240. protected _deleteTexture(texture: Nullable<WebGLTexture>): void;
  41241. protected _setProgram(program: WebGLProgram): void;
  41242. protected _boundUniforms: {
  41243. [key: number]: WebGLUniformLocation;
  41244. };
  41245. /**
  41246. * Binds an effect to the webGL context
  41247. * @param effect defines the effect to bind
  41248. */
  41249. bindSamplers(effect: Effect): void;
  41250. private _activateCurrentTexture;
  41251. /** @hidden */
  41252. _bindTextureDirectly(target: number, texture: Nullable<InternalTexture>, forTextureDataUpdate?: boolean, force?: boolean): boolean;
  41253. /** @hidden */
  41254. _bindTexture(channel: number, texture: Nullable<InternalTexture>, name: string): void;
  41255. /**
  41256. * Unbind all textures from the webGL context
  41257. */
  41258. unbindAllTextures(): void;
  41259. /**
  41260. * Sets a texture to the according uniform.
  41261. * @param channel The texture channel
  41262. * @param uniform The uniform to set
  41263. * @param texture The texture to apply
  41264. * @param name The name of the uniform in the effect
  41265. */
  41266. setTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<ThinTexture>, name: string): void;
  41267. private _bindSamplerUniformToChannel;
  41268. private _getTextureWrapMode;
  41269. protected _setTexture(channel: number, texture: Nullable<ThinTexture>, isPartOfTextureArray?: boolean, depthStencilTexture?: boolean, name?: string): boolean;
  41270. /**
  41271. * Sets an array of texture to the webGL context
  41272. * @param channel defines the channel where the texture array must be set
  41273. * @param uniform defines the associated uniform location
  41274. * @param textures defines the array of textures to bind
  41275. * @param name name of the channel
  41276. */
  41277. setTextureArray(channel: number, uniform: Nullable<WebGLUniformLocation>, textures: ThinTexture[], name: string): void;
  41278. /** @hidden */
  41279. _setAnisotropicLevel(target: number, internalTexture: InternalTexture, anisotropicFilteringLevel: number): void;
  41280. private _setTextureParameterFloat;
  41281. private _setTextureParameterInteger;
  41282. /**
  41283. * Unbind all vertex attributes from the webGL context
  41284. */
  41285. unbindAllAttributes(): void;
  41286. /**
  41287. * 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
  41288. */
  41289. releaseEffects(): void;
  41290. /**
  41291. * Dispose and release all associated resources
  41292. */
  41293. dispose(): void;
  41294. /**
  41295. * Attach a new callback raised when context lost event is fired
  41296. * @param callback defines the callback to call
  41297. */
  41298. attachContextLostEvent(callback: ((event: WebGLContextEvent) => void)): void;
  41299. /**
  41300. * Attach a new callback raised when context restored event is fired
  41301. * @param callback defines the callback to call
  41302. */
  41303. attachContextRestoredEvent(callback: ((event: WebGLContextEvent) => void)): void;
  41304. /**
  41305. * Get the current error code of the webGL context
  41306. * @returns the error code
  41307. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  41308. */
  41309. getError(): number;
  41310. private _canRenderToFloatFramebuffer;
  41311. private _canRenderToHalfFloatFramebuffer;
  41312. private _canRenderToFramebuffer;
  41313. /** @hidden */
  41314. _getWebGLTextureType(type: number): number;
  41315. /** @hidden */
  41316. _getInternalFormat(format: number): number;
  41317. /** @hidden */
  41318. _getRGBABufferInternalSizedFormat(type: number, format?: number): number;
  41319. /** @hidden */
  41320. _getRGBAMultiSampleBufferFormat(type: number): number;
  41321. /** @hidden */
  41322. _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;
  41323. /**
  41324. * Loads a file from a url
  41325. * @param url url to load
  41326. * @param onSuccess callback called when the file successfully loads
  41327. * @param onProgress callback called while file is loading (if the server supports this mode)
  41328. * @param offlineProvider defines the offline provider for caching
  41329. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  41330. * @param onError callback called when the file fails to load
  41331. * @returns a file request object
  41332. * @hidden
  41333. */
  41334. 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;
  41335. /**
  41336. * Reads pixels from the current frame buffer. Please note that this function can be slow
  41337. * @param x defines the x coordinate of the rectangle where pixels must be read
  41338. * @param y defines the y coordinate of the rectangle where pixels must be read
  41339. * @param width defines the width of the rectangle where pixels must be read
  41340. * @param height defines the height of the rectangle where pixels must be read
  41341. * @param hasAlpha defines whether the output should have alpha or not (defaults to true)
  41342. * @param flushRenderer true to flush the renderer from the pending commands before reading the pixels
  41343. * @returns a ArrayBufferView promise (Uint8Array) containing RGBA colors
  41344. */
  41345. readPixels(x: number, y: number, width: number, height: number, hasAlpha?: boolean, flushRenderer?: boolean): Promise<ArrayBufferView>;
  41346. private static _IsSupported;
  41347. private static _HasMajorPerformanceCaveat;
  41348. /**
  41349. * Gets a boolean indicating if the engine can be instantiated (ie. if a webGL context can be found)
  41350. */
  41351. static get IsSupported(): boolean;
  41352. /**
  41353. * Gets a boolean indicating if the engine can be instantiated (ie. if a webGL context can be found)
  41354. * @returns true if the engine can be created
  41355. * @ignorenaming
  41356. */
  41357. static isSupported(): boolean;
  41358. /**
  41359. * Gets a boolean indicating if the engine can be instantiated on a performant device (ie. if a webGL context can be found and it does not use a slow implementation)
  41360. */
  41361. static get HasMajorPerformanceCaveat(): boolean;
  41362. /**
  41363. * Find the next highest power of two.
  41364. * @param x Number to start search from.
  41365. * @return Next highest power of two.
  41366. */
  41367. static CeilingPOT(x: number): number;
  41368. /**
  41369. * Find the next lowest power of two.
  41370. * @param x Number to start search from.
  41371. * @return Next lowest power of two.
  41372. */
  41373. static FloorPOT(x: number): number;
  41374. /**
  41375. * Find the nearest power of two.
  41376. * @param x Number to start search from.
  41377. * @return Next nearest power of two.
  41378. */
  41379. static NearestPOT(x: number): number;
  41380. /**
  41381. * Get the closest exponent of two
  41382. * @param value defines the value to approximate
  41383. * @param max defines the maximum value to return
  41384. * @param mode defines how to define the closest value
  41385. * @returns closest exponent of two of the given value
  41386. */
  41387. static GetExponentOfTwo(value: number, max: number, mode?: number): number;
  41388. /**
  41389. * Queue a new function into the requested animation frame pool (ie. this function will be executed byt the browser for the next frame)
  41390. * @param func - the function to be called
  41391. * @param requester - the object that will request the next frame. Falls back to window.
  41392. * @returns frame number
  41393. */
  41394. static QueueNewFrame(func: () => void, requester?: any): number;
  41395. /**
  41396. * Gets host document
  41397. * @returns the host document object
  41398. */
  41399. getHostDocument(): Nullable<Document>;
  41400. }
  41401. }
  41402. declare module BABYLON {
  41403. /**
  41404. * Defines the source of the internal texture
  41405. */
  41406. export enum InternalTextureSource {
  41407. /**
  41408. * The source of the texture data is unknown
  41409. */
  41410. Unknown = 0,
  41411. /**
  41412. * Texture data comes from an URL
  41413. */
  41414. Url = 1,
  41415. /**
  41416. * Texture data is only used for temporary storage
  41417. */
  41418. Temp = 2,
  41419. /**
  41420. * Texture data comes from raw data (ArrayBuffer)
  41421. */
  41422. Raw = 3,
  41423. /**
  41424. * Texture content is dynamic (video or dynamic texture)
  41425. */
  41426. Dynamic = 4,
  41427. /**
  41428. * Texture content is generated by rendering to it
  41429. */
  41430. RenderTarget = 5,
  41431. /**
  41432. * Texture content is part of a multi render target process
  41433. */
  41434. MultiRenderTarget = 6,
  41435. /**
  41436. * Texture data comes from a cube data file
  41437. */
  41438. Cube = 7,
  41439. /**
  41440. * Texture data comes from a raw cube data
  41441. */
  41442. CubeRaw = 8,
  41443. /**
  41444. * Texture data come from a prefiltered cube data file
  41445. */
  41446. CubePrefiltered = 9,
  41447. /**
  41448. * Texture content is raw 3D data
  41449. */
  41450. Raw3D = 10,
  41451. /**
  41452. * Texture content is raw 2D array data
  41453. */
  41454. Raw2DArray = 11,
  41455. /**
  41456. * Texture content is a depth texture
  41457. */
  41458. Depth = 12,
  41459. /**
  41460. * Texture data comes from a raw cube data encoded with RGBD
  41461. */
  41462. CubeRawRGBD = 13
  41463. }
  41464. /**
  41465. * Class used to store data associated with WebGL texture data for the engine
  41466. * This class should not be used directly
  41467. */
  41468. export class InternalTexture {
  41469. /** @hidden */
  41470. static _UpdateRGBDAsync: (internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number) => Promise<void>;
  41471. /**
  41472. * Defines if the texture is ready
  41473. */
  41474. isReady: boolean;
  41475. /**
  41476. * Defines if the texture is a cube texture
  41477. */
  41478. isCube: boolean;
  41479. /**
  41480. * Defines if the texture contains 3D data
  41481. */
  41482. is3D: boolean;
  41483. /**
  41484. * Defines if the texture contains 2D array data
  41485. */
  41486. is2DArray: boolean;
  41487. /**
  41488. * Defines if the texture contains multiview data
  41489. */
  41490. isMultiview: boolean;
  41491. /**
  41492. * Gets the URL used to load this texture
  41493. */
  41494. url: string;
  41495. /** @hidden */
  41496. _originalUrl: string;
  41497. /**
  41498. * Gets the sampling mode of the texture
  41499. */
  41500. samplingMode: number;
  41501. /**
  41502. * Gets a boolean indicating if the texture needs mipmaps generation
  41503. */
  41504. generateMipMaps: boolean;
  41505. /**
  41506. * Gets the number of samples used by the texture (WebGL2+ only)
  41507. */
  41508. samples: number;
  41509. /**
  41510. * Gets the type of the texture (int, float...)
  41511. */
  41512. type: number;
  41513. /**
  41514. * Gets the format of the texture (RGB, RGBA...)
  41515. */
  41516. format: number;
  41517. /**
  41518. * Observable called when the texture is loaded
  41519. */
  41520. onLoadedObservable: Observable<InternalTexture>;
  41521. /**
  41522. * Gets the width of the texture
  41523. */
  41524. width: number;
  41525. /**
  41526. * Gets the height of the texture
  41527. */
  41528. height: number;
  41529. /**
  41530. * Gets the depth of the texture
  41531. */
  41532. depth: number;
  41533. /**
  41534. * Gets the initial width of the texture (It could be rescaled if the current system does not support non power of two textures)
  41535. */
  41536. baseWidth: number;
  41537. /**
  41538. * Gets the initial height of the texture (It could be rescaled if the current system does not support non power of two textures)
  41539. */
  41540. baseHeight: number;
  41541. /**
  41542. * Gets the initial depth of the texture (It could be rescaled if the current system does not support non power of two textures)
  41543. */
  41544. baseDepth: number;
  41545. /**
  41546. * Gets a boolean indicating if the texture is inverted on Y axis
  41547. */
  41548. invertY: boolean;
  41549. /** @hidden */
  41550. _invertVScale: boolean;
  41551. /** @hidden */
  41552. _associatedChannel: number;
  41553. /** @hidden */
  41554. _source: InternalTextureSource;
  41555. /** @hidden */
  41556. _buffer: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob | ImageBitmap>;
  41557. /** @hidden */
  41558. _bufferView: Nullable<ArrayBufferView>;
  41559. /** @hidden */
  41560. _bufferViewArray: Nullable<ArrayBufferView[]>;
  41561. /** @hidden */
  41562. _bufferViewArrayArray: Nullable<ArrayBufferView[][]>;
  41563. /** @hidden */
  41564. _size: number;
  41565. /** @hidden */
  41566. _extension: string;
  41567. /** @hidden */
  41568. _files: Nullable<string[]>;
  41569. /** @hidden */
  41570. _workingCanvas: Nullable<HTMLCanvasElement | OffscreenCanvas>;
  41571. /** @hidden */
  41572. _workingContext: Nullable<CanvasRenderingContext2D | OffscreenCanvasRenderingContext2D>;
  41573. /** @hidden */
  41574. _framebuffer: Nullable<WebGLFramebuffer>;
  41575. /** @hidden */
  41576. _depthStencilBuffer: Nullable<WebGLRenderbuffer>;
  41577. /** @hidden */
  41578. _MSAAFramebuffer: Nullable<WebGLFramebuffer>;
  41579. /** @hidden */
  41580. _MSAARenderBuffer: Nullable<WebGLRenderbuffer>;
  41581. /** @hidden */
  41582. _attachments: Nullable<number[]>;
  41583. /** @hidden */
  41584. _textureArray: Nullable<InternalTexture[]>;
  41585. /** @hidden */
  41586. _cachedCoordinatesMode: Nullable<number>;
  41587. /** @hidden */
  41588. _cachedWrapU: Nullable<number>;
  41589. /** @hidden */
  41590. _cachedWrapV: Nullable<number>;
  41591. /** @hidden */
  41592. _cachedWrapR: Nullable<number>;
  41593. /** @hidden */
  41594. _cachedAnisotropicFilteringLevel: Nullable<number>;
  41595. /** @hidden */
  41596. _isDisabled: boolean;
  41597. /** @hidden */
  41598. _compression: Nullable<string>;
  41599. /** @hidden */
  41600. _generateStencilBuffer: boolean;
  41601. /** @hidden */
  41602. _generateDepthBuffer: boolean;
  41603. /** @hidden */
  41604. _comparisonFunction: number;
  41605. /** @hidden */
  41606. _sphericalPolynomial: Nullable<SphericalPolynomial>;
  41607. /** @hidden */
  41608. _sphericalPolynomialPromise: Nullable<Promise<SphericalPolynomial>>;
  41609. /** @hidden */
  41610. _sphericalPolynomialComputed: boolean;
  41611. /** @hidden */
  41612. _lodGenerationScale: number;
  41613. /** @hidden */
  41614. _lodGenerationOffset: number;
  41615. /** @hidden */
  41616. _depthStencilTexture: Nullable<InternalTexture>;
  41617. /** @hidden */
  41618. _colorTextureArray: Nullable<WebGLTexture>;
  41619. /** @hidden */
  41620. _depthStencilTextureArray: Nullable<WebGLTexture>;
  41621. /** @hidden */
  41622. _lodTextureHigh: Nullable<BaseTexture>;
  41623. /** @hidden */
  41624. _lodTextureMid: Nullable<BaseTexture>;
  41625. /** @hidden */
  41626. _lodTextureLow: Nullable<BaseTexture>;
  41627. /** @hidden */
  41628. _isRGBD: boolean;
  41629. /** @hidden */
  41630. _linearSpecularLOD: boolean;
  41631. /** @hidden */
  41632. _irradianceTexture: Nullable<BaseTexture>;
  41633. /** @hidden */
  41634. _hardwareTexture: Nullable<HardwareTextureWrapper>;
  41635. /** @hidden */
  41636. _references: number;
  41637. /** @hidden */
  41638. _gammaSpace: Nullable<boolean>;
  41639. private _engine;
  41640. private _uniqueId;
  41641. private static _Counter;
  41642. /** Gets the unique id of the internal texture */
  41643. get uniqueId(): number;
  41644. /**
  41645. * Gets the Engine the texture belongs to.
  41646. * @returns The babylon engine
  41647. */
  41648. getEngine(): ThinEngine;
  41649. /**
  41650. * Gets the data source type of the texture
  41651. */
  41652. get source(): InternalTextureSource;
  41653. /**
  41654. * Creates a new InternalTexture
  41655. * @param engine defines the engine to use
  41656. * @param source defines the type of data that will be used
  41657. * @param delayAllocation if the texture allocation should be delayed (default: false)
  41658. */
  41659. constructor(engine: ThinEngine, source: InternalTextureSource, delayAllocation?: boolean);
  41660. /**
  41661. * Increments the number of references (ie. the number of Texture that point to it)
  41662. */
  41663. incrementReferences(): void;
  41664. /**
  41665. * Change the size of the texture (not the size of the content)
  41666. * @param width defines the new width
  41667. * @param height defines the new height
  41668. * @param depth defines the new depth (1 by default)
  41669. */
  41670. updateSize(width: int, height: int, depth?: int): void;
  41671. /** @hidden */
  41672. _rebuild(): void;
  41673. /** @hidden */
  41674. _swapAndDie(target: InternalTexture): void;
  41675. /**
  41676. * Dispose the current allocated resources
  41677. */
  41678. dispose(): void;
  41679. }
  41680. }
  41681. declare module BABYLON {
  41682. /**
  41683. * Interface used to present a loading screen while loading a scene
  41684. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  41685. */
  41686. export interface ILoadingScreen {
  41687. /**
  41688. * Function called to display the loading screen
  41689. */
  41690. displayLoadingUI: () => void;
  41691. /**
  41692. * Function called to hide the loading screen
  41693. */
  41694. hideLoadingUI: () => void;
  41695. /**
  41696. * Gets or sets the color to use for the background
  41697. */
  41698. loadingUIBackgroundColor: string;
  41699. /**
  41700. * Gets or sets the text to display while loading
  41701. */
  41702. loadingUIText: string;
  41703. }
  41704. /**
  41705. * Class used for the default loading screen
  41706. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  41707. */
  41708. export class DefaultLoadingScreen implements ILoadingScreen {
  41709. private _renderingCanvas;
  41710. private _loadingText;
  41711. private _loadingDivBackgroundColor;
  41712. private _loadingDiv;
  41713. private _loadingTextDiv;
  41714. /** Gets or sets the logo url to use for the default loading screen */
  41715. static DefaultLogoUrl: string;
  41716. /** Gets or sets the spinner url to use for the default loading screen */
  41717. static DefaultSpinnerUrl: string;
  41718. /**
  41719. * Creates a new default loading screen
  41720. * @param _renderingCanvas defines the canvas used to render the scene
  41721. * @param _loadingText defines the default text to display
  41722. * @param _loadingDivBackgroundColor defines the default background color
  41723. */
  41724. constructor(_renderingCanvas: HTMLCanvasElement, _loadingText?: string, _loadingDivBackgroundColor?: string);
  41725. /**
  41726. * Function called to display the loading screen
  41727. */
  41728. displayLoadingUI(): void;
  41729. /**
  41730. * Function called to hide the loading screen
  41731. */
  41732. hideLoadingUI(): void;
  41733. /**
  41734. * Gets or sets the text to display while loading
  41735. */
  41736. set loadingUIText(text: string);
  41737. get loadingUIText(): string;
  41738. /**
  41739. * Gets or sets the color to use for the background
  41740. */
  41741. get loadingUIBackgroundColor(): string;
  41742. set loadingUIBackgroundColor(color: string);
  41743. private _resizeLoadingUI;
  41744. }
  41745. }
  41746. declare module BABYLON {
  41747. /**
  41748. * Interface for any object that can request an animation frame
  41749. */
  41750. export interface ICustomAnimationFrameRequester {
  41751. /**
  41752. * This function will be called when the render loop is ready. If this is not populated, the engine's renderloop function will be called
  41753. */
  41754. renderFunction?: Function;
  41755. /**
  41756. * Called to request the next frame to render to
  41757. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame
  41758. */
  41759. requestAnimationFrame: Function;
  41760. /**
  41761. * You can pass this value to cancelAnimationFrame() to cancel the refresh callback request
  41762. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame#Return_value
  41763. */
  41764. requestID?: number;
  41765. }
  41766. }
  41767. declare module BABYLON {
  41768. /**
  41769. * Performance monitor tracks rolling average frame-time and frame-time variance over a user defined sliding-window
  41770. */
  41771. export class PerformanceMonitor {
  41772. private _enabled;
  41773. private _rollingFrameTime;
  41774. private _lastFrameTimeMs;
  41775. /**
  41776. * constructor
  41777. * @param frameSampleSize The number of samples required to saturate the sliding window
  41778. */
  41779. constructor(frameSampleSize?: number);
  41780. /**
  41781. * Samples current frame
  41782. * @param timeMs A timestamp in milliseconds of the current frame to compare with other frames
  41783. */
  41784. sampleFrame(timeMs?: number): void;
  41785. /**
  41786. * Returns the average frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  41787. */
  41788. get averageFrameTime(): number;
  41789. /**
  41790. * Returns the variance frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  41791. */
  41792. get averageFrameTimeVariance(): number;
  41793. /**
  41794. * Returns the frame time of the most recent frame
  41795. */
  41796. get instantaneousFrameTime(): number;
  41797. /**
  41798. * Returns the average framerate in frames per second over the sliding window (or the subset of frames sampled so far)
  41799. */
  41800. get averageFPS(): number;
  41801. /**
  41802. * Returns the average framerate in frames per second using the most recent frame time
  41803. */
  41804. get instantaneousFPS(): number;
  41805. /**
  41806. * Returns true if enough samples have been taken to completely fill the sliding window
  41807. */
  41808. get isSaturated(): boolean;
  41809. /**
  41810. * Enables contributions to the sliding window sample set
  41811. */
  41812. enable(): void;
  41813. /**
  41814. * Disables contributions to the sliding window sample set
  41815. * Samples will not be interpolated over the disabled period
  41816. */
  41817. disable(): void;
  41818. /**
  41819. * Returns true if sampling is enabled
  41820. */
  41821. get isEnabled(): boolean;
  41822. /**
  41823. * Resets performance monitor
  41824. */
  41825. reset(): void;
  41826. }
  41827. /**
  41828. * RollingAverage
  41829. *
  41830. * Utility to efficiently compute the rolling average and variance over a sliding window of samples
  41831. */
  41832. export class RollingAverage {
  41833. /**
  41834. * Current average
  41835. */
  41836. average: number;
  41837. /**
  41838. * Current variance
  41839. */
  41840. variance: number;
  41841. protected _samples: Array<number>;
  41842. protected _sampleCount: number;
  41843. protected _pos: number;
  41844. protected _m2: number;
  41845. /**
  41846. * constructor
  41847. * @param length The number of samples required to saturate the sliding window
  41848. */
  41849. constructor(length: number);
  41850. /**
  41851. * Adds a sample to the sample set
  41852. * @param v The sample value
  41853. */
  41854. add(v: number): void;
  41855. /**
  41856. * Returns previously added values or null if outside of history or outside the sliding window domain
  41857. * @param i Index in history. For example, pass 0 for the most recent value and 1 for the value before that
  41858. * @return Value previously recorded with add() or null if outside of range
  41859. */
  41860. history(i: number): number;
  41861. /**
  41862. * Returns true if enough samples have been taken to completely fill the sliding window
  41863. * @return true if sample-set saturated
  41864. */
  41865. isSaturated(): boolean;
  41866. /**
  41867. * Resets the rolling average (equivalent to 0 samples taken so far)
  41868. */
  41869. reset(): void;
  41870. /**
  41871. * Wraps a value around the sample range boundaries
  41872. * @param i Position in sample range, for example if the sample length is 5, and i is -3, then 2 will be returned.
  41873. * @return Wrapped position in sample range
  41874. */
  41875. protected _wrapPosition(i: number): number;
  41876. }
  41877. }
  41878. declare module BABYLON {
  41879. /**
  41880. * This class is used to track a performance counter which is number based.
  41881. * The user has access to many properties which give statistics of different nature.
  41882. *
  41883. * The implementer can track two kinds of Performance Counter: time and count.
  41884. * 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.
  41885. * 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.
  41886. */
  41887. export class PerfCounter {
  41888. /**
  41889. * Gets or sets a global boolean to turn on and off all the counters
  41890. */
  41891. static Enabled: boolean;
  41892. /**
  41893. * Returns the smallest value ever
  41894. */
  41895. get min(): number;
  41896. /**
  41897. * Returns the biggest value ever
  41898. */
  41899. get max(): number;
  41900. /**
  41901. * Returns the average value since the performance counter is running
  41902. */
  41903. get average(): number;
  41904. /**
  41905. * Returns the average value of the last second the counter was monitored
  41906. */
  41907. get lastSecAverage(): number;
  41908. /**
  41909. * Returns the current value
  41910. */
  41911. get current(): number;
  41912. /**
  41913. * Gets the accumulated total
  41914. */
  41915. get total(): number;
  41916. /**
  41917. * Gets the total value count
  41918. */
  41919. get count(): number;
  41920. /**
  41921. * Creates a new counter
  41922. */
  41923. constructor();
  41924. /**
  41925. * Call this method to start monitoring a new frame.
  41926. * 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.
  41927. */
  41928. fetchNewFrame(): void;
  41929. /**
  41930. * Call this method to monitor a count of something (e.g. mesh drawn in viewport count)
  41931. * @param newCount the count value to add to the monitored count
  41932. * @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.
  41933. */
  41934. addCount(newCount: number, fetchResult: boolean): void;
  41935. /**
  41936. * Start monitoring this performance counter
  41937. */
  41938. beginMonitoring(): void;
  41939. /**
  41940. * Compute the time lapsed since the previous beginMonitoring() call.
  41941. * @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
  41942. */
  41943. endMonitoring(newFrame?: boolean): void;
  41944. private _fetchResult;
  41945. private _startMonitoringTime;
  41946. private _min;
  41947. private _max;
  41948. private _average;
  41949. private _current;
  41950. private _totalValueCount;
  41951. private _totalAccumulated;
  41952. private _lastSecAverage;
  41953. private _lastSecAccumulated;
  41954. private _lastSecTime;
  41955. private _lastSecValueCount;
  41956. }
  41957. }
  41958. declare module BABYLON {
  41959. interface ThinEngine {
  41960. /** @hidden */
  41961. _readTexturePixels(texture: InternalTexture, width: number, height: number, faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>, flushRenderer?: boolean): Promise<ArrayBufferView>;
  41962. /** @hidden */
  41963. _readTexturePixelsSync(texture: InternalTexture, width: number, height: number, faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>, flushRenderer?: boolean): ArrayBufferView;
  41964. }
  41965. }
  41966. declare module BABYLON {
  41967. /**
  41968. * Class used to work with sound analyzer using fast fourier transform (FFT)
  41969. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  41970. */
  41971. export class Analyser {
  41972. /**
  41973. * Gets or sets the smoothing
  41974. * @ignorenaming
  41975. */
  41976. SMOOTHING: number;
  41977. /**
  41978. * Gets or sets the FFT table size
  41979. * @ignorenaming
  41980. */
  41981. FFT_SIZE: number;
  41982. /**
  41983. * Gets or sets the bar graph amplitude
  41984. * @ignorenaming
  41985. */
  41986. BARGRAPHAMPLITUDE: number;
  41987. /**
  41988. * Gets or sets the position of the debug canvas
  41989. * @ignorenaming
  41990. */
  41991. DEBUGCANVASPOS: {
  41992. x: number;
  41993. y: number;
  41994. };
  41995. /**
  41996. * Gets or sets the debug canvas size
  41997. * @ignorenaming
  41998. */
  41999. DEBUGCANVASSIZE: {
  42000. width: number;
  42001. height: number;
  42002. };
  42003. private _byteFreqs;
  42004. private _byteTime;
  42005. private _floatFreqs;
  42006. private _webAudioAnalyser;
  42007. private _debugCanvas;
  42008. private _debugCanvasContext;
  42009. private _scene;
  42010. private _registerFunc;
  42011. private _audioEngine;
  42012. /**
  42013. * Creates a new analyser
  42014. * @param scene defines hosting scene
  42015. */
  42016. constructor(scene: Scene);
  42017. /**
  42018. * Get the number of data values you will have to play with for the visualization
  42019. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/frequencyBinCount
  42020. * @returns a number
  42021. */
  42022. getFrequencyBinCount(): number;
  42023. /**
  42024. * Gets the current frequency data as a byte array
  42025. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  42026. * @returns a Uint8Array
  42027. */
  42028. getByteFrequencyData(): Uint8Array;
  42029. /**
  42030. * Gets the current waveform as a byte array
  42031. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteTimeDomainData
  42032. * @returns a Uint8Array
  42033. */
  42034. getByteTimeDomainData(): Uint8Array;
  42035. /**
  42036. * Gets the current frequency data as a float array
  42037. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  42038. * @returns a Float32Array
  42039. */
  42040. getFloatFrequencyData(): Float32Array;
  42041. /**
  42042. * Renders the debug canvas
  42043. */
  42044. drawDebugCanvas(): void;
  42045. /**
  42046. * Stops rendering the debug canvas and removes it
  42047. */
  42048. stopDebugCanvas(): void;
  42049. /**
  42050. * Connects two audio nodes
  42051. * @param inputAudioNode defines first node to connect
  42052. * @param outputAudioNode defines second node to connect
  42053. */
  42054. connectAudioNodes(inputAudioNode: AudioNode, outputAudioNode: AudioNode): void;
  42055. /**
  42056. * Releases all associated resources
  42057. */
  42058. dispose(): void;
  42059. }
  42060. }
  42061. declare module BABYLON {
  42062. /**
  42063. * This represents an audio engine and it is responsible
  42064. * to play, synchronize and analyse sounds throughout the application.
  42065. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  42066. */
  42067. export interface IAudioEngine extends IDisposable {
  42068. /**
  42069. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  42070. */
  42071. readonly canUseWebAudio: boolean;
  42072. /**
  42073. * Gets the current AudioContext if available.
  42074. */
  42075. readonly audioContext: Nullable<AudioContext>;
  42076. /**
  42077. * The master gain node defines the global audio volume of your audio engine.
  42078. */
  42079. readonly masterGain: GainNode;
  42080. /**
  42081. * Gets whether or not mp3 are supported by your browser.
  42082. */
  42083. readonly isMP3supported: boolean;
  42084. /**
  42085. * Gets whether or not ogg are supported by your browser.
  42086. */
  42087. readonly isOGGsupported: boolean;
  42088. /**
  42089. * Defines if Babylon should emit a warning if WebAudio is not supported.
  42090. * @ignoreNaming
  42091. */
  42092. WarnedWebAudioUnsupported: boolean;
  42093. /**
  42094. * Defines if the audio engine relies on a custom unlocked button.
  42095. * In this case, the embedded button will not be displayed.
  42096. */
  42097. useCustomUnlockedButton: boolean;
  42098. /**
  42099. * Gets whether or not the audio engine is unlocked (require first a user gesture on some browser).
  42100. */
  42101. readonly unlocked: boolean;
  42102. /**
  42103. * Event raised when audio has been unlocked on the browser.
  42104. */
  42105. onAudioUnlockedObservable: Observable<IAudioEngine>;
  42106. /**
  42107. * Event raised when audio has been locked on the browser.
  42108. */
  42109. onAudioLockedObservable: Observable<IAudioEngine>;
  42110. /**
  42111. * Flags the audio engine in Locked state.
  42112. * This happens due to new browser policies preventing audio to autoplay.
  42113. */
  42114. lock(): void;
  42115. /**
  42116. * Unlocks the audio engine once a user action has been done on the dom.
  42117. * This is helpful to resume play once browser policies have been satisfied.
  42118. */
  42119. unlock(): void;
  42120. /**
  42121. * Gets the global volume sets on the master gain.
  42122. * @returns the global volume if set or -1 otherwise
  42123. */
  42124. getGlobalVolume(): number;
  42125. /**
  42126. * Sets the global volume of your experience (sets on the master gain).
  42127. * @param newVolume Defines the new global volume of the application
  42128. */
  42129. setGlobalVolume(newVolume: number): void;
  42130. /**
  42131. * Connect the audio engine to an audio analyser allowing some amazing
  42132. * synchronization between the sounds/music and your visualization (VuMeter for instance).
  42133. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  42134. * @param analyser The analyser to connect to the engine
  42135. */
  42136. connectToAnalyser(analyser: Analyser): void;
  42137. }
  42138. }
  42139. declare module BABYLON {
  42140. /**
  42141. * Defines the interface used by display changed events
  42142. */
  42143. export interface IDisplayChangedEventArgs {
  42144. /** Gets the vrDisplay object (if any) */
  42145. vrDisplay: Nullable<any>;
  42146. /** Gets a boolean indicating if webVR is supported */
  42147. vrSupported: boolean;
  42148. }
  42149. /**
  42150. * Defines the interface used by objects containing a viewport (like a camera)
  42151. */
  42152. interface IViewportOwnerLike {
  42153. /**
  42154. * Gets or sets the viewport
  42155. */
  42156. viewport: IViewportLike;
  42157. }
  42158. /**
  42159. * The engine class is responsible for interfacing with all lower-level APIs such as WebGL and Audio
  42160. */
  42161. export class Engine extends ThinEngine {
  42162. /** Defines that alpha blending is disabled */
  42163. static readonly ALPHA_DISABLE: number;
  42164. /** Defines that alpha blending to SRC ALPHA * SRC + DEST */
  42165. static readonly ALPHA_ADD: number;
  42166. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  42167. static readonly ALPHA_COMBINE: number;
  42168. /** Defines that alpha blending to DEST - SRC * DEST */
  42169. static readonly ALPHA_SUBTRACT: number;
  42170. /** Defines that alpha blending to SRC * DEST */
  42171. static readonly ALPHA_MULTIPLY: number;
  42172. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC) * DEST */
  42173. static readonly ALPHA_MAXIMIZED: number;
  42174. /** Defines that alpha blending to SRC + DEST */
  42175. static readonly ALPHA_ONEONE: number;
  42176. /** Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST */
  42177. static readonly ALPHA_PREMULTIPLIED: number;
  42178. /**
  42179. * Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST
  42180. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  42181. */
  42182. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  42183. /** Defines that alpha blending to CST * SRC + (1 - CST) * DEST */
  42184. static readonly ALPHA_INTERPOLATE: number;
  42185. /**
  42186. * Defines that alpha blending to SRC + (1 - SRC) * DEST
  42187. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  42188. */
  42189. static readonly ALPHA_SCREENMODE: number;
  42190. /** Defines that the resource is not delayed*/
  42191. static readonly DELAYLOADSTATE_NONE: number;
  42192. /** Defines that the resource was successfully delay loaded */
  42193. static readonly DELAYLOADSTATE_LOADED: number;
  42194. /** Defines that the resource is currently delay loading */
  42195. static readonly DELAYLOADSTATE_LOADING: number;
  42196. /** Defines that the resource is delayed and has not started loading */
  42197. static readonly DELAYLOADSTATE_NOTLOADED: number;
  42198. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  42199. static readonly NEVER: number;
  42200. /** 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 */
  42201. static readonly ALWAYS: number;
  42202. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  42203. static readonly LESS: number;
  42204. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  42205. static readonly EQUAL: number;
  42206. /** 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 */
  42207. static readonly LEQUAL: number;
  42208. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  42209. static readonly GREATER: number;
  42210. /** 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 */
  42211. static readonly GEQUAL: number;
  42212. /** 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 */
  42213. static readonly NOTEQUAL: number;
  42214. /** Passed to stencilOperation to specify that stencil value must be kept */
  42215. static readonly KEEP: number;
  42216. /** Passed to stencilOperation to specify that stencil value must be replaced */
  42217. static readonly REPLACE: number;
  42218. /** Passed to stencilOperation to specify that stencil value must be incremented */
  42219. static readonly INCR: number;
  42220. /** Passed to stencilOperation to specify that stencil value must be decremented */
  42221. static readonly DECR: number;
  42222. /** Passed to stencilOperation to specify that stencil value must be inverted */
  42223. static readonly INVERT: number;
  42224. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  42225. static readonly INCR_WRAP: number;
  42226. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  42227. static readonly DECR_WRAP: number;
  42228. /** Texture is not repeating outside of 0..1 UVs */
  42229. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  42230. /** Texture is repeating outside of 0..1 UVs */
  42231. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  42232. /** Texture is repeating and mirrored */
  42233. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  42234. /** ALPHA */
  42235. static readonly TEXTUREFORMAT_ALPHA: number;
  42236. /** LUMINANCE */
  42237. static readonly TEXTUREFORMAT_LUMINANCE: number;
  42238. /** LUMINANCE_ALPHA */
  42239. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  42240. /** RGB */
  42241. static readonly TEXTUREFORMAT_RGB: number;
  42242. /** RGBA */
  42243. static readonly TEXTUREFORMAT_RGBA: number;
  42244. /** RED */
  42245. static readonly TEXTUREFORMAT_RED: number;
  42246. /** RED (2nd reference) */
  42247. static readonly TEXTUREFORMAT_R: number;
  42248. /** RG */
  42249. static readonly TEXTUREFORMAT_RG: number;
  42250. /** RED_INTEGER */
  42251. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  42252. /** RED_INTEGER (2nd reference) */
  42253. static readonly TEXTUREFORMAT_R_INTEGER: number;
  42254. /** RG_INTEGER */
  42255. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  42256. /** RGB_INTEGER */
  42257. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  42258. /** RGBA_INTEGER */
  42259. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  42260. /** UNSIGNED_BYTE */
  42261. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  42262. /** UNSIGNED_BYTE (2nd reference) */
  42263. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  42264. /** FLOAT */
  42265. static readonly TEXTURETYPE_FLOAT: number;
  42266. /** HALF_FLOAT */
  42267. static readonly TEXTURETYPE_HALF_FLOAT: number;
  42268. /** BYTE */
  42269. static readonly TEXTURETYPE_BYTE: number;
  42270. /** SHORT */
  42271. static readonly TEXTURETYPE_SHORT: number;
  42272. /** UNSIGNED_SHORT */
  42273. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  42274. /** INT */
  42275. static readonly TEXTURETYPE_INT: number;
  42276. /** UNSIGNED_INT */
  42277. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  42278. /** UNSIGNED_SHORT_4_4_4_4 */
  42279. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  42280. /** UNSIGNED_SHORT_5_5_5_1 */
  42281. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  42282. /** UNSIGNED_SHORT_5_6_5 */
  42283. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  42284. /** UNSIGNED_INT_2_10_10_10_REV */
  42285. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  42286. /** UNSIGNED_INT_24_8 */
  42287. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  42288. /** UNSIGNED_INT_10F_11F_11F_REV */
  42289. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  42290. /** UNSIGNED_INT_5_9_9_9_REV */
  42291. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  42292. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  42293. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  42294. /** nearest is mag = nearest and min = nearest and mip = none */
  42295. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  42296. /** Bilinear is mag = linear and min = linear and mip = nearest */
  42297. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  42298. /** Trilinear is mag = linear and min = linear and mip = linear */
  42299. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  42300. /** nearest is mag = nearest and min = nearest and mip = linear */
  42301. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  42302. /** Bilinear is mag = linear and min = linear and mip = nearest */
  42303. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  42304. /** Trilinear is mag = linear and min = linear and mip = linear */
  42305. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  42306. /** mag = nearest and min = nearest and mip = nearest */
  42307. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  42308. /** mag = nearest and min = linear and mip = nearest */
  42309. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  42310. /** mag = nearest and min = linear and mip = linear */
  42311. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  42312. /** mag = nearest and min = linear and mip = none */
  42313. static readonly TEXTURE_NEAREST_LINEAR: number;
  42314. /** mag = nearest and min = nearest and mip = none */
  42315. static readonly TEXTURE_NEAREST_NEAREST: number;
  42316. /** mag = linear and min = nearest and mip = nearest */
  42317. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  42318. /** mag = linear and min = nearest and mip = linear */
  42319. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  42320. /** mag = linear and min = linear and mip = none */
  42321. static readonly TEXTURE_LINEAR_LINEAR: number;
  42322. /** mag = linear and min = nearest and mip = none */
  42323. static readonly TEXTURE_LINEAR_NEAREST: number;
  42324. /** Explicit coordinates mode */
  42325. static readonly TEXTURE_EXPLICIT_MODE: number;
  42326. /** Spherical coordinates mode */
  42327. static readonly TEXTURE_SPHERICAL_MODE: number;
  42328. /** Planar coordinates mode */
  42329. static readonly TEXTURE_PLANAR_MODE: number;
  42330. /** Cubic coordinates mode */
  42331. static readonly TEXTURE_CUBIC_MODE: number;
  42332. /** Projection coordinates mode */
  42333. static readonly TEXTURE_PROJECTION_MODE: number;
  42334. /** Skybox coordinates mode */
  42335. static readonly TEXTURE_SKYBOX_MODE: number;
  42336. /** Inverse Cubic coordinates mode */
  42337. static readonly TEXTURE_INVCUBIC_MODE: number;
  42338. /** Equirectangular coordinates mode */
  42339. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  42340. /** Equirectangular Fixed coordinates mode */
  42341. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  42342. /** Equirectangular Fixed Mirrored coordinates mode */
  42343. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  42344. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  42345. static readonly SCALEMODE_FLOOR: number;
  42346. /** Defines that texture rescaling will look for the nearest power of 2 size */
  42347. static readonly SCALEMODE_NEAREST: number;
  42348. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  42349. static readonly SCALEMODE_CEILING: number;
  42350. /**
  42351. * Returns the current npm package of the sdk
  42352. */
  42353. static get NpmPackage(): string;
  42354. /**
  42355. * Returns the current version of the framework
  42356. */
  42357. static get Version(): string;
  42358. /** Gets the list of created engines */
  42359. static get Instances(): Engine[];
  42360. /**
  42361. * Gets the latest created engine
  42362. */
  42363. static get LastCreatedEngine(): Nullable<Engine>;
  42364. /**
  42365. * Gets the latest created scene
  42366. */
  42367. static get LastCreatedScene(): Nullable<Scene>;
  42368. /**
  42369. * Will flag all materials in all scenes in all engines as dirty to trigger new shader compilation
  42370. * @param flag defines which part of the materials must be marked as dirty
  42371. * @param predicate defines a predicate used to filter which materials should be affected
  42372. */
  42373. static MarkAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  42374. /**
  42375. * Method called to create the default loading screen.
  42376. * This can be overridden in your own app.
  42377. * @param canvas The rendering canvas element
  42378. * @returns The loading screen
  42379. */
  42380. static DefaultLoadingScreenFactory(canvas: HTMLCanvasElement): ILoadingScreen;
  42381. /**
  42382. * Method called to create the default rescale post process on each engine.
  42383. */
  42384. static _RescalePostProcessFactory: Nullable<(engine: Engine) => PostProcess>;
  42385. /**
  42386. * Gets or sets a boolean to enable/disable IndexedDB support and avoid XHR on .manifest
  42387. **/
  42388. enableOfflineSupport: boolean;
  42389. /**
  42390. * 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)
  42391. **/
  42392. disableManifestCheck: boolean;
  42393. /**
  42394. * Gets the list of created scenes
  42395. */
  42396. scenes: Scene[];
  42397. /**
  42398. * Event raised when a new scene is created
  42399. */
  42400. onNewSceneAddedObservable: Observable<Scene>;
  42401. /**
  42402. * Gets the list of created postprocesses
  42403. */
  42404. postProcesses: PostProcess[];
  42405. /**
  42406. * Gets a boolean indicating if the pointer is currently locked
  42407. */
  42408. isPointerLock: boolean;
  42409. /**
  42410. * Observable event triggered each time the rendering canvas is resized
  42411. */
  42412. onResizeObservable: Observable<Engine>;
  42413. /**
  42414. * Observable event triggered each time the canvas loses focus
  42415. */
  42416. onCanvasBlurObservable: Observable<Engine>;
  42417. /**
  42418. * Observable event triggered each time the canvas gains focus
  42419. */
  42420. onCanvasFocusObservable: Observable<Engine>;
  42421. /**
  42422. * Observable event triggered each time the canvas receives pointerout event
  42423. */
  42424. onCanvasPointerOutObservable: Observable<PointerEvent>;
  42425. /**
  42426. * Observable raised when the engine begins a new frame
  42427. */
  42428. onBeginFrameObservable: Observable<Engine>;
  42429. /**
  42430. * If set, will be used to request the next animation frame for the render loop
  42431. */
  42432. customAnimationFrameRequester: Nullable<ICustomAnimationFrameRequester>;
  42433. /**
  42434. * Observable raised when the engine ends the current frame
  42435. */
  42436. onEndFrameObservable: Observable<Engine>;
  42437. /**
  42438. * Observable raised when the engine is about to compile a shader
  42439. */
  42440. onBeforeShaderCompilationObservable: Observable<Engine>;
  42441. /**
  42442. * Observable raised when the engine has just compiled a shader
  42443. */
  42444. onAfterShaderCompilationObservable: Observable<Engine>;
  42445. /**
  42446. * Gets the audio engine
  42447. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  42448. * @ignorenaming
  42449. */
  42450. static audioEngine: IAudioEngine;
  42451. /**
  42452. * Default AudioEngine factory responsible of creating the Audio Engine.
  42453. * By default, this will create a BabylonJS Audio Engine if the workload has been embedded.
  42454. */
  42455. static AudioEngineFactory: (hostElement: Nullable<HTMLElement>) => IAudioEngine;
  42456. /**
  42457. * Default offline support factory responsible of creating a tool used to store data locally.
  42458. * By default, this will create a Database object if the workload has been embedded.
  42459. */
  42460. static OfflineProviderFactory: (urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck: boolean) => IOfflineProvider;
  42461. private _loadingScreen;
  42462. private _pointerLockRequested;
  42463. private _rescalePostProcess;
  42464. protected _deterministicLockstep: boolean;
  42465. protected _lockstepMaxSteps: number;
  42466. protected _timeStep: number;
  42467. protected get _supportsHardwareTextureRescaling(): boolean;
  42468. private _fps;
  42469. private _deltaTime;
  42470. /** @hidden */
  42471. _drawCalls: PerfCounter;
  42472. /** 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 */
  42473. canvasTabIndex: number;
  42474. /**
  42475. * Turn this value on if you want to pause FPS computation when in background
  42476. */
  42477. disablePerformanceMonitorInBackground: boolean;
  42478. private _performanceMonitor;
  42479. /**
  42480. * Gets the performance monitor attached to this engine
  42481. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  42482. */
  42483. get performanceMonitor(): PerformanceMonitor;
  42484. private _onFocus;
  42485. private _onBlur;
  42486. private _onCanvasPointerOut;
  42487. private _onCanvasBlur;
  42488. private _onCanvasFocus;
  42489. private _onFullscreenChange;
  42490. private _onPointerLockChange;
  42491. /**
  42492. * Gets the HTML element used to attach event listeners
  42493. * @returns a HTML element
  42494. */
  42495. getInputElement(): Nullable<HTMLElement>;
  42496. /**
  42497. * Creates a new engine
  42498. * @param canvasOrContext defines the canvas or WebGL context to use for rendering. If you provide a WebGL context, Babylon.js will not hook events on the canvas (like pointers, keyboards, etc...) so no event observables will be available. This is mostly used when Babylon.js is used as a plugin on a system which already used the WebGL context
  42499. * @param antialias defines enable antialiasing (default: false)
  42500. * @param options defines further options to be sent to the getContext() function
  42501. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  42502. */
  42503. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  42504. /**
  42505. * Shared initialization across engines types.
  42506. * @param canvas The canvas associated with this instance of the engine.
  42507. * @param doNotHandleTouchAction Defines that engine should ignore modifying touch action attribute and style
  42508. * @param audioEngine Defines if an audio engine should be created by default
  42509. */
  42510. protected _sharedInit(canvas: HTMLCanvasElement, doNotHandleTouchAction: boolean, audioEngine: boolean): void;
  42511. /**
  42512. * Gets current aspect ratio
  42513. * @param viewportOwner defines the camera to use to get the aspect ratio
  42514. * @param useScreen defines if screen size must be used (or the current render target if any)
  42515. * @returns a number defining the aspect ratio
  42516. */
  42517. getAspectRatio(viewportOwner: IViewportOwnerLike, useScreen?: boolean): number;
  42518. /**
  42519. * Gets current screen aspect ratio
  42520. * @returns a number defining the aspect ratio
  42521. */
  42522. getScreenAspectRatio(): number;
  42523. /**
  42524. * Gets the client rect of the HTML canvas attached with the current webGL context
  42525. * @returns a client rectangle
  42526. */
  42527. getRenderingCanvasClientRect(): Nullable<ClientRect>;
  42528. /**
  42529. * Gets the client rect of the HTML element used for events
  42530. * @returns a client rectangle
  42531. */
  42532. getInputElementClientRect(): Nullable<ClientRect>;
  42533. /**
  42534. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  42535. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  42536. * @returns true if engine is in deterministic lock step mode
  42537. */
  42538. isDeterministicLockStep(): boolean;
  42539. /**
  42540. * Gets the max steps when engine is running in deterministic lock step
  42541. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  42542. * @returns the max steps
  42543. */
  42544. getLockstepMaxSteps(): number;
  42545. /**
  42546. * Returns the time in ms between steps when using deterministic lock step.
  42547. * @returns time step in (ms)
  42548. */
  42549. getTimeStep(): number;
  42550. /**
  42551. * Force the mipmap generation for the given render target texture
  42552. * @param texture defines the render target texture to use
  42553. * @param unbind defines whether or not to unbind the texture after generation. Defaults to true.
  42554. */
  42555. generateMipMapsForCubemap(texture: InternalTexture, unbind?: boolean): void;
  42556. /** States */
  42557. /**
  42558. * Set various states to the webGL context
  42559. * @param culling defines backface culling state
  42560. * @param zOffset defines the value to apply to zOffset (0 by default)
  42561. * @param force defines if states must be applied even if cache is up to date
  42562. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  42563. */
  42564. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  42565. /**
  42566. * Set the z offset to apply to current rendering
  42567. * @param value defines the offset to apply
  42568. */
  42569. setZOffset(value: number): void;
  42570. /**
  42571. * Gets the current value of the zOffset
  42572. * @returns the current zOffset state
  42573. */
  42574. getZOffset(): number;
  42575. /**
  42576. * Gets a boolean indicating if depth testing is enabled
  42577. * @returns the current state
  42578. */
  42579. getDepthBuffer(): boolean;
  42580. /**
  42581. * Enable or disable depth buffering
  42582. * @param enable defines the state to set
  42583. */
  42584. setDepthBuffer(enable: boolean): void;
  42585. /**
  42586. * Gets a boolean indicating if depth writing is enabled
  42587. * @returns the current depth writing state
  42588. */
  42589. getDepthWrite(): boolean;
  42590. /**
  42591. * Enable or disable depth writing
  42592. * @param enable defines the state to set
  42593. */
  42594. setDepthWrite(enable: boolean): void;
  42595. /**
  42596. * Gets a boolean indicating if stencil buffer is enabled
  42597. * @returns the current stencil buffer state
  42598. */
  42599. getStencilBuffer(): boolean;
  42600. /**
  42601. * Enable or disable the stencil buffer
  42602. * @param enable defines if the stencil buffer must be enabled or disabled
  42603. */
  42604. setStencilBuffer(enable: boolean): void;
  42605. /**
  42606. * Gets the current stencil mask
  42607. * @returns a number defining the new stencil mask to use
  42608. */
  42609. getStencilMask(): number;
  42610. /**
  42611. * Sets the current stencil mask
  42612. * @param mask defines the new stencil mask to use
  42613. */
  42614. setStencilMask(mask: number): void;
  42615. /**
  42616. * Gets the current stencil function
  42617. * @returns a number defining the stencil function to use
  42618. */
  42619. getStencilFunction(): number;
  42620. /**
  42621. * Gets the current stencil reference value
  42622. * @returns a number defining the stencil reference value to use
  42623. */
  42624. getStencilFunctionReference(): number;
  42625. /**
  42626. * Gets the current stencil mask
  42627. * @returns a number defining the stencil mask to use
  42628. */
  42629. getStencilFunctionMask(): number;
  42630. /**
  42631. * Sets the current stencil function
  42632. * @param stencilFunc defines the new stencil function to use
  42633. */
  42634. setStencilFunction(stencilFunc: number): void;
  42635. /**
  42636. * Sets the current stencil reference
  42637. * @param reference defines the new stencil reference to use
  42638. */
  42639. setStencilFunctionReference(reference: number): void;
  42640. /**
  42641. * Sets the current stencil mask
  42642. * @param mask defines the new stencil mask to use
  42643. */
  42644. setStencilFunctionMask(mask: number): void;
  42645. /**
  42646. * Gets the current stencil operation when stencil fails
  42647. * @returns a number defining stencil operation to use when stencil fails
  42648. */
  42649. getStencilOperationFail(): number;
  42650. /**
  42651. * Gets the current stencil operation when depth fails
  42652. * @returns a number defining stencil operation to use when depth fails
  42653. */
  42654. getStencilOperationDepthFail(): number;
  42655. /**
  42656. * Gets the current stencil operation when stencil passes
  42657. * @returns a number defining stencil operation to use when stencil passes
  42658. */
  42659. getStencilOperationPass(): number;
  42660. /**
  42661. * Sets the stencil operation to use when stencil fails
  42662. * @param operation defines the stencil operation to use when stencil fails
  42663. */
  42664. setStencilOperationFail(operation: number): void;
  42665. /**
  42666. * Sets the stencil operation to use when depth fails
  42667. * @param operation defines the stencil operation to use when depth fails
  42668. */
  42669. setStencilOperationDepthFail(operation: number): void;
  42670. /**
  42671. * Sets the stencil operation to use when stencil passes
  42672. * @param operation defines the stencil operation to use when stencil passes
  42673. */
  42674. setStencilOperationPass(operation: number): void;
  42675. /**
  42676. * Sets a boolean indicating if the dithering state is enabled or disabled
  42677. * @param value defines the dithering state
  42678. */
  42679. setDitheringState(value: boolean): void;
  42680. /**
  42681. * Sets a boolean indicating if the rasterizer state is enabled or disabled
  42682. * @param value defines the rasterizer state
  42683. */
  42684. setRasterizerState(value: boolean): void;
  42685. /**
  42686. * Gets the current depth function
  42687. * @returns a number defining the depth function
  42688. */
  42689. getDepthFunction(): Nullable<number>;
  42690. /**
  42691. * Sets the current depth function
  42692. * @param depthFunc defines the function to use
  42693. */
  42694. setDepthFunction(depthFunc: number): void;
  42695. /**
  42696. * Sets the current depth function to GREATER
  42697. */
  42698. setDepthFunctionToGreater(): void;
  42699. /**
  42700. * Sets the current depth function to GEQUAL
  42701. */
  42702. setDepthFunctionToGreaterOrEqual(): void;
  42703. /**
  42704. * Sets the current depth function to LESS
  42705. */
  42706. setDepthFunctionToLess(): void;
  42707. /**
  42708. * Sets the current depth function to LEQUAL
  42709. */
  42710. setDepthFunctionToLessOrEqual(): void;
  42711. private _cachedStencilBuffer;
  42712. private _cachedStencilFunction;
  42713. private _cachedStencilMask;
  42714. private _cachedStencilOperationPass;
  42715. private _cachedStencilOperationFail;
  42716. private _cachedStencilOperationDepthFail;
  42717. private _cachedStencilReference;
  42718. /**
  42719. * Caches the the state of the stencil buffer
  42720. */
  42721. cacheStencilState(): void;
  42722. /**
  42723. * Restores the state of the stencil buffer
  42724. */
  42725. restoreStencilState(): void;
  42726. /**
  42727. * Directly set the WebGL Viewport
  42728. * @param x defines the x coordinate of the viewport (in screen space)
  42729. * @param y defines the y coordinate of the viewport (in screen space)
  42730. * @param width defines the width of the viewport (in screen space)
  42731. * @param height defines the height of the viewport (in screen space)
  42732. * @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
  42733. */
  42734. setDirectViewport(x: number, y: number, width: number, height: number): Nullable<IViewportLike>;
  42735. /**
  42736. * Executes a scissor clear (ie. a clear on a specific portion of the screen)
  42737. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  42738. * @param y defines the y-coordinate of the corner of the clear rectangle
  42739. * @param width defines the width of the clear rectangle
  42740. * @param height defines the height of the clear rectangle
  42741. * @param clearColor defines the clear color
  42742. */
  42743. scissorClear(x: number, y: number, width: number, height: number, clearColor: IColor4Like): void;
  42744. /**
  42745. * Enable scissor test on a specific rectangle (ie. render will only be executed on a specific portion of the screen)
  42746. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  42747. * @param y defines the y-coordinate of the corner of the clear rectangle
  42748. * @param width defines the width of the clear rectangle
  42749. * @param height defines the height of the clear rectangle
  42750. */
  42751. enableScissor(x: number, y: number, width: number, height: number): void;
  42752. /**
  42753. * Disable previously set scissor test rectangle
  42754. */
  42755. disableScissor(): void;
  42756. protected _reportDrawCall(): void;
  42757. /**
  42758. * Initializes a webVR display and starts listening to display change events
  42759. * The onVRDisplayChangedObservable will be notified upon these changes
  42760. * @returns The onVRDisplayChangedObservable
  42761. */
  42762. initWebVR(): Observable<IDisplayChangedEventArgs>;
  42763. /** @hidden */
  42764. _prepareVRComponent(): void;
  42765. /** @hidden */
  42766. _connectVREvents(canvas?: HTMLCanvasElement, document?: any): void;
  42767. /** @hidden */
  42768. _submitVRFrame(): void;
  42769. /**
  42770. * Call this function to leave webVR mode
  42771. * Will do nothing if webVR is not supported or if there is no webVR device
  42772. * @see https://doc.babylonjs.com/how_to/webvr_camera
  42773. */
  42774. disableVR(): void;
  42775. /**
  42776. * Gets a boolean indicating that the system is in VR mode and is presenting
  42777. * @returns true if VR mode is engaged
  42778. */
  42779. isVRPresenting(): boolean;
  42780. /** @hidden */
  42781. _requestVRFrame(): void;
  42782. /** @hidden */
  42783. _loadFileAsync(url: string, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  42784. /**
  42785. * Gets the source code of the vertex shader associated with a specific webGL program
  42786. * @param program defines the program to use
  42787. * @returns a string containing the source code of the vertex shader associated with the program
  42788. */
  42789. getVertexShaderSource(program: WebGLProgram): Nullable<string>;
  42790. /**
  42791. * Gets the source code of the fragment shader associated with a specific webGL program
  42792. * @param program defines the program to use
  42793. * @returns a string containing the source code of the fragment shader associated with the program
  42794. */
  42795. getFragmentShaderSource(program: WebGLProgram): Nullable<string>;
  42796. /**
  42797. * Sets a depth stencil texture from a render target to the according uniform.
  42798. * @param channel The texture channel
  42799. * @param uniform The uniform to set
  42800. * @param texture The render target texture containing the depth stencil texture to apply
  42801. * @param name The texture name
  42802. */
  42803. setDepthStencilTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<RenderTargetTexture>, name?: string): void;
  42804. /**
  42805. * Sets a texture to the webGL context from a postprocess
  42806. * @param channel defines the channel to use
  42807. * @param postProcess defines the source postprocess
  42808. * @param name name of the channel
  42809. */
  42810. setTextureFromPostProcess(channel: number, postProcess: Nullable<PostProcess>, name: string): void;
  42811. /**
  42812. * Binds the output of the passed in post process to the texture channel specified
  42813. * @param channel The channel the texture should be bound to
  42814. * @param postProcess The post process which's output should be bound
  42815. * @param name name of the channel
  42816. */
  42817. setTextureFromPostProcessOutput(channel: number, postProcess: Nullable<PostProcess>, name: string): void;
  42818. protected _rebuildBuffers(): void;
  42819. /** @hidden */
  42820. _renderFrame(): void;
  42821. _renderLoop(): void;
  42822. /** @hidden */
  42823. _renderViews(): boolean;
  42824. /**
  42825. * Toggle full screen mode
  42826. * @param requestPointerLock defines if a pointer lock should be requested from the user
  42827. */
  42828. switchFullscreen(requestPointerLock: boolean): void;
  42829. /**
  42830. * Enters full screen mode
  42831. * @param requestPointerLock defines if a pointer lock should be requested from the user
  42832. */
  42833. enterFullscreen(requestPointerLock: boolean): void;
  42834. /**
  42835. * Exits full screen mode
  42836. */
  42837. exitFullscreen(): void;
  42838. /**
  42839. * Enters Pointerlock mode
  42840. */
  42841. enterPointerlock(): void;
  42842. /**
  42843. * Exits Pointerlock mode
  42844. */
  42845. exitPointerlock(): void;
  42846. /**
  42847. * Begin a new frame
  42848. */
  42849. beginFrame(): void;
  42850. /**
  42851. * End the current frame
  42852. */
  42853. endFrame(): void;
  42854. /**
  42855. * Resize the view according to the canvas' size
  42856. * @param forceSetSize true to force setting the sizes of the underlying canvas
  42857. */
  42858. resize(forceSetSize?: boolean): void;
  42859. /**
  42860. * Force a specific size of the canvas
  42861. * @param width defines the new canvas' width
  42862. * @param height defines the new canvas' height
  42863. * @param forceSetSize true to force setting the sizes of the underlying canvas
  42864. * @returns true if the size was changed
  42865. */
  42866. setSize(width: number, height: number, forceSetSize?: boolean): boolean;
  42867. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  42868. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  42869. protected _createShaderProgram(pipelineContext: WebGLPipelineContext, vertexShader: WebGLShader, fragmentShader: WebGLShader, context: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  42870. _releaseTexture(texture: InternalTexture): void;
  42871. /**
  42872. * @hidden
  42873. * Rescales a texture
  42874. * @param source input texture
  42875. * @param destination destination texture
  42876. * @param scene scene to use to render the resize
  42877. * @param internalFormat format to use when resizing
  42878. * @param onComplete callback to be called when resize has completed
  42879. */
  42880. _rescaleTexture(source: InternalTexture, destination: InternalTexture, scene: Nullable<any>, internalFormat: number, onComplete: () => void): void;
  42881. /**
  42882. * Gets the current framerate
  42883. * @returns a number representing the framerate
  42884. */
  42885. getFps(): number;
  42886. /**
  42887. * Gets the time spent between current and previous frame
  42888. * @returns a number representing the delta time in ms
  42889. */
  42890. getDeltaTime(): number;
  42891. private _measureFps;
  42892. /** @hidden */
  42893. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement | ImageBitmap, faceIndex?: number, lod?: number): void;
  42894. /**
  42895. * Updates the sample count of a render target texture
  42896. * @see https://doc.babylonjs.com/features/webgl2#multisample-render-targets
  42897. * @param texture defines the texture to update
  42898. * @param samples defines the sample count to set
  42899. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  42900. */
  42901. updateRenderTargetTextureSampleCount(texture: Nullable<InternalTexture>, samples: number): number;
  42902. /**
  42903. * Updates a depth texture Comparison Mode and Function.
  42904. * If the comparison Function is equal to 0, the mode will be set to none.
  42905. * Otherwise, this only works in webgl 2 and requires a shadow sampler in the shader.
  42906. * @param texture The texture to set the comparison function for
  42907. * @param comparisonFunction The comparison function to set, 0 if no comparison required
  42908. */
  42909. updateTextureComparisonFunction(texture: InternalTexture, comparisonFunction: number): void;
  42910. /**
  42911. * Creates a webGL buffer to use with instantiation
  42912. * @param capacity defines the size of the buffer
  42913. * @returns the webGL buffer
  42914. */
  42915. createInstancesBuffer(capacity: number): DataBuffer;
  42916. /**
  42917. * Delete a webGL buffer used with instantiation
  42918. * @param buffer defines the webGL buffer to delete
  42919. */
  42920. deleteInstancesBuffer(buffer: WebGLBuffer): void;
  42921. private _clientWaitAsync;
  42922. /** @hidden */
  42923. _readPixelsAsync(x: number, y: number, w: number, h: number, format: number, type: number, outputBuffer: ArrayBufferView): Nullable<Promise<ArrayBufferView>>;
  42924. dispose(): void;
  42925. private _disableTouchAction;
  42926. /**
  42927. * Display the loading screen
  42928. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  42929. */
  42930. displayLoadingUI(): void;
  42931. /**
  42932. * Hide the loading screen
  42933. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  42934. */
  42935. hideLoadingUI(): void;
  42936. /**
  42937. * Gets the current loading screen object
  42938. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  42939. */
  42940. get loadingScreen(): ILoadingScreen;
  42941. /**
  42942. * Sets the current loading screen object
  42943. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  42944. */
  42945. set loadingScreen(loadingScreen: ILoadingScreen);
  42946. /**
  42947. * Sets the current loading screen text
  42948. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  42949. */
  42950. set loadingUIText(text: string);
  42951. /**
  42952. * Sets the current loading screen background color
  42953. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  42954. */
  42955. set loadingUIBackgroundColor(color: string);
  42956. /** Pointerlock and fullscreen */
  42957. /**
  42958. * Ask the browser to promote the current element to pointerlock mode
  42959. * @param element defines the DOM element to promote
  42960. */
  42961. static _RequestPointerlock(element: HTMLElement): void;
  42962. /**
  42963. * Asks the browser to exit pointerlock mode
  42964. */
  42965. static _ExitPointerlock(): void;
  42966. /**
  42967. * Ask the browser to promote the current element to fullscreen rendering mode
  42968. * @param element defines the DOM element to promote
  42969. */
  42970. static _RequestFullscreen(element: HTMLElement): void;
  42971. /**
  42972. * Asks the browser to exit fullscreen mode
  42973. */
  42974. static _ExitFullscreen(): void;
  42975. }
  42976. }
  42977. declare module BABYLON {
  42978. /**
  42979. * The engine store class is responsible to hold all the instances of Engine and Scene created
  42980. * during the life time of the application.
  42981. */
  42982. export class EngineStore {
  42983. /** Gets the list of created engines */
  42984. static Instances: Engine[];
  42985. /** @hidden */
  42986. static _LastCreatedScene: Nullable<Scene>;
  42987. /**
  42988. * Gets the latest created engine
  42989. */
  42990. static get LastCreatedEngine(): Nullable<Engine>;
  42991. /**
  42992. * Gets the latest created scene
  42993. */
  42994. static get LastCreatedScene(): Nullable<Scene>;
  42995. /**
  42996. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  42997. * @ignorenaming
  42998. */
  42999. static UseFallbackTexture: boolean;
  43000. /**
  43001. * Texture content used if a texture cannot loaded
  43002. * @ignorenaming
  43003. */
  43004. static FallbackTexture: string;
  43005. }
  43006. }
  43007. declare module BABYLON {
  43008. /**
  43009. * Helper class that provides a small promise polyfill
  43010. */
  43011. export class PromisePolyfill {
  43012. /**
  43013. * Static function used to check if the polyfill is required
  43014. * If this is the case then the function will inject the polyfill to window.Promise
  43015. * @param force defines a boolean used to force the injection (mostly for testing purposes)
  43016. */
  43017. static Apply(force?: boolean): void;
  43018. }
  43019. }
  43020. declare module BABYLON {
  43021. /**
  43022. * Interface for screenshot methods with describe argument called `size` as object with options
  43023. * @link https://doc.babylonjs.com/api/classes/babylon.screenshottools
  43024. */
  43025. export interface IScreenshotSize {
  43026. /**
  43027. * number in pixels for canvas height
  43028. */
  43029. height?: number;
  43030. /**
  43031. * multiplier allowing render at a higher or lower resolution
  43032. * If value is defined then height and width will be ignored and taken from camera
  43033. */
  43034. precision?: number;
  43035. /**
  43036. * number in pixels for canvas width
  43037. */
  43038. width?: number;
  43039. }
  43040. }
  43041. declare module BABYLON {
  43042. interface IColor4Like {
  43043. r: float;
  43044. g: float;
  43045. b: float;
  43046. a: float;
  43047. }
  43048. /**
  43049. * Class containing a set of static utilities functions
  43050. */
  43051. export class Tools {
  43052. /**
  43053. * Gets or sets the base URL to use to load assets
  43054. */
  43055. static get BaseUrl(): string;
  43056. static set BaseUrl(value: string);
  43057. /**
  43058. * Enable/Disable Custom HTTP Request Headers globally.
  43059. * default = false
  43060. * @see CustomRequestHeaders
  43061. */
  43062. static UseCustomRequestHeaders: boolean;
  43063. /**
  43064. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  43065. * i.e. when loading files, where the server/service expects an Authorization header
  43066. */
  43067. static CustomRequestHeaders: {
  43068. [key: string]: string;
  43069. };
  43070. /**
  43071. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  43072. */
  43073. static get DefaultRetryStrategy(): (url: string, request: WebRequest, retryIndex: number) => number;
  43074. static set DefaultRetryStrategy(strategy: (url: string, request: WebRequest, retryIndex: number) => number);
  43075. /**
  43076. * Default behaviour for cors in the application.
  43077. * It can be a string if the expected behavior is identical in the entire app.
  43078. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  43079. */
  43080. static get CorsBehavior(): string | ((url: string | string[]) => string);
  43081. static set CorsBehavior(value: string | ((url: string | string[]) => string));
  43082. /**
  43083. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  43084. * @ignorenaming
  43085. */
  43086. static get UseFallbackTexture(): boolean;
  43087. static set UseFallbackTexture(value: boolean);
  43088. /**
  43089. * Use this object to register external classes like custom textures or material
  43090. * to allow the loaders to instantiate them
  43091. */
  43092. static get RegisteredExternalClasses(): {
  43093. [key: string]: Object;
  43094. };
  43095. static set RegisteredExternalClasses(classes: {
  43096. [key: string]: Object;
  43097. });
  43098. /**
  43099. * Texture content used if a texture cannot loaded
  43100. * @ignorenaming
  43101. */
  43102. static get fallbackTexture(): string;
  43103. static set fallbackTexture(value: string);
  43104. /**
  43105. * Read the content of a byte array at a specified coordinates (taking in account wrapping)
  43106. * @param u defines the coordinate on X axis
  43107. * @param v defines the coordinate on Y axis
  43108. * @param width defines the width of the source data
  43109. * @param height defines the height of the source data
  43110. * @param pixels defines the source byte array
  43111. * @param color defines the output color
  43112. */
  43113. static FetchToRef(u: number, v: number, width: number, height: number, pixels: Uint8Array, color: IColor4Like): void;
  43114. /**
  43115. * Interpolates between a and b via alpha
  43116. * @param a The lower value (returned when alpha = 0)
  43117. * @param b The upper value (returned when alpha = 1)
  43118. * @param alpha The interpolation-factor
  43119. * @return The mixed value
  43120. */
  43121. static Mix(a: number, b: number, alpha: number): number;
  43122. /**
  43123. * Tries to instantiate a new object from a given class name
  43124. * @param className defines the class name to instantiate
  43125. * @returns the new object or null if the system was not able to do the instantiation
  43126. */
  43127. static Instantiate(className: string): any;
  43128. /**
  43129. * Provides a slice function that will work even on IE
  43130. * @param data defines the array to slice
  43131. * @param start defines the start of the data (optional)
  43132. * @param end defines the end of the data (optional)
  43133. * @returns the new sliced array
  43134. */
  43135. static Slice<T>(data: T, start?: number, end?: number): T;
  43136. /**
  43137. * Provides a slice function that will work even on IE
  43138. * The difference between this and Slice is that this will force-convert to array
  43139. * @param data defines the array to slice
  43140. * @param start defines the start of the data (optional)
  43141. * @param end defines the end of the data (optional)
  43142. * @returns the new sliced array
  43143. */
  43144. static SliceToArray<T, P>(data: T, start?: number, end?: number): Array<P>;
  43145. /**
  43146. * Polyfill for setImmediate
  43147. * @param action defines the action to execute after the current execution block
  43148. */
  43149. static SetImmediate(action: () => void): void;
  43150. /**
  43151. * Function indicating if a number is an exponent of 2
  43152. * @param value defines the value to test
  43153. * @returns true if the value is an exponent of 2
  43154. */
  43155. static IsExponentOfTwo(value: number): boolean;
  43156. private static _tmpFloatArray;
  43157. /**
  43158. * Returns the nearest 32-bit single precision float representation of a Number
  43159. * @param value A Number. If the parameter is of a different type, it will get converted
  43160. * to a number or to NaN if it cannot be converted
  43161. * @returns number
  43162. */
  43163. static FloatRound(value: number): number;
  43164. /**
  43165. * Extracts the filename from a path
  43166. * @param path defines the path to use
  43167. * @returns the filename
  43168. */
  43169. static GetFilename(path: string): string;
  43170. /**
  43171. * Extracts the "folder" part of a path (everything before the filename).
  43172. * @param uri The URI to extract the info from
  43173. * @param returnUnchangedIfNoSlash Do not touch the URI if no slashes are present
  43174. * @returns The "folder" part of the path
  43175. */
  43176. static GetFolderPath(uri: string, returnUnchangedIfNoSlash?: boolean): string;
  43177. /**
  43178. * Extracts text content from a DOM element hierarchy
  43179. * Back Compat only, please use DomManagement.GetDOMTextContent instead.
  43180. */
  43181. static GetDOMTextContent: typeof DomManagement.GetDOMTextContent;
  43182. /**
  43183. * Convert an angle in radians to degrees
  43184. * @param angle defines the angle to convert
  43185. * @returns the angle in degrees
  43186. */
  43187. static ToDegrees(angle: number): number;
  43188. /**
  43189. * Convert an angle in degrees to radians
  43190. * @param angle defines the angle to convert
  43191. * @returns the angle in radians
  43192. */
  43193. static ToRadians(angle: number): number;
  43194. /**
  43195. * Returns an array if obj is not an array
  43196. * @param obj defines the object to evaluate as an array
  43197. * @param allowsNullUndefined defines a boolean indicating if obj is allowed to be null or undefined
  43198. * @returns either obj directly if obj is an array or a new array containing obj
  43199. */
  43200. static MakeArray(obj: any, allowsNullUndefined?: boolean): Nullable<Array<any>>;
  43201. /**
  43202. * Gets the pointer prefix to use
  43203. * @param engine defines the engine we are finding the prefix for
  43204. * @returns "pointer" if touch is enabled. Else returns "mouse"
  43205. */
  43206. static GetPointerPrefix(engine: Engine): string;
  43207. /**
  43208. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  43209. * @param url define the url we are trying
  43210. * @param element define the dom element where to configure the cors policy
  43211. */
  43212. static SetCorsBehavior(url: string | string[], element: {
  43213. crossOrigin: string | null;
  43214. }): void;
  43215. /**
  43216. * Removes unwanted characters from an url
  43217. * @param url defines the url to clean
  43218. * @returns the cleaned url
  43219. */
  43220. static CleanUrl(url: string): string;
  43221. /**
  43222. * Gets or sets a function used to pre-process url before using them to load assets
  43223. */
  43224. static get PreprocessUrl(): (url: string) => string;
  43225. static set PreprocessUrl(processor: (url: string) => string);
  43226. /**
  43227. * Loads an image as an HTMLImageElement.
  43228. * @param input url string, ArrayBuffer, or Blob to load
  43229. * @param onLoad callback called when the image successfully loads
  43230. * @param onError callback called when the image fails to load
  43231. * @param offlineProvider offline provider for caching
  43232. * @param mimeType optional mime type
  43233. * @returns the HTMLImageElement of the loaded image
  43234. */
  43235. static LoadImage(input: string | ArrayBuffer | Blob, onLoad: (img: HTMLImageElement | ImageBitmap) => void, onError: (message?: string, exception?: any) => void, offlineProvider: Nullable<IOfflineProvider>, mimeType?: string): Nullable<HTMLImageElement>;
  43236. /**
  43237. * Loads a file from a url
  43238. * @param url url string, ArrayBuffer, or Blob to load
  43239. * @param onSuccess callback called when the file successfully loads
  43240. * @param onProgress callback called while file is loading (if the server supports this mode)
  43241. * @param offlineProvider defines the offline provider for caching
  43242. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  43243. * @param onError callback called when the file fails to load
  43244. * @returns a file request object
  43245. */
  43246. 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;
  43247. /**
  43248. * Loads a file from a url
  43249. * @param url the file url to load
  43250. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  43251. * @returns a promise containing an ArrayBuffer corresponding to the loaded file
  43252. */
  43253. static LoadFileAsync(url: string, useArrayBuffer?: boolean): Promise<ArrayBuffer | string>;
  43254. /**
  43255. * Load a script (identified by an url). When the url returns, the
  43256. * content of this file is added into a new script element, attached to the DOM (body element)
  43257. * @param scriptUrl defines the url of the script to laod
  43258. * @param onSuccess defines the callback called when the script is loaded
  43259. * @param onError defines the callback to call if an error occurs
  43260. * @param scriptId defines the id of the script element
  43261. */
  43262. static LoadScript(scriptUrl: string, onSuccess: () => void, onError?: (message?: string, exception?: any) => void, scriptId?: string): void;
  43263. /**
  43264. * Load an asynchronous script (identified by an url). When the url returns, the
  43265. * content of this file is added into a new script element, attached to the DOM (body element)
  43266. * @param scriptUrl defines the url of the script to laod
  43267. * @param scriptId defines the id of the script element
  43268. * @returns a promise request object
  43269. */
  43270. static LoadScriptAsync(scriptUrl: string, scriptId?: string): Promise<void>;
  43271. /**
  43272. * Loads a file from a blob
  43273. * @param fileToLoad defines the blob to use
  43274. * @param callback defines the callback to call when data is loaded
  43275. * @param progressCallback defines the callback to call during loading process
  43276. * @returns a file request object
  43277. */
  43278. static ReadFileAsDataURL(fileToLoad: Blob, callback: (data: any) => void, progressCallback: (ev: ProgressEvent) => any): IFileRequest;
  43279. /**
  43280. * Reads a file from a File object
  43281. * @param file defines the file to load
  43282. * @param onSuccess defines the callback to call when data is loaded
  43283. * @param onProgress defines the callback to call during loading process
  43284. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  43285. * @param onError defines the callback to call when an error occurs
  43286. * @returns a file request object
  43287. */
  43288. static ReadFile(file: File, onSuccess: (data: any) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: ReadFileError) => void): IFileRequest;
  43289. /**
  43290. * Creates a data url from a given string content
  43291. * @param content defines the content to convert
  43292. * @returns the new data url link
  43293. */
  43294. static FileAsURL(content: string): string;
  43295. /**
  43296. * Format the given number to a specific decimal format
  43297. * @param value defines the number to format
  43298. * @param decimals defines the number of decimals to use
  43299. * @returns the formatted string
  43300. */
  43301. static Format(value: number, decimals?: number): string;
  43302. /**
  43303. * Tries to copy an object by duplicating every property
  43304. * @param source defines the source object
  43305. * @param destination defines the target object
  43306. * @param doNotCopyList defines a list of properties to avoid
  43307. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  43308. */
  43309. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  43310. /**
  43311. * Gets a boolean indicating if the given object has no own property
  43312. * @param obj defines the object to test
  43313. * @returns true if object has no own property
  43314. */
  43315. static IsEmpty(obj: any): boolean;
  43316. /**
  43317. * Function used to register events at window level
  43318. * @param windowElement defines the Window object to use
  43319. * @param events defines the events to register
  43320. */
  43321. static RegisterTopRootEvents(windowElement: Window, events: {
  43322. name: string;
  43323. handler: Nullable<(e: FocusEvent) => any>;
  43324. }[]): void;
  43325. /**
  43326. * Function used to unregister events from window level
  43327. * @param windowElement defines the Window object to use
  43328. * @param events defines the events to unregister
  43329. */
  43330. static UnregisterTopRootEvents(windowElement: Window, events: {
  43331. name: string;
  43332. handler: Nullable<(e: FocusEvent) => any>;
  43333. }[]): void;
  43334. /**
  43335. * @ignore
  43336. */
  43337. static _ScreenshotCanvas: HTMLCanvasElement;
  43338. /**
  43339. * Dumps the current bound framebuffer
  43340. * @param width defines the rendering width
  43341. * @param height defines the rendering height
  43342. * @param engine defines the hosting engine
  43343. * @param successCallback defines the callback triggered once the data are available
  43344. * @param mimeType defines the mime type of the result
  43345. * @param fileName defines the filename to download. If present, the result will automatically be downloaded
  43346. * @return a void promise
  43347. */
  43348. static DumpFramebuffer(width: number, height: number, engine: Engine, successCallback?: (data: string) => void, mimeType?: string, fileName?: string): Promise<void>;
  43349. /**
  43350. * Dumps an array buffer
  43351. * @param width defines the rendering width
  43352. * @param height defines the rendering height
  43353. * @param data the data array
  43354. * @param successCallback defines the callback triggered once the data are available
  43355. * @param mimeType defines the mime type of the result
  43356. * @param fileName defines the filename to download. If present, the result will automatically be downloaded
  43357. * @param invertY true to invert the picture in the Y dimension
  43358. * @param toArrayBuffer true to convert the data to an ArrayBuffer (encoded as `mimeType`) instead of a base64 string
  43359. */
  43360. static DumpData(width: number, height: number, data: ArrayBufferView, successCallback?: (data: string | ArrayBuffer) => void, mimeType?: string, fileName?: string, invertY?: boolean, toArrayBuffer?: boolean): void;
  43361. /**
  43362. * Dumps an array buffer
  43363. * @param width defines the rendering width
  43364. * @param height defines the rendering height
  43365. * @param data the data array
  43366. * @param successCallback defines the callback triggered once the data are available
  43367. * @param mimeType defines the mime type of the result
  43368. * @param fileName defines the filename to download. If present, the result will automatically be downloaded
  43369. * @param invertY true to invert the picture in the Y dimension
  43370. * @param toArrayBuffer true to convert the data to an ArrayBuffer (encoded as `mimeType`) instead of a base64 string
  43371. * @return a promise that resolve to the final data
  43372. */
  43373. static DumpDataAsync(width: number, height: number, data: ArrayBufferView, mimeType?: string, fileName?: string, invertY?: boolean, toArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  43374. /**
  43375. * Converts the canvas data to blob.
  43376. * This acts as a polyfill for browsers not supporting the to blob function.
  43377. * @param canvas Defines the canvas to extract the data from
  43378. * @param successCallback Defines the callback triggered once the data are available
  43379. * @param mimeType Defines the mime type of the result
  43380. */
  43381. static ToBlob(canvas: HTMLCanvasElement, successCallback: (blob: Nullable<Blob>) => void, mimeType?: string): void;
  43382. /**
  43383. * Encodes the canvas data to base 64 or automatically download the result if filename is defined
  43384. * @param successCallback defines the callback triggered once the data are available
  43385. * @param mimeType defines the mime type of the result
  43386. * @param fileName defines he filename to download. If present, the result will automatically be downloaded
  43387. * @param canvas canvas to get the data from. If not provided, use the default screenshot canvas
  43388. */
  43389. static EncodeScreenshotCanvasData(successCallback?: (data: string) => void, mimeType?: string, fileName?: string, canvas?: HTMLCanvasElement): void;
  43390. /**
  43391. * Downloads a blob in the browser
  43392. * @param blob defines the blob to download
  43393. * @param fileName defines the name of the downloaded file
  43394. */
  43395. static Download(blob: Blob, fileName: string): void;
  43396. /**
  43397. * Will return the right value of the noPreventDefault variable
  43398. * Needed to keep backwards compatibility to the old API.
  43399. *
  43400. * @param args arguments passed to the attachControl function
  43401. * @returns the correct value for noPreventDefault
  43402. */
  43403. static BackCompatCameraNoPreventDefault(args: IArguments): boolean;
  43404. /**
  43405. * Captures a screenshot of the current rendering
  43406. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  43407. * @param engine defines the rendering engine
  43408. * @param camera defines the source camera
  43409. * @param size This parameter can be set to a single number or to an object with the
  43410. * following (optional) properties: precision, width, height. If a single number is passed,
  43411. * it will be used for both width and height. If an object is passed, the screenshot size
  43412. * will be derived from the parameters. The precision property is a multiplier allowing
  43413. * rendering at a higher or lower resolution
  43414. * @param successCallback defines the callback receives a single parameter which contains the
  43415. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  43416. * src parameter of an <img> to display it
  43417. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  43418. * Check your browser for supported MIME types
  43419. */
  43420. static CreateScreenshot(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string): void;
  43421. /**
  43422. * Captures a screenshot of the current rendering
  43423. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  43424. * @param engine defines the rendering engine
  43425. * @param camera defines the source camera
  43426. * @param size This parameter can be set to a single number or to an object with the
  43427. * following (optional) properties: precision, width, height. If a single number is passed,
  43428. * it will be used for both width and height. If an object is passed, the screenshot size
  43429. * will be derived from the parameters. The precision property is a multiplier allowing
  43430. * rendering at a higher or lower resolution
  43431. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  43432. * Check your browser for supported MIME types
  43433. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  43434. * to the src parameter of an <img> to display it
  43435. */
  43436. static CreateScreenshotAsync(engine: Engine, camera: Camera, size: IScreenshotSize | number, mimeType?: string): Promise<string>;
  43437. /**
  43438. * Generates an image screenshot from the specified camera.
  43439. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  43440. * @param engine The engine to use for rendering
  43441. * @param camera The camera to use for rendering
  43442. * @param size This parameter can be set to a single number or to an object with the
  43443. * following (optional) properties: precision, width, height. If a single number is passed,
  43444. * it will be used for both width and height. If an object is passed, the screenshot size
  43445. * will be derived from the parameters. The precision property is a multiplier allowing
  43446. * rendering at a higher or lower resolution
  43447. * @param successCallback The callback receives a single parameter which contains the
  43448. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  43449. * src parameter of an <img> to display it
  43450. * @param mimeType The MIME type of the screenshot image (default: image/png).
  43451. * Check your browser for supported MIME types
  43452. * @param samples Texture samples (default: 1)
  43453. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  43454. * @param fileName A name for for the downloaded file.
  43455. */
  43456. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  43457. /**
  43458. * Generates an image screenshot from the specified camera.
  43459. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  43460. * @param engine The engine to use for rendering
  43461. * @param camera The camera to use for rendering
  43462. * @param size This parameter can be set to a single number or to an object with the
  43463. * following (optional) properties: precision, width, height. If a single number is passed,
  43464. * it will be used for both width and height. If an object is passed, the screenshot size
  43465. * will be derived from the parameters. The precision property is a multiplier allowing
  43466. * rendering at a higher or lower resolution
  43467. * @param mimeType The MIME type of the screenshot image (default: image/png).
  43468. * Check your browser for supported MIME types
  43469. * @param samples Texture samples (default: 1)
  43470. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  43471. * @param fileName A name for for the downloaded file.
  43472. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  43473. * to the src parameter of an <img> to display it
  43474. */
  43475. static CreateScreenshotUsingRenderTargetAsync(engine: Engine, camera: Camera, size: IScreenshotSize | number, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): Promise<string>;
  43476. /**
  43477. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  43478. * Be aware Math.random() could cause collisions, but:
  43479. * "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"
  43480. * @returns a pseudo random id
  43481. */
  43482. static RandomId(): string;
  43483. /**
  43484. * Test if the given uri is a base64 string
  43485. * @param uri The uri to test
  43486. * @return True if the uri is a base64 string or false otherwise
  43487. */
  43488. static IsBase64(uri: string): boolean;
  43489. /**
  43490. * Decode the given base64 uri.
  43491. * @param uri The uri to decode
  43492. * @return The decoded base64 data.
  43493. */
  43494. static DecodeBase64(uri: string): ArrayBuffer;
  43495. /**
  43496. * Gets the absolute url.
  43497. * @param url the input url
  43498. * @return the absolute url
  43499. */
  43500. static GetAbsoluteUrl(url: string): string;
  43501. /**
  43502. * No log
  43503. */
  43504. static readonly NoneLogLevel: number;
  43505. /**
  43506. * Only message logs
  43507. */
  43508. static readonly MessageLogLevel: number;
  43509. /**
  43510. * Only warning logs
  43511. */
  43512. static readonly WarningLogLevel: number;
  43513. /**
  43514. * Only error logs
  43515. */
  43516. static readonly ErrorLogLevel: number;
  43517. /**
  43518. * All logs
  43519. */
  43520. static readonly AllLogLevel: number;
  43521. /**
  43522. * Gets a value indicating the number of loading errors
  43523. * @ignorenaming
  43524. */
  43525. static get errorsCount(): number;
  43526. /**
  43527. * Callback called when a new log is added
  43528. */
  43529. static OnNewCacheEntry: (entry: string) => void;
  43530. /**
  43531. * Log a message to the console
  43532. * @param message defines the message to log
  43533. */
  43534. static Log(message: string): void;
  43535. /**
  43536. * Write a warning message to the console
  43537. * @param message defines the message to log
  43538. */
  43539. static Warn(message: string): void;
  43540. /**
  43541. * Write an error message to the console
  43542. * @param message defines the message to log
  43543. */
  43544. static Error(message: string): void;
  43545. /**
  43546. * Gets current log cache (list of logs)
  43547. */
  43548. static get LogCache(): string;
  43549. /**
  43550. * Clears the log cache
  43551. */
  43552. static ClearLogCache(): void;
  43553. /**
  43554. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  43555. */
  43556. static set LogLevels(level: number);
  43557. /**
  43558. * Checks if the window object exists
  43559. * Back Compat only, please use DomManagement.IsWindowObjectExist instead.
  43560. */
  43561. static IsWindowObjectExist: typeof DomManagement.IsWindowObjectExist;
  43562. /**
  43563. * No performance log
  43564. */
  43565. static readonly PerformanceNoneLogLevel: number;
  43566. /**
  43567. * Use user marks to log performance
  43568. */
  43569. static readonly PerformanceUserMarkLogLevel: number;
  43570. /**
  43571. * Log performance to the console
  43572. */
  43573. static readonly PerformanceConsoleLogLevel: number;
  43574. private static _performance;
  43575. /**
  43576. * Sets the current performance log level
  43577. */
  43578. static set PerformanceLogLevel(level: number);
  43579. private static _StartPerformanceCounterDisabled;
  43580. private static _EndPerformanceCounterDisabled;
  43581. private static _StartUserMark;
  43582. private static _EndUserMark;
  43583. private static _StartPerformanceConsole;
  43584. private static _EndPerformanceConsole;
  43585. /**
  43586. * Starts a performance counter
  43587. */
  43588. static StartPerformanceCounter: (counterName: string, condition?: boolean) => void;
  43589. /**
  43590. * Ends a specific performance counter
  43591. */
  43592. static EndPerformanceCounter: (counterName: string, condition?: boolean) => void;
  43593. /**
  43594. * Gets either window.performance.now() if supported or Date.now() else
  43595. */
  43596. static get Now(): number;
  43597. /**
  43598. * This method will return the name of the class used to create the instance of the given object.
  43599. * It will works only on Javascript basic data types (number, string, ...) and instance of class declared with the @className decorator.
  43600. * @param object the object to get the class name from
  43601. * @param isType defines if the object is actually a type
  43602. * @returns the name of the class, will be "object" for a custom data type not using the @className decorator
  43603. */
  43604. static GetClassName(object: any, isType?: boolean): string;
  43605. /**
  43606. * Gets the first element of an array satisfying a given predicate
  43607. * @param array defines the array to browse
  43608. * @param predicate defines the predicate to use
  43609. * @returns null if not found or the element
  43610. */
  43611. static First<T>(array: Array<T>, predicate: (item: T) => boolean): Nullable<T>;
  43612. /**
  43613. * This method will return the name of the full name of the class, including its owning module (if any).
  43614. * 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).
  43615. * @param object the object to get the class name from
  43616. * @param isType defines if the object is actually a type
  43617. * @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.
  43618. * @ignorenaming
  43619. */
  43620. static getFullClassName(object: any, isType?: boolean): Nullable<string>;
  43621. /**
  43622. * Returns a promise that resolves after the given amount of time.
  43623. * @param delay Number of milliseconds to delay
  43624. * @returns Promise that resolves after the given amount of time
  43625. */
  43626. static DelayAsync(delay: number): Promise<void>;
  43627. /**
  43628. * Utility function to detect if the current user agent is Safari
  43629. * @returns whether or not the current user agent is safari
  43630. */
  43631. static IsSafari(): boolean;
  43632. }
  43633. /**
  43634. * Use this className as a decorator on a given class definition to add it a name and optionally its module.
  43635. * You can then use the Tools.getClassName(obj) on an instance to retrieve its class name.
  43636. * This method is the only way to get it done in all cases, even if the .js file declaring the class is minified
  43637. * @param name The name of the class, case should be preserved
  43638. * @param module The name of the Module hosting the class, optional, but strongly recommended to specify if possible. Case should be preserved.
  43639. */
  43640. export function className(name: string, module?: string): (target: Object) => void;
  43641. /**
  43642. * An implementation of a loop for asynchronous functions.
  43643. */
  43644. export class AsyncLoop {
  43645. /**
  43646. * Defines the number of iterations for the loop
  43647. */
  43648. iterations: number;
  43649. /**
  43650. * Defines the current index of the loop.
  43651. */
  43652. index: number;
  43653. private _done;
  43654. private _fn;
  43655. private _successCallback;
  43656. /**
  43657. * Constructor.
  43658. * @param iterations the number of iterations.
  43659. * @param func the function to run each iteration
  43660. * @param successCallback the callback that will be called upon successful execution
  43661. * @param offset starting offset.
  43662. */
  43663. constructor(
  43664. /**
  43665. * Defines the number of iterations for the loop
  43666. */
  43667. iterations: number, func: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number);
  43668. /**
  43669. * Execute the next iteration. Must be called after the last iteration was finished.
  43670. */
  43671. executeNext(): void;
  43672. /**
  43673. * Break the loop and run the success callback.
  43674. */
  43675. breakLoop(): void;
  43676. /**
  43677. * Create and run an async loop.
  43678. * @param iterations the number of iterations.
  43679. * @param fn the function to run each iteration
  43680. * @param successCallback the callback that will be called upon successful execution
  43681. * @param offset starting offset.
  43682. * @returns the created async loop object
  43683. */
  43684. static Run(iterations: number, fn: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number): AsyncLoop;
  43685. /**
  43686. * A for-loop that will run a given number of iterations synchronous and the rest async.
  43687. * @param iterations total number of iterations
  43688. * @param syncedIterations number of synchronous iterations in each async iteration.
  43689. * @param fn the function to call each iteration.
  43690. * @param callback a success call back that will be called when iterating stops.
  43691. * @param breakFunction a break condition (optional)
  43692. * @param timeout timeout settings for the setTimeout function. default - 0.
  43693. * @returns the created async loop object
  43694. */
  43695. static SyncAsyncForLoop(iterations: number, syncedIterations: number, fn: (iteration: number) => void, callback: () => void, breakFunction?: () => boolean, timeout?: number): AsyncLoop;
  43696. }
  43697. }
  43698. declare module BABYLON {
  43699. /**
  43700. * This class implement a typical dictionary using a string as key and the generic type T as value.
  43701. * The underlying implementation relies on an associative array to ensure the best performances.
  43702. * The value can be anything including 'null' but except 'undefined'
  43703. */
  43704. export class StringDictionary<T> {
  43705. /**
  43706. * This will clear this dictionary and copy the content from the 'source' one.
  43707. * If the T value is a custom object, it won't be copied/cloned, the same object will be used
  43708. * @param source the dictionary to take the content from and copy to this dictionary
  43709. */
  43710. copyFrom(source: StringDictionary<T>): void;
  43711. /**
  43712. * Get a value based from its key
  43713. * @param key the given key to get the matching value from
  43714. * @return the value if found, otherwise undefined is returned
  43715. */
  43716. get(key: string): T | undefined;
  43717. /**
  43718. * Get a value from its key or add it if it doesn't exist.
  43719. * This method will ensure you that a given key/data will be present in the dictionary.
  43720. * @param key the given key to get the matching value from
  43721. * @param factory the factory that will create the value if the key is not present in the dictionary.
  43722. * The factory will only be invoked if there's no data for the given key.
  43723. * @return the value corresponding to the key.
  43724. */
  43725. getOrAddWithFactory(key: string, factory: (key: string) => T): T;
  43726. /**
  43727. * Get a value from its key if present in the dictionary otherwise add it
  43728. * @param key the key to get the value from
  43729. * @param val if there's no such key/value pair in the dictionary add it with this value
  43730. * @return the value corresponding to the key
  43731. */
  43732. getOrAdd(key: string, val: T): T;
  43733. /**
  43734. * Check if there's a given key in the dictionary
  43735. * @param key the key to check for
  43736. * @return true if the key is present, false otherwise
  43737. */
  43738. contains(key: string): boolean;
  43739. /**
  43740. * Add a new key and its corresponding value
  43741. * @param key the key to add
  43742. * @param value the value corresponding to the key
  43743. * @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
  43744. */
  43745. add(key: string, value: T): boolean;
  43746. /**
  43747. * Update a specific value associated to a key
  43748. * @param key defines the key to use
  43749. * @param value defines the value to store
  43750. * @returns true if the value was updated (or false if the key was not found)
  43751. */
  43752. set(key: string, value: T): boolean;
  43753. /**
  43754. * Get the element of the given key and remove it from the dictionary
  43755. * @param key defines the key to search
  43756. * @returns the value associated with the key or null if not found
  43757. */
  43758. getAndRemove(key: string): Nullable<T>;
  43759. /**
  43760. * Remove a key/value from the dictionary.
  43761. * @param key the key to remove
  43762. * @return true if the item was successfully deleted, false if no item with such key exist in the dictionary
  43763. */
  43764. remove(key: string): boolean;
  43765. /**
  43766. * Clear the whole content of the dictionary
  43767. */
  43768. clear(): void;
  43769. /**
  43770. * Gets the current count
  43771. */
  43772. get count(): number;
  43773. /**
  43774. * Execute a callback on each key/val of the dictionary.
  43775. * Note that you can remove any element in this dictionary in the callback implementation
  43776. * @param callback the callback to execute on a given key/value pair
  43777. */
  43778. forEach(callback: (key: string, val: T) => void): void;
  43779. /**
  43780. * Execute a callback on every occurrence of the dictionary until it returns a valid TRes object.
  43781. * If the callback returns null or undefined the method will iterate to the next key/value pair
  43782. * Note that you can remove any element in this dictionary in the callback implementation
  43783. * @param callback the callback to execute, if it return a valid T instanced object the enumeration will stop and the object will be returned
  43784. * @returns the first item
  43785. */
  43786. first<TRes>(callback: (key: string, val: T) => TRes): TRes | null;
  43787. private _count;
  43788. private _data;
  43789. }
  43790. }
  43791. declare module BABYLON {
  43792. /** @hidden */
  43793. export interface ICollisionCoordinator {
  43794. createCollider(): Collider;
  43795. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: Nullable<AbstractMesh>, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  43796. init(scene: Scene): void;
  43797. }
  43798. /** @hidden */
  43799. export class DefaultCollisionCoordinator implements ICollisionCoordinator {
  43800. private _scene;
  43801. private _scaledPosition;
  43802. private _scaledVelocity;
  43803. private _finalPosition;
  43804. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: AbstractMesh, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  43805. createCollider(): Collider;
  43806. init(scene: Scene): void;
  43807. private _collideWithWorld;
  43808. }
  43809. }
  43810. declare module BABYLON {
  43811. /**
  43812. * Class used to manage all inputs for the scene.
  43813. */
  43814. export class InputManager {
  43815. /** The distance in pixel that you have to move to prevent some events */
  43816. static DragMovementThreshold: number;
  43817. /** Time in milliseconds to wait to raise long press events if button is still pressed */
  43818. static LongPressDelay: number;
  43819. /** Time in milliseconds with two consecutive clicks will be considered as a double click */
  43820. static DoubleClickDelay: number;
  43821. /** If you need to check double click without raising a single click at first click, enable this flag */
  43822. static ExclusiveDoubleClickMode: boolean;
  43823. /** 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. */
  43824. private _alreadyAttached;
  43825. private _alreadyAttachedTo;
  43826. private _wheelEventName;
  43827. private _onPointerMove;
  43828. private _onPointerDown;
  43829. private _onPointerUp;
  43830. private _initClickEvent;
  43831. private _initActionManager;
  43832. private _delayedSimpleClick;
  43833. private _delayedSimpleClickTimeout;
  43834. private _previousDelayedSimpleClickTimeout;
  43835. private _meshPickProceed;
  43836. private _previousButtonPressed;
  43837. private _currentPickResult;
  43838. private _previousPickResult;
  43839. private _totalPointersPressed;
  43840. private _doubleClickOccured;
  43841. private _pointerOverMesh;
  43842. private _pickedDownMesh;
  43843. private _pickedUpMesh;
  43844. private _pointerX;
  43845. private _pointerY;
  43846. private _unTranslatedPointerX;
  43847. private _unTranslatedPointerY;
  43848. private _startingPointerPosition;
  43849. private _previousStartingPointerPosition;
  43850. private _startingPointerTime;
  43851. private _previousStartingPointerTime;
  43852. private _pointerCaptures;
  43853. private _meshUnderPointerId;
  43854. private _onKeyDown;
  43855. private _onKeyUp;
  43856. private _keyboardIsAttached;
  43857. private _onCanvasFocusObserver;
  43858. private _onCanvasBlurObserver;
  43859. private _scene;
  43860. /**
  43861. * Creates a new InputManager
  43862. * @param scene defines the hosting scene
  43863. */
  43864. constructor(scene: Scene);
  43865. /**
  43866. * Gets the mesh that is currently under the pointer
  43867. */
  43868. get meshUnderPointer(): Nullable<AbstractMesh>;
  43869. /**
  43870. * When using more than one pointer (for example in XR) you can get the mesh under the specific pointer
  43871. * @param pointerId the pointer id to use
  43872. * @returns The mesh under this pointer id or null if not found
  43873. */
  43874. getMeshUnderPointerByPointerId(pointerId: number): Nullable<AbstractMesh>;
  43875. /**
  43876. * Gets the pointer coordinates in 2D without any translation (ie. straight out of the pointer event)
  43877. */
  43878. get unTranslatedPointer(): Vector2;
  43879. /**
  43880. * Gets or sets the current on-screen X position of the pointer
  43881. */
  43882. get pointerX(): number;
  43883. set pointerX(value: number);
  43884. /**
  43885. * Gets or sets the current on-screen Y position of the pointer
  43886. */
  43887. get pointerY(): number;
  43888. set pointerY(value: number);
  43889. private _updatePointerPosition;
  43890. private _processPointerMove;
  43891. private _setRayOnPointerInfo;
  43892. private _checkPrePointerObservable;
  43893. /**
  43894. * Use this method to simulate a pointer move on a mesh
  43895. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  43896. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  43897. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  43898. */
  43899. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  43900. /**
  43901. * Use this method to simulate a pointer down on a mesh
  43902. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  43903. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  43904. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  43905. */
  43906. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  43907. private _processPointerDown;
  43908. /** @hidden */
  43909. _isPointerSwiping(): boolean;
  43910. /**
  43911. * Use this method to simulate a pointer up on a mesh
  43912. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  43913. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  43914. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  43915. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  43916. */
  43917. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): void;
  43918. private _processPointerUp;
  43919. /**
  43920. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  43921. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  43922. * @returns true if the pointer was captured
  43923. */
  43924. isPointerCaptured(pointerId?: number): boolean;
  43925. /**
  43926. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  43927. * @param attachUp defines if you want to attach events to pointerup
  43928. * @param attachDown defines if you want to attach events to pointerdown
  43929. * @param attachMove defines if you want to attach events to pointermove
  43930. * @param elementToAttachTo defines the target DOM element to attach to (will use the canvas by default)
  43931. */
  43932. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean, elementToAttachTo?: Nullable<HTMLElement>): void;
  43933. /**
  43934. * Detaches all event handlers
  43935. */
  43936. detachControl(): void;
  43937. /**
  43938. * Force the value of meshUnderPointer
  43939. * @param mesh defines the mesh to use
  43940. * @param pointerId optional pointer id when using more than one pointer. Defaults to 0
  43941. */
  43942. setPointerOverMesh(mesh: Nullable<AbstractMesh>, pointerId?: number): void;
  43943. /**
  43944. * Gets the mesh under the pointer
  43945. * @returns a Mesh or null if no mesh is under the pointer
  43946. */
  43947. getPointerOverMesh(): Nullable<AbstractMesh>;
  43948. }
  43949. }
  43950. declare module BABYLON {
  43951. /**
  43952. * This class defines the direct association between an animation and a target
  43953. */
  43954. export class TargetedAnimation {
  43955. /**
  43956. * Animation to perform
  43957. */
  43958. animation: Animation;
  43959. /**
  43960. * Target to animate
  43961. */
  43962. target: any;
  43963. /**
  43964. * Returns the string "TargetedAnimation"
  43965. * @returns "TargetedAnimation"
  43966. */
  43967. getClassName(): string;
  43968. /**
  43969. * Serialize the object
  43970. * @returns the JSON object representing the current entity
  43971. */
  43972. serialize(): any;
  43973. }
  43974. /**
  43975. * Use this class to create coordinated animations on multiple targets
  43976. */
  43977. export class AnimationGroup implements IDisposable {
  43978. /** The name of the animation group */
  43979. name: string;
  43980. private _scene;
  43981. private _targetedAnimations;
  43982. private _animatables;
  43983. private _from;
  43984. private _to;
  43985. private _isStarted;
  43986. private _isPaused;
  43987. private _speedRatio;
  43988. private _loopAnimation;
  43989. private _isAdditive;
  43990. /**
  43991. * Gets or sets the unique id of the node
  43992. */
  43993. uniqueId: number;
  43994. /**
  43995. * This observable will notify when one animation have ended
  43996. */
  43997. onAnimationEndObservable: Observable<TargetedAnimation>;
  43998. /**
  43999. * Observer raised when one animation loops
  44000. */
  44001. onAnimationLoopObservable: Observable<TargetedAnimation>;
  44002. /**
  44003. * Observer raised when all animations have looped
  44004. */
  44005. onAnimationGroupLoopObservable: Observable<AnimationGroup>;
  44006. /**
  44007. * This observable will notify when all animations have ended.
  44008. */
  44009. onAnimationGroupEndObservable: Observable<AnimationGroup>;
  44010. /**
  44011. * This observable will notify when all animations have paused.
  44012. */
  44013. onAnimationGroupPauseObservable: Observable<AnimationGroup>;
  44014. /**
  44015. * This observable will notify when all animations are playing.
  44016. */
  44017. onAnimationGroupPlayObservable: Observable<AnimationGroup>;
  44018. /**
  44019. * Gets the first frame
  44020. */
  44021. get from(): number;
  44022. /**
  44023. * Gets the last frame
  44024. */
  44025. get to(): number;
  44026. /**
  44027. * Define if the animations are started
  44028. */
  44029. get isStarted(): boolean;
  44030. /**
  44031. * Gets a value indicating that the current group is playing
  44032. */
  44033. get isPlaying(): boolean;
  44034. /**
  44035. * Gets or sets the speed ratio to use for all animations
  44036. */
  44037. get speedRatio(): number;
  44038. /**
  44039. * Gets or sets the speed ratio to use for all animations
  44040. */
  44041. set speedRatio(value: number);
  44042. /**
  44043. * Gets or sets if all animations should loop or not
  44044. */
  44045. get loopAnimation(): boolean;
  44046. set loopAnimation(value: boolean);
  44047. /**
  44048. * Gets or sets if all animations should be evaluated additively
  44049. */
  44050. get isAdditive(): boolean;
  44051. set isAdditive(value: boolean);
  44052. /**
  44053. * Gets the targeted animations for this animation group
  44054. */
  44055. get targetedAnimations(): Array<TargetedAnimation>;
  44056. /**
  44057. * returning the list of animatables controlled by this animation group.
  44058. */
  44059. get animatables(): Array<Animatable>;
  44060. /**
  44061. * Gets the list of target animations
  44062. */
  44063. get children(): TargetedAnimation[];
  44064. /**
  44065. * Instantiates a new Animation Group.
  44066. * This helps managing several animations at once.
  44067. * @see https://doc.babylonjs.com/how_to/group
  44068. * @param name Defines the name of the group
  44069. * @param scene Defines the scene the group belongs to
  44070. */
  44071. constructor(
  44072. /** The name of the animation group */
  44073. name: string, scene?: Nullable<Scene>);
  44074. /**
  44075. * Add an animation (with its target) in the group
  44076. * @param animation defines the animation we want to add
  44077. * @param target defines the target of the animation
  44078. * @returns the TargetedAnimation object
  44079. */
  44080. addTargetedAnimation(animation: Animation, target: any): TargetedAnimation;
  44081. /**
  44082. * This function will normalize every animation in the group to make sure they all go from beginFrame to endFrame
  44083. * It can add constant keys at begin or end
  44084. * @param beginFrame defines the new begin frame for all animations or the smallest begin frame of all animations if null (defaults to null)
  44085. * @param endFrame defines the new end frame for all animations or the largest end frame of all animations if null (defaults to null)
  44086. * @returns the animation group
  44087. */
  44088. normalize(beginFrame?: Nullable<number>, endFrame?: Nullable<number>): AnimationGroup;
  44089. private _animationLoopCount;
  44090. private _animationLoopFlags;
  44091. private _processLoop;
  44092. /**
  44093. * Start all animations on given targets
  44094. * @param loop defines if animations must loop
  44095. * @param speedRatio defines the ratio to apply to animation speed (1 by default)
  44096. * @param from defines the from key (optional)
  44097. * @param to defines the to key (optional)
  44098. * @param isAdditive defines the additive state for the resulting animatables (optional)
  44099. * @returns the current animation group
  44100. */
  44101. start(loop?: boolean, speedRatio?: number, from?: number, to?: number, isAdditive?: boolean): AnimationGroup;
  44102. /**
  44103. * Pause all animations
  44104. * @returns the animation group
  44105. */
  44106. pause(): AnimationGroup;
  44107. /**
  44108. * Play all animations to initial state
  44109. * This function will start() the animations if they were not started or will restart() them if they were paused
  44110. * @param loop defines if animations must loop
  44111. * @returns the animation group
  44112. */
  44113. play(loop?: boolean): AnimationGroup;
  44114. /**
  44115. * Reset all animations to initial state
  44116. * @returns the animation group
  44117. */
  44118. reset(): AnimationGroup;
  44119. /**
  44120. * Restart animations from key 0
  44121. * @returns the animation group
  44122. */
  44123. restart(): AnimationGroup;
  44124. /**
  44125. * Stop all animations
  44126. * @returns the animation group
  44127. */
  44128. stop(): AnimationGroup;
  44129. /**
  44130. * Set animation weight for all animatables
  44131. * @param weight defines the weight to use
  44132. * @return the animationGroup
  44133. * @see https://doc.babylonjs.com/babylon101/animations#animation-weights
  44134. */
  44135. setWeightForAllAnimatables(weight: number): AnimationGroup;
  44136. /**
  44137. * Synchronize and normalize all animatables with a source animatable
  44138. * @param root defines the root animatable to synchronize with
  44139. * @return the animationGroup
  44140. * @see https://doc.babylonjs.com/babylon101/animations#animation-weights
  44141. */
  44142. syncAllAnimationsWith(root: Animatable): AnimationGroup;
  44143. /**
  44144. * Goes to a specific frame in this animation group
  44145. * @param frame the frame number to go to
  44146. * @return the animationGroup
  44147. */
  44148. goToFrame(frame: number): AnimationGroup;
  44149. /**
  44150. * Dispose all associated resources
  44151. */
  44152. dispose(): void;
  44153. private _checkAnimationGroupEnded;
  44154. /**
  44155. * Clone the current animation group and returns a copy
  44156. * @param newName defines the name of the new group
  44157. * @param targetConverter defines an optional function used to convert current animation targets to new ones
  44158. * @returns the new animation group
  44159. */
  44160. clone(newName: string, targetConverter?: (oldTarget: any) => any): AnimationGroup;
  44161. /**
  44162. * Serializes the animationGroup to an object
  44163. * @returns Serialized object
  44164. */
  44165. serialize(): any;
  44166. /**
  44167. * Returns a new AnimationGroup object parsed from the source provided.
  44168. * @param parsedAnimationGroup defines the source
  44169. * @param scene defines the scene that will receive the animationGroup
  44170. * @returns a new AnimationGroup
  44171. */
  44172. static Parse(parsedAnimationGroup: any, scene: Scene): AnimationGroup;
  44173. /**
  44174. * Convert the keyframes for all animations belonging to the group to be relative to a given reference frame.
  44175. * @param sourceAnimationGroup defines the AnimationGroup containing animations to convert
  44176. * @param referenceFrame defines the frame that keyframes in the range will be relative to
  44177. * @param range defines the name of the AnimationRange belonging to the animations in the group to convert
  44178. * @param cloneOriginal defines whether or not to clone the group and convert the clone or convert the original group (default is false)
  44179. * @param clonedName defines the name of the resulting cloned AnimationGroup if cloneOriginal is true
  44180. * @returns a new AnimationGroup if cloneOriginal is true or the original AnimationGroup if cloneOriginal is false
  44181. */
  44182. static MakeAnimationAdditive(sourceAnimationGroup: AnimationGroup, referenceFrame?: number, range?: string, cloneOriginal?: boolean, clonedName?: string): AnimationGroup;
  44183. /**
  44184. * Returns the string "AnimationGroup"
  44185. * @returns "AnimationGroup"
  44186. */
  44187. getClassName(): string;
  44188. /**
  44189. * Creates a detailed string about the object
  44190. * @param fullDetails defines if the output string will support multiple levels of logging within scene loading
  44191. * @returns a string representing the object
  44192. */
  44193. toString(fullDetails?: boolean): string;
  44194. }
  44195. }
  44196. declare module BABYLON {
  44197. /**
  44198. * @hidden
  44199. **/
  44200. export class _TimeToken {
  44201. _startTimeQuery: Nullable<WebGLQuery>;
  44202. _endTimeQuery: Nullable<WebGLQuery>;
  44203. _timeElapsedQuery: Nullable<WebGLQuery>;
  44204. _timeElapsedQueryEnded: boolean;
  44205. }
  44206. }
  44207. declare module BABYLON {
  44208. /** @hidden */
  44209. export enum ExtensionName {
  44210. DepthClamping = "depth-clamping",
  44211. Depth24UnormStencil8 = "depth24unorm-stencil8",
  44212. Depth32FloatStencil8 = "depth32float-stencil8",
  44213. PipelineStatisticsQuery = "pipeline-statistics-query",
  44214. TextureCompressionBC = "texture-compression-bc",
  44215. TimestampQuery = "timestamp-query"
  44216. }
  44217. /** @hidden */
  44218. export enum AddressMode {
  44219. ClampToEdge = "clamp-to-edge",
  44220. Repeat = "repeat",
  44221. MirrorRepeat = "mirror-repeat"
  44222. }
  44223. /** @hidden */
  44224. export enum BindingType {
  44225. UniformBuffer = "uniform-buffer",
  44226. StorageBuffer = "storage-buffer",
  44227. ReadonlyStorageBuffer = "readonly-storage-buffer",
  44228. Sampler = "sampler",
  44229. ComparisonSampler = "comparison-sampler",
  44230. SampledTexture = "sampled-texture",
  44231. ReadonlyStorageTexture = "readonly-storage-texture",
  44232. WriteonlyStorageTexture = "writeonly-storage-texture"
  44233. }
  44234. /** @hidden */
  44235. export enum BlendFactor {
  44236. Zero = "zero",
  44237. One = "one",
  44238. SrcColor = "src-color",
  44239. OneMinusSrcColor = "one-minus-src-color",
  44240. SrcAlpha = "src-alpha",
  44241. OneMinusSrcAlpha = "one-minus-src-alpha",
  44242. DstColor = "dst-color",
  44243. OneMinusDstColor = "one-minus-dst-color",
  44244. DstAlpha = "dst-alpha",
  44245. OneMinusDstAlpha = "one-minus-dst-alpha",
  44246. SrcAlphaSaturated = "src-alpha-saturated",
  44247. BlendColor = "blend-color",
  44248. OneMinusBlendColor = "one-minus-blend-color"
  44249. }
  44250. /** @hidden */
  44251. export enum BlendOperation {
  44252. Add = "add",
  44253. Subtract = "subtract",
  44254. ReverseSubtract = "reverse-subtract",
  44255. Min = "min",
  44256. Max = "max"
  44257. }
  44258. /** @hidden */
  44259. export enum CompareFunction {
  44260. Never = "never",
  44261. Less = "less",
  44262. Equal = "equal",
  44263. LessEqual = "less-equal",
  44264. Greater = "greater",
  44265. NotEqual = "not-equal",
  44266. GreaterEqual = "greater-equal",
  44267. Always = "always"
  44268. }
  44269. /** @hidden */
  44270. export enum CullMode {
  44271. None = "none",
  44272. Front = "front",
  44273. Back = "back"
  44274. }
  44275. /** @hidden */
  44276. export enum FilterMode {
  44277. Nearest = "nearest",
  44278. Linear = "linear"
  44279. }
  44280. /** @hidden */
  44281. export enum FrontFace {
  44282. CCW = "ccw",
  44283. CW = "cw"
  44284. }
  44285. /** @hidden */
  44286. export enum IndexFormat {
  44287. Uint16 = "uint16",
  44288. Uint32 = "uint32"
  44289. }
  44290. /** @hidden */
  44291. export enum InputStepMode {
  44292. Vertex = "vertex",
  44293. Instance = "instance"
  44294. }
  44295. /** @hidden */
  44296. export enum LoadOp {
  44297. Load = "load"
  44298. }
  44299. /** @hidden */
  44300. export enum PrimitiveTopology {
  44301. PointList = "point-list",
  44302. LineList = "line-list",
  44303. LineStrip = "line-strip",
  44304. TriangleList = "triangle-list",
  44305. TriangleStrip = "triangle-strip"
  44306. }
  44307. /** @hidden */
  44308. export enum StencilOperation {
  44309. Keep = "keep",
  44310. Zero = "zero",
  44311. Replace = "replace",
  44312. Invert = "invert",
  44313. IncrementClamp = "increment-clamp",
  44314. DecrementClamp = "decrement-clamp",
  44315. IncrementWrap = "increment-wrap",
  44316. DecrementWrap = "decrement-wrap"
  44317. }
  44318. /** @hidden */
  44319. export enum StoreOp {
  44320. Store = "store",
  44321. Clear = "clear"
  44322. }
  44323. /** @hidden */
  44324. export enum TextureDimension {
  44325. E1d = "1d",
  44326. E2d = "2d",
  44327. E3d = "3d"
  44328. }
  44329. /** @hidden */
  44330. export enum TextureFormat {
  44331. R8Unorm = "r8unorm",
  44332. R8Snorm = "r8snorm",
  44333. R8Uint = "r8uint",
  44334. R8Sint = "r8sint",
  44335. R16Uint = "r16uint",
  44336. R16Sint = "r16sint",
  44337. R16Float = "r16float",
  44338. RG8Unorm = "rg8unorm",
  44339. RG8Snorm = "rg8snorm",
  44340. RG8Uint = "rg8uint",
  44341. RG8Sint = "rg8sint",
  44342. R32Uint = "r32uint",
  44343. R32Sint = "r32sint",
  44344. R32Float = "r32float",
  44345. RG16Uint = "rg16uint",
  44346. RG16Sint = "rg16sint",
  44347. RG16Float = "rg16float",
  44348. RGBA8Unorm = "rgba8unorm",
  44349. RGBA8UnormSRGB = "rgba8unorm-srgb",
  44350. RGBA8Snorm = "rgba8snorm",
  44351. RGBA8Uint = "rgba8uint",
  44352. RGBA8Sint = "rgba8sint",
  44353. BGRA8Unorm = "bgra8unorm",
  44354. BGRA8UnormSRGB = "bgra8unorm-srgb",
  44355. RGB9E5UFloat = "rgb9e5ufloat",
  44356. RGB10A2Unorm = "rgb10a2unorm",
  44357. RG11B10UFloat = "rg11b10ufloat",
  44358. RG32Uint = "rg32uint",
  44359. RG32Sint = "rg32sint",
  44360. RG32Float = "rg32float",
  44361. RGBA16Uint = "rgba16uint",
  44362. RGBA16Sint = "rgba16sint",
  44363. RGBA16Float = "rgba16float",
  44364. RGBA32Uint = "rgba32uint",
  44365. RGBA32Sint = "rgba32sint",
  44366. RGBA32Float = "rgba32float",
  44367. Stencil8 = "stencil8",
  44368. Depth16Unorm = "depth16unorm",
  44369. Depth24Plus = "depth24plus",
  44370. Depth24PlusStencil8 = "depth24plus-stencil8",
  44371. Depth32Float = "depth32float",
  44372. BC1RGBAUNorm = "bc1-rgba-unorm",
  44373. BC1RGBAUnormSRGB = "bc1-rgba-unorm-srgb",
  44374. BC2RGBAUnorm = "bc2-rgba-unorm",
  44375. BC2RGBAUnormSRGB = "bc2-rgba-unorm-srgb",
  44376. BC3RGBAUnorm = "bc3-rgba-unorm",
  44377. BC3RGBAUnormSRGB = "bc3-rgba-unorm-srgb",
  44378. BC4RUnorm = "bc4-r-unorm",
  44379. BC4RSnorm = "bc4-r-snorm",
  44380. BC5RGUnorm = "bc5-rg-unorm",
  44381. BC5RGSnorm = "bc5-rg-snorm",
  44382. BC6HRGBUFloat = "bc6h-rgb-ufloat",
  44383. BC6HRGBFloat = "bc6h-rgb-float",
  44384. BC7RGBAUnorm = "bc7-rgba-unorm",
  44385. BC7RGBAUnormSRGB = "bc7-rgba-unorm-srgb",
  44386. Depth24UnormStencil8 = "depth24unorm-stencil8",
  44387. Depth32FloatStencil8 = "depth32float-stencil8"
  44388. }
  44389. /** @hidden */
  44390. export enum TextureComponentType {
  44391. Float = "float",
  44392. Sint = "sint",
  44393. Uint = "uint",
  44394. DepthComparison = "depth-comparison"
  44395. }
  44396. /** @hidden */
  44397. export enum TextureViewDimension {
  44398. E1d = "1d",
  44399. E2d = "2d",
  44400. E2dArray = "2d-array",
  44401. Cube = "cube",
  44402. CubeArray = "cube-array",
  44403. E3d = "3d"
  44404. }
  44405. /** @hidden */
  44406. export enum VertexFormat {
  44407. Uchar2 = "uchar2",
  44408. Uchar4 = "uchar4",
  44409. Char2 = "char2",
  44410. Char4 = "char4",
  44411. Uchar2Norm = "uchar2norm",
  44412. Uchar4Norm = "uchar4norm",
  44413. Char2Norm = "char2norm",
  44414. Char4Norm = "char4norm",
  44415. Ushort2 = "ushort2",
  44416. Ushort4 = "ushort4",
  44417. Short2 = "short2",
  44418. Short4 = "short4",
  44419. Ushort2Norm = "ushort2norm",
  44420. Ushort4Norm = "ushort4norm",
  44421. Short2Norm = "short2norm",
  44422. Short4Norm = "short4norm",
  44423. Half2 = "half2",
  44424. Half4 = "half4",
  44425. Float = "float",
  44426. Float2 = "float2",
  44427. Float3 = "float3",
  44428. Float4 = "float4",
  44429. Uint = "uint",
  44430. Uint2 = "uint2",
  44431. Uint3 = "uint3",
  44432. Uint4 = "uint4",
  44433. Int = "int",
  44434. Int2 = "int2",
  44435. Int3 = "int3",
  44436. Int4 = "int4"
  44437. }
  44438. /** @hidden */
  44439. export enum TextureAspect {
  44440. All = "all",
  44441. StencilOnly = "stencil-only",
  44442. DepthOnly = "depth-only"
  44443. }
  44444. /** @hidden */
  44445. export enum CompilationMessageType {
  44446. Error = "error",
  44447. Warning = "warning",
  44448. Info = "info"
  44449. }
  44450. /** @hidden */
  44451. export enum QueryType {
  44452. Occlusion = "occlusion"
  44453. }
  44454. /** @hidden */
  44455. export enum BufferUsage {
  44456. MapRead = 1,
  44457. MapWrite = 2,
  44458. CopySrc = 4,
  44459. CopyDst = 8,
  44460. Index = 16,
  44461. Vertex = 32,
  44462. Uniform = 64,
  44463. Storage = 128,
  44464. Indirect = 256,
  44465. QueryResolve = 512
  44466. }
  44467. /** @hidden */
  44468. export enum ColorWrite {
  44469. Red = 1,
  44470. Green = 2,
  44471. Blue = 4,
  44472. Alpha = 8,
  44473. All = 15
  44474. }
  44475. /** @hidden */
  44476. export enum ShaderStage {
  44477. Vertex = 1,
  44478. Fragment = 2,
  44479. Compute = 4
  44480. }
  44481. /** @hidden */
  44482. export enum TextureUsage {
  44483. CopySrc = 1,
  44484. CopyDst = 2,
  44485. Sampled = 4,
  44486. Storage = 8,
  44487. OutputAttachment = 16
  44488. }
  44489. /** @hidden */
  44490. export enum MapMode {
  44491. Read = 1,
  44492. Write = 2
  44493. }
  44494. }
  44495. declare module BABYLON {
  44496. /** @hidden */
  44497. export interface WebGPUBindingInfo {
  44498. setIndex: number;
  44499. bindingIndex: number;
  44500. }
  44501. /** @hidden */
  44502. export interface WebGPUTextureSamplerBindingDescription {
  44503. sampler: WebGPUBindingInfo;
  44504. isTextureArray: boolean;
  44505. textures: Array<WebGPUBindingInfo>;
  44506. }
  44507. /** @hidden
  44508. * If the binding is a UBO, isSampler=isTexture=false
  44509. */
  44510. export interface WebGPUBindingDescription {
  44511. name: string;
  44512. usedInVertex: boolean;
  44513. usedInFragment: boolean;
  44514. isSampler: boolean;
  44515. isComparisonSampler?: boolean;
  44516. isTexture: boolean;
  44517. componentType?: GPUTextureComponentType;
  44518. textureDimension?: GPUTextureViewDimension;
  44519. }
  44520. /**
  44521. * @hidden
  44522. */
  44523. export class WebGPUShaderProcessingContext implements ShaderProcessingContext {
  44524. uboNextBindingIndex: number;
  44525. freeSetIndex: number;
  44526. freeBindingIndex: number;
  44527. availableVaryings: {
  44528. [key: string]: number;
  44529. };
  44530. availableAttributes: {
  44531. [key: string]: number;
  44532. };
  44533. availableUBOs: {
  44534. [key: string]: {
  44535. setIndex: number;
  44536. bindingIndex: number;
  44537. };
  44538. };
  44539. availableSamplers: {
  44540. [key: string]: WebGPUTextureSamplerBindingDescription;
  44541. };
  44542. leftOverUniforms: {
  44543. name: string;
  44544. type: string;
  44545. length: number;
  44546. }[];
  44547. orderedAttributes: string[];
  44548. orderedUBOsAndSamplers: WebGPUBindingDescription[][];
  44549. uniformBufferNames: string[];
  44550. private _attributeNextLocation;
  44551. private _varyingNextLocation;
  44552. constructor();
  44553. getAttributeNextLocation(dataType: string, arrayLength?: number): number;
  44554. getVaryingNextLocation(dataType: string, arrayLength?: number): number;
  44555. getNextFreeUBOBinding(): {
  44556. setIndex: number;
  44557. bindingIndex: number;
  44558. };
  44559. private _getNextFreeBinding;
  44560. }
  44561. }
  44562. declare module BABYLON {
  44563. /** @hidden */
  44564. export interface IWebGPUPipelineContextSamplerCache {
  44565. samplerBinding: number;
  44566. firstTextureName: string;
  44567. }
  44568. /** @hidden */
  44569. export interface IWebGPUPipelineContextTextureCache {
  44570. textureBinding: number;
  44571. texture: InternalTexture;
  44572. }
  44573. /** @hidden */
  44574. export interface IWebGPUPipelineContextVertexInputsCache {
  44575. indexBuffer: Nullable<GPUBuffer>;
  44576. indexOffset: number;
  44577. vertexStartSlot: number;
  44578. vertexBuffers: GPUBuffer[];
  44579. vertexOffsets: number[];
  44580. }
  44581. /** @hidden */
  44582. export interface IWebGPURenderPipelineStageDescriptor {
  44583. vertexStage: GPUProgrammableStageDescriptor;
  44584. fragmentStage?: GPUProgrammableStageDescriptor;
  44585. }
  44586. /** @hidden */
  44587. export class WebGPUPipelineContext implements IPipelineContext {
  44588. engine: WebGPUEngine;
  44589. shaderProcessingContext: WebGPUShaderProcessingContext;
  44590. leftOverUniformsByName: {
  44591. [name: string]: string;
  44592. };
  44593. sources: {
  44594. vertex: string;
  44595. fragment: string;
  44596. rawVertex: string;
  44597. rawFragment: string;
  44598. };
  44599. stages: Nullable<IWebGPURenderPipelineStageDescriptor>;
  44600. samplers: {
  44601. [name: string]: Nullable<IWebGPUPipelineContextSamplerCache>;
  44602. };
  44603. textures: {
  44604. [name: string]: Nullable<IWebGPUPipelineContextTextureCache>;
  44605. };
  44606. bindGroupLayouts: GPUBindGroupLayout[];
  44607. bindGroupsCache: {
  44608. [key: string]: GPUBindGroup[];
  44609. };
  44610. /**
  44611. * Stores the uniform buffer
  44612. */
  44613. uniformBuffer: Nullable<UniformBuffer>;
  44614. onCompiled?: () => void;
  44615. get isAsync(): boolean;
  44616. get isReady(): boolean;
  44617. /** @hidden */
  44618. _name: string;
  44619. constructor(shaderProcessingContext: WebGPUShaderProcessingContext, engine: WebGPUEngine);
  44620. _handlesSpectorRebuildCallback(onCompiled: (program: any) => void): void;
  44621. _fillEffectInformation(effect: Effect, uniformBuffersNames: {
  44622. [key: string]: number;
  44623. }, uniformsNames: string[], uniforms: {
  44624. [key: string]: Nullable<WebGLUniformLocation>;
  44625. }, samplerList: string[], samplers: {
  44626. [key: string]: number;
  44627. }, attributesNames: string[], attributes: number[]): void;
  44628. /** @hidden */
  44629. /**
  44630. * Build the uniform buffer used in the material.
  44631. */
  44632. buildUniformLayout(): void;
  44633. /**
  44634. * Release all associated resources.
  44635. **/
  44636. dispose(): void;
  44637. /**
  44638. * Sets an integer value on a uniform variable.
  44639. * @param uniformName Name of the variable.
  44640. * @param value Value to be set.
  44641. */
  44642. setInt(uniformName: string, value: number): void;
  44643. /**
  44644. * Sets an int2 value on a uniform variable.
  44645. * @param uniformName Name of the variable.
  44646. * @param x First int in int2.
  44647. * @param y Second int in int2.
  44648. */
  44649. setInt2(uniformName: string, x: number, y: number): void;
  44650. /**
  44651. * Sets an int3 value on a uniform variable.
  44652. * @param uniformName Name of the variable.
  44653. * @param x First int in int3.
  44654. * @param y Second int in int3.
  44655. * @param z Third int in int3.
  44656. */
  44657. setInt3(uniformName: string, x: number, y: number, z: number): void;
  44658. /**
  44659. * Sets an int4 value on a uniform variable.
  44660. * @param uniformName Name of the variable.
  44661. * @param x First int in int4.
  44662. * @param y Second int in int4.
  44663. * @param z Third int in int4.
  44664. * @param w Fourth int in int4.
  44665. */
  44666. setInt4(uniformName: string, x: number, y: number, z: number, w: number): void;
  44667. /**
  44668. * Sets an int array on a uniform variable.
  44669. * @param uniformName Name of the variable.
  44670. * @param array array to be set.
  44671. */
  44672. setIntArray(uniformName: string, array: Int32Array): void;
  44673. /**
  44674. * 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)
  44675. * @param uniformName Name of the variable.
  44676. * @param array array to be set.
  44677. */
  44678. setIntArray2(uniformName: string, array: Int32Array): void;
  44679. /**
  44680. * 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)
  44681. * @param uniformName Name of the variable.
  44682. * @param array array to be set.
  44683. */
  44684. setIntArray3(uniformName: string, array: Int32Array): void;
  44685. /**
  44686. * 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)
  44687. * @param uniformName Name of the variable.
  44688. * @param array array to be set.
  44689. */
  44690. setIntArray4(uniformName: string, array: Int32Array): void;
  44691. /**
  44692. * Sets an array on a uniform variable.
  44693. * @param uniformName Name of the variable.
  44694. * @param array array to be set.
  44695. */
  44696. setArray(uniformName: string, array: number[]): void;
  44697. /**
  44698. * 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)
  44699. * @param uniformName Name of the variable.
  44700. * @param array array to be set.
  44701. */
  44702. setArray2(uniformName: string, array: number[]): void;
  44703. /**
  44704. * 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)
  44705. * @param uniformName Name of the variable.
  44706. * @param array array to be set.
  44707. * @returns this effect.
  44708. */
  44709. setArray3(uniformName: string, array: number[]): void;
  44710. /**
  44711. * 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)
  44712. * @param uniformName Name of the variable.
  44713. * @param array array to be set.
  44714. */
  44715. setArray4(uniformName: string, array: number[]): void;
  44716. /**
  44717. * Sets matrices on a uniform variable.
  44718. * @param uniformName Name of the variable.
  44719. * @param matrices matrices to be set.
  44720. */
  44721. setMatrices(uniformName: string, matrices: Float32Array): void;
  44722. /**
  44723. * Sets matrix on a uniform variable.
  44724. * @param uniformName Name of the variable.
  44725. * @param matrix matrix to be set.
  44726. */
  44727. setMatrix(uniformName: string, matrix: IMatrixLike): void;
  44728. /**
  44729. * Sets a 3x3 matrix on a uniform variable. (Specified as [1,2,3,4,5,6,7,8,9] will result in [1,2,3][4,5,6][7,8,9] matrix)
  44730. * @param uniformName Name of the variable.
  44731. * @param matrix matrix to be set.
  44732. */
  44733. setMatrix3x3(uniformName: string, matrix: Float32Array): void;
  44734. /**
  44735. * Sets a 2x2 matrix on a uniform variable. (Specified as [1,2,3,4] will result in [1,2][3,4] matrix)
  44736. * @param uniformName Name of the variable.
  44737. * @param matrix matrix to be set.
  44738. */
  44739. setMatrix2x2(uniformName: string, matrix: Float32Array): void;
  44740. /**
  44741. * Sets a float on a uniform variable.
  44742. * @param uniformName Name of the variable.
  44743. * @param value value to be set.
  44744. * @returns this effect.
  44745. */
  44746. setFloat(uniformName: string, value: number): void;
  44747. /**
  44748. * Sets a Vector2 on a uniform variable.
  44749. * @param uniformName Name of the variable.
  44750. * @param vector2 vector2 to be set.
  44751. */
  44752. setVector2(uniformName: string, vector2: IVector2Like): void;
  44753. /**
  44754. * Sets a float2 on a uniform variable.
  44755. * @param uniformName Name of the variable.
  44756. * @param x First float in float2.
  44757. * @param y Second float in float2.
  44758. */
  44759. setFloat2(uniformName: string, x: number, y: number): void;
  44760. /**
  44761. * Sets a Vector3 on a uniform variable.
  44762. * @param uniformName Name of the variable.
  44763. * @param vector3 Value to be set.
  44764. */
  44765. setVector3(uniformName: string, vector3: IVector3Like): void;
  44766. /**
  44767. * Sets a float3 on a uniform variable.
  44768. * @param uniformName Name of the variable.
  44769. * @param x First float in float3.
  44770. * @param y Second float in float3.
  44771. * @param z Third float in float3.
  44772. */
  44773. setFloat3(uniformName: string, x: number, y: number, z: number): void;
  44774. /**
  44775. * Sets a Vector4 on a uniform variable.
  44776. * @param uniformName Name of the variable.
  44777. * @param vector4 Value to be set.
  44778. */
  44779. setVector4(uniformName: string, vector4: IVector4Like): void;
  44780. /**
  44781. * Sets a float4 on a uniform variable.
  44782. * @param uniformName Name of the variable.
  44783. * @param x First float in float4.
  44784. * @param y Second float in float4.
  44785. * @param z Third float in float4.
  44786. * @param w Fourth float in float4.
  44787. * @returns this effect.
  44788. */
  44789. setFloat4(uniformName: string, x: number, y: number, z: number, w: number): void;
  44790. /**
  44791. * Sets a Color3 on a uniform variable.
  44792. * @param uniformName Name of the variable.
  44793. * @param color3 Value to be set.
  44794. */
  44795. setColor3(uniformName: string, color3: IColor3Like): void;
  44796. /**
  44797. * Sets a Color4 on a uniform variable.
  44798. * @param uniformName Name of the variable.
  44799. * @param color3 Value to be set.
  44800. * @param alpha Alpha value to be set.
  44801. */
  44802. setColor4(uniformName: string, color3: IColor3Like, alpha: number): void;
  44803. /**
  44804. * Sets a Color4 on a uniform variable
  44805. * @param uniformName defines the name of the variable
  44806. * @param color4 defines the value to be set
  44807. */
  44808. setDirectColor4(uniformName: string, color4: IColor4Like): void;
  44809. _getVertexShaderCode(): string | null;
  44810. _getFragmentShaderCode(): string | null;
  44811. }
  44812. }
  44813. declare module BABYLON {
  44814. /** @hidden */
  44815. export class WebGPUDataBuffer extends DataBuffer {
  44816. private _buffer;
  44817. constructor(resource: GPUBuffer);
  44818. get underlyingResource(): any;
  44819. }
  44820. }
  44821. declare module BABYLON {
  44822. /**
  44823. * Class used to inline functions in shader code
  44824. */
  44825. export class ShaderCodeInliner {
  44826. private static readonly _RegexpFindFunctionNameAndType;
  44827. private _sourceCode;
  44828. private _functionDescr;
  44829. private _numMaxIterations;
  44830. /** Gets or sets the token used to mark the functions to inline */
  44831. inlineToken: string;
  44832. /** Gets or sets the debug mode */
  44833. debug: boolean;
  44834. /** Gets the code after the inlining process */
  44835. get code(): string;
  44836. /**
  44837. * Initializes the inliner
  44838. * @param sourceCode shader code source to inline
  44839. * @param numMaxIterations maximum number of iterations (used to detect recursive calls)
  44840. */
  44841. constructor(sourceCode: string, numMaxIterations?: number);
  44842. /**
  44843. * Start the processing of the shader code
  44844. */
  44845. processCode(): void;
  44846. private _collectFunctions;
  44847. private _processInlining;
  44848. private _extractBetweenMarkers;
  44849. private _skipWhitespaces;
  44850. private _isIdentifierChar;
  44851. private _removeComments;
  44852. private _replaceFunctionCallsByCode;
  44853. private _findBackward;
  44854. private _escapeRegExp;
  44855. private _replaceNames;
  44856. }
  44857. }
  44858. declare module BABYLON {
  44859. /** @hidden */
  44860. export class WebGPUShaderProcessor implements IShaderProcessor {
  44861. protected _missingVaryings: Array<string>;
  44862. protected _textureArrayProcessing: Array<string>;
  44863. protected _preProcessors: {
  44864. [key: string]: string;
  44865. };
  44866. private _getArraySize;
  44867. initializeShaders(processingContext: Nullable<ShaderProcessingContext>): void;
  44868. varyingProcessor(varying: string, isFragment: boolean, preProcessors: {
  44869. [key: string]: string;
  44870. }, processingContext: Nullable<ShaderProcessingContext>): string;
  44871. attributeProcessor(attribute: string, preProcessors: {
  44872. [key: string]: string;
  44873. }, processingContext: Nullable<ShaderProcessingContext>): string;
  44874. uniformProcessor(uniform: string, isFragment: boolean, preProcessors: {
  44875. [key: string]: string;
  44876. }, processingContext: Nullable<ShaderProcessingContext>): string;
  44877. uniformBufferProcessor(uniformBuffer: string, isFragment: boolean, processingContext: Nullable<ShaderProcessingContext>): string;
  44878. postProcessor(code: string, defines: string[], isFragment: boolean, processingContext: Nullable<ShaderProcessingContext>): string;
  44879. private _applyTextureArrayProcessing;
  44880. finalizeShaders(vertexCode: string, fragmentCode: string, processingContext: Nullable<ShaderProcessingContext>): {
  44881. vertexCode: string;
  44882. fragmentCode: string;
  44883. };
  44884. }
  44885. }
  44886. declare module BABYLON {
  44887. /** @hidden */
  44888. export class WebGPUBufferManager {
  44889. private _device;
  44890. private _deferredReleaseBuffers;
  44891. private static _IsGPUBuffer;
  44892. constructor(device: GPUDevice);
  44893. createRawBuffer(viewOrSize: ArrayBufferView | number, flags: GPUBufferUsageFlags, mappedAtCreation?: boolean): GPUBuffer;
  44894. createBuffer(viewOrSize: ArrayBufferView | number, flags: GPUBufferUsageFlags): DataBuffer;
  44895. setSubData(dataBuffer: WebGPUDataBuffer, dstByteOffset: number, src: ArrayBufferView, srcByteOffset?: number, byteLength?: number): void;
  44896. private _FromHalfFloat;
  44897. private _GetHalfFloatAsFloatRGBAArrayBuffer;
  44898. readDataFromBuffer(gpuBuffer: GPUBuffer, size: number, width: number, height: number, bytesPerRow: number, bytesPerRowAligned: number, floatFormat?: number, offset?: number, buffer?: Nullable<ArrayBufferView>, destroyBuffer?: boolean): Promise<ArrayBufferView>;
  44899. releaseBuffer(buffer: DataBuffer | GPUBuffer): boolean;
  44900. destroyDeferredBuffers(): void;
  44901. }
  44902. }
  44903. declare module BABYLON {
  44904. /** @hidden */
  44905. export class WebGPUHardwareTexture implements HardwareTextureWrapper {
  44906. private _webgpuTexture;
  44907. private _webgpuMSAATexture;
  44908. get underlyingResource(): Nullable<GPUTexture>;
  44909. get msaaTexture(): Nullable<GPUTexture>;
  44910. set msaaTexture(texture: Nullable<GPUTexture>);
  44911. view: Nullable<GPUTextureView>;
  44912. format: GPUTextureFormat;
  44913. textureUsages: number;
  44914. constructor(existingTexture?: Nullable<GPUTexture>);
  44915. set(hardwareTexture: GPUTexture): void;
  44916. setMSAATexture(hardwareTexture: GPUTexture): void;
  44917. setUsage(textureSource: number, generateMipMaps: boolean, isCube: boolean, width: number, height: number): void;
  44918. createView(descriptor?: GPUTextureViewDescriptor): void;
  44919. reset(): void;
  44920. release(): void;
  44921. }
  44922. }
  44923. declare module BABYLON {
  44924. /** @hidden */
  44925. export class WebGPUTextureHelper {
  44926. private _device;
  44927. private _glslang;
  44928. private _bufferManager;
  44929. private _mipmapSampler;
  44930. private _invertYPreMultiplyAlphaSampler;
  44931. private _pipelines;
  44932. private _compiledShaders;
  44933. private _deferredReleaseTextures;
  44934. private _commandEncoderForCreation;
  44935. static ComputeNumMipmapLevels(width: number, height: number): number;
  44936. constructor(device: GPUDevice, glslang: any, bufferManager: WebGPUBufferManager);
  44937. private _getPipeline;
  44938. private static _GetTextureTypeFromFormat;
  44939. private static _GetBlockInformationFromFormat;
  44940. private static _IsHardwareTexture;
  44941. private static _IsInternalTexture;
  44942. static GetCompareFunction(compareFunction: Nullable<number>): GPUCompareFunction;
  44943. static IsImageBitmap(imageBitmap: ImageBitmap | {
  44944. width: number;
  44945. height: number;
  44946. }): imageBitmap is ImageBitmap;
  44947. static IsImageBitmapArray(imageBitmap: ImageBitmap[] | {
  44948. width: number;
  44949. height: number;
  44950. }): imageBitmap is ImageBitmap[];
  44951. setCommandEncoder(encoder: GPUCommandEncoder): void;
  44952. static IsCompressedFormat(format: GPUTextureFormat): boolean;
  44953. static GetWebGPUTextureFormat(type: number, format: number): GPUTextureFormat;
  44954. invertYPreMultiplyAlpha(gpuTexture: GPUTexture, width: number, height: number, format: GPUTextureFormat, invertY?: boolean, premultiplyAlpha?: boolean, faceIndex?: number, commandEncoder?: GPUCommandEncoder): void;
  44955. clear(format: GPUTextureFormat, color: IColor4Like, passEncoder: GPURenderPassEncoder): void;
  44956. createTexture(imageBitmap: ImageBitmap | {
  44957. width: number;
  44958. height: number;
  44959. layers: number;
  44960. }, hasMipmaps?: boolean, generateMipmaps?: boolean, invertY?: boolean, premultiplyAlpha?: boolean, is3D?: boolean, format?: GPUTextureFormat, sampleCount?: number, commandEncoder?: GPUCommandEncoder, usage?: number): GPUTexture;
  44961. createCubeTexture(imageBitmaps: ImageBitmap[] | {
  44962. width: number;
  44963. height: number;
  44964. }, hasMipmaps?: boolean, generateMipmaps?: boolean, invertY?: boolean, premultiplyAlpha?: boolean, format?: GPUTextureFormat, sampleCount?: number, commandEncoder?: GPUCommandEncoder, usage?: number): GPUTexture;
  44965. generateCubeMipmaps(gpuTexture: GPUTexture, format: GPUTextureFormat, mipLevelCount: number, commandEncoder?: GPUCommandEncoder): void;
  44966. generateMipmaps(gpuTexture: GPUTexture, format: GPUTextureFormat, mipLevelCount: number, faceIndex?: number, commandEncoder?: GPUCommandEncoder): void;
  44967. createGPUTextureForInternalTexture(texture: InternalTexture, width?: number, height?: number, depth?: number): WebGPUHardwareTexture;
  44968. createMSAATexture(texture: InternalTexture, samples: number): void;
  44969. updateCubeTextures(imageBitmaps: ImageBitmap[] | Uint8Array[], gpuTexture: GPUTexture, width: number, height: number, format: GPUTextureFormat, invertY?: boolean, premultiplyAlpha?: boolean, offsetX?: number, offsetY?: number, commandEncoder?: GPUCommandEncoder): void;
  44970. 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;
  44971. readPixels(texture: GPUTexture, x: number, y: number, width: number, height: number, format: GPUTextureFormat, faceIndex?: number, mipLevel?: number, buffer?: Nullable<ArrayBufferView>): Promise<ArrayBufferView>;
  44972. releaseTexture(texture: InternalTexture | GPUTexture): void;
  44973. destroyDeferredTextures(): void;
  44974. }
  44975. }
  44976. declare module BABYLON {
  44977. /** @hidden */
  44978. export class WebGPURenderPassWrapper {
  44979. renderPassDescriptor: Nullable<GPURenderPassDescriptor>;
  44980. renderPass: Nullable<GPURenderPassEncoder>;
  44981. colorAttachmentViewDescriptor: Nullable<GPUTextureViewDescriptor>;
  44982. depthAttachmentViewDescriptor: Nullable<GPUTextureViewDescriptor>;
  44983. colorAttachmentGPUTextures: WebGPUHardwareTexture[];
  44984. depthTextureFormat: GPUTextureFormat | undefined;
  44985. constructor();
  44986. reset(fullReset?: boolean): void;
  44987. }
  44988. }
  44989. declare module BABYLON {
  44990. /** @hidden */
  44991. export class WebGPUCacheSampler {
  44992. private _samplers;
  44993. private _device;
  44994. disabled: boolean;
  44995. constructor(device: GPUDevice);
  44996. private static _GetSamplerHashCode;
  44997. private static _GetSamplerFilterDescriptor;
  44998. private static _GetWrappingMode;
  44999. private static _GetSamplerWrappingDescriptor;
  45000. private static _GetSamplerDescriptor;
  45001. getSampler(internalTexture: InternalTexture, bypassCache?: boolean): GPUSampler;
  45002. }
  45003. }
  45004. declare module BABYLON {
  45005. /** @hidden */
  45006. export class WebGPUShaderManager {
  45007. private _shaders;
  45008. private _device;
  45009. constructor(device: GPUDevice);
  45010. getCompiledShaders(name: string): IWebGPURenderPipelineStageDescriptor;
  45011. }
  45012. }
  45013. declare module BABYLON {
  45014. /** @hidden */
  45015. export class WebGPUCacheRenderPipeline {
  45016. static NumCacheHitWithoutHash: number;
  45017. static NumCacheHitWithHash: number;
  45018. static NumCacheMiss: number;
  45019. static NumPipelineCreationLastFrame: number;
  45020. disabled: boolean;
  45021. private static _Cache;
  45022. private static _NumPipelineCreationCurrentFrame;
  45023. private _device;
  45024. private _states;
  45025. private _isDirty;
  45026. private _currentRenderPipeline;
  45027. private _emptyVertexBuffer;
  45028. private _shaderId;
  45029. private _alphaToCoverageEnabled;
  45030. private _frontFace;
  45031. private _cullEnabled;
  45032. private _cullFace;
  45033. private _clampDepth;
  45034. private _rasterizationState;
  45035. private _depthBias;
  45036. private _depthBiasClamp;
  45037. private _depthBiasSlopeScale;
  45038. private _colorFormat;
  45039. private _webgpuColorFormat;
  45040. private _mrtAttachments1;
  45041. private _mrtAttachments2;
  45042. private _mrtFormats;
  45043. private _alphaBlendEnabled;
  45044. private _alphaBlendFuncParams;
  45045. private _alphaBlendEqParams;
  45046. private _writeMask;
  45047. private _colorStates;
  45048. private _depthStencilFormat;
  45049. private _webgpuDepthStencilFormat;
  45050. private _depthTestEnabled;
  45051. private _depthWriteEnabled;
  45052. private _depthCompare;
  45053. private _stencilEnabled;
  45054. private _stencilFrontCompare;
  45055. private _stencilFrontDepthFailOp;
  45056. private _stencilFrontPassOp;
  45057. private _stencilFrontFailOp;
  45058. private _stencilReadMask;
  45059. private _stencilWriteMask;
  45060. private _depthStencilState;
  45061. private _vertexBuffers;
  45062. private _overrideVertexBuffers;
  45063. private _indexBuffer;
  45064. constructor(device: GPUDevice, emptyVertexBuffer: VertexBuffer);
  45065. reset(): void;
  45066. getRenderPipeline(fillMode: number, effect: Effect, sampleCount: number): GPURenderPipeline;
  45067. endFrame(): void;
  45068. setAlphaToCoverage(enabled: boolean): void;
  45069. setFrontFace(frontFace: number): void;
  45070. setCullEnabled(enabled: boolean): void;
  45071. setCullFace(cullFace: number): void;
  45072. setClampDepth(clampDepth: boolean): void;
  45073. resetDepthCullingState(): void;
  45074. setDepthCullingState(cullEnabled: boolean, frontFace: number, cullFace: number, zOffset: number, depthTestEnabled: boolean, depthWriteEnabled: boolean, depthCompare: Nullable<number>): void;
  45075. setDepthBiasSlopeScale(depthBiasSlopeScale: number): void;
  45076. setColorFormat(format: GPUTextureFormat): void;
  45077. setMRTAttachments(attachments: number[], textureArray: InternalTexture[]): void;
  45078. setAlphaBlendEnabled(enabled: boolean): void;
  45079. setAlphaBlendFactors(factors: Array<Nullable<number>>, operations: Array<Nullable<number>>): void;
  45080. setWriteMask(mask: number): void;
  45081. setDepthStencilFormat(format: GPUTextureFormat | undefined): void;
  45082. setDepthTestEnabled(enabled: boolean): void;
  45083. setDepthWriteEnabled(enabled: boolean): void;
  45084. setDepthCompare(func: Nullable<number>): void;
  45085. setStencilEnabled(enabled: boolean): void;
  45086. setStencilCompare(func: Nullable<number>): void;
  45087. setStencilDepthFailOp(op: Nullable<number>): void;
  45088. setStencilPassOp(op: Nullable<number>): void;
  45089. setStencilFailOp(op: Nullable<number>): void;
  45090. setStencilReadMask(mask: number): void;
  45091. setStencilWriteMask(mask: number): void;
  45092. resetStencilState(): void;
  45093. setStencilState(stencilEnabled: boolean, compare: Nullable<number>, depthFailOp: Nullable<number>, passOp: Nullable<number>, failOp: Nullable<number>, readMask: number, writeMask: number): void;
  45094. setBuffers(vertexBuffers: Nullable<{
  45095. [key: string]: Nullable<VertexBuffer>;
  45096. }>, indexBuffer: Nullable<DataBuffer>, overrideVertexBuffers: Nullable<{
  45097. [key: string]: Nullable<VertexBuffer>;
  45098. }>): void;
  45099. private static _GetTopology;
  45100. private static _GetAphaBlendOperation;
  45101. private static _GetAphaBlendFactor;
  45102. private static _GetCompareFunction;
  45103. private static _GetStencilOpFunction;
  45104. private static _GetVertexInputDescriptorFormat;
  45105. private _getAphaBlendState;
  45106. private _getColorBlendState;
  45107. private _setShaderStage;
  45108. private _setRasterizationState;
  45109. private _setColorStates;
  45110. private _setDepthStencilState;
  45111. private _setVertexState;
  45112. private _createPipelineLayout;
  45113. private _getVertexInputDescriptor;
  45114. private _createRenderPipeline;
  45115. }
  45116. }
  45117. declare module BABYLON {
  45118. /** @hidden */
  45119. export var clearQuadVertexShader: {
  45120. name: string;
  45121. shader: string;
  45122. };
  45123. }
  45124. declare module BABYLON {
  45125. /** @hidden */
  45126. export var clearQuadPixelShader: {
  45127. name: string;
  45128. shader: string;
  45129. };
  45130. }
  45131. declare module BABYLON {
  45132. /**
  45133. * Options to load the associated Glslang library
  45134. */
  45135. export interface GlslangOptions {
  45136. /**
  45137. * Defines an existing instance of Glslang (useful in modules who do not access the global instance).
  45138. */
  45139. glslang?: any;
  45140. /**
  45141. * Defines the URL of the glslang JS File.
  45142. */
  45143. jsPath?: string;
  45144. /**
  45145. * Defines the URL of the glslang WASM File.
  45146. */
  45147. wasmPath?: string;
  45148. }
  45149. /**
  45150. * Options to create the WebGPU engine
  45151. */
  45152. export interface WebGPUEngineOptions extends GPURequestAdapterOptions {
  45153. /**
  45154. * If delta time between frames should be constant
  45155. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  45156. */
  45157. deterministicLockstep?: boolean;
  45158. /**
  45159. * Maximum about of steps between frames (Default: 4)
  45160. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  45161. */
  45162. lockstepMaxSteps?: number;
  45163. /**
  45164. * Defines the seconds between each deterministic lock step
  45165. */
  45166. timeStep?: number;
  45167. /**
  45168. * Defines that engine should ignore modifying touch action attribute and style
  45169. * If not handle, you might need to set it up on your side for expected touch devices behavior.
  45170. */
  45171. doNotHandleTouchAction?: boolean;
  45172. /**
  45173. * Defines if webaudio should be initialized as well
  45174. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  45175. */
  45176. audioEngine?: boolean;
  45177. /**
  45178. * Defines the category of adapter to use.
  45179. * Is it the discrete or integrated device.
  45180. */
  45181. powerPreference?: GPUPowerPreference;
  45182. /**
  45183. * Defines the device descriptor used to create a device.
  45184. */
  45185. deviceDescriptor?: GPUDeviceDescriptor;
  45186. /**
  45187. * Defines the requested Swap Chain Format.
  45188. */
  45189. swapChainFormat?: GPUTextureFormat;
  45190. /**
  45191. * Defines whether MSAA is enabled on the canvas.
  45192. */
  45193. antialiasing?: boolean;
  45194. /**
  45195. * Defines whether the stencil buffer should be enabled.
  45196. */
  45197. stencil?: boolean;
  45198. /**
  45199. * Defines whether we should generate debug markers in the gpu command lists (can be seen with PIX for eg)
  45200. */
  45201. enableGPUDebugMarkers?: boolean;
  45202. /**
  45203. * Options to load the associated Glslang library
  45204. */
  45205. glslangOptions?: GlslangOptions;
  45206. }
  45207. /**
  45208. * The web GPU engine class provides support for WebGPU version of babylon.js.
  45209. */
  45210. export class WebGPUEngine extends Engine {
  45211. private static readonly _glslangDefaultOptions;
  45212. private readonly _uploadEncoderDescriptor;
  45213. private readonly _renderEncoderDescriptor;
  45214. private readonly _renderTargetEncoderDescriptor;
  45215. private readonly _clearDepthValue;
  45216. private readonly _clearReverseDepthValue;
  45217. private readonly _clearStencilValue;
  45218. private readonly _defaultSampleCount;
  45219. private _canvas;
  45220. private _options;
  45221. private _glslang;
  45222. private _adapter;
  45223. private _adapterSupportedExtensions;
  45224. private _device;
  45225. private _deviceEnabledExtensions;
  45226. private _context;
  45227. private _swapChain;
  45228. private _swapChainTexture;
  45229. private _mainPassSampleCount;
  45230. private _textureHelper;
  45231. private _bufferManager;
  45232. private _shaderManager;
  45233. private _cacheSampler;
  45234. private _cacheRenderPipeline;
  45235. private _emptyVertexBuffer;
  45236. private _lastCachedWrapU;
  45237. private _lastCachedWrapV;
  45238. private _lastCachedWrapR;
  45239. private _mrtAttachments;
  45240. private _counters;
  45241. private _mainTexture;
  45242. private _depthTexture;
  45243. private _mainTextureExtends;
  45244. private _depthTextureFormat;
  45245. private _colorFormat;
  45246. private _uploadEncoder;
  45247. private _renderEncoder;
  45248. private _renderTargetEncoder;
  45249. private _commandBuffers;
  45250. private _currentRenderPass;
  45251. private _mainRenderPassWrapper;
  45252. private _rttRenderPassWrapper;
  45253. private _pendingDebugCommands;
  45254. private _currentVertexBuffers;
  45255. private _currentOverrideVertexBuffers;
  45256. private _currentIndexBuffer;
  45257. private __colorWrite;
  45258. private _uniformsBuffers;
  45259. private _forceEnableEffect;
  45260. /** @hidden */
  45261. dbgShowShaderCode: boolean;
  45262. /** @hidden */
  45263. dbgSanityChecks: boolean;
  45264. /** @hidden */
  45265. dbgGenerateLogs: boolean;
  45266. /** @hidden */
  45267. dbgVerboseLogsForFirstFrames: boolean;
  45268. /** @hidden */
  45269. dbgVerboseLogsNumFrames: number;
  45270. /** @hidden */
  45271. dbgShowWarningsNotImplemented: boolean;
  45272. /**
  45273. * Sets this to true to disable the cache for the samplers. You should do it only for testing purpose!
  45274. */
  45275. get disableCacheSamplers(): boolean;
  45276. set disableCacheSamplers(disable: boolean);
  45277. /**
  45278. * Sets this to true to disable the cache for the render pipelines. You should do it only for testing purpose!
  45279. */
  45280. get disableCacheRenderPipelines(): boolean;
  45281. set disableCacheRenderPipelines(disable: boolean);
  45282. /**
  45283. * Gets a boolean indicating if the engine can be instantiated (ie. if a WebGPU context can be found)
  45284. * @returns true if the engine can be created
  45285. */
  45286. static get IsSupported(): boolean;
  45287. /**
  45288. * Gets a boolean indicating that the engine supports uniform buffers
  45289. */
  45290. get supportsUniformBuffers(): boolean;
  45291. /** Gets the supported extensions by the WebGPU adapter */
  45292. get supportedExtensions(): Immutable<GPUExtensionName[]>;
  45293. /** Gets the currently enabled extensions on the WebGPU device */
  45294. get enabledExtensions(): Immutable<GPUExtensionName[]>;
  45295. /**
  45296. * Returns the name of the engine
  45297. */
  45298. get name(): string;
  45299. /**
  45300. * Returns a string describing the current engine
  45301. */
  45302. get description(): string;
  45303. /**
  45304. * Returns the version of the engine
  45305. */
  45306. get version(): number;
  45307. /**
  45308. * Create a new instance of the gpu engine asynchronously
  45309. * @param canvas Defines the canvas to use to display the result
  45310. * @param options Defines the options passed to the engine to create the GPU context dependencies
  45311. * @returns a promise that resolves with the created engine
  45312. */
  45313. static CreateAsync(canvas: HTMLCanvasElement, options?: WebGPUEngineOptions): Promise<WebGPUEngine>;
  45314. /**
  45315. * Create a new instance of the gpu engine.
  45316. * @param canvas Defines the canvas to use to display the result
  45317. * @param options Defines the options passed to the engine to create the GPU context dependencies
  45318. */
  45319. constructor(canvas: HTMLCanvasElement, options?: WebGPUEngineOptions);
  45320. /**
  45321. * Initializes the WebGPU context and dependencies.
  45322. * @param glslangOptions Defines the GLSLang compiler options if necessary
  45323. * @returns a promise notifying the readiness of the engine.
  45324. */
  45325. initAsync(glslangOptions?: GlslangOptions): Promise<void>;
  45326. private _initGlslang;
  45327. private _initializeLimits;
  45328. private _initializeContextAndSwapChain;
  45329. private _initializeMainAttachments;
  45330. /**
  45331. * Force a specific size of the canvas
  45332. * @param width defines the new canvas' width
  45333. * @param height defines the new canvas' height
  45334. * @param forceSetSize true to force setting the sizes of the underlying canvas
  45335. * @returns true if the size was changed
  45336. */
  45337. setSize(width: number, height: number, forceSetSize?: boolean): boolean;
  45338. /**
  45339. * Gets a shader processor implementation fitting with the current engine type.
  45340. * @returns The shader processor implementation.
  45341. */
  45342. protected _getShaderProcessor(): Nullable<IShaderProcessor>;
  45343. /** @hidden */
  45344. _getShaderProcessingContext(): Nullable<ShaderProcessingContext>;
  45345. /**
  45346. * Force the entire cache to be cleared
  45347. * You should not have to use this function unless your engine needs to share the WebGPU context with another engine
  45348. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  45349. */
  45350. wipeCaches(bruteForce?: boolean): void;
  45351. /**
  45352. * Enable or disable color writing
  45353. * @param enable defines the state to set
  45354. */
  45355. setColorWrite(enable: boolean): void;
  45356. /**
  45357. * Gets a boolean indicating if color writing is enabled
  45358. * @returns the current color writing state
  45359. */
  45360. getColorWrite(): boolean;
  45361. private _viewportsCurrent;
  45362. private _resetCurrentViewport;
  45363. private _applyViewport;
  45364. /** @hidden */
  45365. _viewport(x: number, y: number, width: number, height: number): void;
  45366. private _scissorsCurrent;
  45367. protected _scissorCached: {
  45368. x: number;
  45369. y: number;
  45370. z: number;
  45371. w: number;
  45372. };
  45373. private _resetCurrentScissor;
  45374. private _applyScissor;
  45375. private _scissorIsActive;
  45376. enableScissor(x: number, y: number, width: number, height: number): void;
  45377. disableScissor(): void;
  45378. /**
  45379. * Clear the current render buffer or the current render target (if any is set up)
  45380. * @param color defines the color to use
  45381. * @param backBuffer defines if the back buffer must be cleared
  45382. * @param depth defines if the depth buffer must be cleared
  45383. * @param stencil defines if the stencil buffer must be cleared
  45384. */
  45385. clear(color: Nullable<IColor4Like>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  45386. /**
  45387. * Clears a list of attachments
  45388. * @param attachments list of the attachments
  45389. * @param colorMain clear color for the main attachment (the first one)
  45390. * @param colorOthers clear color for the other attachments
  45391. * @param clearDepth true to clear the depth buffer. Used only for the first attachment
  45392. * @param clearStencil true to clear the stencil buffer. Used only for the first attachment
  45393. */
  45394. clearAttachments(attachments: number[], colorMain: Nullable<IColor4Like>, colorOthers: Nullable<IColor4Like>, clearDepth: boolean, clearStencil: boolean): void;
  45395. /**
  45396. * Creates a vertex buffer
  45397. * @param data the data for the vertex buffer
  45398. * @returns the new buffer
  45399. */
  45400. createVertexBuffer(data: DataArray): DataBuffer;
  45401. /**
  45402. * Creates a vertex buffer
  45403. * @param data the data for the dynamic vertex buffer
  45404. * @returns the new buffer
  45405. */
  45406. createDynamicVertexBuffer(data: DataArray): DataBuffer;
  45407. /**
  45408. * Updates a vertex buffer.
  45409. * @param vertexBuffer the vertex buffer to update
  45410. * @param data the data used to update the vertex buffer
  45411. * @param byteOffset the byte offset of the data
  45412. * @param byteLength the byte length of the data
  45413. */
  45414. updateDynamicVertexBuffer(vertexBuffer: DataBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  45415. /**
  45416. * Creates a new index buffer
  45417. * @param indices defines the content of the index buffer
  45418. * @param updatable defines if the index buffer must be updatable - not used in WebGPU
  45419. * @returns a new buffer
  45420. */
  45421. createIndexBuffer(indices: IndicesArray, updatable?: boolean): DataBuffer;
  45422. /**
  45423. * Update an index buffer
  45424. * @param indexBuffer defines the target index buffer
  45425. * @param indices defines the data to update
  45426. * @param offset defines the offset in the target index buffer where update should start
  45427. */
  45428. updateDynamicIndexBuffer(indexBuffer: DataBuffer, indices: IndicesArray, offset?: number): void;
  45429. /** @hidden */
  45430. bindBuffersDirectly(vertexBuffer: DataBuffer, indexBuffer: DataBuffer, vertexDeclaration: number[], vertexStrideSize: number, effect: Effect): void;
  45431. /** @hidden */
  45432. updateAndBindInstancesBuffer(instancesBuffer: DataBuffer, data: Float32Array, offsetLocations: number[] | InstancingAttributeInfo[]): void;
  45433. /**
  45434. * Bind a list of vertex buffers with the engine
  45435. * @param vertexBuffers defines the list of vertex buffers to bind
  45436. * @param indexBuffer defines the index buffer to bind
  45437. * @param effect defines the effect associated with the vertex buffers
  45438. * @param overrideVertexBuffers defines optional list of avertex buffers that overrides the entries in vertexBuffers
  45439. */
  45440. bindBuffers(vertexBuffers: {
  45441. [key: string]: Nullable<VertexBuffer>;
  45442. }, indexBuffer: Nullable<DataBuffer>, effect: Effect, overrideVertexBuffers?: {
  45443. [kind: string]: Nullable<VertexBuffer>;
  45444. }): void;
  45445. /** @hidden */
  45446. _releaseBuffer(buffer: DataBuffer): boolean;
  45447. createUniformBuffer(elements: FloatArray): DataBuffer;
  45448. createDynamicUniformBuffer(elements: FloatArray): DataBuffer;
  45449. updateUniformBuffer(uniformBuffer: DataBuffer, elements: FloatArray, offset?: number, count?: number): void;
  45450. bindUniformBufferBase(buffer: DataBuffer, location: number, name: string): void;
  45451. /**
  45452. * Create a new effect (used to store vertex/fragment shaders)
  45453. * @param baseName defines the base name of the effect (The name of file without .fragment.fx or .vertex.fx)
  45454. * @param attributesNamesOrOptions defines either a list of attribute names or an IEffectCreationOptions object
  45455. * @param uniformsNamesOrEngine defines either a list of uniform names or the engine to use
  45456. * @param samplers defines an array of string used to represent textures
  45457. * @param defines defines the string containing the defines to use to compile the shaders
  45458. * @param fallbacks defines the list of potential fallbacks to use if shader compilation fails
  45459. * @param onCompiled defines a function to call when the effect creation is successful
  45460. * @param onError defines a function to call when the effect creation has failed
  45461. * @param indexParameters defines an object containing the index values to use to compile shaders (like the maximum number of simultaneous lights)
  45462. * @returns the new Effect
  45463. */
  45464. 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;
  45465. private _compileRawShaderToSpirV;
  45466. private _compileShaderToSpirV;
  45467. private _createPipelineStageDescriptor;
  45468. private _compileRawPipelineStageDescriptor;
  45469. private _compilePipelineStageDescriptor;
  45470. /** @hidden */
  45471. createRawShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  45472. /** @hidden */
  45473. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  45474. /**
  45475. * Creates a new pipeline context
  45476. * @param shaderProcessingContext defines the shader processing context used during the processing if available
  45477. * @returns the new pipeline
  45478. */
  45479. createPipelineContext(shaderProcessingContext: Nullable<ShaderProcessingContext>): IPipelineContext;
  45480. /** @hidden */
  45481. _preparePipelineContext(pipelineContext: IPipelineContext, vertexSourceCode: string, fragmentSourceCode: string, createAsRaw: boolean, rawVertexSourceCode: string, rawFragmentSourceCode: string, rebuildRebind: any, defines: Nullable<string>, transformFeedbackVaryings: Nullable<string[]>, key: string): void;
  45482. /**
  45483. * Gets the list of active attributes for a given WebGPU program
  45484. * @param pipelineContext defines the pipeline context to use
  45485. * @param attributesNames defines the list of attribute names to get
  45486. * @returns an array of indices indicating the offset of each attribute
  45487. */
  45488. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  45489. /**
  45490. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  45491. * @param effect defines the effect to activate
  45492. */
  45493. enableEffect(effect: Nullable<Effect>): void;
  45494. /** @hidden */
  45495. _releaseEffect(effect: Effect): void;
  45496. /**
  45497. * 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
  45498. */
  45499. releaseEffects(): void;
  45500. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  45501. /**
  45502. * Gets a boolean indicating that only power of 2 textures are supported
  45503. * Please note that you can still use non power of 2 textures but in this case the engine will forcefully convert them
  45504. */
  45505. get needPOTTextures(): boolean;
  45506. /** @hidden */
  45507. _createHardwareTexture(): HardwareTextureWrapper;
  45508. /** @hidden */
  45509. _releaseTexture(texture: InternalTexture): void;
  45510. /** @hidden */
  45511. _getRGBABufferInternalSizedFormat(type: number, format?: number): number;
  45512. updateTextureComparisonFunction(texture: InternalTexture, comparisonFunction: number): void;
  45513. /**
  45514. * Usually called from Texture.ts.
  45515. * Passed information to create a hardware texture
  45516. * @param url defines a value which contains one of the following:
  45517. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  45518. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  45519. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  45520. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  45521. * @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)
  45522. * @param scene needed for loading to the correct scene
  45523. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  45524. * @param onLoad optional callback to be called upon successful completion
  45525. * @param onError optional callback to be called upon failure
  45526. * @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
  45527. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  45528. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  45529. * @param forcedExtension defines the extension to use to pick the right loader
  45530. * @param mimeType defines an optional mime type
  45531. * @param loaderOptions options to be passed to the loader
  45532. * @returns a InternalTexture for assignment back into BABYLON.Texture
  45533. */
  45534. 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;
  45535. /** @hidden */
  45536. _setCubeMapTextureParams(texture: InternalTexture, loadMipmap: boolean): void;
  45537. /**
  45538. * Creates a cube texture
  45539. * @param rootUrl defines the url where the files to load is located
  45540. * @param scene defines the current scene
  45541. * @param files defines the list of files to load (1 per face)
  45542. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  45543. * @param onLoad defines an optional callback raised when the texture is loaded
  45544. * @param onError defines an optional callback raised if there is an issue to load the texture
  45545. * @param format defines the format of the data
  45546. * @param forcedExtension defines the extension to use to pick the right loader
  45547. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  45548. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  45549. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  45550. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  45551. * @param loaderOptions options to be passed to the loader
  45552. * @returns the cube texture as an InternalTexture
  45553. */
  45554. 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;
  45555. /**
  45556. * Creates a raw texture
  45557. * @param data defines the data to store in the texture
  45558. * @param width defines the width of the texture
  45559. * @param height defines the height of the texture
  45560. * @param format defines the format of the data
  45561. * @param generateMipMaps defines if the engine should generate the mip levels
  45562. * @param invertY defines if data must be stored with Y axis inverted
  45563. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  45564. * @param compression defines the compression used (null by default)
  45565. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  45566. * @returns the raw texture inside an InternalTexture
  45567. */
  45568. createRawTexture(data: Nullable<ArrayBufferView>, width: number, height: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>, type?: number): InternalTexture;
  45569. /**
  45570. * Creates a new raw cube texture
  45571. * @param data defines the array of data to use to create each face
  45572. * @param size defines the size of the textures
  45573. * @param format defines the format of the data
  45574. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  45575. * @param generateMipMaps defines if the engine should generate the mip levels
  45576. * @param invertY defines if data must be stored with Y axis inverted
  45577. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  45578. * @param compression defines the compression used (null by default)
  45579. * @returns the cube texture as an InternalTexture
  45580. */
  45581. createRawCubeTexture(data: Nullable<ArrayBufferView[]>, size: number, format: number, type: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>): InternalTexture;
  45582. /**
  45583. * Creates a new raw cube texture from a specified url
  45584. * @param url defines the url where the data is located
  45585. * @param scene defines the current scene
  45586. * @param size defines the size of the textures
  45587. * @param format defines the format of the data
  45588. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  45589. * @param noMipmap defines if the engine should avoid generating the mip levels
  45590. * @param callback defines a callback used to extract texture data from loaded data
  45591. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  45592. * @param onLoad defines a callback called when texture is loaded
  45593. * @param onError defines a callback called if there is an error
  45594. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  45595. * @param invertY defines if data must be stored with Y axis inverted
  45596. * @returns the cube texture as an InternalTexture
  45597. */
  45598. 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;
  45599. /**
  45600. * Creates a new raw 2D array texture
  45601. * @param data defines the data used to create the texture
  45602. * @param width defines the width of the texture
  45603. * @param height defines the height of the texture
  45604. * @param depth defines the number of layers of the texture
  45605. * @param format defines the format of the texture
  45606. * @param generateMipMaps defines if the engine must generate mip levels
  45607. * @param invertY defines if data must be stored with Y axis inverted
  45608. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  45609. * @param compression defines the compressed used (can be null)
  45610. * @param textureType defines the compressed used (can be null)
  45611. * @returns a new raw 2D array texture (stored in an InternalTexture)
  45612. */
  45613. createRawTexture2DArray(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>, textureType?: number): InternalTexture;
  45614. /**
  45615. * Creates a new raw 3D texture
  45616. * @param data defines the data used to create the texture
  45617. * @param width defines the width of the texture
  45618. * @param height defines the height of the texture
  45619. * @param depth defines the depth of the texture
  45620. * @param format defines the format of the texture
  45621. * @param generateMipMaps defines if the engine must generate mip levels
  45622. * @param invertY defines if data must be stored with Y axis inverted
  45623. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  45624. * @param compression defines the compressed used (can be null)
  45625. * @param textureType defines the compressed used (can be null)
  45626. * @returns a new raw 3D texture (stored in an InternalTexture)
  45627. */
  45628. createRawTexture3D(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>, textureType?: number): InternalTexture;
  45629. generateMipMapsForCubemap(texture: InternalTexture, unbind?: boolean): void;
  45630. /**
  45631. * Update the sampling mode of a given texture
  45632. * @param samplingMode defines the required sampling mode
  45633. * @param texture defines the texture to update
  45634. * @param generateMipMaps defines whether to generate mipmaps for the texture
  45635. */
  45636. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture, generateMipMaps?: boolean): void;
  45637. /**
  45638. * Update the sampling mode of a given texture
  45639. * @param texture defines the texture to update
  45640. * @param wrapU defines the texture wrap mode of the u coordinates
  45641. * @param wrapV defines the texture wrap mode of the v coordinates
  45642. * @param wrapR defines the texture wrap mode of the r coordinates
  45643. */
  45644. updateTextureWrappingMode(texture: InternalTexture, wrapU: Nullable<number>, wrapV?: Nullable<number>, wrapR?: Nullable<number>): void;
  45645. /**
  45646. * Update the dimensions of a texture
  45647. * @param texture texture to update
  45648. * @param width new width of the texture
  45649. * @param height new height of the texture
  45650. * @param depth new depth of the texture
  45651. */
  45652. updateTextureDimensions(texture: InternalTexture, width: number, height: number, depth?: number): void;
  45653. private _setInternalTexture;
  45654. /**
  45655. * Sets a texture to the according uniform.
  45656. * @param channel The texture channel
  45657. * @param unused unused parameter
  45658. * @param texture The texture to apply
  45659. * @param name The name of the uniform in the effect
  45660. */
  45661. setTexture(channel: number, unused: Nullable<WebGLUniformLocation>, texture: Nullable<BaseTexture>, name: string): void;
  45662. /**
  45663. * Sets an array of texture to the WebGPU context
  45664. * @param channel defines the channel where the texture array must be set
  45665. * @param unused unused parameter
  45666. * @param textures defines the array of textures to bind
  45667. * @param name name of the channel
  45668. */
  45669. setTextureArray(channel: number, unused: Nullable<WebGLUniformLocation>, textures: BaseTexture[], name: string): void;
  45670. protected _setTexture(channel: number, texture: Nullable<BaseTexture>, isPartOfTextureArray?: boolean, depthStencilTexture?: boolean, name?: string, baseName?: string, textureIndex?: number): boolean;
  45671. /** @hidden */
  45672. _setAnisotropicLevel(target: number, internalTexture: InternalTexture, anisotropicFilteringLevel: number): void;
  45673. /** @hidden */
  45674. _bindTexture(channel: number, texture: InternalTexture, name: string): void;
  45675. private _generateMipmaps;
  45676. /**
  45677. * Update the content of a texture
  45678. * @param texture defines the texture to update
  45679. * @param canvas defines the source containing the data
  45680. * @param invertY defines if data must be stored with Y axis inverted
  45681. * @param premulAlpha defines if alpha is stored as premultiplied
  45682. * @param format defines the format of the data
  45683. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  45684. */
  45685. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement | OffscreenCanvas, invertY: boolean, premulAlpha?: boolean, format?: number, forceBindTexture?: boolean): void;
  45686. /**
  45687. * Update a portion of an internal texture
  45688. * @param texture defines the texture to update
  45689. * @param imageData defines the data to store into the texture
  45690. * @param xOffset defines the x coordinates of the update rectangle
  45691. * @param yOffset defines the y coordinates of the update rectangle
  45692. * @param width defines the width of the update rectangle
  45693. * @param height defines the height of the update rectangle
  45694. * @param faceIndex defines the face index if texture is a cube (0 by default)
  45695. * @param lod defines the lod level to update (0 by default)
  45696. */
  45697. updateTextureData(texture: InternalTexture, imageData: ArrayBufferView, xOffset: number, yOffset: number, width: number, height: number, faceIndex?: number, lod?: number): void;
  45698. /**
  45699. * Update a video texture
  45700. * @param texture defines the texture to update
  45701. * @param video defines the video element to use
  45702. * @param invertY defines if data must be stored with Y axis inverted
  45703. */
  45704. updateVideoTexture(texture: Nullable<InternalTexture>, video: HTMLVideoElement, invertY: boolean): void;
  45705. /** @hidden */
  45706. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  45707. /** @hidden */
  45708. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number, babylonInternalFormat?: number, useTextureWidthAndHeight?: boolean): void;
  45709. /** @hidden */
  45710. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  45711. /** @hidden */
  45712. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement | ImageBitmap, faceIndex?: number, lod?: number): void;
  45713. /**
  45714. * Update a raw texture
  45715. * @param texture defines the texture to update
  45716. * @param bufferView defines the data to store in the texture
  45717. * @param format defines the format of the data
  45718. * @param invertY defines if data must be stored with Y axis inverted
  45719. * @param compression defines the compression used (null by default)
  45720. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  45721. */
  45722. updateRawTexture(texture: Nullable<InternalTexture>, bufferView: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression?: Nullable<string>, type?: number): void;
  45723. /**
  45724. * Update a raw cube texture
  45725. * @param texture defines the texture to update
  45726. * @param bufferView defines the data to store
  45727. * @param format defines the data format
  45728. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  45729. * @param invertY defines if data must be stored with Y axis inverted
  45730. * @param compression defines the compression used (null by default)
  45731. * @param level defines which level of the texture to update
  45732. */
  45733. updateRawCubeTexture(texture: InternalTexture, bufferView: ArrayBufferView[], format: number, type: number, invertY: boolean, compression?: Nullable<string>, level?: number): void;
  45734. /**
  45735. * Update a raw 2D array texture
  45736. * @param texture defines the texture to update
  45737. * @param bufferView defines the data to store
  45738. * @param format defines the data format
  45739. * @param invertY defines if data must be stored with Y axis inverted
  45740. * @param compression defines the used compression (can be null)
  45741. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  45742. */
  45743. updateRawTexture2DArray(texture: InternalTexture, bufferView: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression?: Nullable<string>, textureType?: number): void;
  45744. /**
  45745. * Update a raw 3D texture
  45746. * @param texture defines the texture to update
  45747. * @param bufferView defines the data to store
  45748. * @param format defines the data format
  45749. * @param invertY defines if data must be stored with Y axis inverted
  45750. * @param compression defines the used compression (can be null)
  45751. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  45752. */
  45753. updateRawTexture3D(texture: InternalTexture, bufferView: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression?: Nullable<string>, textureType?: number): void;
  45754. /**
  45755. * Reads pixels from the current frame buffer. Please note that this function can be slow
  45756. * @param x defines the x coordinate of the rectangle where pixels must be read
  45757. * @param y defines the y coordinate of the rectangle where pixels must be read
  45758. * @param width defines the width of the rectangle where pixels must be read
  45759. * @param height defines the height of the rectangle where pixels must be read
  45760. * @param hasAlpha defines whether the output should have alpha or not (defaults to true)
  45761. * @param flushRenderer true to flush the renderer from the pending commands before reading the pixels
  45762. * @returns a ArrayBufferView promise (Uint8Array) containing RGBA colors
  45763. */
  45764. readPixels(x: number, y: number, width: number, height: number, hasAlpha?: boolean, flushRenderer?: boolean): Promise<ArrayBufferView>;
  45765. /** @hidden */
  45766. _readTexturePixels(texture: InternalTexture, width: number, height: number, faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>, flushRenderer?: boolean): Promise<ArrayBufferView>;
  45767. /** @hidden */
  45768. _readTexturePixelsSync(texture: InternalTexture, width: number, height: number, faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>, flushRenderer?: boolean): ArrayBufferView;
  45769. /**
  45770. * Creates a new render target texture
  45771. * @param size defines the size of the texture
  45772. * @param options defines the options used to create the texture
  45773. * @returns a new render target texture stored in an InternalTexture
  45774. */
  45775. createRenderTargetTexture(size: any, options: boolean | RenderTargetCreationOptions): InternalTexture;
  45776. /**
  45777. * Create a multi render target texture
  45778. * @param size defines the size of the texture
  45779. * @param options defines the creation options
  45780. * @returns the cube texture as an InternalTexture
  45781. */
  45782. createMultipleRenderTarget(size: any, options: IMultiRenderTargetOptions): InternalTexture[];
  45783. /**
  45784. * Creates a new render target cube texture
  45785. * @param size defines the size of the texture
  45786. * @param options defines the options used to create the texture
  45787. * @returns a new render target cube texture stored in an InternalTexture
  45788. */
  45789. createRenderTargetCubeTexture(size: number, options?: Partial<RenderTargetCreationOptions>): InternalTexture;
  45790. /** @hidden */
  45791. _setupDepthStencilTexture(internalTexture: InternalTexture, size: number | {
  45792. width: number;
  45793. height: number;
  45794. layers?: number;
  45795. }, generateStencil: boolean, bilinearFiltering: boolean, comparisonFunction: number, samples?: number): void;
  45796. /** @hidden */
  45797. _createDepthStencilTexture(size: number | {
  45798. width: number;
  45799. height: number;
  45800. layers?: number;
  45801. }, options: DepthTextureCreationOptions): InternalTexture;
  45802. /** @hidden */
  45803. _createDepthStencilCubeTexture(size: number, options: DepthTextureCreationOptions): InternalTexture;
  45804. updateRenderTargetTextureSampleCount(texture: Nullable<InternalTexture>, samples: number): number;
  45805. /**
  45806. * Update the sample count for a given multiple render target texture
  45807. * @param textures defines the textures to update
  45808. * @param samples defines the sample count to set
  45809. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  45810. */
  45811. updateMultipleRenderTargetTextureSampleCount(textures: Nullable<InternalTexture[]>, samples: number): number;
  45812. /**
  45813. * Begin a new frame
  45814. */
  45815. beginFrame(): void;
  45816. /**
  45817. * End the current frame
  45818. */
  45819. endFrame(): void;
  45820. /**
  45821. * Force a WebGPU flush (ie. a flush of all waiting commands)
  45822. */
  45823. flushFramebuffer(): void;
  45824. private _startRenderTargetRenderPass;
  45825. private _endRenderTargetRenderPass;
  45826. private _getCurrentRenderPass;
  45827. private _startMainRenderPass;
  45828. private _endMainRenderPass;
  45829. /**
  45830. * Restores the WebGPU state to only draw on the main color attachment
  45831. */
  45832. restoreSingleAttachment(): void;
  45833. /**
  45834. * Creates a layout object to draw/clear on specific textures in a MRT
  45835. * @param textureStatus textureStatus[i] indicates if the i-th is active
  45836. * @returns A layout to be fed to the engine, calling `bindAttachments`.
  45837. */
  45838. buildTextureLayout(textureStatus: boolean[]): number[];
  45839. /**
  45840. * Select a subsets of attachments to draw to.
  45841. * @param attachments index of attachments
  45842. */
  45843. bindAttachments(attachments: number[]): void;
  45844. /**
  45845. * Binds the frame buffer to the specified texture.
  45846. * @param texture The texture to render to or null for the default canvas
  45847. * @param faceIndex The face of the texture to render to in case of cube texture
  45848. * @param requiredWidth The width of the target to render to
  45849. * @param requiredHeight The height of the target to render to
  45850. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  45851. * @param lodLevel defines the lod level to bind to the frame buffer
  45852. * @param layer defines the 2d array index to bind to frame buffer to
  45853. */
  45854. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean, lodLevel?: number, layer?: number): void;
  45855. /**
  45856. * Unbind the current render target texture from the WebGPU context
  45857. * @param texture defines the render target texture to unbind
  45858. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  45859. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  45860. */
  45861. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  45862. /**
  45863. * Unbind a list of render target textures from the WebGPU context
  45864. * @param textures defines the render target textures to unbind
  45865. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  45866. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  45867. */
  45868. unBindMultiColorAttachmentFramebuffer(textures: InternalTexture[], disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  45869. /**
  45870. * Unbind the current render target and bind the default framebuffer
  45871. */
  45872. restoreDefaultFramebuffer(): void;
  45873. setZOffset(value: number): void;
  45874. private _setColorFormat;
  45875. private _setDepthTextureFormat;
  45876. setDepthBuffer(enable: boolean): void;
  45877. setDepthWrite(enable: boolean): void;
  45878. setStencilBuffer(enable: boolean): void;
  45879. setStencilMask(mask: number): void;
  45880. setStencilFunction(stencilFunc: number): void;
  45881. setStencilFunctionReference(reference: number): void;
  45882. setStencilFunctionMask(mask: number): void;
  45883. setStencilOperationFail(operation: number): void;
  45884. setStencilOperationDepthFail(operation: number): void;
  45885. setStencilOperationPass(operation: number): void;
  45886. setDitheringState(value: boolean): void;
  45887. setRasterizerState(value: boolean): void;
  45888. setDepthFunction(depthFunc: number): void;
  45889. setDepthFunctionToGreater(): void;
  45890. setDepthFunctionToGreaterOrEqual(): void;
  45891. setDepthFunctionToLess(): void;
  45892. setDepthFunctionToLessOrEqual(): void;
  45893. /**
  45894. * Set various states to the context
  45895. * @param culling defines backface culling state
  45896. * @param zOffset defines the value to apply to zOffset (0 by default)
  45897. * @param force defines if states must be applied even if cache is up to date
  45898. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  45899. */
  45900. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  45901. /**
  45902. * Sets the current alpha mode
  45903. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  45904. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  45905. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  45906. */
  45907. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  45908. /**
  45909. * Sets the current alpha equation
  45910. * @param equation defines the equation to use (one of the Engine.ALPHA_EQUATION_XXX)
  45911. */
  45912. setAlphaEquation(equation: number): void;
  45913. private _getBindGroupsToRender;
  45914. private _bindVertexInputs;
  45915. private _setRenderBindGroups;
  45916. private _setRenderPipeline;
  45917. /**
  45918. * Draw a list of indexed primitives
  45919. * @param fillMode defines the primitive to use
  45920. * @param indexStart defines the starting index
  45921. * @param indexCount defines the number of index to draw
  45922. * @param instancesCount defines the number of instances to draw (if instantiation is enabled)
  45923. */
  45924. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  45925. /**
  45926. * Draw a list of unindexed primitives
  45927. * @param fillMode defines the primitive to use
  45928. * @param verticesStart defines the index of first vertex to draw
  45929. * @param verticesCount defines the count of vertices to draw
  45930. * @param instancesCount defines the number of instances to draw (if instantiation is enabled)
  45931. */
  45932. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  45933. private _bundleEncoder;
  45934. /**
  45935. * Start recording all the gpu calls into a bundle.
  45936. */
  45937. startRecordBundle(): void;
  45938. /**
  45939. * Stops recording the bundle.
  45940. * @returns the recorded bundle
  45941. */
  45942. stopRecordBundle(): GPURenderBundle;
  45943. /**
  45944. * Execute the previously recorded bundle.
  45945. * @param bundles defines the bundle to replay
  45946. */
  45947. executeBundles(bundles: GPURenderBundle[]): void;
  45948. /**
  45949. * Dispose and release all associated resources
  45950. */
  45951. dispose(): void;
  45952. /**
  45953. * Gets the current render width
  45954. * @param useScreen defines if screen size must be used (or the current render target if any)
  45955. * @returns a number defining the current render width
  45956. */
  45957. getRenderWidth(useScreen?: boolean): number;
  45958. /**
  45959. * Gets the current render height
  45960. * @param useScreen defines if screen size must be used (or the current render target if any)
  45961. * @returns a number defining the current render height
  45962. */
  45963. getRenderHeight(useScreen?: boolean): number;
  45964. /**
  45965. * Gets the HTML canvas attached with the current WebGPU context
  45966. * @returns a HTML canvas
  45967. */
  45968. getRenderingCanvas(): Nullable<HTMLCanvasElement>;
  45969. /** @hidden */
  45970. _debugPushGroup(groupName: string, targetObject?: number): void;
  45971. /** @hidden */
  45972. _debugPopGroup(targetObject?: number): void;
  45973. /** @hidden */
  45974. _debugInsertMarker(text: string, targetObject?: number): void;
  45975. private _debugFlushPendingCommands;
  45976. /**
  45977. * Get the current error code of the WebGPU context
  45978. * @returns the error code
  45979. */
  45980. getError(): number;
  45981. /** @hidden */
  45982. bindSamplers(effect: Effect): void;
  45983. /** @hidden */
  45984. _bindTextureDirectly(target: number, texture: InternalTexture, forTextureDataUpdate?: boolean, force?: boolean): boolean;
  45985. /** @hidden */
  45986. _releaseFramebufferObjects(texture: InternalTexture): void;
  45987. /** @hidden */
  45988. applyStates(): void;
  45989. /**
  45990. * Gets a boolean indicating if all created effects are ready
  45991. * @returns always true - No parallel shader compilation
  45992. */
  45993. areAllEffectsReady(): boolean;
  45994. /** @hidden */
  45995. _executeWhenRenderingStateIsCompiled(pipelineContext: IPipelineContext, action: () => void): void;
  45996. /** @hidden */
  45997. _isRenderingStateCompiled(pipelineContext: IPipelineContext): boolean;
  45998. /** @hidden */
  45999. _getUnpackAlignement(): number;
  46000. /** @hidden */
  46001. _unpackFlipY(value: boolean): void;
  46002. /** @hidden */
  46003. _getSamplingParameters(samplingMode: number, generateMipMaps: boolean): {
  46004. min: number;
  46005. mag: number;
  46006. };
  46007. /** @hidden */
  46008. bindUniformBlock(pipelineContext: IPipelineContext, blockName: string, index: number): void;
  46009. /** @hidden */
  46010. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  46011. /** @hidden */
  46012. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): boolean;
  46013. /** @hidden */
  46014. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): boolean;
  46015. /** @hidden */
  46016. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): boolean;
  46017. /** @hidden */
  46018. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): boolean;
  46019. /** @hidden */
  46020. setArray(uniform: WebGLUniformLocation, array: number[]): boolean;
  46021. /** @hidden */
  46022. setArray2(uniform: WebGLUniformLocation, array: number[]): boolean;
  46023. /** @hidden */
  46024. setArray3(uniform: WebGLUniformLocation, array: number[]): boolean;
  46025. /** @hidden */
  46026. setArray4(uniform: WebGLUniformLocation, array: number[]): boolean;
  46027. /** @hidden */
  46028. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): boolean;
  46029. /** @hidden */
  46030. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): boolean;
  46031. /** @hidden */
  46032. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): boolean;
  46033. /** @hidden */
  46034. setFloat(uniform: WebGLUniformLocation, value: number): boolean;
  46035. /** @hidden */
  46036. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): boolean;
  46037. /** @hidden */
  46038. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): boolean;
  46039. /** @hidden */
  46040. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): boolean;
  46041. }
  46042. }
  46043. declare module BABYLON {
  46044. /**
  46045. * Define an interface for all classes that will hold resources
  46046. */
  46047. export interface IDisposable {
  46048. /**
  46049. * Releases all held resources
  46050. */
  46051. dispose(): void;
  46052. }
  46053. /** Interface defining initialization parameters for Scene class */
  46054. export interface SceneOptions {
  46055. /**
  46056. * Defines that scene should keep up-to-date a map of geometry to enable fast look-up by uniqueId
  46057. * It will improve performance when the number of geometries becomes important.
  46058. */
  46059. useGeometryUniqueIdsMap?: boolean;
  46060. /**
  46061. * Defines that each material of the scene should keep up-to-date a map of referencing meshes for fast diposing
  46062. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  46063. */
  46064. useMaterialMeshMap?: boolean;
  46065. /**
  46066. * Defines that each mesh of the scene should keep up-to-date a map of referencing cloned meshes for fast diposing
  46067. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  46068. */
  46069. useClonedMeshMap?: boolean;
  46070. /** Defines if the creation of the scene should impact the engine (Eg. UtilityLayer's scene) */
  46071. virtual?: boolean;
  46072. }
  46073. /**
  46074. * Represents a scene to be rendered by the engine.
  46075. * @see https://doc.babylonjs.com/features/scene
  46076. */
  46077. export class Scene extends AbstractScene implements IAnimatable, IClipPlanesHolder {
  46078. /** The fog is deactivated */
  46079. static readonly FOGMODE_NONE: number;
  46080. /** The fog density is following an exponential function */
  46081. static readonly FOGMODE_EXP: number;
  46082. /** The fog density is following an exponential function faster than FOGMODE_EXP */
  46083. static readonly FOGMODE_EXP2: number;
  46084. /** The fog density is following a linear function. */
  46085. static readonly FOGMODE_LINEAR: number;
  46086. /**
  46087. * Gets or sets the minimum deltatime when deterministic lock step is enabled
  46088. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  46089. */
  46090. static MinDeltaTime: number;
  46091. /**
  46092. * Gets or sets the maximum deltatime when deterministic lock step is enabled
  46093. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  46094. */
  46095. static MaxDeltaTime: number;
  46096. /**
  46097. * Factory used to create the default material.
  46098. * @param name The name of the material to create
  46099. * @param scene The scene to create the material for
  46100. * @returns The default material
  46101. */
  46102. static DefaultMaterialFactory(scene: Scene): Material;
  46103. /**
  46104. * Factory used to create the a collision coordinator.
  46105. * @returns The collision coordinator
  46106. */
  46107. static CollisionCoordinatorFactory(): ICollisionCoordinator;
  46108. /** @hidden */
  46109. _inputManager: InputManager;
  46110. /** Define this parameter if you are using multiple cameras and you want to specify which one should be used for pointer position */
  46111. cameraToUseForPointers: Nullable<Camera>;
  46112. /** @hidden */
  46113. readonly _isScene: boolean;
  46114. /** @hidden */
  46115. _blockEntityCollection: boolean;
  46116. /**
  46117. * Gets or sets a boolean that indicates if the scene must clear the render buffer before rendering a frame
  46118. */
  46119. autoClear: boolean;
  46120. /**
  46121. * Gets or sets a boolean that indicates if the scene must clear the depth and stencil buffers before rendering a frame
  46122. */
  46123. autoClearDepthAndStencil: boolean;
  46124. /**
  46125. * Defines the color used to clear the render buffer (Default is (0.2, 0.2, 0.3, 1.0))
  46126. */
  46127. clearColor: Color4;
  46128. /**
  46129. * Defines the color used to simulate the ambient color (Default is (0, 0, 0))
  46130. */
  46131. ambientColor: Color3;
  46132. /**
  46133. * This is use to store the default BRDF lookup for PBR materials in your scene.
  46134. * It should only be one of the following (if not the default embedded one):
  46135. * * For uncorrelated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = false) : https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  46136. * * For correlated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedBRDF.dds
  46137. * * For correlated multi scattering BRDF (pbr.brdf.useEnergyConservation = true and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  46138. * The material properties need to be setup according to the type of texture in use.
  46139. */
  46140. environmentBRDFTexture: BaseTexture;
  46141. /**
  46142. * Texture used in all pbr material as the reflection texture.
  46143. * As in the majority of the scene they are the same (exception for multi room and so on),
  46144. * this is easier to reference from here than from all the materials.
  46145. */
  46146. get environmentTexture(): Nullable<BaseTexture>;
  46147. /**
  46148. * Texture used in all pbr material as the reflection texture.
  46149. * As in the majority of the scene they are the same (exception for multi room and so on),
  46150. * this is easier to set here than in all the materials.
  46151. */
  46152. set environmentTexture(value: Nullable<BaseTexture>);
  46153. /** @hidden */
  46154. protected _environmentIntensity: number;
  46155. /**
  46156. * Intensity of the environment in all pbr material.
  46157. * This dims or reinforces the IBL lighting overall (reflection and diffuse).
  46158. * As in the majority of the scene they are the same (exception for multi room and so on),
  46159. * this is easier to reference from here than from all the materials.
  46160. */
  46161. get environmentIntensity(): number;
  46162. /**
  46163. * Intensity of the environment in all pbr material.
  46164. * This dims or reinforces the IBL lighting overall (reflection and diffuse).
  46165. * As in the majority of the scene they are the same (exception for multi room and so on),
  46166. * this is easier to set here than in all the materials.
  46167. */
  46168. set environmentIntensity(value: number);
  46169. /** @hidden */
  46170. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  46171. /**
  46172. * Default image processing configuration used either in the rendering
  46173. * Forward main pass or through the imageProcessingPostProcess if present.
  46174. * As in the majority of the scene they are the same (exception for multi camera),
  46175. * this is easier to reference from here than from all the materials and post process.
  46176. *
  46177. * No setter as we it is a shared configuration, you can set the values instead.
  46178. */
  46179. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  46180. private _forceWireframe;
  46181. /**
  46182. * Gets or sets a boolean indicating if all rendering must be done in wireframe
  46183. */
  46184. set forceWireframe(value: boolean);
  46185. get forceWireframe(): boolean;
  46186. private _skipFrustumClipping;
  46187. /**
  46188. * Gets or sets a boolean indicating if we should skip the frustum clipping part of the active meshes selection
  46189. */
  46190. set skipFrustumClipping(value: boolean);
  46191. get skipFrustumClipping(): boolean;
  46192. private _forcePointsCloud;
  46193. /**
  46194. * Gets or sets a boolean indicating if all rendering must be done in point cloud
  46195. */
  46196. set forcePointsCloud(value: boolean);
  46197. get forcePointsCloud(): boolean;
  46198. /**
  46199. * Gets or sets the active clipplane 1
  46200. */
  46201. clipPlane: Nullable<Plane>;
  46202. /**
  46203. * Gets or sets the active clipplane 2
  46204. */
  46205. clipPlane2: Nullable<Plane>;
  46206. /**
  46207. * Gets or sets the active clipplane 3
  46208. */
  46209. clipPlane3: Nullable<Plane>;
  46210. /**
  46211. * Gets or sets the active clipplane 4
  46212. */
  46213. clipPlane4: Nullable<Plane>;
  46214. /**
  46215. * Gets or sets the active clipplane 5
  46216. */
  46217. clipPlane5: Nullable<Plane>;
  46218. /**
  46219. * Gets or sets the active clipplane 6
  46220. */
  46221. clipPlane6: Nullable<Plane>;
  46222. /**
  46223. * Gets or sets a boolean indicating if animations are enabled
  46224. */
  46225. animationsEnabled: boolean;
  46226. private _animationPropertiesOverride;
  46227. /**
  46228. * Gets or sets the animation properties override
  46229. */
  46230. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  46231. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  46232. /**
  46233. * Gets or sets a boolean indicating if a constant deltatime has to be used
  46234. * This is mostly useful for testing purposes when you do not want the animations to scale with the framerate
  46235. */
  46236. useConstantAnimationDeltaTime: boolean;
  46237. /**
  46238. * Gets or sets a boolean indicating if the scene must keep the meshUnderPointer property updated
  46239. * Please note that it requires to run a ray cast through the scene on every frame
  46240. */
  46241. constantlyUpdateMeshUnderPointer: boolean;
  46242. /**
  46243. * Defines the HTML cursor to use when hovering over interactive elements
  46244. */
  46245. hoverCursor: string;
  46246. /**
  46247. * Defines the HTML default cursor to use (empty by default)
  46248. */
  46249. defaultCursor: string;
  46250. /**
  46251. * Defines whether cursors are handled by the scene.
  46252. */
  46253. doNotHandleCursors: boolean;
  46254. /**
  46255. * This is used to call preventDefault() on pointer down
  46256. * in order to block unwanted artifacts like system double clicks
  46257. */
  46258. preventDefaultOnPointerDown: boolean;
  46259. /**
  46260. * This is used to call preventDefault() on pointer up
  46261. * in order to block unwanted artifacts like system double clicks
  46262. */
  46263. preventDefaultOnPointerUp: boolean;
  46264. /**
  46265. * Gets or sets user defined metadata
  46266. */
  46267. metadata: any;
  46268. /**
  46269. * For internal use only. Please do not use.
  46270. */
  46271. reservedDataStore: any;
  46272. /**
  46273. * Gets the name of the plugin used to load this scene (null by default)
  46274. */
  46275. loadingPluginName: string;
  46276. /**
  46277. * Use this array to add regular expressions used to disable offline support for specific urls
  46278. */
  46279. disableOfflineSupportExceptionRules: RegExp[];
  46280. /**
  46281. * An event triggered when the scene is disposed.
  46282. */
  46283. onDisposeObservable: Observable<Scene>;
  46284. private _onDisposeObserver;
  46285. /** Sets a function to be executed when this scene is disposed. */
  46286. set onDispose(callback: () => void);
  46287. /**
  46288. * An event triggered before rendering the scene (right after animations and physics)
  46289. */
  46290. onBeforeRenderObservable: Observable<Scene>;
  46291. private _onBeforeRenderObserver;
  46292. /** Sets a function to be executed before rendering this scene */
  46293. set beforeRender(callback: Nullable<() => void>);
  46294. /**
  46295. * An event triggered after rendering the scene
  46296. */
  46297. onAfterRenderObservable: Observable<Scene>;
  46298. /**
  46299. * An event triggered after rendering the scene for an active camera (When scene.render is called this will be called after each camera)
  46300. */
  46301. onAfterRenderCameraObservable: Observable<Camera>;
  46302. private _onAfterRenderObserver;
  46303. /** Sets a function to be executed after rendering this scene */
  46304. set afterRender(callback: Nullable<() => void>);
  46305. /**
  46306. * An event triggered before animating the scene
  46307. */
  46308. onBeforeAnimationsObservable: Observable<Scene>;
  46309. /**
  46310. * An event triggered after animations processing
  46311. */
  46312. onAfterAnimationsObservable: Observable<Scene>;
  46313. /**
  46314. * An event triggered before draw calls are ready to be sent
  46315. */
  46316. onBeforeDrawPhaseObservable: Observable<Scene>;
  46317. /**
  46318. * An event triggered after draw calls have been sent
  46319. */
  46320. onAfterDrawPhaseObservable: Observable<Scene>;
  46321. /**
  46322. * An event triggered when the scene is ready
  46323. */
  46324. onReadyObservable: Observable<Scene>;
  46325. /**
  46326. * An event triggered before rendering a camera
  46327. */
  46328. onBeforeCameraRenderObservable: Observable<Camera>;
  46329. private _onBeforeCameraRenderObserver;
  46330. /** Sets a function to be executed before rendering a camera*/
  46331. set beforeCameraRender(callback: () => void);
  46332. /**
  46333. * An event triggered after rendering a camera
  46334. */
  46335. onAfterCameraRenderObservable: Observable<Camera>;
  46336. private _onAfterCameraRenderObserver;
  46337. /** Sets a function to be executed after rendering a camera*/
  46338. set afterCameraRender(callback: () => void);
  46339. /**
  46340. * An event triggered when active meshes evaluation is about to start
  46341. */
  46342. onBeforeActiveMeshesEvaluationObservable: Observable<Scene>;
  46343. /**
  46344. * An event triggered when active meshes evaluation is done
  46345. */
  46346. onAfterActiveMeshesEvaluationObservable: Observable<Scene>;
  46347. /**
  46348. * An event triggered when particles rendering is about to start
  46349. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  46350. */
  46351. onBeforeParticlesRenderingObservable: Observable<Scene>;
  46352. /**
  46353. * An event triggered when particles rendering is done
  46354. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  46355. */
  46356. onAfterParticlesRenderingObservable: Observable<Scene>;
  46357. /**
  46358. * An event triggered when SceneLoader.Append or SceneLoader.Load or SceneLoader.ImportMesh were successfully executed
  46359. */
  46360. onDataLoadedObservable: Observable<Scene>;
  46361. /**
  46362. * An event triggered when a camera is created
  46363. */
  46364. onNewCameraAddedObservable: Observable<Camera>;
  46365. /**
  46366. * An event triggered when a camera is removed
  46367. */
  46368. onCameraRemovedObservable: Observable<Camera>;
  46369. /**
  46370. * An event triggered when a light is created
  46371. */
  46372. onNewLightAddedObservable: Observable<Light>;
  46373. /**
  46374. * An event triggered when a light is removed
  46375. */
  46376. onLightRemovedObservable: Observable<Light>;
  46377. /**
  46378. * An event triggered when a geometry is created
  46379. */
  46380. onNewGeometryAddedObservable: Observable<Geometry>;
  46381. /**
  46382. * An event triggered when a geometry is removed
  46383. */
  46384. onGeometryRemovedObservable: Observable<Geometry>;
  46385. /**
  46386. * An event triggered when a transform node is created
  46387. */
  46388. onNewTransformNodeAddedObservable: Observable<TransformNode>;
  46389. /**
  46390. * An event triggered when a transform node is removed
  46391. */
  46392. onTransformNodeRemovedObservable: Observable<TransformNode>;
  46393. /**
  46394. * An event triggered when a mesh is created
  46395. */
  46396. onNewMeshAddedObservable: Observable<AbstractMesh>;
  46397. /**
  46398. * An event triggered when a mesh is removed
  46399. */
  46400. onMeshRemovedObservable: Observable<AbstractMesh>;
  46401. /**
  46402. * An event triggered when a skeleton is created
  46403. */
  46404. onNewSkeletonAddedObservable: Observable<Skeleton>;
  46405. /**
  46406. * An event triggered when a skeleton is removed
  46407. */
  46408. onSkeletonRemovedObservable: Observable<Skeleton>;
  46409. /**
  46410. * An event triggered when a material is created
  46411. */
  46412. onNewMaterialAddedObservable: Observable<Material>;
  46413. /**
  46414. * An event triggered when a multi material is created
  46415. */
  46416. onNewMultiMaterialAddedObservable: Observable<MultiMaterial>;
  46417. /**
  46418. * An event triggered when a material is removed
  46419. */
  46420. onMaterialRemovedObservable: Observable<Material>;
  46421. /**
  46422. * An event triggered when a multi material is removed
  46423. */
  46424. onMultiMaterialRemovedObservable: Observable<MultiMaterial>;
  46425. /**
  46426. * An event triggered when a texture is created
  46427. */
  46428. onNewTextureAddedObservable: Observable<BaseTexture>;
  46429. /**
  46430. * An event triggered when a texture is removed
  46431. */
  46432. onTextureRemovedObservable: Observable<BaseTexture>;
  46433. /**
  46434. * An event triggered when render targets are about to be rendered
  46435. * Can happen multiple times per frame.
  46436. */
  46437. onBeforeRenderTargetsRenderObservable: Observable<Scene>;
  46438. /**
  46439. * An event triggered when render targets were rendered.
  46440. * Can happen multiple times per frame.
  46441. */
  46442. onAfterRenderTargetsRenderObservable: Observable<Scene>;
  46443. /**
  46444. * An event triggered before calculating deterministic simulation step
  46445. */
  46446. onBeforeStepObservable: Observable<Scene>;
  46447. /**
  46448. * An event triggered after calculating deterministic simulation step
  46449. */
  46450. onAfterStepObservable: Observable<Scene>;
  46451. /**
  46452. * An event triggered when the activeCamera property is updated
  46453. */
  46454. onActiveCameraChanged: Observable<Scene>;
  46455. /**
  46456. * This Observable will be triggered before rendering each renderingGroup of each rendered camera.
  46457. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  46458. * 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)
  46459. */
  46460. onBeforeRenderingGroupObservable: Observable<RenderingGroupInfo>;
  46461. /**
  46462. * This Observable will be triggered after rendering each renderingGroup of each rendered camera.
  46463. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  46464. * 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)
  46465. */
  46466. onAfterRenderingGroupObservable: Observable<RenderingGroupInfo>;
  46467. /**
  46468. * This Observable will when a mesh has been imported into the scene.
  46469. */
  46470. onMeshImportedObservable: Observable<AbstractMesh>;
  46471. /**
  46472. * This Observable will when an animation file has been imported into the scene.
  46473. */
  46474. onAnimationFileImportedObservable: Observable<Scene>;
  46475. /**
  46476. * Gets or sets a user defined funtion to select LOD from a mesh and a camera.
  46477. * By default this function is undefined and Babylon.js will select LOD based on distance to camera
  46478. */
  46479. customLODSelector: (mesh: AbstractMesh, camera: Camera) => Nullable<AbstractMesh>;
  46480. /** @hidden */
  46481. _registeredForLateAnimationBindings: SmartArrayNoDuplicate<any>;
  46482. /**
  46483. * Gets or sets a predicate used to select candidate meshes for a pointer down event
  46484. */
  46485. pointerDownPredicate: (Mesh: AbstractMesh) => boolean;
  46486. /**
  46487. * Gets or sets a predicate used to select candidate meshes for a pointer up event
  46488. */
  46489. pointerUpPredicate: (Mesh: AbstractMesh) => boolean;
  46490. /**
  46491. * Gets or sets a predicate used to select candidate meshes for a pointer move event
  46492. */
  46493. pointerMovePredicate: (Mesh: AbstractMesh) => boolean;
  46494. /** Callback called when a pointer move is detected */
  46495. onPointerMove: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  46496. /** Callback called when a pointer down is detected */
  46497. onPointerDown: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  46498. /** Callback called when a pointer up is detected */
  46499. onPointerUp: (evt: PointerEvent, pickInfo: Nullable<PickingInfo>, type: PointerEventTypes) => void;
  46500. /** Callback called when a pointer pick is detected */
  46501. onPointerPick: (evt: PointerEvent, pickInfo: PickingInfo) => void;
  46502. /**
  46503. * 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).
  46504. * You have the possibility to skip the process and the call to onPointerObservable by setting PointerInfoPre.skipOnPointerObservable to true
  46505. */
  46506. onPrePointerObservable: Observable<PointerInfoPre>;
  46507. /**
  46508. * Observable event triggered each time an input event is received from the rendering canvas
  46509. */
  46510. onPointerObservable: Observable<PointerInfo>;
  46511. /**
  46512. * Gets the pointer coordinates without any translation (ie. straight out of the pointer event)
  46513. */
  46514. get unTranslatedPointer(): Vector2;
  46515. /**
  46516. * Gets or sets the distance in pixel that you have to move to prevent some events. Default is 10 pixels
  46517. */
  46518. static get DragMovementThreshold(): number;
  46519. static set DragMovementThreshold(value: number);
  46520. /**
  46521. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 500 ms
  46522. */
  46523. static get LongPressDelay(): number;
  46524. static set LongPressDelay(value: number);
  46525. /**
  46526. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 300 ms
  46527. */
  46528. static get DoubleClickDelay(): number;
  46529. static set DoubleClickDelay(value: number);
  46530. /** If you need to check double click without raising a single click at first click, enable this flag */
  46531. static get ExclusiveDoubleClickMode(): boolean;
  46532. static set ExclusiveDoubleClickMode(value: boolean);
  46533. /** @hidden */
  46534. _mirroredCameraPosition: Nullable<Vector3>;
  46535. /**
  46536. * This observable event is triggered when any keyboard event si raised and registered during Scene.attachControl()
  46537. * You have the possibility to skip the process and the call to onKeyboardObservable by setting KeyboardInfoPre.skipOnPointerObservable to true
  46538. */
  46539. onPreKeyboardObservable: Observable<KeyboardInfoPre>;
  46540. /**
  46541. * Observable event triggered each time an keyboard event is received from the hosting window
  46542. */
  46543. onKeyboardObservable: Observable<KeyboardInfo>;
  46544. private _useRightHandedSystem;
  46545. /**
  46546. * Gets or sets a boolean indicating if the scene must use right-handed coordinates system
  46547. */
  46548. set useRightHandedSystem(value: boolean);
  46549. get useRightHandedSystem(): boolean;
  46550. private _timeAccumulator;
  46551. private _currentStepId;
  46552. private _currentInternalStep;
  46553. /**
  46554. * Sets the step Id used by deterministic lock step
  46555. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  46556. * @param newStepId defines the step Id
  46557. */
  46558. setStepId(newStepId: number): void;
  46559. /**
  46560. * Gets the step Id used by deterministic lock step
  46561. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  46562. * @returns the step Id
  46563. */
  46564. getStepId(): number;
  46565. /**
  46566. * Gets the internal step used by deterministic lock step
  46567. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  46568. * @returns the internal step
  46569. */
  46570. getInternalStep(): number;
  46571. private _fogEnabled;
  46572. /**
  46573. * Gets or sets a boolean indicating if fog is enabled on this scene
  46574. * @see https://doc.babylonjs.com/babylon101/environment#fog
  46575. * (Default is true)
  46576. */
  46577. set fogEnabled(value: boolean);
  46578. get fogEnabled(): boolean;
  46579. private _fogMode;
  46580. /**
  46581. * Gets or sets the fog mode to use
  46582. * @see https://doc.babylonjs.com/babylon101/environment#fog
  46583. * | mode | value |
  46584. * | --- | --- |
  46585. * | FOGMODE_NONE | 0 |
  46586. * | FOGMODE_EXP | 1 |
  46587. * | FOGMODE_EXP2 | 2 |
  46588. * | FOGMODE_LINEAR | 3 |
  46589. */
  46590. set fogMode(value: number);
  46591. get fogMode(): number;
  46592. /**
  46593. * Gets or sets the fog color to use
  46594. * @see https://doc.babylonjs.com/babylon101/environment#fog
  46595. * (Default is Color3(0.2, 0.2, 0.3))
  46596. */
  46597. fogColor: Color3;
  46598. /**
  46599. * Gets or sets the fog density to use
  46600. * @see https://doc.babylonjs.com/babylon101/environment#fog
  46601. * (Default is 0.1)
  46602. */
  46603. fogDensity: number;
  46604. /**
  46605. * Gets or sets the fog start distance to use
  46606. * @see https://doc.babylonjs.com/babylon101/environment#fog
  46607. * (Default is 0)
  46608. */
  46609. fogStart: number;
  46610. /**
  46611. * Gets or sets the fog end distance to use
  46612. * @see https://doc.babylonjs.com/babylon101/environment#fog
  46613. * (Default is 1000)
  46614. */
  46615. fogEnd: number;
  46616. /**
  46617. * Flag indicating that the frame buffer binding is handled by another component
  46618. */
  46619. get prePass(): boolean;
  46620. private _shadowsEnabled;
  46621. /**
  46622. * Gets or sets a boolean indicating if shadows are enabled on this scene
  46623. */
  46624. set shadowsEnabled(value: boolean);
  46625. get shadowsEnabled(): boolean;
  46626. private _lightsEnabled;
  46627. /**
  46628. * Gets or sets a boolean indicating if lights are enabled on this scene
  46629. */
  46630. set lightsEnabled(value: boolean);
  46631. get lightsEnabled(): boolean;
  46632. /** All of the active cameras added to this scene. */
  46633. activeCameras: Nullable<Camera[]>;
  46634. /** @hidden */
  46635. _activeCamera: Nullable<Camera>;
  46636. /** Gets or sets the current active camera */
  46637. get activeCamera(): Nullable<Camera>;
  46638. set activeCamera(value: Nullable<Camera>);
  46639. private _defaultMaterial;
  46640. /** The default material used on meshes when no material is affected */
  46641. get defaultMaterial(): Material;
  46642. /** The default material used on meshes when no material is affected */
  46643. set defaultMaterial(value: Material);
  46644. private _texturesEnabled;
  46645. /**
  46646. * Gets or sets a boolean indicating if textures are enabled on this scene
  46647. */
  46648. set texturesEnabled(value: boolean);
  46649. get texturesEnabled(): boolean;
  46650. /**
  46651. * Gets or sets a boolean indicating if physic engines are enabled on this scene
  46652. */
  46653. physicsEnabled: boolean;
  46654. /**
  46655. * Gets or sets a boolean indicating if particles are enabled on this scene
  46656. */
  46657. particlesEnabled: boolean;
  46658. /**
  46659. * Gets or sets a boolean indicating if sprites are enabled on this scene
  46660. */
  46661. spritesEnabled: boolean;
  46662. private _skeletonsEnabled;
  46663. /**
  46664. * Gets or sets a boolean indicating if skeletons are enabled on this scene
  46665. */
  46666. set skeletonsEnabled(value: boolean);
  46667. get skeletonsEnabled(): boolean;
  46668. /**
  46669. * Gets or sets a boolean indicating if lens flares are enabled on this scene
  46670. */
  46671. lensFlaresEnabled: boolean;
  46672. /**
  46673. * Gets or sets a boolean indicating if collisions are enabled on this scene
  46674. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  46675. */
  46676. collisionsEnabled: boolean;
  46677. private _collisionCoordinator;
  46678. /** @hidden */
  46679. get collisionCoordinator(): ICollisionCoordinator;
  46680. /**
  46681. * Defines the gravity applied to this scene (used only for collisions)
  46682. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  46683. */
  46684. gravity: Vector3;
  46685. /**
  46686. * Gets or sets a boolean indicating if postprocesses are enabled on this scene
  46687. */
  46688. postProcessesEnabled: boolean;
  46689. /**
  46690. * Gets the current postprocess manager
  46691. */
  46692. postProcessManager: PostProcessManager;
  46693. /**
  46694. * Gets or sets a boolean indicating if render targets are enabled on this scene
  46695. */
  46696. renderTargetsEnabled: boolean;
  46697. /**
  46698. * Gets or sets a boolean indicating if next render targets must be dumped as image for debugging purposes
  46699. * We recommend not using it and instead rely on Spector.js: http://spector.babylonjs.com
  46700. */
  46701. dumpNextRenderTargets: boolean;
  46702. /**
  46703. * The list of user defined render targets added to the scene
  46704. */
  46705. customRenderTargets: RenderTargetTexture[];
  46706. /**
  46707. * Defines if texture loading must be delayed
  46708. * If true, textures will only be loaded when they need to be rendered
  46709. */
  46710. useDelayedTextureLoading: boolean;
  46711. /**
  46712. * Gets the list of meshes imported to the scene through SceneLoader
  46713. */
  46714. importedMeshesFiles: String[];
  46715. /**
  46716. * Gets or sets a boolean indicating if probes are enabled on this scene
  46717. */
  46718. probesEnabled: boolean;
  46719. /**
  46720. * Gets or sets the current offline provider to use to store scene data
  46721. * @see https://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  46722. */
  46723. offlineProvider: IOfflineProvider;
  46724. /**
  46725. * Gets or sets the action manager associated with the scene
  46726. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  46727. */
  46728. actionManager: AbstractActionManager;
  46729. private _meshesForIntersections;
  46730. /**
  46731. * Gets or sets a boolean indicating if procedural textures are enabled on this scene
  46732. */
  46733. proceduralTexturesEnabled: boolean;
  46734. private _engine;
  46735. private _totalVertices;
  46736. /** @hidden */
  46737. _activeIndices: PerfCounter;
  46738. /** @hidden */
  46739. _activeParticles: PerfCounter;
  46740. /** @hidden */
  46741. _activeBones: PerfCounter;
  46742. private _animationRatio;
  46743. /** @hidden */
  46744. _animationTimeLast: number;
  46745. /** @hidden */
  46746. _animationTime: number;
  46747. /**
  46748. * Gets or sets a general scale for animation speed
  46749. * @see https://www.babylonjs-playground.com/#IBU2W7#3
  46750. */
  46751. animationTimeScale: number;
  46752. /** @hidden */
  46753. _cachedMaterial: Nullable<Material>;
  46754. /** @hidden */
  46755. _cachedEffect: Nullable<Effect>;
  46756. /** @hidden */
  46757. _cachedVisibility: Nullable<number>;
  46758. private _renderId;
  46759. private _frameId;
  46760. private _executeWhenReadyTimeoutId;
  46761. private _intermediateRendering;
  46762. private _viewUpdateFlag;
  46763. private _projectionUpdateFlag;
  46764. /** @hidden */
  46765. _toBeDisposed: Nullable<IDisposable>[];
  46766. private _activeRequests;
  46767. /** @hidden */
  46768. _pendingData: any[];
  46769. private _isDisposed;
  46770. /**
  46771. * Gets or sets a boolean indicating that all submeshes of active meshes must be rendered
  46772. * Use this boolean to avoid computing frustum clipping on submeshes (This could help when you are CPU bound)
  46773. */
  46774. dispatchAllSubMeshesOfActiveMeshes: boolean;
  46775. private _activeMeshes;
  46776. private _processedMaterials;
  46777. private _renderTargets;
  46778. /** @hidden */
  46779. _activeParticleSystems: SmartArray<IParticleSystem>;
  46780. private _activeSkeletons;
  46781. private _softwareSkinnedMeshes;
  46782. private _renderingManager;
  46783. /** @hidden */
  46784. _activeAnimatables: Animatable[];
  46785. private _transformMatrix;
  46786. private _sceneUbo;
  46787. /** @hidden */
  46788. _viewMatrix: Matrix;
  46789. /** @hidden */
  46790. _projectionMatrix: Matrix;
  46791. /** @hidden */
  46792. _forcedViewPosition: Nullable<Vector3>;
  46793. /** @hidden */
  46794. _frustumPlanes: Plane[];
  46795. /**
  46796. * Gets the list of frustum planes (built from the active camera)
  46797. */
  46798. get frustumPlanes(): Plane[];
  46799. /**
  46800. * Gets or sets a boolean indicating if lights must be sorted by priority (off by default)
  46801. * This is useful if there are more lights that the maximum simulteanous authorized
  46802. */
  46803. requireLightSorting: boolean;
  46804. /** @hidden */
  46805. readonly useMaterialMeshMap: boolean;
  46806. /** @hidden */
  46807. readonly useClonedMeshMap: boolean;
  46808. private _externalData;
  46809. private _uid;
  46810. /**
  46811. * @hidden
  46812. * Backing store of defined scene components.
  46813. */
  46814. _components: ISceneComponent[];
  46815. /**
  46816. * @hidden
  46817. * Backing store of defined scene components.
  46818. */
  46819. _serializableComponents: ISceneSerializableComponent[];
  46820. /**
  46821. * List of components to register on the next registration step.
  46822. */
  46823. private _transientComponents;
  46824. /**
  46825. * Registers the transient components if needed.
  46826. */
  46827. private _registerTransientComponents;
  46828. /**
  46829. * @hidden
  46830. * Add a component to the scene.
  46831. * Note that the ccomponent could be registered on th next frame if this is called after
  46832. * the register component stage.
  46833. * @param component Defines the component to add to the scene
  46834. */
  46835. _addComponent(component: ISceneComponent): void;
  46836. /**
  46837. * @hidden
  46838. * Gets a component from the scene.
  46839. * @param name defines the name of the component to retrieve
  46840. * @returns the component or null if not present
  46841. */
  46842. _getComponent(name: string): Nullable<ISceneComponent>;
  46843. /**
  46844. * @hidden
  46845. * Defines the actions happening before camera updates.
  46846. */
  46847. _beforeCameraUpdateStage: Stage<SimpleStageAction>;
  46848. /**
  46849. * @hidden
  46850. * Defines the actions happening before clear the canvas.
  46851. */
  46852. _beforeClearStage: Stage<SimpleStageAction>;
  46853. /**
  46854. * @hidden
  46855. * Defines the actions happening before clear the canvas.
  46856. */
  46857. _beforeRenderTargetClearStage: Stage<RenderTargetStageAction>;
  46858. /**
  46859. * @hidden
  46860. * Defines the actions when collecting render targets for the frame.
  46861. */
  46862. _gatherRenderTargetsStage: Stage<RenderTargetsStageAction>;
  46863. /**
  46864. * @hidden
  46865. * Defines the actions happening for one camera in the frame.
  46866. */
  46867. _gatherActiveCameraRenderTargetsStage: Stage<RenderTargetsStageAction>;
  46868. /**
  46869. * @hidden
  46870. * Defines the actions happening during the per mesh ready checks.
  46871. */
  46872. _isReadyForMeshStage: Stage<MeshStageAction>;
  46873. /**
  46874. * @hidden
  46875. * Defines the actions happening before evaluate active mesh checks.
  46876. */
  46877. _beforeEvaluateActiveMeshStage: Stage<SimpleStageAction>;
  46878. /**
  46879. * @hidden
  46880. * Defines the actions happening during the evaluate sub mesh checks.
  46881. */
  46882. _evaluateSubMeshStage: Stage<EvaluateSubMeshStageAction>;
  46883. /**
  46884. * @hidden
  46885. * Defines the actions happening during the active mesh stage.
  46886. */
  46887. _preActiveMeshStage: Stage<PreActiveMeshStageAction>;
  46888. /**
  46889. * @hidden
  46890. * Defines the actions happening during the per camera render target step.
  46891. */
  46892. _cameraDrawRenderTargetStage: Stage<CameraStageFrameBufferAction>;
  46893. /**
  46894. * @hidden
  46895. * Defines the actions happening just before the active camera is drawing.
  46896. */
  46897. _beforeCameraDrawStage: Stage<CameraStageAction>;
  46898. /**
  46899. * @hidden
  46900. * Defines the actions happening just before a render target is drawing.
  46901. */
  46902. _beforeRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  46903. /**
  46904. * @hidden
  46905. * Defines the actions happening just before a rendering group is drawing.
  46906. */
  46907. _beforeRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  46908. /**
  46909. * @hidden
  46910. * Defines the actions happening just before a mesh is drawing.
  46911. */
  46912. _beforeRenderingMeshStage: Stage<RenderingMeshStageAction>;
  46913. /**
  46914. * @hidden
  46915. * Defines the actions happening just after a mesh has been drawn.
  46916. */
  46917. _afterRenderingMeshStage: Stage<RenderingMeshStageAction>;
  46918. /**
  46919. * @hidden
  46920. * Defines the actions happening just after a rendering group has been drawn.
  46921. */
  46922. _afterRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  46923. /**
  46924. * @hidden
  46925. * Defines the actions happening just after the active camera has been drawn.
  46926. */
  46927. _afterCameraDrawStage: Stage<CameraStageAction>;
  46928. /**
  46929. * @hidden
  46930. * Defines the actions happening just after a render target has been drawn.
  46931. */
  46932. _afterRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  46933. /**
  46934. * @hidden
  46935. * Defines the actions happening just after rendering all cameras and computing intersections.
  46936. */
  46937. _afterRenderStage: Stage<SimpleStageAction>;
  46938. /**
  46939. * @hidden
  46940. * Defines the actions happening when a pointer move event happens.
  46941. */
  46942. _pointerMoveStage: Stage<PointerMoveStageAction>;
  46943. /**
  46944. * @hidden
  46945. * Defines the actions happening when a pointer down event happens.
  46946. */
  46947. _pointerDownStage: Stage<PointerUpDownStageAction>;
  46948. /**
  46949. * @hidden
  46950. * Defines the actions happening when a pointer up event happens.
  46951. */
  46952. _pointerUpStage: Stage<PointerUpDownStageAction>;
  46953. /**
  46954. * an optional map from Geometry Id to Geometry index in the 'geometries' array
  46955. */
  46956. private geometriesByUniqueId;
  46957. private _renderBundles;
  46958. /**
  46959. * Creates a new Scene
  46960. * @param engine defines the engine to use to render this scene
  46961. * @param options defines the scene options
  46962. */
  46963. constructor(engine: Engine, options?: SceneOptions);
  46964. /**
  46965. * Gets a string identifying the name of the class
  46966. * @returns "Scene" string
  46967. */
  46968. getClassName(): string;
  46969. private _defaultMeshCandidates;
  46970. /**
  46971. * @hidden
  46972. */
  46973. _getDefaultMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  46974. private _defaultSubMeshCandidates;
  46975. /**
  46976. * @hidden
  46977. */
  46978. _getDefaultSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  46979. /**
  46980. * Sets the default candidate providers for the scene.
  46981. * This sets the getActiveMeshCandidates, getActiveSubMeshCandidates, getIntersectingSubMeshCandidates
  46982. * and getCollidingSubMeshCandidates to their default function
  46983. */
  46984. setDefaultCandidateProviders(): void;
  46985. /**
  46986. * Gets the mesh that is currently under the pointer
  46987. */
  46988. get meshUnderPointer(): Nullable<AbstractMesh>;
  46989. /**
  46990. * Gets or sets the current on-screen X position of the pointer
  46991. */
  46992. get pointerX(): number;
  46993. set pointerX(value: number);
  46994. /**
  46995. * Gets or sets the current on-screen Y position of the pointer
  46996. */
  46997. get pointerY(): number;
  46998. set pointerY(value: number);
  46999. /**
  47000. * Gets the cached material (ie. the latest rendered one)
  47001. * @returns the cached material
  47002. */
  47003. getCachedMaterial(): Nullable<Material>;
  47004. /**
  47005. * Gets the cached effect (ie. the latest rendered one)
  47006. * @returns the cached effect
  47007. */
  47008. getCachedEffect(): Nullable<Effect>;
  47009. /**
  47010. * Gets the cached visibility state (ie. the latest rendered one)
  47011. * @returns the cached visibility state
  47012. */
  47013. getCachedVisibility(): Nullable<number>;
  47014. /**
  47015. * Gets a boolean indicating if the current material / effect / visibility must be bind again
  47016. * @param material defines the current material
  47017. * @param effect defines the current effect
  47018. * @param visibility defines the current visibility state
  47019. * @returns true if one parameter is not cached
  47020. */
  47021. isCachedMaterialInvalid(material: Material, effect: Effect, visibility?: number): boolean;
  47022. /**
  47023. * Gets the engine associated with the scene
  47024. * @returns an Engine
  47025. */
  47026. getEngine(): Engine;
  47027. /**
  47028. * Gets the total number of vertices rendered per frame
  47029. * @returns the total number of vertices rendered per frame
  47030. */
  47031. getTotalVertices(): number;
  47032. /**
  47033. * Gets the performance counter for total vertices
  47034. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  47035. */
  47036. get totalVerticesPerfCounter(): PerfCounter;
  47037. /**
  47038. * Gets the total number of active indices rendered per frame (You can deduce the number of rendered triangles by dividing this number by 3)
  47039. * @returns the total number of active indices rendered per frame
  47040. */
  47041. getActiveIndices(): number;
  47042. /**
  47043. * Gets the performance counter for active indices
  47044. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  47045. */
  47046. get totalActiveIndicesPerfCounter(): PerfCounter;
  47047. /**
  47048. * Gets the total number of active particles rendered per frame
  47049. * @returns the total number of active particles rendered per frame
  47050. */
  47051. getActiveParticles(): number;
  47052. /**
  47053. * Gets the performance counter for active particles
  47054. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  47055. */
  47056. get activeParticlesPerfCounter(): PerfCounter;
  47057. /**
  47058. * Gets the total number of active bones rendered per frame
  47059. * @returns the total number of active bones rendered per frame
  47060. */
  47061. getActiveBones(): number;
  47062. /**
  47063. * Gets the performance counter for active bones
  47064. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  47065. */
  47066. get activeBonesPerfCounter(): PerfCounter;
  47067. /**
  47068. * Gets the array of active meshes
  47069. * @returns an array of AbstractMesh
  47070. */
  47071. getActiveMeshes(): SmartArray<AbstractMesh>;
  47072. /**
  47073. * Gets the animation ratio (which is 1.0 is the scene renders at 60fps and 2 if the scene renders at 30fps, etc.)
  47074. * @returns a number
  47075. */
  47076. getAnimationRatio(): number;
  47077. /**
  47078. * Gets an unique Id for the current render phase
  47079. * @returns a number
  47080. */
  47081. getRenderId(): number;
  47082. /**
  47083. * Gets an unique Id for the current frame
  47084. * @returns a number
  47085. */
  47086. getFrameId(): number;
  47087. /** Call this function if you want to manually increment the render Id*/
  47088. incrementRenderId(): void;
  47089. private _createUbo;
  47090. /**
  47091. * Use this method to simulate a pointer move on a mesh
  47092. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  47093. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  47094. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  47095. * @returns the current scene
  47096. */
  47097. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  47098. /**
  47099. * Use this method to simulate a pointer down on a mesh
  47100. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  47101. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  47102. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  47103. * @returns the current scene
  47104. */
  47105. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  47106. /**
  47107. * Use this method to simulate a pointer up on a mesh
  47108. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  47109. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  47110. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  47111. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  47112. * @returns the current scene
  47113. */
  47114. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): Scene;
  47115. /**
  47116. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  47117. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  47118. * @returns true if the pointer was captured
  47119. */
  47120. isPointerCaptured(pointerId?: number): boolean;
  47121. /**
  47122. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  47123. * @param attachUp defines if you want to attach events to pointerup
  47124. * @param attachDown defines if you want to attach events to pointerdown
  47125. * @param attachMove defines if you want to attach events to pointermove
  47126. */
  47127. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean): void;
  47128. /** Detaches all event handlers*/
  47129. detachControl(): void;
  47130. /**
  47131. * This function will check if the scene can be rendered (textures are loaded, shaders are compiled)
  47132. * Delay loaded resources are not taking in account
  47133. * @return true if all required resources are ready
  47134. */
  47135. isReady(): boolean;
  47136. /** Resets all cached information relative to material (including effect and visibility) */
  47137. resetCachedMaterial(): void;
  47138. /**
  47139. * Registers a function to be called before every frame render
  47140. * @param func defines the function to register
  47141. */
  47142. registerBeforeRender(func: () => void): void;
  47143. /**
  47144. * Unregisters a function called before every frame render
  47145. * @param func defines the function to unregister
  47146. */
  47147. unregisterBeforeRender(func: () => void): void;
  47148. /**
  47149. * Registers a function to be called after every frame render
  47150. * @param func defines the function to register
  47151. */
  47152. registerAfterRender(func: () => void): void;
  47153. /**
  47154. * Unregisters a function called after every frame render
  47155. * @param func defines the function to unregister
  47156. */
  47157. unregisterAfterRender(func: () => void): void;
  47158. private _executeOnceBeforeRender;
  47159. /**
  47160. * The provided function will run before render once and will be disposed afterwards.
  47161. * A timeout delay can be provided so that the function will be executed in N ms.
  47162. * The timeout is using the browser's native setTimeout so time percision cannot be guaranteed.
  47163. * @param func The function to be executed.
  47164. * @param timeout optional delay in ms
  47165. */
  47166. executeOnceBeforeRender(func: () => void, timeout?: number): void;
  47167. /** @hidden */
  47168. _addPendingData(data: any): void;
  47169. /** @hidden */
  47170. _removePendingData(data: any): void;
  47171. /**
  47172. * Returns the number of items waiting to be loaded
  47173. * @returns the number of items waiting to be loaded
  47174. */
  47175. getWaitingItemsCount(): number;
  47176. /**
  47177. * Returns a boolean indicating if the scene is still loading data
  47178. */
  47179. get isLoading(): boolean;
  47180. /**
  47181. * Registers a function to be executed when the scene is ready
  47182. * @param {Function} func - the function to be executed
  47183. */
  47184. executeWhenReady(func: () => void): void;
  47185. /**
  47186. * Returns a promise that resolves when the scene is ready
  47187. * @returns A promise that resolves when the scene is ready
  47188. */
  47189. whenReadyAsync(): Promise<void>;
  47190. /** @hidden */
  47191. _checkIsReady(): void;
  47192. /**
  47193. * Gets all animatable attached to the scene
  47194. */
  47195. get animatables(): Animatable[];
  47196. /**
  47197. * Resets the last animation time frame.
  47198. * Useful to override when animations start running when loading a scene for the first time.
  47199. */
  47200. resetLastAnimationTimeFrame(): void;
  47201. /**
  47202. * Gets the current view matrix
  47203. * @returns a Matrix
  47204. */
  47205. getViewMatrix(): Matrix;
  47206. /**
  47207. * Gets the current projection matrix
  47208. * @returns a Matrix
  47209. */
  47210. getProjectionMatrix(): Matrix;
  47211. /**
  47212. * Gets the current transform matrix
  47213. * @returns a Matrix made of View * Projection
  47214. */
  47215. getTransformMatrix(): Matrix;
  47216. /**
  47217. * Sets the current transform matrix
  47218. * @param viewL defines the View matrix to use
  47219. * @param projectionL defines the Projection matrix to use
  47220. * @param viewR defines the right View matrix to use (if provided)
  47221. * @param projectionR defines the right Projection matrix to use (if provided)
  47222. */
  47223. setTransformMatrix(viewL: Matrix, projectionL: Matrix, viewR?: Matrix, projectionR?: Matrix): void;
  47224. /**
  47225. * Gets the uniform buffer used to store scene data
  47226. * @returns a UniformBuffer
  47227. */
  47228. getSceneUniformBuffer(): UniformBuffer;
  47229. /**
  47230. * Gets an unique (relatively to the current scene) Id
  47231. * @returns an unique number for the scene
  47232. */
  47233. getUniqueId(): number;
  47234. /**
  47235. * Add a mesh to the list of scene's meshes
  47236. * @param newMesh defines the mesh to add
  47237. * @param recursive if all child meshes should also be added to the scene
  47238. */
  47239. addMesh(newMesh: AbstractMesh, recursive?: boolean): void;
  47240. /**
  47241. * Remove a mesh for the list of scene's meshes
  47242. * @param toRemove defines the mesh to remove
  47243. * @param recursive if all child meshes should also be removed from the scene
  47244. * @returns the index where the mesh was in the mesh list
  47245. */
  47246. removeMesh(toRemove: AbstractMesh, recursive?: boolean): number;
  47247. /**
  47248. * Add a transform node to the list of scene's transform nodes
  47249. * @param newTransformNode defines the transform node to add
  47250. */
  47251. addTransformNode(newTransformNode: TransformNode): void;
  47252. /**
  47253. * Remove a transform node for the list of scene's transform nodes
  47254. * @param toRemove defines the transform node to remove
  47255. * @returns the index where the transform node was in the transform node list
  47256. */
  47257. removeTransformNode(toRemove: TransformNode): number;
  47258. /**
  47259. * Remove a skeleton for the list of scene's skeletons
  47260. * @param toRemove defines the skeleton to remove
  47261. * @returns the index where the skeleton was in the skeleton list
  47262. */
  47263. removeSkeleton(toRemove: Skeleton): number;
  47264. /**
  47265. * Remove a morph target for the list of scene's morph targets
  47266. * @param toRemove defines the morph target to remove
  47267. * @returns the index where the morph target was in the morph target list
  47268. */
  47269. removeMorphTargetManager(toRemove: MorphTargetManager): number;
  47270. /**
  47271. * Remove a light for the list of scene's lights
  47272. * @param toRemove defines the light to remove
  47273. * @returns the index where the light was in the light list
  47274. */
  47275. removeLight(toRemove: Light): number;
  47276. /**
  47277. * Remove a camera for the list of scene's cameras
  47278. * @param toRemove defines the camera to remove
  47279. * @returns the index where the camera was in the camera list
  47280. */
  47281. removeCamera(toRemove: Camera): number;
  47282. /**
  47283. * Remove a particle system for the list of scene's particle systems
  47284. * @param toRemove defines the particle system to remove
  47285. * @returns the index where the particle system was in the particle system list
  47286. */
  47287. removeParticleSystem(toRemove: IParticleSystem): number;
  47288. /**
  47289. * Remove a animation for the list of scene's animations
  47290. * @param toRemove defines the animation to remove
  47291. * @returns the index where the animation was in the animation list
  47292. */
  47293. removeAnimation(toRemove: Animation): number;
  47294. /**
  47295. * Will stop the animation of the given target
  47296. * @param target - the target
  47297. * @param animationName - the name of the animation to stop (all animations will be stopped if both this and targetMask are empty)
  47298. * @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)
  47299. */
  47300. stopAnimation(target: any, animationName?: string, targetMask?: (target: any) => boolean): void;
  47301. /**
  47302. * Removes the given animation group from this scene.
  47303. * @param toRemove The animation group to remove
  47304. * @returns The index of the removed animation group
  47305. */
  47306. removeAnimationGroup(toRemove: AnimationGroup): number;
  47307. /**
  47308. * Removes the given multi-material from this scene.
  47309. * @param toRemove The multi-material to remove
  47310. * @returns The index of the removed multi-material
  47311. */
  47312. removeMultiMaterial(toRemove: MultiMaterial): number;
  47313. /**
  47314. * Removes the given material from this scene.
  47315. * @param toRemove The material to remove
  47316. * @returns The index of the removed material
  47317. */
  47318. removeMaterial(toRemove: Material): number;
  47319. /**
  47320. * Removes the given action manager from this scene.
  47321. * @param toRemove The action manager to remove
  47322. * @returns The index of the removed action manager
  47323. */
  47324. removeActionManager(toRemove: AbstractActionManager): number;
  47325. /**
  47326. * Removes the given texture from this scene.
  47327. * @param toRemove The texture to remove
  47328. * @returns The index of the removed texture
  47329. */
  47330. removeTexture(toRemove: BaseTexture): number;
  47331. /**
  47332. * Adds the given light to this scene
  47333. * @param newLight The light to add
  47334. */
  47335. addLight(newLight: Light): void;
  47336. /**
  47337. * Sorts the list list based on light priorities
  47338. */
  47339. sortLightsByPriority(): void;
  47340. /**
  47341. * Adds the given camera to this scene
  47342. * @param newCamera The camera to add
  47343. */
  47344. addCamera(newCamera: Camera): void;
  47345. /**
  47346. * Adds the given skeleton to this scene
  47347. * @param newSkeleton The skeleton to add
  47348. */
  47349. addSkeleton(newSkeleton: Skeleton): void;
  47350. /**
  47351. * Adds the given particle system to this scene
  47352. * @param newParticleSystem The particle system to add
  47353. */
  47354. addParticleSystem(newParticleSystem: IParticleSystem): void;
  47355. /**
  47356. * Adds the given animation to this scene
  47357. * @param newAnimation The animation to add
  47358. */
  47359. addAnimation(newAnimation: Animation): void;
  47360. /**
  47361. * Adds the given animation group to this scene.
  47362. * @param newAnimationGroup The animation group to add
  47363. */
  47364. addAnimationGroup(newAnimationGroup: AnimationGroup): void;
  47365. /**
  47366. * Adds the given multi-material to this scene
  47367. * @param newMultiMaterial The multi-material to add
  47368. */
  47369. addMultiMaterial(newMultiMaterial: MultiMaterial): void;
  47370. /**
  47371. * Adds the given material to this scene
  47372. * @param newMaterial The material to add
  47373. */
  47374. addMaterial(newMaterial: Material): void;
  47375. /**
  47376. * Adds the given morph target to this scene
  47377. * @param newMorphTargetManager The morph target to add
  47378. */
  47379. addMorphTargetManager(newMorphTargetManager: MorphTargetManager): void;
  47380. /**
  47381. * Adds the given geometry to this scene
  47382. * @param newGeometry The geometry to add
  47383. */
  47384. addGeometry(newGeometry: Geometry): void;
  47385. /**
  47386. * Adds the given action manager to this scene
  47387. * @param newActionManager The action manager to add
  47388. */
  47389. addActionManager(newActionManager: AbstractActionManager): void;
  47390. /**
  47391. * Adds the given texture to this scene.
  47392. * @param newTexture The texture to add
  47393. */
  47394. addTexture(newTexture: BaseTexture): void;
  47395. /**
  47396. * Switch active camera
  47397. * @param newCamera defines the new active camera
  47398. * @param attachControl defines if attachControl must be called for the new active camera (default: true)
  47399. */
  47400. switchActiveCamera(newCamera: Camera, attachControl?: boolean): void;
  47401. /**
  47402. * sets the active camera of the scene using its ID
  47403. * @param id defines the camera's ID
  47404. * @return the new active camera or null if none found.
  47405. */
  47406. setActiveCameraByID(id: string): Nullable<Camera>;
  47407. /**
  47408. * sets the active camera of the scene using its name
  47409. * @param name defines the camera's name
  47410. * @returns the new active camera or null if none found.
  47411. */
  47412. setActiveCameraByName(name: string): Nullable<Camera>;
  47413. /**
  47414. * get an animation group using its name
  47415. * @param name defines the material's name
  47416. * @return the animation group or null if none found.
  47417. */
  47418. getAnimationGroupByName(name: string): Nullable<AnimationGroup>;
  47419. /**
  47420. * Get a material using its unique id
  47421. * @param uniqueId defines the material's unique id
  47422. * @return the material or null if none found.
  47423. */
  47424. getMaterialByUniqueID(uniqueId: number): Nullable<Material>;
  47425. /**
  47426. * get a material using its id
  47427. * @param id defines the material's ID
  47428. * @return the material or null if none found.
  47429. */
  47430. getMaterialByID(id: string): Nullable<Material>;
  47431. /**
  47432. * Gets a the last added material using a given id
  47433. * @param id defines the material's ID
  47434. * @return the last material with the given id or null if none found.
  47435. */
  47436. getLastMaterialByID(id: string): Nullable<Material>;
  47437. /**
  47438. * Gets a material using its name
  47439. * @param name defines the material's name
  47440. * @return the material or null if none found.
  47441. */
  47442. getMaterialByName(name: string): Nullable<Material>;
  47443. /**
  47444. * Get a texture using its unique id
  47445. * @param uniqueId defines the texture's unique id
  47446. * @return the texture or null if none found.
  47447. */
  47448. getTextureByUniqueID(uniqueId: number): Nullable<BaseTexture>;
  47449. /**
  47450. * Gets a camera using its id
  47451. * @param id defines the id to look for
  47452. * @returns the camera or null if not found
  47453. */
  47454. getCameraByID(id: string): Nullable<Camera>;
  47455. /**
  47456. * Gets a camera using its unique id
  47457. * @param uniqueId defines the unique id to look for
  47458. * @returns the camera or null if not found
  47459. */
  47460. getCameraByUniqueID(uniqueId: number): Nullable<Camera>;
  47461. /**
  47462. * Gets a camera using its name
  47463. * @param name defines the camera's name
  47464. * @return the camera or null if none found.
  47465. */
  47466. getCameraByName(name: string): Nullable<Camera>;
  47467. /**
  47468. * Gets a bone using its id
  47469. * @param id defines the bone's id
  47470. * @return the bone or null if not found
  47471. */
  47472. getBoneByID(id: string): Nullable<Bone>;
  47473. /**
  47474. * Gets a bone using its id
  47475. * @param name defines the bone's name
  47476. * @return the bone or null if not found
  47477. */
  47478. getBoneByName(name: string): Nullable<Bone>;
  47479. /**
  47480. * Gets a light node using its name
  47481. * @param name defines the the light's name
  47482. * @return the light or null if none found.
  47483. */
  47484. getLightByName(name: string): Nullable<Light>;
  47485. /**
  47486. * Gets a light node using its id
  47487. * @param id defines the light's id
  47488. * @return the light or null if none found.
  47489. */
  47490. getLightByID(id: string): Nullable<Light>;
  47491. /**
  47492. * Gets a light node using its scene-generated unique ID
  47493. * @param uniqueId defines the light's unique id
  47494. * @return the light or null if none found.
  47495. */
  47496. getLightByUniqueID(uniqueId: number): Nullable<Light>;
  47497. /**
  47498. * Gets a particle system by id
  47499. * @param id defines the particle system id
  47500. * @return the corresponding system or null if none found
  47501. */
  47502. getParticleSystemByID(id: string): Nullable<IParticleSystem>;
  47503. /**
  47504. * Gets a geometry using its ID
  47505. * @param id defines the geometry's id
  47506. * @return the geometry or null if none found.
  47507. */
  47508. getGeometryByID(id: string): Nullable<Geometry>;
  47509. private _getGeometryByUniqueID;
  47510. /**
  47511. * Add a new geometry to this scene
  47512. * @param geometry defines the geometry to be added to the scene.
  47513. * @param force defines if the geometry must be pushed even if a geometry with this id already exists
  47514. * @return a boolean defining if the geometry was added or not
  47515. */
  47516. pushGeometry(geometry: Geometry, force?: boolean): boolean;
  47517. /**
  47518. * Removes an existing geometry
  47519. * @param geometry defines the geometry to be removed from the scene
  47520. * @return a boolean defining if the geometry was removed or not
  47521. */
  47522. removeGeometry(geometry: Geometry): boolean;
  47523. /**
  47524. * Gets the list of geometries attached to the scene
  47525. * @returns an array of Geometry
  47526. */
  47527. getGeometries(): Geometry[];
  47528. /**
  47529. * Gets the first added mesh found of a given ID
  47530. * @param id defines the id to search for
  47531. * @return the mesh found or null if not found at all
  47532. */
  47533. getMeshByID(id: string): Nullable<AbstractMesh>;
  47534. /**
  47535. * Gets a list of meshes using their id
  47536. * @param id defines the id to search for
  47537. * @returns a list of meshes
  47538. */
  47539. getMeshesByID(id: string): Array<AbstractMesh>;
  47540. /**
  47541. * Gets the first added transform node found of a given ID
  47542. * @param id defines the id to search for
  47543. * @return the found transform node or null if not found at all.
  47544. */
  47545. getTransformNodeByID(id: string): Nullable<TransformNode>;
  47546. /**
  47547. * Gets a transform node with its auto-generated unique id
  47548. * @param uniqueId efines the unique id to search for
  47549. * @return the found transform node or null if not found at all.
  47550. */
  47551. getTransformNodeByUniqueID(uniqueId: number): Nullable<TransformNode>;
  47552. /**
  47553. * Gets a list of transform nodes using their id
  47554. * @param id defines the id to search for
  47555. * @returns a list of transform nodes
  47556. */
  47557. getTransformNodesByID(id: string): Array<TransformNode>;
  47558. /**
  47559. * Gets a mesh with its auto-generated unique id
  47560. * @param uniqueId defines the unique id to search for
  47561. * @return the found mesh or null if not found at all.
  47562. */
  47563. getMeshByUniqueID(uniqueId: number): Nullable<AbstractMesh>;
  47564. /**
  47565. * Gets a the last added mesh using a given id
  47566. * @param id defines the id to search for
  47567. * @return the found mesh or null if not found at all.
  47568. */
  47569. getLastMeshByID(id: string): Nullable<AbstractMesh>;
  47570. /**
  47571. * Gets a the last added node (Mesh, Camera, Light) using a given id
  47572. * @param id defines the id to search for
  47573. * @return the found node or null if not found at all
  47574. */
  47575. getLastEntryByID(id: string): Nullable<Node>;
  47576. /**
  47577. * Gets a node (Mesh, Camera, Light) using a given id
  47578. * @param id defines the id to search for
  47579. * @return the found node or null if not found at all
  47580. */
  47581. getNodeByID(id: string): Nullable<Node>;
  47582. /**
  47583. * Gets a node (Mesh, Camera, Light) using a given name
  47584. * @param name defines the name to search for
  47585. * @return the found node or null if not found at all.
  47586. */
  47587. getNodeByName(name: string): Nullable<Node>;
  47588. /**
  47589. * Gets a mesh using a given name
  47590. * @param name defines the name to search for
  47591. * @return the found mesh or null if not found at all.
  47592. */
  47593. getMeshByName(name: string): Nullable<AbstractMesh>;
  47594. /**
  47595. * Gets a transform node using a given name
  47596. * @param name defines the name to search for
  47597. * @return the found transform node or null if not found at all.
  47598. */
  47599. getTransformNodeByName(name: string): Nullable<TransformNode>;
  47600. /**
  47601. * Gets a skeleton using a given id (if many are found, this function will pick the last one)
  47602. * @param id defines the id to search for
  47603. * @return the found skeleton or null if not found at all.
  47604. */
  47605. getLastSkeletonByID(id: string): Nullable<Skeleton>;
  47606. /**
  47607. * Gets a skeleton using a given auto generated unique id
  47608. * @param uniqueId defines the unique id to search for
  47609. * @return the found skeleton or null if not found at all.
  47610. */
  47611. getSkeletonByUniqueId(uniqueId: number): Nullable<Skeleton>;
  47612. /**
  47613. * Gets a skeleton using a given id (if many are found, this function will pick the first one)
  47614. * @param id defines the id to search for
  47615. * @return the found skeleton or null if not found at all.
  47616. */
  47617. getSkeletonById(id: string): Nullable<Skeleton>;
  47618. /**
  47619. * Gets a skeleton using a given name
  47620. * @param name defines the name to search for
  47621. * @return the found skeleton or null if not found at all.
  47622. */
  47623. getSkeletonByName(name: string): Nullable<Skeleton>;
  47624. /**
  47625. * Gets a morph target manager using a given id (if many are found, this function will pick the last one)
  47626. * @param id defines the id to search for
  47627. * @return the found morph target manager or null if not found at all.
  47628. */
  47629. getMorphTargetManagerById(id: number): Nullable<MorphTargetManager>;
  47630. /**
  47631. * Gets a morph target using a given id (if many are found, this function will pick the first one)
  47632. * @param id defines the id to search for
  47633. * @return the found morph target or null if not found at all.
  47634. */
  47635. getMorphTargetById(id: string): Nullable<MorphTarget>;
  47636. /**
  47637. * Gets a morph target using a given name (if many are found, this function will pick the first one)
  47638. * @param name defines the name to search for
  47639. * @return the found morph target or null if not found at all.
  47640. */
  47641. getMorphTargetByName(name: string): Nullable<MorphTarget>;
  47642. /**
  47643. * Gets a post process using a given name (if many are found, this function will pick the first one)
  47644. * @param name defines the name to search for
  47645. * @return the found post process or null if not found at all.
  47646. */
  47647. getPostProcessByName(name: string): Nullable<PostProcess>;
  47648. /**
  47649. * Gets a boolean indicating if the given mesh is active
  47650. * @param mesh defines the mesh to look for
  47651. * @returns true if the mesh is in the active list
  47652. */
  47653. isActiveMesh(mesh: AbstractMesh): boolean;
  47654. /**
  47655. * Return a unique id as a string which can serve as an identifier for the scene
  47656. */
  47657. get uid(): string;
  47658. /**
  47659. * Add an externaly attached data from its key.
  47660. * This method call will fail and return false, if such key already exists.
  47661. * If you don't care and just want to get the data no matter what, use the more convenient getOrAddExternalDataWithFactory() method.
  47662. * @param key the unique key that identifies the data
  47663. * @param data the data object to associate to the key for this Engine instance
  47664. * @return true if no such key were already present and the data was added successfully, false otherwise
  47665. */
  47666. addExternalData<T>(key: string, data: T): boolean;
  47667. /**
  47668. * Get an externaly attached data from its key
  47669. * @param key the unique key that identifies the data
  47670. * @return the associated data, if present (can be null), or undefined if not present
  47671. */
  47672. getExternalData<T>(key: string): Nullable<T>;
  47673. /**
  47674. * Get an externaly attached data from its key, create it using a factory if it's not already present
  47675. * @param key the unique key that identifies the data
  47676. * @param factory the factory that will be called to create the instance if and only if it doesn't exists
  47677. * @return the associated data, can be null if the factory returned null.
  47678. */
  47679. getOrAddExternalDataWithFactory<T>(key: string, factory: (k: string) => T): T;
  47680. /**
  47681. * Remove an externaly attached data from the Engine instance
  47682. * @param key the unique key that identifies the data
  47683. * @return true if the data was successfully removed, false if it doesn't exist
  47684. */
  47685. removeExternalData(key: string): boolean;
  47686. private _evaluateSubMesh;
  47687. /**
  47688. * Clear the processed materials smart array preventing retention point in material dispose.
  47689. */
  47690. freeProcessedMaterials(): void;
  47691. private _preventFreeActiveMeshesAndRenderingGroups;
  47692. /** Gets or sets a boolean blocking all the calls to freeActiveMeshes and freeRenderingGroups
  47693. * It can be used in order to prevent going through methods freeRenderingGroups and freeActiveMeshes several times to improve performance
  47694. * when disposing several meshes in a row or a hierarchy of meshes.
  47695. * When used, it is the responsability of the user to blockfreeActiveMeshesAndRenderingGroups back to false.
  47696. */
  47697. get blockfreeActiveMeshesAndRenderingGroups(): boolean;
  47698. set blockfreeActiveMeshesAndRenderingGroups(value: boolean);
  47699. /**
  47700. * Clear the active meshes smart array preventing retention point in mesh dispose.
  47701. */
  47702. freeActiveMeshes(): void;
  47703. /**
  47704. * Clear the info related to rendering groups preventing retention points during dispose.
  47705. */
  47706. freeRenderingGroups(): void;
  47707. /** @hidden */
  47708. _isInIntermediateRendering(): boolean;
  47709. /**
  47710. * Lambda returning the list of potentially active meshes.
  47711. */
  47712. getActiveMeshCandidates: () => ISmartArrayLike<AbstractMesh>;
  47713. /**
  47714. * Lambda returning the list of potentially active sub meshes.
  47715. */
  47716. getActiveSubMeshCandidates: (mesh: AbstractMesh) => ISmartArrayLike<SubMesh>;
  47717. /**
  47718. * Lambda returning the list of potentially intersecting sub meshes.
  47719. */
  47720. getIntersectingSubMeshCandidates: (mesh: AbstractMesh, localRay: Ray) => ISmartArrayLike<SubMesh>;
  47721. /**
  47722. * Lambda returning the list of potentially colliding sub meshes.
  47723. */
  47724. getCollidingSubMeshCandidates: (mesh: AbstractMesh, collider: Collider) => ISmartArrayLike<SubMesh>;
  47725. /** @hidden */
  47726. _activeMeshesFrozen: boolean;
  47727. private _skipEvaluateActiveMeshesCompletely;
  47728. /**
  47729. * Use this function to stop evaluating active meshes. The current list will be keep alive between frames
  47730. * @param skipEvaluateActiveMeshes defines an optional boolean indicating that the evaluate active meshes step must be completely skipped
  47731. * @param onSuccess optional success callback
  47732. * @param onError optional error callback
  47733. * @returns the current scene
  47734. */
  47735. freezeActiveMeshes(skipEvaluateActiveMeshes?: boolean, onSuccess?: () => void, onError?: (message: string) => void): Scene;
  47736. /**
  47737. * Use this function to restart evaluating active meshes on every frame
  47738. * @returns the current scene
  47739. */
  47740. unfreezeActiveMeshes(): Scene;
  47741. private _evaluateActiveMeshes;
  47742. private _activeMesh;
  47743. /**
  47744. * Update the transform matrix to update from the current active camera
  47745. * @param force defines a boolean used to force the update even if cache is up to date
  47746. */
  47747. updateTransformMatrix(force?: boolean): void;
  47748. private _bindFrameBuffer;
  47749. /** @hidden */
  47750. _allowPostProcessClearColor: boolean;
  47751. /** @hidden */
  47752. _renderForCamera(camera: Camera, rigParent?: Camera): void;
  47753. private _processSubCameras;
  47754. private _checkIntersections;
  47755. /** @hidden */
  47756. _advancePhysicsEngineStep(step: number): void;
  47757. /**
  47758. * User updatable function that will return a deterministic frame time when engine is in deterministic lock step mode
  47759. */
  47760. getDeterministicFrameTime: () => number;
  47761. /** @hidden */
  47762. _animate(): void;
  47763. /** Execute all animations (for a frame) */
  47764. animate(): void;
  47765. /**
  47766. * Render the scene
  47767. * @param updateCameras defines a boolean indicating if cameras must update according to their inputs (true by default)
  47768. * @param ignoreAnimations defines a boolean indicating if animations should not be executed (false by default)
  47769. */
  47770. render(updateCameras?: boolean, ignoreAnimations?: boolean): void;
  47771. /**
  47772. * Freeze all materials
  47773. * A frozen material will not be updatable but should be faster to render
  47774. */
  47775. freezeMaterials(): void;
  47776. /**
  47777. * Unfreeze all materials
  47778. * A frozen material will not be updatable but should be faster to render
  47779. */
  47780. unfreezeMaterials(): void;
  47781. /**
  47782. * Releases all held ressources
  47783. */
  47784. dispose(): void;
  47785. /**
  47786. * Gets if the scene is already disposed
  47787. */
  47788. get isDisposed(): boolean;
  47789. /**
  47790. * Call this function to reduce memory footprint of the scene.
  47791. * Vertex buffers will not store CPU data anymore (this will prevent picking, collisions or physics to work correctly)
  47792. */
  47793. clearCachedVertexData(): void;
  47794. /**
  47795. * This function will remove the local cached buffer data from texture.
  47796. * It will save memory but will prevent the texture from being rebuilt
  47797. */
  47798. cleanCachedTextureBuffer(): void;
  47799. /**
  47800. * Get the world extend vectors with an optional filter
  47801. *
  47802. * @param filterPredicate the predicate - which meshes should be included when calculating the world size
  47803. * @returns {{ min: Vector3; max: Vector3 }} min and max vectors
  47804. */
  47805. getWorldExtends(filterPredicate?: (mesh: AbstractMesh) => boolean): {
  47806. min: Vector3;
  47807. max: Vector3;
  47808. };
  47809. /**
  47810. * Creates a ray that can be used to pick in the scene
  47811. * @param x defines the x coordinate of the origin (on-screen)
  47812. * @param y defines the y coordinate of the origin (on-screen)
  47813. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  47814. * @param camera defines the camera to use for the picking
  47815. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  47816. * @returns a Ray
  47817. */
  47818. createPickingRay(x: number, y: number, world: Matrix, camera: Nullable<Camera>, cameraViewSpace?: boolean): Ray;
  47819. /**
  47820. * Creates a ray that can be used to pick in the scene
  47821. * @param x defines the x coordinate of the origin (on-screen)
  47822. * @param y defines the y coordinate of the origin (on-screen)
  47823. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  47824. * @param result defines the ray where to store the picking ray
  47825. * @param camera defines the camera to use for the picking
  47826. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  47827. * @returns the current scene
  47828. */
  47829. createPickingRayToRef(x: number, y: number, world: Matrix, result: Ray, camera: Nullable<Camera>, cameraViewSpace?: boolean): Scene;
  47830. /**
  47831. * Creates a ray that can be used to pick in the scene
  47832. * @param x defines the x coordinate of the origin (on-screen)
  47833. * @param y defines the y coordinate of the origin (on-screen)
  47834. * @param camera defines the camera to use for the picking
  47835. * @returns a Ray
  47836. */
  47837. createPickingRayInCameraSpace(x: number, y: number, camera?: Camera): Ray;
  47838. /**
  47839. * Creates a ray that can be used to pick in the scene
  47840. * @param x defines the x coordinate of the origin (on-screen)
  47841. * @param y defines the y coordinate of the origin (on-screen)
  47842. * @param result defines the ray where to store the picking ray
  47843. * @param camera defines the camera to use for the picking
  47844. * @returns the current scene
  47845. */
  47846. createPickingRayInCameraSpaceToRef(x: number, y: number, result: Ray, camera?: Camera): Scene;
  47847. /** Launch a ray to try to pick a mesh in the scene
  47848. * @param x position on screen
  47849. * @param y position on screen
  47850. * @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
  47851. * @param fastCheck defines if the first intersection will be used (and not the closest)
  47852. * @param camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  47853. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  47854. * @returns a PickingInfo
  47855. */
  47856. pick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, camera?: Nullable<Camera>, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  47857. /** Launch a ray to try to pick a mesh in the scene using only bounding information of the main mesh (not using submeshes)
  47858. * @param x position on screen
  47859. * @param y position on screen
  47860. * @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
  47861. * @param fastCheck defines if the first intersection will be used (and not the closest)
  47862. * @param camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  47863. * @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)
  47864. */
  47865. pickWithBoundingInfo(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, camera?: Nullable<Camera>): Nullable<PickingInfo>;
  47866. /** Use the given ray to pick a mesh in the scene
  47867. * @param ray The ray to use to pick meshes
  47868. * @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
  47869. * @param fastCheck defines if the first intersection will be used (and not the closest)
  47870. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  47871. * @returns a PickingInfo
  47872. */
  47873. pickWithRay(ray: Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  47874. /**
  47875. * Launch a ray to try to pick a mesh in the scene
  47876. * @param x X position on screen
  47877. * @param y Y position on screen
  47878. * @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
  47879. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  47880. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  47881. * @returns an array of PickingInfo
  47882. */
  47883. multiPick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, camera?: Camera, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  47884. /**
  47885. * Launch a ray to try to pick a mesh in the scene
  47886. * @param ray Ray to use
  47887. * @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
  47888. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  47889. * @returns an array of PickingInfo
  47890. */
  47891. multiPickWithRay(ray: Ray, predicate: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  47892. /**
  47893. * Force the value of meshUnderPointer
  47894. * @param mesh defines the mesh to use
  47895. * @param pointerId optional pointer id when using more than one pointer
  47896. */
  47897. setPointerOverMesh(mesh: Nullable<AbstractMesh>, pointerId?: number): void;
  47898. /**
  47899. * Gets the mesh under the pointer
  47900. * @returns a Mesh or null if no mesh is under the pointer
  47901. */
  47902. getPointerOverMesh(): Nullable<AbstractMesh>;
  47903. /** @hidden */
  47904. _rebuildGeometries(): void;
  47905. /** @hidden */
  47906. _rebuildTextures(): void;
  47907. private _getByTags;
  47908. /**
  47909. * Get a list of meshes by tags
  47910. * @param tagsQuery defines the tags query to use
  47911. * @param forEach defines a predicate used to filter results
  47912. * @returns an array of Mesh
  47913. */
  47914. getMeshesByTags(tagsQuery: string, forEach?: (mesh: AbstractMesh) => void): Mesh[];
  47915. /**
  47916. * Get a list of cameras by tags
  47917. * @param tagsQuery defines the tags query to use
  47918. * @param forEach defines a predicate used to filter results
  47919. * @returns an array of Camera
  47920. */
  47921. getCamerasByTags(tagsQuery: string, forEach?: (camera: Camera) => void): Camera[];
  47922. /**
  47923. * Get a list of lights by tags
  47924. * @param tagsQuery defines the tags query to use
  47925. * @param forEach defines a predicate used to filter results
  47926. * @returns an array of Light
  47927. */
  47928. getLightsByTags(tagsQuery: string, forEach?: (light: Light) => void): Light[];
  47929. /**
  47930. * Get a list of materials by tags
  47931. * @param tagsQuery defines the tags query to use
  47932. * @param forEach defines a predicate used to filter results
  47933. * @returns an array of Material
  47934. */
  47935. getMaterialByTags(tagsQuery: string, forEach?: (material: Material) => void): Material[];
  47936. /**
  47937. * Get a list of transform nodes by tags
  47938. * @param tagsQuery defines the tags query to use
  47939. * @param forEach defines a predicate used to filter results
  47940. * @returns an array of TransformNode
  47941. */
  47942. getTransformNodesByTags(tagsQuery: string, forEach?: (transform: TransformNode) => void): TransformNode[];
  47943. /**
  47944. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  47945. * This allowed control for front to back rendering or reversly depending of the special needs.
  47946. *
  47947. * @param renderingGroupId The rendering group id corresponding to its index
  47948. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  47949. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  47950. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  47951. */
  47952. 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;
  47953. /**
  47954. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  47955. *
  47956. * @param renderingGroupId The rendering group id corresponding to its index
  47957. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  47958. * @param depth Automatically clears depth between groups if true and autoClear is true.
  47959. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  47960. */
  47961. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  47962. /**
  47963. * Gets the current auto clear configuration for one rendering group of the rendering
  47964. * manager.
  47965. * @param index the rendering group index to get the information for
  47966. * @returns The auto clear setup for the requested rendering group
  47967. */
  47968. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  47969. private _blockMaterialDirtyMechanism;
  47970. /** Gets or sets a boolean blocking all the calls to markAllMaterialsAsDirty (ie. the materials won't be updated if they are out of sync) */
  47971. get blockMaterialDirtyMechanism(): boolean;
  47972. set blockMaterialDirtyMechanism(value: boolean);
  47973. /**
  47974. * Will flag all materials as dirty to trigger new shader compilation
  47975. * @param flag defines the flag used to specify which material part must be marked as dirty
  47976. * @param predicate If not null, it will be used to specifiy if a material has to be marked as dirty
  47977. */
  47978. markAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  47979. /** @hidden */
  47980. _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;
  47981. /** @hidden */
  47982. _loadFileAsync(url: string, onProgress?: (data: any) => void, useOfflineSupport?: boolean, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  47983. /** @hidden */
  47984. _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;
  47985. /** @hidden */
  47986. _requestFileAsync(url: string, onProgress?: (ev: ProgressEvent) => void, useOfflineSupport?: boolean, useArrayBuffer?: boolean, onOpened?: (request: WebRequest) => void): Promise<string | ArrayBuffer>;
  47987. /** @hidden */
  47988. _readFile(file: File, onSuccess: (data: string | ArrayBuffer) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: ReadFileError) => void): IFileRequest;
  47989. /** @hidden */
  47990. _readFileAsync(file: File, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  47991. }
  47992. }
  47993. declare module BABYLON {
  47994. /**
  47995. * Set of assets to keep when moving a scene into an asset container.
  47996. */
  47997. export class KeepAssets extends AbstractScene {
  47998. }
  47999. /**
  48000. * Class used to store the output of the AssetContainer.instantiateAllMeshesToScene function
  48001. */
  48002. export class InstantiatedEntries {
  48003. /**
  48004. * List of new root nodes (eg. nodes with no parent)
  48005. */
  48006. rootNodes: TransformNode[];
  48007. /**
  48008. * List of new skeletons
  48009. */
  48010. skeletons: Skeleton[];
  48011. /**
  48012. * List of new animation groups
  48013. */
  48014. animationGroups: AnimationGroup[];
  48015. }
  48016. /**
  48017. * Container with a set of assets that can be added or removed from a scene.
  48018. */
  48019. export class AssetContainer extends AbstractScene {
  48020. private _wasAddedToScene;
  48021. /**
  48022. * The scene the AssetContainer belongs to.
  48023. */
  48024. scene: Scene;
  48025. /**
  48026. * Instantiates an AssetContainer.
  48027. * @param scene The scene the AssetContainer belongs to.
  48028. */
  48029. constructor(scene: Scene);
  48030. /**
  48031. * Instantiate or clone all meshes and add the new ones to the scene.
  48032. * Skeletons and animation groups will all be cloned
  48033. * @param nameFunction defines an optional function used to get new names for clones
  48034. * @param cloneMaterials defines an optional boolean that defines if materials must be cloned as well (false by default)
  48035. * @returns a list of rootNodes, skeletons and aniamtion groups that were duplicated
  48036. */
  48037. instantiateModelsToScene(nameFunction?: (sourceName: string) => string, cloneMaterials?: boolean): InstantiatedEntries;
  48038. /**
  48039. * Adds all the assets from the container to the scene.
  48040. */
  48041. addAllToScene(): void;
  48042. /**
  48043. * Removes all the assets in the container from the scene
  48044. */
  48045. removeAllFromScene(): void;
  48046. /**
  48047. * Disposes all the assets in the container
  48048. */
  48049. dispose(): void;
  48050. private _moveAssets;
  48051. /**
  48052. * Removes all the assets contained in the scene and adds them to the container.
  48053. * @param keepAssets Set of assets to keep in the scene. (default: empty)
  48054. */
  48055. moveAllFromScene(keepAssets?: KeepAssets): void;
  48056. /**
  48057. * 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.
  48058. * @returns the root mesh
  48059. */
  48060. createRootMesh(): Mesh;
  48061. /**
  48062. * Merge animations (direct and animation groups) from this asset container into a scene
  48063. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  48064. * @param animatables set of animatables to retarget to a node from the scene
  48065. * @param targetConverter defines a function used to convert animation targets from the asset container to the scene (default: search node by name)
  48066. * @returns an array of the new AnimationGroup added to the scene (empty array if none)
  48067. */
  48068. mergeAnimationsTo(scene: Scene | null | undefined, animatables: Animatable[], targetConverter?: Nullable<(target: any) => Nullable<Node>>): AnimationGroup[];
  48069. }
  48070. }
  48071. declare module BABYLON {
  48072. /**
  48073. * Defines how the parser contract is defined.
  48074. * These parsers are used to parse a list of specific assets (like particle systems, etc..)
  48075. */
  48076. export type BabylonFileParser = (parsedData: any, scene: Scene, container: AssetContainer, rootUrl: string) => void;
  48077. /**
  48078. * Defines how the individual parser contract is defined.
  48079. * These parser can parse an individual asset
  48080. */
  48081. export type IndividualBabylonFileParser = (parsedData: any, scene: Scene, rootUrl: string) => any;
  48082. /**
  48083. * Base class of the scene acting as a container for the different elements composing a scene.
  48084. * This class is dynamically extended by the different components of the scene increasing
  48085. * flexibility and reducing coupling
  48086. */
  48087. export abstract class AbstractScene {
  48088. /**
  48089. * Stores the list of available parsers in the application.
  48090. */
  48091. private static _BabylonFileParsers;
  48092. /**
  48093. * Stores the list of available individual parsers in the application.
  48094. */
  48095. private static _IndividualBabylonFileParsers;
  48096. /**
  48097. * Adds a parser in the list of available ones
  48098. * @param name Defines the name of the parser
  48099. * @param parser Defines the parser to add
  48100. */
  48101. static AddParser(name: string, parser: BabylonFileParser): void;
  48102. /**
  48103. * Gets a general parser from the list of avaialble ones
  48104. * @param name Defines the name of the parser
  48105. * @returns the requested parser or null
  48106. */
  48107. static GetParser(name: string): Nullable<BabylonFileParser>;
  48108. /**
  48109. * Adds n individual parser in the list of available ones
  48110. * @param name Defines the name of the parser
  48111. * @param parser Defines the parser to add
  48112. */
  48113. static AddIndividualParser(name: string, parser: IndividualBabylonFileParser): void;
  48114. /**
  48115. * Gets an individual parser from the list of avaialble ones
  48116. * @param name Defines the name of the parser
  48117. * @returns the requested parser or null
  48118. */
  48119. static GetIndividualParser(name: string): Nullable<IndividualBabylonFileParser>;
  48120. /**
  48121. * Parser json data and populate both a scene and its associated container object
  48122. * @param jsonData Defines the data to parse
  48123. * @param scene Defines the scene to parse the data for
  48124. * @param container Defines the container attached to the parsing sequence
  48125. * @param rootUrl Defines the root url of the data
  48126. */
  48127. static Parse(jsonData: any, scene: Scene, container: AssetContainer, rootUrl: string): void;
  48128. /**
  48129. * Gets the list of root nodes (ie. nodes with no parent)
  48130. */
  48131. rootNodes: Node[];
  48132. /** All of the cameras added to this scene
  48133. * @see https://doc.babylonjs.com/babylon101/cameras
  48134. */
  48135. cameras: Camera[];
  48136. /**
  48137. * All of the lights added to this scene
  48138. * @see https://doc.babylonjs.com/babylon101/lights
  48139. */
  48140. lights: Light[];
  48141. /**
  48142. * All of the (abstract) meshes added to this scene
  48143. */
  48144. meshes: AbstractMesh[];
  48145. /**
  48146. * The list of skeletons added to the scene
  48147. * @see https://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  48148. */
  48149. skeletons: Skeleton[];
  48150. /**
  48151. * All of the particle systems added to this scene
  48152. * @see https://doc.babylonjs.com/babylon101/particles
  48153. */
  48154. particleSystems: IParticleSystem[];
  48155. /**
  48156. * Gets a list of Animations associated with the scene
  48157. */
  48158. animations: Animation[];
  48159. /**
  48160. * All of the animation groups added to this scene
  48161. * @see https://doc.babylonjs.com/how_to/group
  48162. */
  48163. animationGroups: AnimationGroup[];
  48164. /**
  48165. * All of the multi-materials added to this scene
  48166. * @see https://doc.babylonjs.com/how_to/multi_materials
  48167. */
  48168. multiMaterials: MultiMaterial[];
  48169. /**
  48170. * All of the materials added to this scene
  48171. * In the context of a Scene, it is not supposed to be modified manually.
  48172. * Any addition or removal should be done using the addMaterial and removeMaterial Scene methods.
  48173. * Note also that the order of the Material within the array is not significant and might change.
  48174. * @see https://doc.babylonjs.com/babylon101/materials
  48175. */
  48176. materials: Material[];
  48177. /**
  48178. * The list of morph target managers added to the scene
  48179. * @see https://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh
  48180. */
  48181. morphTargetManagers: MorphTargetManager[];
  48182. /**
  48183. * The list of geometries used in the scene.
  48184. */
  48185. geometries: Geometry[];
  48186. /**
  48187. * All of the tranform nodes added to this scene
  48188. * In the context of a Scene, it is not supposed to be modified manually.
  48189. * Any addition or removal should be done using the addTransformNode and removeTransformNode Scene methods.
  48190. * Note also that the order of the TransformNode wihin the array is not significant and might change.
  48191. * @see https://doc.babylonjs.com/how_to/transformnode
  48192. */
  48193. transformNodes: TransformNode[];
  48194. /**
  48195. * ActionManagers available on the scene.
  48196. */
  48197. actionManagers: AbstractActionManager[];
  48198. /**
  48199. * Textures to keep.
  48200. */
  48201. textures: BaseTexture[];
  48202. /** @hidden */
  48203. protected _environmentTexture: Nullable<BaseTexture>;
  48204. /**
  48205. * Texture used in all pbr material as the reflection texture.
  48206. * As in the majority of the scene they are the same (exception for multi room and so on),
  48207. * this is easier to reference from here than from all the materials.
  48208. */
  48209. get environmentTexture(): Nullable<BaseTexture>;
  48210. set environmentTexture(value: Nullable<BaseTexture>);
  48211. /**
  48212. * The list of postprocesses added to the scene
  48213. */
  48214. postProcesses: PostProcess[];
  48215. /**
  48216. * @returns all meshes, lights, cameras, transformNodes and bones
  48217. */
  48218. getNodes(): Array<Node>;
  48219. }
  48220. }
  48221. declare module BABYLON {
  48222. /**
  48223. * Interface used to define options for Sound class
  48224. */
  48225. export interface ISoundOptions {
  48226. /**
  48227. * Does the sound autoplay once loaded.
  48228. */
  48229. autoplay?: boolean;
  48230. /**
  48231. * Does the sound loop after it finishes playing once.
  48232. */
  48233. loop?: boolean;
  48234. /**
  48235. * Sound's volume
  48236. */
  48237. volume?: number;
  48238. /**
  48239. * Is it a spatial sound?
  48240. */
  48241. spatialSound?: boolean;
  48242. /**
  48243. * Maximum distance to hear that sound
  48244. */
  48245. maxDistance?: number;
  48246. /**
  48247. * Uses user defined attenuation function
  48248. */
  48249. useCustomAttenuation?: boolean;
  48250. /**
  48251. * Define the roll off factor of spatial sounds.
  48252. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  48253. */
  48254. rolloffFactor?: number;
  48255. /**
  48256. * Define the reference distance the sound should be heard perfectly.
  48257. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  48258. */
  48259. refDistance?: number;
  48260. /**
  48261. * Define the distance attenuation model the sound will follow.
  48262. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  48263. */
  48264. distanceModel?: string;
  48265. /**
  48266. * Defines the playback speed (1 by default)
  48267. */
  48268. playbackRate?: number;
  48269. /**
  48270. * Defines if the sound is from a streaming source
  48271. */
  48272. streaming?: boolean;
  48273. /**
  48274. * Defines an optional length (in seconds) inside the sound file
  48275. */
  48276. length?: number;
  48277. /**
  48278. * Defines an optional offset (in seconds) inside the sound file
  48279. */
  48280. offset?: number;
  48281. /**
  48282. * If true, URLs will not be required to state the audio file codec to use.
  48283. */
  48284. skipCodecCheck?: boolean;
  48285. }
  48286. }
  48287. declare module BABYLON {
  48288. /**
  48289. * Defines a sound that can be played in the application.
  48290. * The sound can either be an ambient track or a simple sound played in reaction to a user action.
  48291. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  48292. */
  48293. export class Sound {
  48294. /**
  48295. * The name of the sound in the scene.
  48296. */
  48297. name: string;
  48298. /**
  48299. * Does the sound autoplay once loaded.
  48300. */
  48301. autoplay: boolean;
  48302. private _loop;
  48303. /**
  48304. * Does the sound loop after it finishes playing once.
  48305. */
  48306. get loop(): boolean;
  48307. set loop(value: boolean);
  48308. /**
  48309. * Does the sound use a custom attenuation curve to simulate the falloff
  48310. * happening when the source gets further away from the camera.
  48311. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  48312. */
  48313. useCustomAttenuation: boolean;
  48314. /**
  48315. * The sound track id this sound belongs to.
  48316. */
  48317. soundTrackId: number;
  48318. /**
  48319. * Is this sound currently played.
  48320. */
  48321. isPlaying: boolean;
  48322. /**
  48323. * Is this sound currently paused.
  48324. */
  48325. isPaused: boolean;
  48326. /**
  48327. * Does this sound enables spatial sound.
  48328. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  48329. */
  48330. spatialSound: boolean;
  48331. /**
  48332. * Define the reference distance the sound should be heard perfectly.
  48333. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  48334. */
  48335. refDistance: number;
  48336. /**
  48337. * Define the roll off factor of spatial sounds.
  48338. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  48339. */
  48340. rolloffFactor: number;
  48341. /**
  48342. * Define the max distance the sound should be heard (intensity just became 0 at this point).
  48343. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  48344. */
  48345. maxDistance: number;
  48346. /**
  48347. * Define the distance attenuation model the sound will follow.
  48348. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  48349. */
  48350. distanceModel: string;
  48351. /**
  48352. * @hidden
  48353. * Back Compat
  48354. **/
  48355. onended: () => any;
  48356. /**
  48357. * Gets or sets an object used to store user defined information for the sound.
  48358. */
  48359. metadata: any;
  48360. /**
  48361. * Observable event when the current playing sound finishes.
  48362. */
  48363. onEndedObservable: Observable<Sound>;
  48364. /**
  48365. * Gets the current time for the sound.
  48366. */
  48367. get currentTime(): number;
  48368. private _panningModel;
  48369. private _playbackRate;
  48370. private _streaming;
  48371. private _startTime;
  48372. private _startOffset;
  48373. private _position;
  48374. /** @hidden */
  48375. _positionInEmitterSpace: boolean;
  48376. private _localDirection;
  48377. private _volume;
  48378. private _isReadyToPlay;
  48379. private _isDirectional;
  48380. private _readyToPlayCallback;
  48381. private _audioBuffer;
  48382. private _soundSource;
  48383. private _streamingSource;
  48384. private _soundPanner;
  48385. private _soundGain;
  48386. private _inputAudioNode;
  48387. private _outputAudioNode;
  48388. private _coneInnerAngle;
  48389. private _coneOuterAngle;
  48390. private _coneOuterGain;
  48391. private _scene;
  48392. private _connectedTransformNode;
  48393. private _customAttenuationFunction;
  48394. private _registerFunc;
  48395. private _isOutputConnected;
  48396. private _htmlAudioElement;
  48397. private _urlType;
  48398. private _length?;
  48399. private _offset?;
  48400. /** @hidden */
  48401. static _SceneComponentInitialization: (scene: Scene) => void;
  48402. /**
  48403. * Create a sound and attach it to a scene
  48404. * @param name Name of your sound
  48405. * @param urlOrArrayBuffer Url to the sound to load async or ArrayBuffer, it also works with MediaStreams
  48406. * @param scene defines the scene the sound belongs to
  48407. * @param readyToPlayCallback Provide a callback function if you'd like to load your code once the sound is ready to be played
  48408. * @param options Objects to provide with the current available options: autoplay, loop, volume, spatialSound, maxDistance, rolloffFactor, refDistance, distanceModel, panningModel, streaming
  48409. */
  48410. constructor(name: string, urlOrArrayBuffer: any, scene: Scene, readyToPlayCallback?: Nullable<() => void>, options?: ISoundOptions);
  48411. /**
  48412. * Release the sound and its associated resources
  48413. */
  48414. dispose(): void;
  48415. /**
  48416. * Gets if the sounds is ready to be played or not.
  48417. * @returns true if ready, otherwise false
  48418. */
  48419. isReady(): boolean;
  48420. /**
  48421. * Get the current class name.
  48422. * @returns current class name
  48423. */
  48424. getClassName(): string;
  48425. private _soundLoaded;
  48426. /**
  48427. * Sets the data of the sound from an audiobuffer
  48428. * @param audioBuffer The audioBuffer containing the data
  48429. */
  48430. setAudioBuffer(audioBuffer: AudioBuffer): void;
  48431. /**
  48432. * Updates the current sounds options such as maxdistance, loop...
  48433. * @param options A JSON object containing values named as the object properties
  48434. */
  48435. updateOptions(options: ISoundOptions): void;
  48436. private _createSpatialParameters;
  48437. private _updateSpatialParameters;
  48438. /**
  48439. * Switch the panning model to HRTF:
  48440. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  48441. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  48442. */
  48443. switchPanningModelToHRTF(): void;
  48444. /**
  48445. * Switch the panning model to Equal Power:
  48446. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  48447. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  48448. */
  48449. switchPanningModelToEqualPower(): void;
  48450. private _switchPanningModel;
  48451. /**
  48452. * Connect this sound to a sound track audio node like gain...
  48453. * @param soundTrackAudioNode the sound track audio node to connect to
  48454. */
  48455. connectToSoundTrackAudioNode(soundTrackAudioNode: AudioNode): void;
  48456. /**
  48457. * Transform this sound into a directional source
  48458. * @param coneInnerAngle Size of the inner cone in degree
  48459. * @param coneOuterAngle Size of the outer cone in degree
  48460. * @param coneOuterGain Volume of the sound outside the outer cone (between 0.0 and 1.0)
  48461. */
  48462. setDirectionalCone(coneInnerAngle: number, coneOuterAngle: number, coneOuterGain: number): void;
  48463. /**
  48464. * Gets or sets the inner angle for the directional cone.
  48465. */
  48466. get directionalConeInnerAngle(): number;
  48467. /**
  48468. * Gets or sets the inner angle for the directional cone.
  48469. */
  48470. set directionalConeInnerAngle(value: number);
  48471. /**
  48472. * Gets or sets the outer angle for the directional cone.
  48473. */
  48474. get directionalConeOuterAngle(): number;
  48475. /**
  48476. * Gets or sets the outer angle for the directional cone.
  48477. */
  48478. set directionalConeOuterAngle(value: number);
  48479. /**
  48480. * Sets the position of the emitter if spatial sound is enabled
  48481. * @param newPosition Defines the new position
  48482. */
  48483. setPosition(newPosition: Vector3): void;
  48484. /**
  48485. * Sets the local direction of the emitter if spatial sound is enabled
  48486. * @param newLocalDirection Defines the new local direction
  48487. */
  48488. setLocalDirectionToMesh(newLocalDirection: Vector3): void;
  48489. private _updateDirection;
  48490. /** @hidden */
  48491. updateDistanceFromListener(): void;
  48492. /**
  48493. * Sets a new custom attenuation function for the sound.
  48494. * @param callback Defines the function used for the attenuation
  48495. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  48496. */
  48497. setAttenuationFunction(callback: (currentVolume: number, currentDistance: number, maxDistance: number, refDistance: number, rolloffFactor: number) => number): void;
  48498. /**
  48499. * Play the sound
  48500. * @param time (optional) Start the sound after X seconds. Start immediately (0) by default.
  48501. * @param offset (optional) Start the sound at a specific time in seconds
  48502. * @param length (optional) Sound duration (in seconds)
  48503. */
  48504. play(time?: number, offset?: number, length?: number): void;
  48505. private _onended;
  48506. /**
  48507. * Stop the sound
  48508. * @param time (optional) Stop the sound after X seconds. Stop immediately (0) by default.
  48509. */
  48510. stop(time?: number): void;
  48511. /**
  48512. * Put the sound in pause
  48513. */
  48514. pause(): void;
  48515. /**
  48516. * Sets a dedicated volume for this sounds
  48517. * @param newVolume Define the new volume of the sound
  48518. * @param time Define time for gradual change to new volume
  48519. */
  48520. setVolume(newVolume: number, time?: number): void;
  48521. /**
  48522. * Set the sound play back rate
  48523. * @param newPlaybackRate Define the playback rate the sound should be played at
  48524. */
  48525. setPlaybackRate(newPlaybackRate: number): void;
  48526. /**
  48527. * Gets the volume of the sound.
  48528. * @returns the volume of the sound
  48529. */
  48530. getVolume(): number;
  48531. /**
  48532. * Attach the sound to a dedicated mesh
  48533. * @param transformNode The transform node to connect the sound with
  48534. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  48535. */
  48536. attachToMesh(transformNode: TransformNode): void;
  48537. /**
  48538. * Detach the sound from the previously attached mesh
  48539. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  48540. */
  48541. detachFromMesh(): void;
  48542. private _onRegisterAfterWorldMatrixUpdate;
  48543. /**
  48544. * Clone the current sound in the scene.
  48545. * @returns the new sound clone
  48546. */
  48547. clone(): Nullable<Sound>;
  48548. /**
  48549. * Gets the current underlying audio buffer containing the data
  48550. * @returns the audio buffer
  48551. */
  48552. getAudioBuffer(): Nullable<AudioBuffer>;
  48553. /**
  48554. * Gets the WebAudio AudioBufferSourceNode, lets you keep track of and stop instances of this Sound.
  48555. * @returns the source node
  48556. */
  48557. getSoundSource(): Nullable<AudioBufferSourceNode>;
  48558. /**
  48559. * Gets the WebAudio GainNode, gives you precise control over the gain of instances of this Sound.
  48560. * @returns the gain node
  48561. */
  48562. getSoundGain(): Nullable<GainNode>;
  48563. /**
  48564. * Serializes the Sound in a JSON representation
  48565. * @returns the JSON representation of the sound
  48566. */
  48567. serialize(): any;
  48568. /**
  48569. * Parse a JSON representation of a sound to instantiate in a given scene
  48570. * @param parsedSound Define the JSON representation of the sound (usually coming from the serialize method)
  48571. * @param scene Define the scene the new parsed sound should be created in
  48572. * @param rootUrl Define the rooturl of the load in case we need to fetch relative dependencies
  48573. * @param sourceSound Define a sound place holder if do not need to instantiate a new one
  48574. * @returns the newly parsed sound
  48575. */
  48576. static Parse(parsedSound: any, scene: Scene, rootUrl: string, sourceSound?: Sound): Sound;
  48577. }
  48578. }
  48579. declare module BABYLON {
  48580. /**
  48581. * This defines an action helpful to play a defined sound on a triggered action.
  48582. */
  48583. export class PlaySoundAction extends Action {
  48584. private _sound;
  48585. /**
  48586. * Instantiate the action
  48587. * @param triggerOptions defines the trigger options
  48588. * @param sound defines the sound to play
  48589. * @param condition defines the trigger related conditions
  48590. */
  48591. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  48592. /** @hidden */
  48593. _prepare(): void;
  48594. /**
  48595. * Execute the action and play the sound.
  48596. */
  48597. execute(): void;
  48598. /**
  48599. * Serializes the actions and its related information.
  48600. * @param parent defines the object to serialize in
  48601. * @returns the serialized object
  48602. */
  48603. serialize(parent: any): any;
  48604. }
  48605. /**
  48606. * This defines an action helpful to stop a defined sound on a triggered action.
  48607. */
  48608. export class StopSoundAction extends Action {
  48609. private _sound;
  48610. /**
  48611. * Instantiate the action
  48612. * @param triggerOptions defines the trigger options
  48613. * @param sound defines the sound to stop
  48614. * @param condition defines the trigger related conditions
  48615. */
  48616. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  48617. /** @hidden */
  48618. _prepare(): void;
  48619. /**
  48620. * Execute the action and stop the sound.
  48621. */
  48622. execute(): void;
  48623. /**
  48624. * Serializes the actions and its related information.
  48625. * @param parent defines the object to serialize in
  48626. * @returns the serialized object
  48627. */
  48628. serialize(parent: any): any;
  48629. }
  48630. }
  48631. declare module BABYLON {
  48632. /**
  48633. * This defines an action responsible to change the value of a property
  48634. * by interpolating between its current value and the newly set one once triggered.
  48635. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  48636. */
  48637. export class InterpolateValueAction extends Action {
  48638. /**
  48639. * Defines the path of the property where the value should be interpolated
  48640. */
  48641. propertyPath: string;
  48642. /**
  48643. * Defines the target value at the end of the interpolation.
  48644. */
  48645. value: any;
  48646. /**
  48647. * Defines the time it will take for the property to interpolate to the value.
  48648. */
  48649. duration: number;
  48650. /**
  48651. * Defines if the other scene animations should be stopped when the action has been triggered
  48652. */
  48653. stopOtherAnimations?: boolean;
  48654. /**
  48655. * Defines a callback raised once the interpolation animation has been done.
  48656. */
  48657. onInterpolationDone?: () => void;
  48658. /**
  48659. * Observable triggered once the interpolation animation has been done.
  48660. */
  48661. onInterpolationDoneObservable: Observable<InterpolateValueAction>;
  48662. private _target;
  48663. private _effectiveTarget;
  48664. private _property;
  48665. /**
  48666. * Instantiate the action
  48667. * @param triggerOptions defines the trigger options
  48668. * @param target defines the object containing the value to interpolate
  48669. * @param propertyPath defines the path to the property in the target object
  48670. * @param value defines the target value at the end of the interpolation
  48671. * @param duration defines the time it will take for the property to interpolate to the value.
  48672. * @param condition defines the trigger related conditions
  48673. * @param stopOtherAnimations defines if the other scene animations should be stopped when the action has been triggered
  48674. * @param onInterpolationDone defines a callback raised once the interpolation animation has been done
  48675. */
  48676. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, duration?: number, condition?: Condition, stopOtherAnimations?: boolean, onInterpolationDone?: () => void);
  48677. /** @hidden */
  48678. _prepare(): void;
  48679. /**
  48680. * Execute the action starts the value interpolation.
  48681. */
  48682. execute(): void;
  48683. /**
  48684. * Serializes the actions and its related information.
  48685. * @param parent defines the object to serialize in
  48686. * @returns the serialized object
  48687. */
  48688. serialize(parent: any): any;
  48689. }
  48690. }
  48691. declare module BABYLON {
  48692. /**
  48693. * This represents the default audio engine used in babylon.
  48694. * It is responsible to play, synchronize and analyse sounds throughout the application.
  48695. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  48696. */
  48697. export class AudioEngine implements IAudioEngine {
  48698. private _audioContext;
  48699. private _audioContextInitialized;
  48700. private _muteButton;
  48701. private _hostElement;
  48702. /**
  48703. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  48704. */
  48705. canUseWebAudio: boolean;
  48706. /**
  48707. * The master gain node defines the global audio volume of your audio engine.
  48708. */
  48709. masterGain: GainNode;
  48710. /**
  48711. * Defines if Babylon should emit a warning if WebAudio is not supported.
  48712. * @ignoreNaming
  48713. */
  48714. WarnedWebAudioUnsupported: boolean;
  48715. /**
  48716. * Gets whether or not mp3 are supported by your browser.
  48717. */
  48718. isMP3supported: boolean;
  48719. /**
  48720. * Gets whether or not ogg are supported by your browser.
  48721. */
  48722. isOGGsupported: boolean;
  48723. /**
  48724. * Gets whether audio has been unlocked on the device.
  48725. * Some Browsers have strong restrictions about Audio and won t autoplay unless
  48726. * a user interaction has happened.
  48727. */
  48728. unlocked: boolean;
  48729. /**
  48730. * Defines if the audio engine relies on a custom unlocked button.
  48731. * In this case, the embedded button will not be displayed.
  48732. */
  48733. useCustomUnlockedButton: boolean;
  48734. /**
  48735. * Event raised when audio has been unlocked on the browser.
  48736. */
  48737. onAudioUnlockedObservable: Observable<IAudioEngine>;
  48738. /**
  48739. * Event raised when audio has been locked on the browser.
  48740. */
  48741. onAudioLockedObservable: Observable<IAudioEngine>;
  48742. /**
  48743. * Gets the current AudioContext if available.
  48744. */
  48745. get audioContext(): Nullable<AudioContext>;
  48746. private _connectedAnalyser;
  48747. /**
  48748. * Instantiates a new audio engine.
  48749. *
  48750. * There should be only one per page as some browsers restrict the number
  48751. * of audio contexts you can create.
  48752. * @param hostElement defines the host element where to display the mute icon if necessary
  48753. */
  48754. constructor(hostElement?: Nullable<HTMLElement>);
  48755. /**
  48756. * Flags the audio engine in Locked state.
  48757. * This happens due to new browser policies preventing audio to autoplay.
  48758. */
  48759. lock(): void;
  48760. /**
  48761. * Unlocks the audio engine once a user action has been done on the dom.
  48762. * This is helpful to resume play once browser policies have been satisfied.
  48763. */
  48764. unlock(): void;
  48765. private _resumeAudioContext;
  48766. private _initializeAudioContext;
  48767. private _tryToRun;
  48768. private _triggerRunningState;
  48769. private _triggerSuspendedState;
  48770. private _displayMuteButton;
  48771. private _moveButtonToTopLeft;
  48772. private _onResize;
  48773. private _hideMuteButton;
  48774. /**
  48775. * Destroy and release the resources associated with the audio context.
  48776. */
  48777. dispose(): void;
  48778. /**
  48779. * Gets the global volume sets on the master gain.
  48780. * @returns the global volume if set or -1 otherwise
  48781. */
  48782. getGlobalVolume(): number;
  48783. /**
  48784. * Sets the global volume of your experience (sets on the master gain).
  48785. * @param newVolume Defines the new global volume of the application
  48786. */
  48787. setGlobalVolume(newVolume: number): void;
  48788. /**
  48789. * Connect the audio engine to an audio analyser allowing some amazing
  48790. * synchronization between the sounds/music and your visualization (VuMeter for instance).
  48791. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  48792. * @param analyser The analyser to connect to the engine
  48793. */
  48794. connectToAnalyser(analyser: Analyser): void;
  48795. }
  48796. }
  48797. declare module BABYLON {
  48798. /**
  48799. * Options allowed during the creation of a sound track.
  48800. */
  48801. export interface ISoundTrackOptions {
  48802. /**
  48803. * The volume the sound track should take during creation
  48804. */
  48805. volume?: number;
  48806. /**
  48807. * Define if the sound track is the main sound track of the scene
  48808. */
  48809. mainTrack?: boolean;
  48810. }
  48811. /**
  48812. * It could be useful to isolate your music & sounds on several tracks to better manage volume on a grouped instance of sounds.
  48813. * It will be also used in a future release to apply effects on a specific track.
  48814. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  48815. */
  48816. export class SoundTrack {
  48817. /**
  48818. * The unique identifier of the sound track in the scene.
  48819. */
  48820. id: number;
  48821. /**
  48822. * The list of sounds included in the sound track.
  48823. */
  48824. soundCollection: Array<Sound>;
  48825. private _outputAudioNode;
  48826. private _scene;
  48827. private _connectedAnalyser;
  48828. private _options;
  48829. private _isInitialized;
  48830. /**
  48831. * Creates a new sound track.
  48832. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  48833. * @param scene Define the scene the sound track belongs to
  48834. * @param options
  48835. */
  48836. constructor(scene: Scene, options?: ISoundTrackOptions);
  48837. private _initializeSoundTrackAudioGraph;
  48838. /**
  48839. * Release the sound track and its associated resources
  48840. */
  48841. dispose(): void;
  48842. /**
  48843. * Adds a sound to this sound track
  48844. * @param sound define the sound to add
  48845. * @ignoreNaming
  48846. */
  48847. addSound(sound: Sound): void;
  48848. /**
  48849. * Removes a sound to this sound track
  48850. * @param sound define the sound to remove
  48851. * @ignoreNaming
  48852. */
  48853. removeSound(sound: Sound): void;
  48854. /**
  48855. * Set a global volume for the full sound track.
  48856. * @param newVolume Define the new volume of the sound track
  48857. */
  48858. setVolume(newVolume: number): void;
  48859. /**
  48860. * Switch the panning model to HRTF:
  48861. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  48862. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  48863. */
  48864. switchPanningModelToHRTF(): void;
  48865. /**
  48866. * Switch the panning model to Equal Power:
  48867. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  48868. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  48869. */
  48870. switchPanningModelToEqualPower(): void;
  48871. /**
  48872. * Connect the sound track to an audio analyser allowing some amazing
  48873. * synchronization between the sounds/music and your visualization (VuMeter for instance).
  48874. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  48875. * @param analyser The analyser to connect to the engine
  48876. */
  48877. connectToAnalyser(analyser: Analyser): void;
  48878. }
  48879. }
  48880. declare module BABYLON {
  48881. interface AbstractScene {
  48882. /**
  48883. * The list of sounds used in the scene.
  48884. */
  48885. sounds: Nullable<Array<Sound>>;
  48886. }
  48887. interface Scene {
  48888. /**
  48889. * @hidden
  48890. * Backing field
  48891. */
  48892. _mainSoundTrack: SoundTrack;
  48893. /**
  48894. * The main sound track played by the scene.
  48895. * It contains your primary collection of sounds.
  48896. */
  48897. mainSoundTrack: SoundTrack;
  48898. /**
  48899. * The list of sound tracks added to the scene
  48900. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  48901. */
  48902. soundTracks: Nullable<Array<SoundTrack>>;
  48903. /**
  48904. * Gets a sound using a given name
  48905. * @param name defines the name to search for
  48906. * @return the found sound or null if not found at all.
  48907. */
  48908. getSoundByName(name: string): Nullable<Sound>;
  48909. /**
  48910. * Gets or sets if audio support is enabled
  48911. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  48912. */
  48913. audioEnabled: boolean;
  48914. /**
  48915. * Gets or sets if audio will be output to headphones
  48916. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  48917. */
  48918. headphone: boolean;
  48919. /**
  48920. * Gets or sets custom audio listener position provider
  48921. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  48922. */
  48923. audioListenerPositionProvider: Nullable<() => Vector3>;
  48924. /**
  48925. * Gets or sets a refresh rate when using 3D audio positioning
  48926. */
  48927. audioPositioningRefreshRate: number;
  48928. }
  48929. /**
  48930. * Defines the sound scene component responsible to manage any sounds
  48931. * in a given scene.
  48932. */
  48933. export class AudioSceneComponent implements ISceneSerializableComponent {
  48934. private static _CameraDirectionLH;
  48935. private static _CameraDirectionRH;
  48936. /**
  48937. * The component name helpful to identify the component in the list of scene components.
  48938. */
  48939. readonly name: string;
  48940. /**
  48941. * The scene the component belongs to.
  48942. */
  48943. scene: Scene;
  48944. private _audioEnabled;
  48945. /**
  48946. * Gets whether audio is enabled or not.
  48947. * Please use related enable/disable method to switch state.
  48948. */
  48949. get audioEnabled(): boolean;
  48950. private _headphone;
  48951. /**
  48952. * Gets whether audio is outputting to headphone or not.
  48953. * Please use the according Switch methods to change output.
  48954. */
  48955. get headphone(): boolean;
  48956. /**
  48957. * Gets or sets a refresh rate when using 3D audio positioning
  48958. */
  48959. audioPositioningRefreshRate: number;
  48960. private _audioListenerPositionProvider;
  48961. /**
  48962. * Gets the current audio listener position provider
  48963. */
  48964. get audioListenerPositionProvider(): Nullable<() => Vector3>;
  48965. /**
  48966. * Sets a custom listener position for all sounds in the scene
  48967. * By default, this is the position of the first active camera
  48968. */
  48969. set audioListenerPositionProvider(value: Nullable<() => Vector3>);
  48970. /**
  48971. * Creates a new instance of the component for the given scene
  48972. * @param scene Defines the scene to register the component in
  48973. */
  48974. constructor(scene: Scene);
  48975. /**
  48976. * Registers the component in a given scene
  48977. */
  48978. register(): void;
  48979. /**
  48980. * Rebuilds the elements related to this component in case of
  48981. * context lost for instance.
  48982. */
  48983. rebuild(): void;
  48984. /**
  48985. * Serializes the component data to the specified json object
  48986. * @param serializationObject The object to serialize to
  48987. */
  48988. serialize(serializationObject: any): void;
  48989. /**
  48990. * Adds all the elements from the container to the scene
  48991. * @param container the container holding the elements
  48992. */
  48993. addFromContainer(container: AbstractScene): void;
  48994. /**
  48995. * Removes all the elements in the container from the scene
  48996. * @param container contains the elements to remove
  48997. * @param dispose if the removed element should be disposed (default: false)
  48998. */
  48999. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  49000. /**
  49001. * Disposes the component and the associated resources.
  49002. */
  49003. dispose(): void;
  49004. /**
  49005. * Disables audio in the associated scene.
  49006. */
  49007. disableAudio(): void;
  49008. /**
  49009. * Enables audio in the associated scene.
  49010. */
  49011. enableAudio(): void;
  49012. /**
  49013. * Switch audio to headphone output.
  49014. */
  49015. switchAudioModeForHeadphones(): void;
  49016. /**
  49017. * Switch audio to normal speakers.
  49018. */
  49019. switchAudioModeForNormalSpeakers(): void;
  49020. private _cachedCameraDirection;
  49021. private _cachedCameraPosition;
  49022. private _lastCheck;
  49023. private _afterRender;
  49024. }
  49025. }
  49026. declare module BABYLON {
  49027. /**
  49028. * Wraps one or more Sound objects and selects one with random weight for playback.
  49029. */
  49030. export class WeightedSound {
  49031. /** When true a Sound will be selected and played when the current playing Sound completes. */
  49032. loop: boolean;
  49033. private _coneInnerAngle;
  49034. private _coneOuterAngle;
  49035. private _volume;
  49036. /** A Sound is currently playing. */
  49037. isPlaying: boolean;
  49038. /** A Sound is currently paused. */
  49039. isPaused: boolean;
  49040. private _sounds;
  49041. private _weights;
  49042. private _currentIndex?;
  49043. /**
  49044. * Creates a new WeightedSound from the list of sounds given.
  49045. * @param loop When true a Sound will be selected and played when the current playing Sound completes.
  49046. * @param sounds Array of Sounds that will be selected from.
  49047. * @param weights Array of number values for selection weights; length must equal sounds, values will be normalized to 1
  49048. */
  49049. constructor(loop: boolean, sounds: Sound[], weights: number[]);
  49050. /**
  49051. * The size of cone in degrees for a directional sound in which there will be no attenuation.
  49052. */
  49053. get directionalConeInnerAngle(): number;
  49054. /**
  49055. * The size of cone in degrees for a directional sound in which there will be no attenuation.
  49056. */
  49057. set directionalConeInnerAngle(value: number);
  49058. /**
  49059. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  49060. * Listener angles between innerAngle and outerAngle will falloff linearly.
  49061. */
  49062. get directionalConeOuterAngle(): number;
  49063. /**
  49064. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  49065. * Listener angles between innerAngle and outerAngle will falloff linearly.
  49066. */
  49067. set directionalConeOuterAngle(value: number);
  49068. /**
  49069. * Playback volume.
  49070. */
  49071. get volume(): number;
  49072. /**
  49073. * Playback volume.
  49074. */
  49075. set volume(value: number);
  49076. private _onended;
  49077. /**
  49078. * Suspend playback
  49079. */
  49080. pause(): void;
  49081. /**
  49082. * Stop playback
  49083. */
  49084. stop(): void;
  49085. /**
  49086. * Start playback.
  49087. * @param startOffset Position the clip head at a specific time in seconds.
  49088. */
  49089. play(startOffset?: number): void;
  49090. }
  49091. }
  49092. declare module BABYLON {
  49093. /**
  49094. * Add a bouncing effect to an ArcRotateCamera when reaching a specified minimum and maximum radius
  49095. * @see https://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  49096. */
  49097. export class BouncingBehavior implements Behavior<ArcRotateCamera> {
  49098. /**
  49099. * Gets the name of the behavior.
  49100. */
  49101. get name(): string;
  49102. /**
  49103. * The easing function used by animations
  49104. */
  49105. static EasingFunction: BackEase;
  49106. /**
  49107. * The easing mode used by animations
  49108. */
  49109. static EasingMode: number;
  49110. /**
  49111. * The duration of the animation, in milliseconds
  49112. */
  49113. transitionDuration: number;
  49114. /**
  49115. * Length of the distance animated by the transition when lower radius is reached
  49116. */
  49117. lowerRadiusTransitionRange: number;
  49118. /**
  49119. * Length of the distance animated by the transition when upper radius is reached
  49120. */
  49121. upperRadiusTransitionRange: number;
  49122. private _autoTransitionRange;
  49123. /**
  49124. * Gets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  49125. */
  49126. get autoTransitionRange(): boolean;
  49127. /**
  49128. * Sets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  49129. * Transition ranges will be set to 5% of the bounding box diagonal in world space
  49130. */
  49131. set autoTransitionRange(value: boolean);
  49132. private _attachedCamera;
  49133. private _onAfterCheckInputsObserver;
  49134. private _onMeshTargetChangedObserver;
  49135. /**
  49136. * Initializes the behavior.
  49137. */
  49138. init(): void;
  49139. /**
  49140. * Attaches the behavior to its arc rotate camera.
  49141. * @param camera Defines the camera to attach the behavior to
  49142. */
  49143. attach(camera: ArcRotateCamera): void;
  49144. /**
  49145. * Detaches the behavior from its current arc rotate camera.
  49146. */
  49147. detach(): void;
  49148. private _radiusIsAnimating;
  49149. private _radiusBounceTransition;
  49150. private _animatables;
  49151. private _cachedWheelPrecision;
  49152. /**
  49153. * Checks if the camera radius is at the specified limit. Takes into account animation locks.
  49154. * @param radiusLimit The limit to check against.
  49155. * @return Bool to indicate if at limit.
  49156. */
  49157. private _isRadiusAtLimit;
  49158. /**
  49159. * Applies an animation to the radius of the camera, extending by the radiusDelta.
  49160. * @param radiusDelta The delta by which to animate to. Can be negative.
  49161. */
  49162. private _applyBoundRadiusAnimation;
  49163. /**
  49164. * Removes all animation locks. Allows new animations to be added to any of the camera properties.
  49165. */
  49166. protected _clearAnimationLocks(): void;
  49167. /**
  49168. * Stops and removes all animations that have been applied to the camera
  49169. */
  49170. stopAllAnimations(): void;
  49171. }
  49172. }
  49173. declare module BABYLON {
  49174. /**
  49175. * 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.
  49176. * @see https://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  49177. */
  49178. export class FramingBehavior implements Behavior<ArcRotateCamera> {
  49179. /**
  49180. * Gets the name of the behavior.
  49181. */
  49182. get name(): string;
  49183. private _mode;
  49184. private _radiusScale;
  49185. private _positionScale;
  49186. private _defaultElevation;
  49187. private _elevationReturnTime;
  49188. private _elevationReturnWaitTime;
  49189. private _zoomStopsAnimation;
  49190. private _framingTime;
  49191. /**
  49192. * The easing function used by animations
  49193. */
  49194. static EasingFunction: ExponentialEase;
  49195. /**
  49196. * The easing mode used by animations
  49197. */
  49198. static EasingMode: number;
  49199. /**
  49200. * Sets the current mode used by the behavior
  49201. */
  49202. set mode(mode: number);
  49203. /**
  49204. * Gets current mode used by the behavior.
  49205. */
  49206. get mode(): number;
  49207. /**
  49208. * Sets the scale applied to the radius (1 by default)
  49209. */
  49210. set radiusScale(radius: number);
  49211. /**
  49212. * Gets the scale applied to the radius
  49213. */
  49214. get radiusScale(): number;
  49215. /**
  49216. * Sets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  49217. */
  49218. set positionScale(scale: number);
  49219. /**
  49220. * Gets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  49221. */
  49222. get positionScale(): number;
  49223. /**
  49224. * Sets the angle above/below the horizontal plane to return to when the return to default elevation idle
  49225. * behaviour is triggered, in radians.
  49226. */
  49227. set defaultElevation(elevation: number);
  49228. /**
  49229. * Gets the angle above/below the horizontal plane to return to when the return to default elevation idle
  49230. * behaviour is triggered, in radians.
  49231. */
  49232. get defaultElevation(): number;
  49233. /**
  49234. * Sets the time (in milliseconds) taken to return to the default beta position.
  49235. * Negative value indicates camera should not return to default.
  49236. */
  49237. set elevationReturnTime(speed: number);
  49238. /**
  49239. * Gets the time (in milliseconds) taken to return to the default beta position.
  49240. * Negative value indicates camera should not return to default.
  49241. */
  49242. get elevationReturnTime(): number;
  49243. /**
  49244. * Sets the delay (in milliseconds) taken before the camera returns to the default beta position.
  49245. */
  49246. set elevationReturnWaitTime(time: number);
  49247. /**
  49248. * Gets the delay (in milliseconds) taken before the camera returns to the default beta position.
  49249. */
  49250. get elevationReturnWaitTime(): number;
  49251. /**
  49252. * Sets the flag that indicates if user zooming should stop animation.
  49253. */
  49254. set zoomStopsAnimation(flag: boolean);
  49255. /**
  49256. * Gets the flag that indicates if user zooming should stop animation.
  49257. */
  49258. get zoomStopsAnimation(): boolean;
  49259. /**
  49260. * Sets the transition time when framing the mesh, in milliseconds
  49261. */
  49262. set framingTime(time: number);
  49263. /**
  49264. * Gets the transition time when framing the mesh, in milliseconds
  49265. */
  49266. get framingTime(): number;
  49267. /**
  49268. * Define if the behavior should automatically change the configured
  49269. * camera limits and sensibilities.
  49270. */
  49271. autoCorrectCameraLimitsAndSensibility: boolean;
  49272. private _onPrePointerObservableObserver;
  49273. private _onAfterCheckInputsObserver;
  49274. private _onMeshTargetChangedObserver;
  49275. private _attachedCamera;
  49276. private _isPointerDown;
  49277. private _lastInteractionTime;
  49278. /**
  49279. * Initializes the behavior.
  49280. */
  49281. init(): void;
  49282. /**
  49283. * Attaches the behavior to its arc rotate camera.
  49284. * @param camera Defines the camera to attach the behavior to
  49285. */
  49286. attach(camera: ArcRotateCamera): void;
  49287. /**
  49288. * Detaches the behavior from its current arc rotate camera.
  49289. */
  49290. detach(): void;
  49291. private _animatables;
  49292. private _betaIsAnimating;
  49293. private _betaTransition;
  49294. private _radiusTransition;
  49295. private _vectorTransition;
  49296. /**
  49297. * Targets the given mesh and updates zoom level accordingly.
  49298. * @param mesh The mesh to target.
  49299. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  49300. * @param onAnimationEnd Callback triggered at the end of the framing animation
  49301. */
  49302. zoomOnMesh(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  49303. /**
  49304. * Targets the given mesh with its children and updates zoom level accordingly.
  49305. * @param mesh The mesh to target.
  49306. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  49307. * @param onAnimationEnd Callback triggered at the end of the framing animation
  49308. */
  49309. zoomOnMeshHierarchy(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  49310. /**
  49311. * Targets the given meshes with their children and updates zoom level accordingly.
  49312. * @param meshes The mesh to target.
  49313. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  49314. * @param onAnimationEnd Callback triggered at the end of the framing animation
  49315. */
  49316. zoomOnMeshesHierarchy(meshes: AbstractMesh[], focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  49317. /**
  49318. * Targets the bounding box info defined by its extends and updates zoom level accordingly.
  49319. * @param minimumWorld Determines the smaller position of the bounding box extend
  49320. * @param maximumWorld Determines the bigger position of the bounding box extend
  49321. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  49322. * @param onAnimationEnd Callback triggered at the end of the framing animation
  49323. */
  49324. zoomOnBoundingInfo(minimumWorld: Vector3, maximumWorld: Vector3, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  49325. /**
  49326. * Calculates the lowest radius for the camera based on the bounding box of the mesh.
  49327. * @param mesh The mesh on which to base the calculation. mesh boundingInfo used to estimate necessary
  49328. * frustum width.
  49329. * @return The minimum distance from the primary mesh's center point at which the camera must be kept in order
  49330. * to fully enclose the mesh in the viewing frustum.
  49331. */
  49332. protected _calculateLowerRadiusFromModelBoundingSphere(minimumWorld: Vector3, maximumWorld: Vector3): number;
  49333. /**
  49334. * Keeps the camera above the ground plane. If the user pulls the camera below the ground plane, the camera
  49335. * is automatically returned to its default position (expected to be above ground plane).
  49336. */
  49337. private _maintainCameraAboveGround;
  49338. /**
  49339. * Returns the frustum slope based on the canvas ratio and camera FOV
  49340. * @returns The frustum slope represented as a Vector2 with X and Y slopes
  49341. */
  49342. private _getFrustumSlope;
  49343. /**
  49344. * Removes all animation locks. Allows new animations to be added to any of the arcCamera properties.
  49345. */
  49346. private _clearAnimationLocks;
  49347. /**
  49348. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  49349. */
  49350. private _applyUserInteraction;
  49351. /**
  49352. * Stops and removes all animations that have been applied to the camera
  49353. */
  49354. stopAllAnimations(): void;
  49355. /**
  49356. * Gets a value indicating if the user is moving the camera
  49357. */
  49358. get isUserIsMoving(): boolean;
  49359. /**
  49360. * The camera can move all the way towards the mesh.
  49361. */
  49362. static IgnoreBoundsSizeMode: number;
  49363. /**
  49364. * The camera is not allowed to zoom closer to the mesh than the point at which the adjusted bounding sphere touches the frustum sides
  49365. */
  49366. static FitFrustumSidesMode: number;
  49367. }
  49368. }
  49369. declare module BABYLON {
  49370. /**
  49371. * Base class for Camera Pointer Inputs.
  49372. * See FollowCameraPointersInput in src/Cameras/Inputs/followCameraPointersInput.ts
  49373. * for example usage.
  49374. */
  49375. export abstract class BaseCameraPointersInput implements ICameraInput<Camera> {
  49376. /**
  49377. * Defines the camera the input is attached to.
  49378. */
  49379. abstract camera: Camera;
  49380. /**
  49381. * Whether keyboard modifier keys are pressed at time of last mouse event.
  49382. */
  49383. protected _altKey: boolean;
  49384. protected _ctrlKey: boolean;
  49385. protected _metaKey: boolean;
  49386. protected _shiftKey: boolean;
  49387. /**
  49388. * Which mouse buttons were pressed at time of last mouse event.
  49389. * https://developer.mozilla.org/en-US/docs/Web/API/MouseEvent/buttons
  49390. */
  49391. protected _buttonsPressed: number;
  49392. /**
  49393. * Defines the buttons associated with the input to handle camera move.
  49394. */
  49395. buttons: number[];
  49396. /**
  49397. * Attach the input controls to a specific dom element to get the input from.
  49398. * @param element Defines the element the controls should be listened from
  49399. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  49400. */
  49401. attachControl(noPreventDefault?: boolean): void;
  49402. /**
  49403. * Detach the current controls from the specified dom element.
  49404. */
  49405. detachControl(): void;
  49406. /**
  49407. * Gets the class name of the current input.
  49408. * @returns the class name
  49409. */
  49410. getClassName(): string;
  49411. /**
  49412. * Get the friendly name associated with the input class.
  49413. * @returns the input friendly name
  49414. */
  49415. getSimpleName(): string;
  49416. /**
  49417. * Called on pointer POINTERDOUBLETAP event.
  49418. * Override this method to provide functionality on POINTERDOUBLETAP event.
  49419. */
  49420. protected onDoubleTap(type: string): void;
  49421. /**
  49422. * Called on pointer POINTERMOVE event if only a single touch is active.
  49423. * Override this method to provide functionality.
  49424. */
  49425. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  49426. /**
  49427. * Called on pointer POINTERMOVE event if multiple touches are active.
  49428. * Override this method to provide functionality.
  49429. */
  49430. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  49431. /**
  49432. * Called on JS contextmenu event.
  49433. * Override this method to provide functionality.
  49434. */
  49435. protected onContextMenu(evt: PointerEvent): void;
  49436. /**
  49437. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  49438. * press.
  49439. * Override this method to provide functionality.
  49440. */
  49441. protected onButtonDown(evt: PointerEvent): void;
  49442. /**
  49443. * Called each time a new POINTERUP event occurs. Ie, for each button
  49444. * release.
  49445. * Override this method to provide functionality.
  49446. */
  49447. protected onButtonUp(evt: PointerEvent): void;
  49448. /**
  49449. * Called when window becomes inactive.
  49450. * Override this method to provide functionality.
  49451. */
  49452. protected onLostFocus(): void;
  49453. private _pointerInput;
  49454. private _observer;
  49455. private _onLostFocus;
  49456. private pointA;
  49457. private pointB;
  49458. }
  49459. }
  49460. declare module BABYLON {
  49461. /**
  49462. * Manage the pointers inputs to control an arc rotate camera.
  49463. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  49464. */
  49465. export class ArcRotateCameraPointersInput extends BaseCameraPointersInput {
  49466. /**
  49467. * Defines the camera the input is attached to.
  49468. */
  49469. camera: ArcRotateCamera;
  49470. /**
  49471. * Gets the class name of the current input.
  49472. * @returns the class name
  49473. */
  49474. getClassName(): string;
  49475. /**
  49476. * Defines the buttons associated with the input to handle camera move.
  49477. */
  49478. buttons: number[];
  49479. /**
  49480. * Defines the pointer angular sensibility along the X axis or how fast is
  49481. * the camera rotating.
  49482. */
  49483. angularSensibilityX: number;
  49484. /**
  49485. * Defines the pointer angular sensibility along the Y axis or how fast is
  49486. * the camera rotating.
  49487. */
  49488. angularSensibilityY: number;
  49489. /**
  49490. * Defines the pointer pinch precision or how fast is the camera zooming.
  49491. */
  49492. pinchPrecision: number;
  49493. /**
  49494. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  49495. * from 0.
  49496. * It defines the percentage of current camera.radius to use as delta when
  49497. * pinch zoom is used.
  49498. */
  49499. pinchDeltaPercentage: number;
  49500. /**
  49501. * When useNaturalPinchZoom is true, multi touch zoom will zoom in such
  49502. * that any object in the plane at the camera's target point will scale
  49503. * perfectly with finger motion.
  49504. * Overrides pinchDeltaPercentage and pinchPrecision.
  49505. */
  49506. useNaturalPinchZoom: boolean;
  49507. /**
  49508. * Defines whether zoom (2 fingers pinch) is enabled through multitouch
  49509. */
  49510. pinchZoom: boolean;
  49511. /**
  49512. * Defines the pointer panning sensibility or how fast is the camera moving.
  49513. */
  49514. panningSensibility: number;
  49515. /**
  49516. * Defines whether panning (2 fingers swipe) is enabled through multitouch.
  49517. */
  49518. multiTouchPanning: boolean;
  49519. /**
  49520. * Defines whether panning is enabled for both pan (2 fingers swipe) and
  49521. * zoom (pinch) through multitouch.
  49522. */
  49523. multiTouchPanAndZoom: boolean;
  49524. /**
  49525. * Revers pinch action direction.
  49526. */
  49527. pinchInwards: boolean;
  49528. private _isPanClick;
  49529. private _twoFingerActivityCount;
  49530. private _isPinching;
  49531. /**
  49532. * Move camera from multi touch panning positions.
  49533. */
  49534. private _computeMultiTouchPanning;
  49535. /**
  49536. * Move camera from pinch zoom distances.
  49537. */
  49538. private _computePinchZoom;
  49539. /**
  49540. * Called on pointer POINTERMOVE event if only a single touch is active.
  49541. */
  49542. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  49543. /**
  49544. * Called on pointer POINTERDOUBLETAP event.
  49545. */
  49546. protected onDoubleTap(type: string): void;
  49547. /**
  49548. * Called on pointer POINTERMOVE event if multiple touches are active.
  49549. */
  49550. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  49551. /**
  49552. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  49553. * press.
  49554. */
  49555. protected onButtonDown(evt: PointerEvent): void;
  49556. /**
  49557. * Called each time a new POINTERUP event occurs. Ie, for each button
  49558. * release.
  49559. */
  49560. protected onButtonUp(evt: PointerEvent): void;
  49561. /**
  49562. * Called when window becomes inactive.
  49563. */
  49564. protected onLostFocus(): void;
  49565. }
  49566. }
  49567. declare module BABYLON {
  49568. /**
  49569. * Manage the keyboard inputs to control the movement of an arc rotate camera.
  49570. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  49571. */
  49572. export class ArcRotateCameraKeyboardMoveInput implements ICameraInput<ArcRotateCamera> {
  49573. /**
  49574. * Defines the camera the input is attached to.
  49575. */
  49576. camera: ArcRotateCamera;
  49577. /**
  49578. * Defines the list of key codes associated with the up action (increase alpha)
  49579. */
  49580. keysUp: number[];
  49581. /**
  49582. * Defines the list of key codes associated with the down action (decrease alpha)
  49583. */
  49584. keysDown: number[];
  49585. /**
  49586. * Defines the list of key codes associated with the left action (increase beta)
  49587. */
  49588. keysLeft: number[];
  49589. /**
  49590. * Defines the list of key codes associated with the right action (decrease beta)
  49591. */
  49592. keysRight: number[];
  49593. /**
  49594. * Defines the list of key codes associated with the reset action.
  49595. * Those keys reset the camera to its last stored state (with the method camera.storeState())
  49596. */
  49597. keysReset: number[];
  49598. /**
  49599. * Defines the panning sensibility of the inputs.
  49600. * (How fast is the camera panning)
  49601. */
  49602. panningSensibility: number;
  49603. /**
  49604. * Defines the zooming sensibility of the inputs.
  49605. * (How fast is the camera zooming)
  49606. */
  49607. zoomingSensibility: number;
  49608. /**
  49609. * Defines whether maintaining the alt key down switch the movement mode from
  49610. * orientation to zoom.
  49611. */
  49612. useAltToZoom: boolean;
  49613. /**
  49614. * Rotation speed of the camera
  49615. */
  49616. angularSpeed: number;
  49617. private _keys;
  49618. private _ctrlPressed;
  49619. private _altPressed;
  49620. private _onCanvasBlurObserver;
  49621. private _onKeyboardObserver;
  49622. private _engine;
  49623. private _scene;
  49624. /**
  49625. * Attach the input controls to a specific dom element to get the input from.
  49626. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  49627. */
  49628. attachControl(noPreventDefault?: boolean): void;
  49629. /**
  49630. * Detach the current controls from the specified dom element.
  49631. */
  49632. detachControl(): void;
  49633. /**
  49634. * Update the current camera state depending on the inputs that have been used this frame.
  49635. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  49636. */
  49637. checkInputs(): void;
  49638. /**
  49639. * Gets the class name of the current input.
  49640. * @returns the class name
  49641. */
  49642. getClassName(): string;
  49643. /**
  49644. * Get the friendly name associated with the input class.
  49645. * @returns the input friendly name
  49646. */
  49647. getSimpleName(): string;
  49648. }
  49649. }
  49650. declare module BABYLON {
  49651. /**
  49652. * Manage the mouse wheel inputs to control an arc rotate camera.
  49653. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  49654. */
  49655. export class ArcRotateCameraMouseWheelInput implements ICameraInput<ArcRotateCamera> {
  49656. /**
  49657. * Defines the camera the input is attached to.
  49658. */
  49659. camera: ArcRotateCamera;
  49660. /**
  49661. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  49662. */
  49663. wheelPrecision: number;
  49664. /**
  49665. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  49666. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  49667. */
  49668. wheelDeltaPercentage: number;
  49669. private _wheel;
  49670. private _observer;
  49671. private computeDeltaFromMouseWheelLegacyEvent;
  49672. /**
  49673. * Attach the input controls to a specific dom element to get the input from.
  49674. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  49675. */
  49676. attachControl(noPreventDefault?: boolean): void;
  49677. /**
  49678. * Detach the current controls from the specified dom element.
  49679. */
  49680. detachControl(): void;
  49681. /**
  49682. * Gets the class name of the current input.
  49683. * @returns the class name
  49684. */
  49685. getClassName(): string;
  49686. /**
  49687. * Get the friendly name associated with the input class.
  49688. * @returns the input friendly name
  49689. */
  49690. getSimpleName(): string;
  49691. }
  49692. }
  49693. declare module BABYLON {
  49694. /**
  49695. * Default Inputs manager for the ArcRotateCamera.
  49696. * It groups all the default supported inputs for ease of use.
  49697. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  49698. */
  49699. export class ArcRotateCameraInputsManager extends CameraInputsManager<ArcRotateCamera> {
  49700. /**
  49701. * Instantiates a new ArcRotateCameraInputsManager.
  49702. * @param camera Defines the camera the inputs belong to
  49703. */
  49704. constructor(camera: ArcRotateCamera);
  49705. /**
  49706. * Add mouse wheel input support to the input manager.
  49707. * @returns the current input manager
  49708. */
  49709. addMouseWheel(): ArcRotateCameraInputsManager;
  49710. /**
  49711. * Add pointers input support to the input manager.
  49712. * @returns the current input manager
  49713. */
  49714. addPointers(): ArcRotateCameraInputsManager;
  49715. /**
  49716. * Add keyboard input support to the input manager.
  49717. * @returns the current input manager
  49718. */
  49719. addKeyboard(): ArcRotateCameraInputsManager;
  49720. }
  49721. }
  49722. declare module BABYLON {
  49723. /**
  49724. * This represents an orbital type of camera.
  49725. *
  49726. * 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.
  49727. * 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.
  49728. * @see https://doc.babylonjs.com/babylon101/cameras#arc-rotate-camera
  49729. */
  49730. export class ArcRotateCamera extends TargetCamera {
  49731. /**
  49732. * Defines the rotation angle of the camera along the longitudinal axis.
  49733. */
  49734. alpha: number;
  49735. /**
  49736. * Defines the rotation angle of the camera along the latitudinal axis.
  49737. */
  49738. beta: number;
  49739. /**
  49740. * Defines the radius of the camera from it s target point.
  49741. */
  49742. radius: number;
  49743. protected _target: Vector3;
  49744. protected _targetHost: Nullable<AbstractMesh>;
  49745. /**
  49746. * Defines the target point of the camera.
  49747. * The camera looks towards it form the radius distance.
  49748. * Please note that you can set the target to a mesh and thus the target will be copied from mesh.position
  49749. */
  49750. get target(): Vector3;
  49751. set target(value: Vector3);
  49752. /**
  49753. * Define the current local position of the camera in the scene
  49754. */
  49755. get position(): Vector3;
  49756. set position(newPosition: Vector3);
  49757. protected _upToYMatrix: Matrix;
  49758. protected _YToUpMatrix: Matrix;
  49759. /**
  49760. * The vector the camera should consider as up. (default is Vector3(0, 1, 0) as returned by Vector3.Up())
  49761. * Setting this will copy the given vector to the camera's upVector, and set rotation matrices to and from Y up.
  49762. * DO NOT set the up vector using copyFrom or copyFromFloats, as this bypasses setting the above matrices.
  49763. */
  49764. set upVector(vec: Vector3);
  49765. get upVector(): Vector3;
  49766. /**
  49767. * Sets the Y-up to camera up-vector rotation matrix, and the up-vector to Y-up rotation matrix.
  49768. */
  49769. setMatUp(): void;
  49770. /**
  49771. * Current inertia value on the longitudinal axis.
  49772. * The bigger this number the longer it will take for the camera to stop.
  49773. */
  49774. inertialAlphaOffset: number;
  49775. /**
  49776. * Current inertia value on the latitudinal axis.
  49777. * The bigger this number the longer it will take for the camera to stop.
  49778. */
  49779. inertialBetaOffset: number;
  49780. /**
  49781. * Current inertia value on the radius axis.
  49782. * The bigger this number the longer it will take for the camera to stop.
  49783. */
  49784. inertialRadiusOffset: number;
  49785. /**
  49786. * Minimum allowed angle on the longitudinal axis.
  49787. * This can help limiting how the Camera is able to move in the scene.
  49788. */
  49789. lowerAlphaLimit: Nullable<number>;
  49790. /**
  49791. * Maximum allowed angle on the longitudinal axis.
  49792. * This can help limiting how the Camera is able to move in the scene.
  49793. */
  49794. upperAlphaLimit: Nullable<number>;
  49795. /**
  49796. * Minimum allowed angle on the latitudinal axis.
  49797. * This can help limiting how the Camera is able to move in the scene.
  49798. */
  49799. lowerBetaLimit: number;
  49800. /**
  49801. * Maximum allowed angle on the latitudinal axis.
  49802. * This can help limiting how the Camera is able to move in the scene.
  49803. */
  49804. upperBetaLimit: number;
  49805. /**
  49806. * Minimum allowed distance of the camera to the target (The camera can not get closer).
  49807. * This can help limiting how the Camera is able to move in the scene.
  49808. */
  49809. lowerRadiusLimit: Nullable<number>;
  49810. /**
  49811. * Maximum allowed distance of the camera to the target (The camera can not get further).
  49812. * This can help limiting how the Camera is able to move in the scene.
  49813. */
  49814. upperRadiusLimit: Nullable<number>;
  49815. /**
  49816. * Defines the current inertia value used during panning of the camera along the X axis.
  49817. */
  49818. inertialPanningX: number;
  49819. /**
  49820. * Defines the current inertia value used during panning of the camera along the Y axis.
  49821. */
  49822. inertialPanningY: number;
  49823. /**
  49824. * Defines the distance used to consider the camera in pan mode vs pinch/zoom.
  49825. * Basically if your fingers moves away from more than this distance you will be considered
  49826. * in pinch mode.
  49827. */
  49828. pinchToPanMaxDistance: number;
  49829. /**
  49830. * Defines the maximum distance the camera can pan.
  49831. * This could help keeping the camera always in your scene.
  49832. */
  49833. panningDistanceLimit: Nullable<number>;
  49834. /**
  49835. * Defines the target of the camera before panning.
  49836. */
  49837. panningOriginTarget: Vector3;
  49838. /**
  49839. * Defines the value of the inertia used during panning.
  49840. * 0 would mean stop inertia and one would mean no decelleration at all.
  49841. */
  49842. panningInertia: number;
  49843. /**
  49844. * Gets or Set the pointer angular sensibility along the X axis or how fast is the camera rotating.
  49845. */
  49846. get angularSensibilityX(): number;
  49847. set angularSensibilityX(value: number);
  49848. /**
  49849. * Gets or Set the pointer angular sensibility along the Y axis or how fast is the camera rotating.
  49850. */
  49851. get angularSensibilityY(): number;
  49852. set angularSensibilityY(value: number);
  49853. /**
  49854. * Gets or Set the pointer pinch precision or how fast is the camera zooming.
  49855. */
  49856. get pinchPrecision(): number;
  49857. set pinchPrecision(value: number);
  49858. /**
  49859. * Gets or Set the pointer pinch delta percentage or how fast is the camera zooming.
  49860. * It will be used instead of pinchDeltaPrecision if different from 0.
  49861. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  49862. */
  49863. get pinchDeltaPercentage(): number;
  49864. set pinchDeltaPercentage(value: number);
  49865. /**
  49866. * Gets or Set the pointer use natural pinch zoom to override the pinch precision
  49867. * and pinch delta percentage.
  49868. * When useNaturalPinchZoom is true, multi touch zoom will zoom in such
  49869. * that any object in the plane at the camera's target point will scale
  49870. * perfectly with finger motion.
  49871. */
  49872. get useNaturalPinchZoom(): boolean;
  49873. set useNaturalPinchZoom(value: boolean);
  49874. /**
  49875. * Gets or Set the pointer panning sensibility or how fast is the camera moving.
  49876. */
  49877. get panningSensibility(): number;
  49878. set panningSensibility(value: number);
  49879. /**
  49880. * Gets or Set the list of keyboard keys used to control beta angle in a positive direction.
  49881. */
  49882. get keysUp(): number[];
  49883. set keysUp(value: number[]);
  49884. /**
  49885. * Gets or Set the list of keyboard keys used to control beta angle in a negative direction.
  49886. */
  49887. get keysDown(): number[];
  49888. set keysDown(value: number[]);
  49889. /**
  49890. * Gets or Set the list of keyboard keys used to control alpha angle in a negative direction.
  49891. */
  49892. get keysLeft(): number[];
  49893. set keysLeft(value: number[]);
  49894. /**
  49895. * Gets or Set the list of keyboard keys used to control alpha angle in a positive direction.
  49896. */
  49897. get keysRight(): number[];
  49898. set keysRight(value: number[]);
  49899. /**
  49900. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  49901. */
  49902. get wheelPrecision(): number;
  49903. set wheelPrecision(value: number);
  49904. /**
  49905. * Gets or Set the mouse wheel delta percentage or how fast is the camera zooming.
  49906. * It will be used instead of pinchDeltaPrecision if different from 0.
  49907. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  49908. */
  49909. get wheelDeltaPercentage(): number;
  49910. set wheelDeltaPercentage(value: number);
  49911. /**
  49912. * Defines how much the radius should be scaled while zooming on a particular mesh (through the zoomOn function)
  49913. */
  49914. zoomOnFactor: number;
  49915. /**
  49916. * Defines a screen offset for the camera position.
  49917. */
  49918. targetScreenOffset: Vector2;
  49919. /**
  49920. * Allows the camera to be completely reversed.
  49921. * If false the camera can not arrive upside down.
  49922. */
  49923. allowUpsideDown: boolean;
  49924. /**
  49925. * Define if double tap/click is used to restore the previously saved state of the camera.
  49926. */
  49927. useInputToRestoreState: boolean;
  49928. /** @hidden */
  49929. _viewMatrix: Matrix;
  49930. /** @hidden */
  49931. _useCtrlForPanning: boolean;
  49932. /** @hidden */
  49933. _panningMouseButton: number;
  49934. /**
  49935. * Defines the input associated to the camera.
  49936. */
  49937. inputs: ArcRotateCameraInputsManager;
  49938. /** @hidden */
  49939. _reset: () => void;
  49940. /**
  49941. * Defines the allowed panning axis.
  49942. */
  49943. panningAxis: Vector3;
  49944. protected _transformedDirection: Vector3;
  49945. private _bouncingBehavior;
  49946. /**
  49947. * Gets the bouncing behavior of the camera if it has been enabled.
  49948. * @see https://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  49949. */
  49950. get bouncingBehavior(): Nullable<BouncingBehavior>;
  49951. /**
  49952. * Defines if the bouncing behavior of the camera is enabled on the camera.
  49953. * @see https://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  49954. */
  49955. get useBouncingBehavior(): boolean;
  49956. set useBouncingBehavior(value: boolean);
  49957. private _framingBehavior;
  49958. /**
  49959. * Gets the framing behavior of the camera if it has been enabled.
  49960. * @see https://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  49961. */
  49962. get framingBehavior(): Nullable<FramingBehavior>;
  49963. /**
  49964. * Defines if the framing behavior of the camera is enabled on the camera.
  49965. * @see https://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  49966. */
  49967. get useFramingBehavior(): boolean;
  49968. set useFramingBehavior(value: boolean);
  49969. private _autoRotationBehavior;
  49970. /**
  49971. * Gets the auto rotation behavior of the camera if it has been enabled.
  49972. * @see https://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  49973. */
  49974. get autoRotationBehavior(): Nullable<AutoRotationBehavior>;
  49975. /**
  49976. * Defines if the auto rotation behavior of the camera is enabled on the camera.
  49977. * @see https://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  49978. */
  49979. get useAutoRotationBehavior(): boolean;
  49980. set useAutoRotationBehavior(value: boolean);
  49981. /**
  49982. * Observable triggered when the mesh target has been changed on the camera.
  49983. */
  49984. onMeshTargetChangedObservable: Observable<Nullable<AbstractMesh>>;
  49985. /**
  49986. * Event raised when the camera is colliding with a mesh.
  49987. */
  49988. onCollide: (collidedMesh: AbstractMesh) => void;
  49989. /**
  49990. * Defines whether the camera should check collision with the objects oh the scene.
  49991. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#how-can-i-do-this
  49992. */
  49993. checkCollisions: boolean;
  49994. /**
  49995. * Defines the collision radius of the camera.
  49996. * This simulates a sphere around the camera.
  49997. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  49998. */
  49999. collisionRadius: Vector3;
  50000. protected _collider: Collider;
  50001. protected _previousPosition: Vector3;
  50002. protected _collisionVelocity: Vector3;
  50003. protected _newPosition: Vector3;
  50004. protected _previousAlpha: number;
  50005. protected _previousBeta: number;
  50006. protected _previousRadius: number;
  50007. protected _collisionTriggered: boolean;
  50008. protected _targetBoundingCenter: Nullable<Vector3>;
  50009. private _computationVector;
  50010. /**
  50011. * Instantiates a new ArcRotateCamera in a given scene
  50012. * @param name Defines the name of the camera
  50013. * @param alpha Defines the camera rotation along the longitudinal axis
  50014. * @param beta Defines the camera rotation along the latitudinal axis
  50015. * @param radius Defines the camera distance from its target
  50016. * @param target Defines the camera target
  50017. * @param scene Defines the scene the camera belongs to
  50018. * @param setActiveOnSceneIfNoneActive Defines whether the camera should be marked as active if not other active cameras have been defined
  50019. */
  50020. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  50021. /** @hidden */
  50022. _initCache(): void;
  50023. /** @hidden */
  50024. _updateCache(ignoreParentClass?: boolean): void;
  50025. protected _getTargetPosition(): Vector3;
  50026. private _storedAlpha;
  50027. private _storedBeta;
  50028. private _storedRadius;
  50029. private _storedTarget;
  50030. private _storedTargetScreenOffset;
  50031. /**
  50032. * Stores the current state of the camera (alpha, beta, radius and target)
  50033. * @returns the camera itself
  50034. */
  50035. storeState(): Camera;
  50036. /**
  50037. * @hidden
  50038. * Restored camera state. You must call storeState() first
  50039. */
  50040. _restoreStateValues(): boolean;
  50041. /** @hidden */
  50042. _isSynchronizedViewMatrix(): boolean;
  50043. /**
  50044. * Attach the input controls to a specific dom element to get the input from.
  50045. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  50046. */
  50047. attachControl(noPreventDefault?: boolean): void;
  50048. /**
  50049. * Attach the input controls to a specific dom element to get the input from.
  50050. * @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
  50051. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  50052. */
  50053. attachControl(ignored: any, noPreventDefault?: boolean): void;
  50054. /**
  50055. * Attached controls to the current camera.
  50056. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  50057. * @param useCtrlForPanning Defines whether ctrl is used for panning within the controls
  50058. */
  50059. attachControl(noPreventDefault: boolean, useCtrlForPanning: boolean): void;
  50060. /**
  50061. * Attached controls to the current camera.
  50062. * @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
  50063. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  50064. * @param useCtrlForPanning Defines whether ctrl is used for panning within the controls
  50065. */
  50066. attachControl(ignored: any, noPreventDefault: boolean, useCtrlForPanning: boolean): void;
  50067. /**
  50068. * Attached controls to the current camera.
  50069. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  50070. * @param useCtrlForPanning Defines whether ctrl is used for panning within the controls
  50071. * @param panningMouseButton Defines whether panning is allowed through mouse click button
  50072. */
  50073. attachControl(noPreventDefault: boolean, useCtrlForPanning: boolean, panningMouseButton: number): void;
  50074. /**
  50075. * Detach the current controls from the specified dom element.
  50076. */
  50077. detachControl(): void;
  50078. /**
  50079. * Detach the current controls from the specified dom element.
  50080. * @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
  50081. */
  50082. detachControl(ignored: any): void;
  50083. /** @hidden */
  50084. _checkInputs(): void;
  50085. protected _checkLimits(): void;
  50086. /**
  50087. * Rebuilds angles (alpha, beta) and radius from the give position and target
  50088. */
  50089. rebuildAnglesAndRadius(): void;
  50090. /**
  50091. * Use a position to define the current camera related information like alpha, beta and radius
  50092. * @param position Defines the position to set the camera at
  50093. */
  50094. setPosition(position: Vector3): void;
  50095. /**
  50096. * Defines the target the camera should look at.
  50097. * This will automatically adapt alpha beta and radius to fit within the new target.
  50098. * @param target Defines the new target as a Vector or a mesh
  50099. * @param toBoundingCenter In case of a mesh target, defines whether to target the mesh position or its bounding information center
  50100. * @param allowSamePosition If false, prevents reapplying the new computed position if it is identical to the current one (optim)
  50101. */
  50102. setTarget(target: AbstractMesh | Vector3, toBoundingCenter?: boolean, allowSamePosition?: boolean): void;
  50103. /** @hidden */
  50104. _getViewMatrix(): Matrix;
  50105. protected _onCollisionPositionChange: (collisionId: number, newPosition: Vector3, collidedMesh?: Nullable<AbstractMesh>) => void;
  50106. /**
  50107. * Zooms on a mesh to be at the min distance where we could see it fully in the current viewport.
  50108. * @param meshes Defines the mesh to zoom on
  50109. * @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)
  50110. */
  50111. zoomOn(meshes?: AbstractMesh[], doNotUpdateMaxZ?: boolean): void;
  50112. /**
  50113. * Focus on a mesh or a bounding box. This adapts the target and maxRadius if necessary but does not update the current radius.
  50114. * The target will be changed but the radius
  50115. * @param meshesOrMinMaxVectorAndDistance Defines the mesh or bounding info to focus on
  50116. * @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)
  50117. */
  50118. focusOn(meshesOrMinMaxVectorAndDistance: AbstractMesh[] | {
  50119. min: Vector3;
  50120. max: Vector3;
  50121. distance: number;
  50122. }, doNotUpdateMaxZ?: boolean): void;
  50123. /**
  50124. * @override
  50125. * Override Camera.createRigCamera
  50126. */
  50127. createRigCamera(name: string, cameraIndex: number): Camera;
  50128. /**
  50129. * @hidden
  50130. * @override
  50131. * Override Camera._updateRigCameras
  50132. */
  50133. _updateRigCameras(): void;
  50134. /**
  50135. * Destroy the camera and release the current resources hold by it.
  50136. */
  50137. dispose(): void;
  50138. /**
  50139. * Gets the current object class name.
  50140. * @return the class name
  50141. */
  50142. getClassName(): string;
  50143. }
  50144. }
  50145. declare module BABYLON {
  50146. /**
  50147. * The autoRotation behavior (AutoRotationBehavior) is designed to create a smooth rotation of an ArcRotateCamera when there is no user interaction.
  50148. * @see https://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  50149. */
  50150. export class AutoRotationBehavior implements Behavior<ArcRotateCamera> {
  50151. /**
  50152. * Gets the name of the behavior.
  50153. */
  50154. get name(): string;
  50155. private _zoomStopsAnimation;
  50156. private _idleRotationSpeed;
  50157. private _idleRotationWaitTime;
  50158. private _idleRotationSpinupTime;
  50159. /**
  50160. * Sets the flag that indicates if user zooming should stop animation.
  50161. */
  50162. set zoomStopsAnimation(flag: boolean);
  50163. /**
  50164. * Gets the flag that indicates if user zooming should stop animation.
  50165. */
  50166. get zoomStopsAnimation(): boolean;
  50167. /**
  50168. * Sets the default speed at which the camera rotates around the model.
  50169. */
  50170. set idleRotationSpeed(speed: number);
  50171. /**
  50172. * Gets the default speed at which the camera rotates around the model.
  50173. */
  50174. get idleRotationSpeed(): number;
  50175. /**
  50176. * Sets the time (in milliseconds) to wait after user interaction before the camera starts rotating.
  50177. */
  50178. set idleRotationWaitTime(time: number);
  50179. /**
  50180. * Gets the time (milliseconds) to wait after user interaction before the camera starts rotating.
  50181. */
  50182. get idleRotationWaitTime(): number;
  50183. /**
  50184. * Sets the time (milliseconds) to take to spin up to the full idle rotation speed.
  50185. */
  50186. set idleRotationSpinupTime(time: number);
  50187. /**
  50188. * Gets the time (milliseconds) to take to spin up to the full idle rotation speed.
  50189. */
  50190. get idleRotationSpinupTime(): number;
  50191. /**
  50192. * Gets a value indicating if the camera is currently rotating because of this behavior
  50193. */
  50194. get rotationInProgress(): boolean;
  50195. private _onPrePointerObservableObserver;
  50196. private _onAfterCheckInputsObserver;
  50197. private _attachedCamera;
  50198. private _isPointerDown;
  50199. private _lastFrameTime;
  50200. private _lastInteractionTime;
  50201. private _cameraRotationSpeed;
  50202. /**
  50203. * Initializes the behavior.
  50204. */
  50205. init(): void;
  50206. /**
  50207. * Attaches the behavior to its arc rotate camera.
  50208. * @param camera Defines the camera to attach the behavior to
  50209. */
  50210. attach(camera: ArcRotateCamera): void;
  50211. /**
  50212. * Detaches the behavior from its current arc rotate camera.
  50213. */
  50214. detach(): void;
  50215. /**
  50216. * Returns true if user is scrolling.
  50217. * @return true if user is scrolling.
  50218. */
  50219. private _userIsZooming;
  50220. private _lastFrameRadius;
  50221. private _shouldAnimationStopForInteraction;
  50222. /**
  50223. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  50224. */
  50225. private _applyUserInteraction;
  50226. private _userIsMoving;
  50227. }
  50228. }
  50229. declare module BABYLON {
  50230. /**
  50231. * A behavior that when attached to a mesh will will place a specified node on the meshes face pointing towards the camera
  50232. */
  50233. export class AttachToBoxBehavior implements Behavior<Mesh> {
  50234. private ui;
  50235. /**
  50236. * The name of the behavior
  50237. */
  50238. name: string;
  50239. /**
  50240. * The distance away from the face of the mesh that the UI should be attached to (default: 0.15)
  50241. */
  50242. distanceAwayFromFace: number;
  50243. /**
  50244. * The distance from the bottom of the face that the UI should be attached to (default: 0.15)
  50245. */
  50246. distanceAwayFromBottomOfFace: number;
  50247. private _faceVectors;
  50248. private _target;
  50249. private _scene;
  50250. private _onRenderObserver;
  50251. private _tmpMatrix;
  50252. private _tmpVector;
  50253. /**
  50254. * Creates the AttachToBoxBehavior, used to attach UI to the closest face of the box to a camera
  50255. * @param ui The transform node that should be attached to the mesh
  50256. */
  50257. constructor(ui: TransformNode);
  50258. /**
  50259. * Initializes the behavior
  50260. */
  50261. init(): void;
  50262. private _closestFace;
  50263. private _zeroVector;
  50264. private _lookAtTmpMatrix;
  50265. private _lookAtToRef;
  50266. /**
  50267. * Attaches the AttachToBoxBehavior to the passed in mesh
  50268. * @param target The mesh that the specified node will be attached to
  50269. */
  50270. attach(target: Mesh): void;
  50271. /**
  50272. * Detaches the behavior from the mesh
  50273. */
  50274. detach(): void;
  50275. }
  50276. }
  50277. declare module BABYLON {
  50278. /**
  50279. * A behavior that when attached to a mesh will allow the mesh to fade in and out
  50280. */
  50281. export class FadeInOutBehavior implements Behavior<Mesh> {
  50282. /**
  50283. * Time in milliseconds to delay before fading in (Default: 0)
  50284. */
  50285. delay: number;
  50286. /**
  50287. * Time in milliseconds for the mesh to fade in (Default: 300)
  50288. */
  50289. fadeInTime: number;
  50290. private _millisecondsPerFrame;
  50291. private _hovered;
  50292. private _hoverValue;
  50293. private _ownerNode;
  50294. /**
  50295. * Instantiates the FadeInOutBehavior
  50296. */
  50297. constructor();
  50298. /**
  50299. * The name of the behavior
  50300. */
  50301. get name(): string;
  50302. /**
  50303. * Initializes the behavior
  50304. */
  50305. init(): void;
  50306. /**
  50307. * Attaches the fade behavior on the passed in mesh
  50308. * @param ownerNode The mesh that will be faded in/out once attached
  50309. */
  50310. attach(ownerNode: Mesh): void;
  50311. /**
  50312. * Detaches the behavior from the mesh
  50313. */
  50314. detach(): void;
  50315. /**
  50316. * Triggers the mesh to begin fading in or out
  50317. * @param value if the object should fade in or out (true to fade in)
  50318. */
  50319. fadeIn(value: boolean): void;
  50320. private _update;
  50321. private _setAllVisibility;
  50322. }
  50323. }
  50324. declare module BABYLON {
  50325. /**
  50326. * Class containing a set of static utilities functions for managing Pivots
  50327. * @hidden
  50328. */
  50329. export class PivotTools {
  50330. private static _PivotCached;
  50331. private static _OldPivotPoint;
  50332. private static _PivotTranslation;
  50333. private static _PivotTmpVector;
  50334. private static _PivotPostMultiplyPivotMatrix;
  50335. /** @hidden */
  50336. static _RemoveAndStorePivotPoint(mesh: AbstractMesh): void;
  50337. /** @hidden */
  50338. static _RestorePivotPoint(mesh: AbstractMesh): void;
  50339. }
  50340. }
  50341. declare module BABYLON {
  50342. /**
  50343. * Class containing static functions to help procedurally build meshes
  50344. */
  50345. export class PlaneBuilder {
  50346. /**
  50347. * Creates a plane mesh
  50348. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  50349. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  50350. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  50351. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  50352. * * 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
  50353. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  50354. * @param name defines the name of the mesh
  50355. * @param options defines the options used to create the mesh
  50356. * @param scene defines the hosting scene
  50357. * @returns the plane mesh
  50358. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  50359. */
  50360. static CreatePlane(name: string, options: {
  50361. size?: number;
  50362. width?: number;
  50363. height?: number;
  50364. sideOrientation?: number;
  50365. frontUVs?: Vector4;
  50366. backUVs?: Vector4;
  50367. updatable?: boolean;
  50368. sourcePlane?: Plane;
  50369. }, scene?: Nullable<Scene>): Mesh;
  50370. }
  50371. }
  50372. declare module BABYLON {
  50373. /**
  50374. * A behavior that when attached to a mesh will allow the mesh to be dragged around the screen based on pointer events
  50375. */
  50376. export class PointerDragBehavior implements Behavior<AbstractMesh> {
  50377. private static _AnyMouseID;
  50378. /**
  50379. * Abstract mesh the behavior is set on
  50380. */
  50381. attachedNode: AbstractMesh;
  50382. private _dragPlane;
  50383. private _scene;
  50384. private _pointerObserver;
  50385. private _beforeRenderObserver;
  50386. private static _planeScene;
  50387. private _useAlternatePickedPointAboveMaxDragAngleDragSpeed;
  50388. /**
  50389. * 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)
  50390. */
  50391. maxDragAngle: number;
  50392. /**
  50393. * @hidden
  50394. */
  50395. _useAlternatePickedPointAboveMaxDragAngle: boolean;
  50396. /**
  50397. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  50398. */
  50399. currentDraggingPointerID: number;
  50400. /**
  50401. * The last position where the pointer hit the drag plane in world space
  50402. */
  50403. lastDragPosition: Vector3;
  50404. /**
  50405. * If the behavior is currently in a dragging state
  50406. */
  50407. dragging: boolean;
  50408. /**
  50409. * 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)
  50410. */
  50411. dragDeltaRatio: number;
  50412. /**
  50413. * If the drag plane orientation should be updated during the dragging (Default: true)
  50414. */
  50415. updateDragPlane: boolean;
  50416. private _debugMode;
  50417. private _moving;
  50418. /**
  50419. * Fires each time the attached mesh is dragged with the pointer
  50420. * * delta between last drag position and current drag position in world space
  50421. * * dragDistance along the drag axis
  50422. * * dragPlaneNormal normal of the current drag plane used during the drag
  50423. * * dragPlanePoint in world space where the drag intersects the drag plane
  50424. */
  50425. onDragObservable: Observable<{
  50426. delta: Vector3;
  50427. dragPlanePoint: Vector3;
  50428. dragPlaneNormal: Vector3;
  50429. dragDistance: number;
  50430. pointerId: number;
  50431. }>;
  50432. /**
  50433. * Fires each time a drag begins (eg. mouse down on mesh)
  50434. */
  50435. onDragStartObservable: Observable<{
  50436. dragPlanePoint: Vector3;
  50437. pointerId: number;
  50438. }>;
  50439. /**
  50440. * Fires each time a drag ends (eg. mouse release after drag)
  50441. */
  50442. onDragEndObservable: Observable<{
  50443. dragPlanePoint: Vector3;
  50444. pointerId: number;
  50445. }>;
  50446. /**
  50447. * If the attached mesh should be moved when dragged
  50448. */
  50449. moveAttached: boolean;
  50450. /**
  50451. * If the drag behavior will react to drag events (Default: true)
  50452. */
  50453. enabled: boolean;
  50454. /**
  50455. * If pointer events should start and release the drag (Default: true)
  50456. */
  50457. startAndReleaseDragOnPointerEvents: boolean;
  50458. /**
  50459. * If camera controls should be detached during the drag
  50460. */
  50461. detachCameraControls: boolean;
  50462. /**
  50463. * If set, the drag plane/axis will be rotated based on the attached mesh's world rotation (Default: true)
  50464. */
  50465. useObjectOrientationForDragging: boolean;
  50466. private _options;
  50467. /**
  50468. * Gets the options used by the behavior
  50469. */
  50470. get options(): {
  50471. dragAxis?: Vector3;
  50472. dragPlaneNormal?: Vector3;
  50473. };
  50474. /**
  50475. * Sets the options used by the behavior
  50476. */
  50477. set options(options: {
  50478. dragAxis?: Vector3;
  50479. dragPlaneNormal?: Vector3;
  50480. });
  50481. /**
  50482. * Creates a pointer drag behavior that can be attached to a mesh
  50483. * @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)
  50484. */
  50485. constructor(options?: {
  50486. dragAxis?: Vector3;
  50487. dragPlaneNormal?: Vector3;
  50488. });
  50489. /**
  50490. * Predicate to determine if it is valid to move the object to a new position when it is moved
  50491. */
  50492. validateDrag: (targetPosition: Vector3) => boolean;
  50493. /**
  50494. * The name of the behavior
  50495. */
  50496. get name(): string;
  50497. /**
  50498. * Initializes the behavior
  50499. */
  50500. init(): void;
  50501. private _tmpVector;
  50502. private _alternatePickedPoint;
  50503. private _worldDragAxis;
  50504. private _targetPosition;
  50505. private _attachedToElement;
  50506. /**
  50507. * Attaches the drag behavior the passed in mesh
  50508. * @param ownerNode The mesh that will be dragged around once attached
  50509. * @param predicate Predicate to use for pick filtering
  50510. */
  50511. attach(ownerNode: AbstractMesh, predicate?: (m: AbstractMesh) => boolean): void;
  50512. /**
  50513. * Force release the drag action by code.
  50514. */
  50515. releaseDrag(): void;
  50516. private _startDragRay;
  50517. private _lastPointerRay;
  50518. /**
  50519. * Simulates the start of a pointer drag event on the behavior
  50520. * @param pointerId pointerID of the pointer that should be simulated (Default: Any mouse pointer ID)
  50521. * @param fromRay initial ray of the pointer to be simulated (Default: Ray from camera to attached mesh)
  50522. * @param startPickedPoint picked point of the pointer to be simulated (Default: attached mesh position)
  50523. */
  50524. startDrag(pointerId?: number, fromRay?: Ray, startPickedPoint?: Vector3): void;
  50525. protected _startDrag(pointerId: number, fromRay?: Ray, startPickedPoint?: Vector3): void;
  50526. private _dragDelta;
  50527. protected _moveDrag(ray: Ray): void;
  50528. private _pickWithRayOnDragPlane;
  50529. private _pointA;
  50530. private _pointC;
  50531. private _localAxis;
  50532. private _lookAt;
  50533. private _updateDragPlanePosition;
  50534. /**
  50535. * Detaches the behavior from the mesh
  50536. */
  50537. detach(): void;
  50538. }
  50539. }
  50540. declare module BABYLON {
  50541. /**
  50542. * A behavior that when attached to a mesh will allow the mesh to be scaled
  50543. */
  50544. export class MultiPointerScaleBehavior implements Behavior<Mesh> {
  50545. private _dragBehaviorA;
  50546. private _dragBehaviorB;
  50547. private _startDistance;
  50548. private _initialScale;
  50549. private _targetScale;
  50550. private _ownerNode;
  50551. private _sceneRenderObserver;
  50552. /**
  50553. * Instantiate a new behavior that when attached to a mesh will allow the mesh to be scaled
  50554. */
  50555. constructor();
  50556. /**
  50557. * The name of the behavior
  50558. */
  50559. get name(): string;
  50560. /**
  50561. * Initializes the behavior
  50562. */
  50563. init(): void;
  50564. private _getCurrentDistance;
  50565. /**
  50566. * Attaches the scale behavior the passed in mesh
  50567. * @param ownerNode The mesh that will be scaled around once attached
  50568. */
  50569. attach(ownerNode: Mesh): void;
  50570. /**
  50571. * Detaches the behavior from the mesh
  50572. */
  50573. detach(): void;
  50574. }
  50575. }
  50576. declare module BABYLON {
  50577. /**
  50578. * 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
  50579. */
  50580. export class SixDofDragBehavior implements Behavior<Mesh> {
  50581. private static _virtualScene;
  50582. private _ownerNode;
  50583. private _sceneRenderObserver;
  50584. private _scene;
  50585. private _targetPosition;
  50586. private _virtualOriginMesh;
  50587. private _virtualDragMesh;
  50588. private _pointerObserver;
  50589. private _moving;
  50590. private _startingOrientation;
  50591. private _attachedToElement;
  50592. /**
  50593. * 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)
  50594. */
  50595. private zDragFactor;
  50596. /**
  50597. * If the object should rotate to face the drag origin
  50598. */
  50599. rotateDraggedObject: boolean;
  50600. /**
  50601. * If the behavior is currently in a dragging state
  50602. */
  50603. dragging: boolean;
  50604. /**
  50605. * 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)
  50606. */
  50607. dragDeltaRatio: number;
  50608. /**
  50609. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  50610. */
  50611. currentDraggingPointerID: number;
  50612. /**
  50613. * If camera controls should be detached during the drag
  50614. */
  50615. detachCameraControls: boolean;
  50616. /**
  50617. * Fires each time a drag starts
  50618. */
  50619. onDragStartObservable: Observable<{}>;
  50620. /**
  50621. * Fires each time a drag happens
  50622. */
  50623. onDragObservable: Observable<void>;
  50624. /**
  50625. * Fires each time a drag ends (eg. mouse release after drag)
  50626. */
  50627. onDragEndObservable: Observable<{}>;
  50628. /**
  50629. * 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
  50630. */
  50631. constructor();
  50632. /**
  50633. * The name of the behavior
  50634. */
  50635. get name(): string;
  50636. /**
  50637. * Initializes the behavior
  50638. */
  50639. init(): void;
  50640. /**
  50641. * In the case of multiple active cameras, the cameraToUseForPointers should be used if set instead of active camera
  50642. */
  50643. private get _pointerCamera();
  50644. /**
  50645. * Attaches the scale behavior the passed in mesh
  50646. * @param ownerNode The mesh that will be scaled around once attached
  50647. */
  50648. attach(ownerNode: Mesh): void;
  50649. /**
  50650. * Detaches the behavior from the mesh
  50651. */
  50652. detach(): void;
  50653. }
  50654. }
  50655. declare module BABYLON {
  50656. /**
  50657. * Class used to apply inverse kinematics to bones
  50658. * @see https://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#boneikcontroller
  50659. */
  50660. export class BoneIKController {
  50661. private static _tmpVecs;
  50662. private static _tmpQuat;
  50663. private static _tmpMats;
  50664. /**
  50665. * Gets or sets the target mesh
  50666. */
  50667. targetMesh: AbstractMesh;
  50668. /** Gets or sets the mesh used as pole */
  50669. poleTargetMesh: AbstractMesh;
  50670. /**
  50671. * Gets or sets the bone used as pole
  50672. */
  50673. poleTargetBone: Nullable<Bone>;
  50674. /**
  50675. * Gets or sets the target position
  50676. */
  50677. targetPosition: Vector3;
  50678. /**
  50679. * Gets or sets the pole target position
  50680. */
  50681. poleTargetPosition: Vector3;
  50682. /**
  50683. * Gets or sets the pole target local offset
  50684. */
  50685. poleTargetLocalOffset: Vector3;
  50686. /**
  50687. * Gets or sets the pole angle
  50688. */
  50689. poleAngle: number;
  50690. /**
  50691. * Gets or sets the mesh associated with the controller
  50692. */
  50693. mesh: AbstractMesh;
  50694. /**
  50695. * 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)
  50696. */
  50697. slerpAmount: number;
  50698. private _bone1Quat;
  50699. private _bone1Mat;
  50700. private _bone2Ang;
  50701. private _bone1;
  50702. private _bone2;
  50703. private _bone1Length;
  50704. private _bone2Length;
  50705. private _maxAngle;
  50706. private _maxReach;
  50707. private _rightHandedSystem;
  50708. private _bendAxis;
  50709. private _slerping;
  50710. private _adjustRoll;
  50711. /**
  50712. * Gets or sets maximum allowed angle
  50713. */
  50714. get maxAngle(): number;
  50715. set maxAngle(value: number);
  50716. /**
  50717. * Creates a new BoneIKController
  50718. * @param mesh defines the mesh to control
  50719. * @param bone defines the bone to control
  50720. * @param options defines options to set up the controller
  50721. */
  50722. constructor(mesh: AbstractMesh, bone: Bone, options?: {
  50723. targetMesh?: AbstractMesh;
  50724. poleTargetMesh?: AbstractMesh;
  50725. poleTargetBone?: Bone;
  50726. poleTargetLocalOffset?: Vector3;
  50727. poleAngle?: number;
  50728. bendAxis?: Vector3;
  50729. maxAngle?: number;
  50730. slerpAmount?: number;
  50731. });
  50732. private _setMaxAngle;
  50733. /**
  50734. * Force the controller to update the bones
  50735. */
  50736. update(): void;
  50737. }
  50738. }
  50739. declare module BABYLON {
  50740. /**
  50741. * Class used to make a bone look toward a point in space
  50742. * @see https://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#bonelookcontroller
  50743. */
  50744. export class BoneLookController {
  50745. private static _tmpVecs;
  50746. private static _tmpQuat;
  50747. private static _tmpMats;
  50748. /**
  50749. * The target Vector3 that the bone will look at
  50750. */
  50751. target: Vector3;
  50752. /**
  50753. * The mesh that the bone is attached to
  50754. */
  50755. mesh: AbstractMesh;
  50756. /**
  50757. * The bone that will be looking to the target
  50758. */
  50759. bone: Bone;
  50760. /**
  50761. * The up axis of the coordinate system that is used when the bone is rotated
  50762. */
  50763. upAxis: Vector3;
  50764. /**
  50765. * The space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD
  50766. */
  50767. upAxisSpace: Space;
  50768. /**
  50769. * Used to make an adjustment to the yaw of the bone
  50770. */
  50771. adjustYaw: number;
  50772. /**
  50773. * Used to make an adjustment to the pitch of the bone
  50774. */
  50775. adjustPitch: number;
  50776. /**
  50777. * Used to make an adjustment to the roll of the bone
  50778. */
  50779. adjustRoll: number;
  50780. /**
  50781. * 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)
  50782. */
  50783. slerpAmount: number;
  50784. private _minYaw;
  50785. private _maxYaw;
  50786. private _minPitch;
  50787. private _maxPitch;
  50788. private _minYawSin;
  50789. private _minYawCos;
  50790. private _maxYawSin;
  50791. private _maxYawCos;
  50792. private _midYawConstraint;
  50793. private _minPitchTan;
  50794. private _maxPitchTan;
  50795. private _boneQuat;
  50796. private _slerping;
  50797. private _transformYawPitch;
  50798. private _transformYawPitchInv;
  50799. private _firstFrameSkipped;
  50800. private _yawRange;
  50801. private _fowardAxis;
  50802. /**
  50803. * Gets or sets the minimum yaw angle that the bone can look to
  50804. */
  50805. get minYaw(): number;
  50806. set minYaw(value: number);
  50807. /**
  50808. * Gets or sets the maximum yaw angle that the bone can look to
  50809. */
  50810. get maxYaw(): number;
  50811. set maxYaw(value: number);
  50812. /**
  50813. * Gets or sets the minimum pitch angle that the bone can look to
  50814. */
  50815. get minPitch(): number;
  50816. set minPitch(value: number);
  50817. /**
  50818. * Gets or sets the maximum pitch angle that the bone can look to
  50819. */
  50820. get maxPitch(): number;
  50821. set maxPitch(value: number);
  50822. /**
  50823. * Create a BoneLookController
  50824. * @param mesh the mesh that the bone belongs to
  50825. * @param bone the bone that will be looking to the target
  50826. * @param target the target Vector3 to look at
  50827. * @param options optional settings:
  50828. * * maxYaw: the maximum angle the bone will yaw to
  50829. * * minYaw: the minimum angle the bone will yaw to
  50830. * * maxPitch: the maximum angle the bone will pitch to
  50831. * * minPitch: the minimum angle the bone will yaw to
  50832. * * slerpAmount: set the between 0 and 1 to make the bone slerp to the target.
  50833. * * upAxis: the up axis of the coordinate system
  50834. * * upAxisSpace: the space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD.
  50835. * * yawAxis: set yawAxis if the bone does not yaw on the y axis
  50836. * * pitchAxis: set pitchAxis if the bone does not pitch on the x axis
  50837. * * adjustYaw: used to make an adjustment to the yaw of the bone
  50838. * * adjustPitch: used to make an adjustment to the pitch of the bone
  50839. * * adjustRoll: used to make an adjustment to the roll of the bone
  50840. **/
  50841. constructor(mesh: AbstractMesh, bone: Bone, target: Vector3, options?: {
  50842. maxYaw?: number;
  50843. minYaw?: number;
  50844. maxPitch?: number;
  50845. minPitch?: number;
  50846. slerpAmount?: number;
  50847. upAxis?: Vector3;
  50848. upAxisSpace?: Space;
  50849. yawAxis?: Vector3;
  50850. pitchAxis?: Vector3;
  50851. adjustYaw?: number;
  50852. adjustPitch?: number;
  50853. adjustRoll?: number;
  50854. });
  50855. /**
  50856. * Update the bone to look at the target. This should be called before the scene is rendered (use scene.registerBeforeRender())
  50857. */
  50858. update(): void;
  50859. private _getAngleDiff;
  50860. private _getAngleBetween;
  50861. private _isAngleBetween;
  50862. }
  50863. }
  50864. declare module BABYLON {
  50865. /**
  50866. * Manage the gamepad inputs to control an arc rotate camera.
  50867. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  50868. */
  50869. export class ArcRotateCameraGamepadInput implements ICameraInput<ArcRotateCamera> {
  50870. /**
  50871. * Defines the camera the input is attached to.
  50872. */
  50873. camera: ArcRotateCamera;
  50874. /**
  50875. * Defines the gamepad the input is gathering event from.
  50876. */
  50877. gamepad: Nullable<Gamepad>;
  50878. /**
  50879. * Defines the gamepad rotation sensiblity.
  50880. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  50881. */
  50882. gamepadRotationSensibility: number;
  50883. /**
  50884. * Defines the gamepad move sensiblity.
  50885. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  50886. */
  50887. gamepadMoveSensibility: number;
  50888. private _yAxisScale;
  50889. /**
  50890. * Gets or sets a boolean indicating that Yaxis (for right stick) should be inverted
  50891. */
  50892. get invertYAxis(): boolean;
  50893. set invertYAxis(value: boolean);
  50894. private _onGamepadConnectedObserver;
  50895. private _onGamepadDisconnectedObserver;
  50896. /**
  50897. * Attach the input controls to a specific dom element to get the input from.
  50898. */
  50899. attachControl(): void;
  50900. /**
  50901. * Detach the current controls from the specified dom element.
  50902. */
  50903. detachControl(): void;
  50904. /**
  50905. * Update the current camera state depending on the inputs that have been used this frame.
  50906. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  50907. */
  50908. checkInputs(): void;
  50909. /**
  50910. * Gets the class name of the current intput.
  50911. * @returns the class name
  50912. */
  50913. getClassName(): string;
  50914. /**
  50915. * Get the friendly name associated with the input class.
  50916. * @returns the input friendly name
  50917. */
  50918. getSimpleName(): string;
  50919. }
  50920. }
  50921. declare module BABYLON {
  50922. interface ArcRotateCameraInputsManager {
  50923. /**
  50924. * Add orientation input support to the input manager.
  50925. * @returns the current input manager
  50926. */
  50927. addVRDeviceOrientation(): ArcRotateCameraInputsManager;
  50928. }
  50929. /**
  50930. * Manage the device orientation inputs (gyroscope) to control an arc rotate camera.
  50931. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  50932. */
  50933. export class ArcRotateCameraVRDeviceOrientationInput implements ICameraInput<ArcRotateCamera> {
  50934. /**
  50935. * Defines the camera the input is attached to.
  50936. */
  50937. camera: ArcRotateCamera;
  50938. /**
  50939. * Defines a correction factor applied on the alpha value retrieved from the orientation events.
  50940. */
  50941. alphaCorrection: number;
  50942. /**
  50943. * Defines a correction factor applied on the gamma value retrieved from the orientation events.
  50944. */
  50945. gammaCorrection: number;
  50946. private _alpha;
  50947. private _gamma;
  50948. private _dirty;
  50949. private _deviceOrientationHandler;
  50950. /**
  50951. * Instantiate a new ArcRotateCameraVRDeviceOrientationInput.
  50952. */
  50953. constructor();
  50954. /**
  50955. * Attach the input controls to a specific dom element to get the input from.
  50956. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  50957. */
  50958. attachControl(noPreventDefault?: boolean): void;
  50959. /** @hidden */
  50960. _onOrientationEvent(evt: DeviceOrientationEvent): void;
  50961. /**
  50962. * Update the current camera state depending on the inputs that have been used this frame.
  50963. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  50964. */
  50965. checkInputs(): void;
  50966. /**
  50967. * Detach the current controls from the specified dom element.
  50968. */
  50969. detachControl(): void;
  50970. /**
  50971. * Gets the class name of the current input.
  50972. * @returns the class name
  50973. */
  50974. getClassName(): string;
  50975. /**
  50976. * Get the friendly name associated with the input class.
  50977. * @returns the input friendly name
  50978. */
  50979. getSimpleName(): string;
  50980. }
  50981. }
  50982. declare module BABYLON {
  50983. /**
  50984. * Listen to mouse events to control the camera.
  50985. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  50986. */
  50987. export class FlyCameraMouseInput implements ICameraInput<FlyCamera> {
  50988. /**
  50989. * Defines the camera the input is attached to.
  50990. */
  50991. camera: FlyCamera;
  50992. /**
  50993. * Defines if touch is enabled. (Default is true.)
  50994. */
  50995. touchEnabled: boolean;
  50996. /**
  50997. * Defines the buttons associated with the input to handle camera rotation.
  50998. */
  50999. buttons: number[];
  51000. /**
  51001. * Assign buttons for Yaw control.
  51002. */
  51003. buttonsYaw: number[];
  51004. /**
  51005. * Assign buttons for Pitch control.
  51006. */
  51007. buttonsPitch: number[];
  51008. /**
  51009. * Assign buttons for Roll control.
  51010. */
  51011. buttonsRoll: number[];
  51012. /**
  51013. * Detect if any button is being pressed while mouse is moved.
  51014. * -1 = Mouse locked.
  51015. * 0 = Left button.
  51016. * 1 = Middle Button.
  51017. * 2 = Right Button.
  51018. */
  51019. activeButton: number;
  51020. /**
  51021. * Defines the pointer's angular sensibility, to control the camera rotation speed.
  51022. * Higher values reduce its sensitivity.
  51023. */
  51024. angularSensibility: number;
  51025. private _observer;
  51026. private _rollObserver;
  51027. private previousPosition;
  51028. private noPreventDefault;
  51029. private element;
  51030. /**
  51031. * Listen to mouse events to control the camera.
  51032. * @param touchEnabled Define if touch is enabled. (Default is true.)
  51033. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  51034. */
  51035. constructor(touchEnabled?: boolean);
  51036. /**
  51037. * Attach the mouse control to the HTML DOM element.
  51038. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault().
  51039. */
  51040. attachControl(noPreventDefault?: boolean): void;
  51041. /**
  51042. * Detach the current controls from the specified dom element.
  51043. */
  51044. detachControl(): void;
  51045. /**
  51046. * Gets the class name of the current input.
  51047. * @returns the class name.
  51048. */
  51049. getClassName(): string;
  51050. /**
  51051. * Get the friendly name associated with the input class.
  51052. * @returns the input's friendly name.
  51053. */
  51054. getSimpleName(): string;
  51055. private _pointerInput;
  51056. private _onMouseMove;
  51057. /**
  51058. * Rotate camera by mouse offset.
  51059. */
  51060. private rotateCamera;
  51061. }
  51062. }
  51063. declare module BABYLON {
  51064. /**
  51065. * Default Inputs manager for the FlyCamera.
  51066. * It groups all the default supported inputs for ease of use.
  51067. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  51068. */
  51069. export class FlyCameraInputsManager extends CameraInputsManager<FlyCamera> {
  51070. /**
  51071. * Instantiates a new FlyCameraInputsManager.
  51072. * @param camera Defines the camera the inputs belong to.
  51073. */
  51074. constructor(camera: FlyCamera);
  51075. /**
  51076. * Add keyboard input support to the input manager.
  51077. * @returns the new FlyCameraKeyboardMoveInput().
  51078. */
  51079. addKeyboard(): FlyCameraInputsManager;
  51080. /**
  51081. * Add mouse input support to the input manager.
  51082. * @param touchEnabled Enable touch screen support.
  51083. * @returns the new FlyCameraMouseInput().
  51084. */
  51085. addMouse(touchEnabled?: boolean): FlyCameraInputsManager;
  51086. }
  51087. }
  51088. declare module BABYLON {
  51089. /**
  51090. * This is a flying camera, designed for 3D movement and rotation in all directions,
  51091. * such as in a 3D Space Shooter or a Flight Simulator.
  51092. */
  51093. export class FlyCamera extends TargetCamera {
  51094. /**
  51095. * Define the collision ellipsoid of the camera.
  51096. * This is helpful for simulating a camera body, like a player's body.
  51097. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  51098. */
  51099. ellipsoid: Vector3;
  51100. /**
  51101. * Define an offset for the position of the ellipsoid around the camera.
  51102. * This can be helpful if the camera is attached away from the player's body center,
  51103. * such as at its head.
  51104. */
  51105. ellipsoidOffset: Vector3;
  51106. /**
  51107. * Enable or disable collisions of the camera with the rest of the scene objects.
  51108. */
  51109. checkCollisions: boolean;
  51110. /**
  51111. * Enable or disable gravity on the camera.
  51112. */
  51113. applyGravity: boolean;
  51114. /**
  51115. * Define the current direction the camera is moving to.
  51116. */
  51117. cameraDirection: Vector3;
  51118. /**
  51119. * Define the current local rotation of the camera as a quaternion to prevent Gimbal lock.
  51120. * This overrides and empties cameraRotation.
  51121. */
  51122. rotationQuaternion: Quaternion;
  51123. /**
  51124. * Track Roll to maintain the wanted Rolling when looking around.
  51125. */
  51126. _trackRoll: number;
  51127. /**
  51128. * Slowly correct the Roll to its original value after a Pitch+Yaw rotation.
  51129. */
  51130. rollCorrect: number;
  51131. /**
  51132. * Mimic a banked turn, Rolling the camera when Yawing.
  51133. * It's recommended to use rollCorrect = 10 for faster banking correction.
  51134. */
  51135. bankedTurn: boolean;
  51136. /**
  51137. * Limit in radians for how much Roll banking will add. (Default: 90°)
  51138. */
  51139. bankedTurnLimit: number;
  51140. /**
  51141. * Value of 0 disables the banked Roll.
  51142. * Value of 1 is equal to the Yaw angle in radians.
  51143. */
  51144. bankedTurnMultiplier: number;
  51145. /**
  51146. * The inputs manager loads all the input sources, such as keyboard and mouse.
  51147. */
  51148. inputs: FlyCameraInputsManager;
  51149. /**
  51150. * Gets the input sensibility for mouse input.
  51151. * Higher values reduce sensitivity.
  51152. */
  51153. get angularSensibility(): number;
  51154. /**
  51155. * Sets the input sensibility for a mouse input.
  51156. * Higher values reduce sensitivity.
  51157. */
  51158. set angularSensibility(value: number);
  51159. /**
  51160. * Get the keys for camera movement forward.
  51161. */
  51162. get keysForward(): number[];
  51163. /**
  51164. * Set the keys for camera movement forward.
  51165. */
  51166. set keysForward(value: number[]);
  51167. /**
  51168. * Get the keys for camera movement backward.
  51169. */
  51170. get keysBackward(): number[];
  51171. set keysBackward(value: number[]);
  51172. /**
  51173. * Get the keys for camera movement up.
  51174. */
  51175. get keysUp(): number[];
  51176. /**
  51177. * Set the keys for camera movement up.
  51178. */
  51179. set keysUp(value: number[]);
  51180. /**
  51181. * Get the keys for camera movement down.
  51182. */
  51183. get keysDown(): number[];
  51184. /**
  51185. * Set the keys for camera movement down.
  51186. */
  51187. set keysDown(value: number[]);
  51188. /**
  51189. * Get the keys for camera movement left.
  51190. */
  51191. get keysLeft(): number[];
  51192. /**
  51193. * Set the keys for camera movement left.
  51194. */
  51195. set keysLeft(value: number[]);
  51196. /**
  51197. * Set the keys for camera movement right.
  51198. */
  51199. get keysRight(): number[];
  51200. /**
  51201. * Set the keys for camera movement right.
  51202. */
  51203. set keysRight(value: number[]);
  51204. /**
  51205. * Event raised when the camera collides with a mesh in the scene.
  51206. */
  51207. onCollide: (collidedMesh: AbstractMesh) => void;
  51208. private _collider;
  51209. private _needMoveForGravity;
  51210. private _oldPosition;
  51211. private _diffPosition;
  51212. private _newPosition;
  51213. /** @hidden */
  51214. _localDirection: Vector3;
  51215. /** @hidden */
  51216. _transformedDirection: Vector3;
  51217. /**
  51218. * Instantiates a FlyCamera.
  51219. * This is a flying camera, designed for 3D movement and rotation in all directions,
  51220. * such as in a 3D Space Shooter or a Flight Simulator.
  51221. * @param name Define the name of the camera in the scene.
  51222. * @param position Define the starting position of the camera in the scene.
  51223. * @param scene Define the scene the camera belongs to.
  51224. * @param setActiveOnSceneIfNoneActive Defines whether the camera should be marked as active, if no other camera has been defined as active.
  51225. */
  51226. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  51227. /**
  51228. * Attach the input controls to a specific dom element to get the input from.
  51229. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  51230. */
  51231. attachControl(noPreventDefault?: boolean): void;
  51232. /**
  51233. * Detach a control from the HTML DOM element.
  51234. * The camera will stop reacting to that input.
  51235. */
  51236. detachControl(): void;
  51237. private _collisionMask;
  51238. /**
  51239. * Get the mask that the camera ignores in collision events.
  51240. */
  51241. get collisionMask(): number;
  51242. /**
  51243. * Set the mask that the camera ignores in collision events.
  51244. */
  51245. set collisionMask(mask: number);
  51246. /** @hidden */
  51247. _collideWithWorld(displacement: Vector3): void;
  51248. /** @hidden */
  51249. private _onCollisionPositionChange;
  51250. /** @hidden */
  51251. _checkInputs(): void;
  51252. /** @hidden */
  51253. _decideIfNeedsToMove(): boolean;
  51254. /** @hidden */
  51255. _updatePosition(): void;
  51256. /**
  51257. * Restore the Roll to its target value at the rate specified.
  51258. * @param rate - Higher means slower restoring.
  51259. * @hidden
  51260. */
  51261. restoreRoll(rate: number): void;
  51262. /**
  51263. * Destroy the camera and release the current resources held by it.
  51264. */
  51265. dispose(): void;
  51266. /**
  51267. * Get the current object class name.
  51268. * @returns the class name.
  51269. */
  51270. getClassName(): string;
  51271. }
  51272. }
  51273. declare module BABYLON {
  51274. /**
  51275. * Listen to keyboard events to control the camera.
  51276. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  51277. */
  51278. export class FlyCameraKeyboardInput implements ICameraInput<FlyCamera> {
  51279. /**
  51280. * Defines the camera the input is attached to.
  51281. */
  51282. camera: FlyCamera;
  51283. /**
  51284. * The list of keyboard keys used to control the forward move of the camera.
  51285. */
  51286. keysForward: number[];
  51287. /**
  51288. * The list of keyboard keys used to control the backward move of the camera.
  51289. */
  51290. keysBackward: number[];
  51291. /**
  51292. * The list of keyboard keys used to control the forward move of the camera.
  51293. */
  51294. keysUp: number[];
  51295. /**
  51296. * The list of keyboard keys used to control the backward move of the camera.
  51297. */
  51298. keysDown: number[];
  51299. /**
  51300. * The list of keyboard keys used to control the right strafe move of the camera.
  51301. */
  51302. keysRight: number[];
  51303. /**
  51304. * The list of keyboard keys used to control the left strafe move of the camera.
  51305. */
  51306. keysLeft: number[];
  51307. private _keys;
  51308. private _onCanvasBlurObserver;
  51309. private _onKeyboardObserver;
  51310. private _engine;
  51311. private _scene;
  51312. /**
  51313. * Attach the input controls to a specific dom element to get the input from.
  51314. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  51315. */
  51316. attachControl(noPreventDefault?: boolean): void;
  51317. /**
  51318. * Detach the current controls from the specified dom element.
  51319. */
  51320. detachControl(): void;
  51321. /**
  51322. * Gets the class name of the current intput.
  51323. * @returns the class name
  51324. */
  51325. getClassName(): string;
  51326. /** @hidden */
  51327. _onLostFocus(e: FocusEvent): void;
  51328. /**
  51329. * Get the friendly name associated with the input class.
  51330. * @returns the input friendly name
  51331. */
  51332. getSimpleName(): string;
  51333. /**
  51334. * Update the current camera state depending on the inputs that have been used this frame.
  51335. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  51336. */
  51337. checkInputs(): void;
  51338. }
  51339. }
  51340. declare module BABYLON {
  51341. /**
  51342. * Manage the mouse wheel inputs to control a follow camera.
  51343. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  51344. */
  51345. export class FollowCameraMouseWheelInput implements ICameraInput<FollowCamera> {
  51346. /**
  51347. * Defines the camera the input is attached to.
  51348. */
  51349. camera: FollowCamera;
  51350. /**
  51351. * Moue wheel controls zoom. (Mouse wheel modifies camera.radius value.)
  51352. */
  51353. axisControlRadius: boolean;
  51354. /**
  51355. * Moue wheel controls height. (Mouse wheel modifies camera.heightOffset value.)
  51356. */
  51357. axisControlHeight: boolean;
  51358. /**
  51359. * Moue wheel controls angle. (Mouse wheel modifies camera.rotationOffset value.)
  51360. */
  51361. axisControlRotation: boolean;
  51362. /**
  51363. * Gets or Set the mouse wheel precision or how fast is the camera moves in
  51364. * relation to mouseWheel events.
  51365. */
  51366. wheelPrecision: number;
  51367. /**
  51368. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  51369. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  51370. */
  51371. wheelDeltaPercentage: number;
  51372. private _wheel;
  51373. private _observer;
  51374. /**
  51375. * Attach the input controls to a specific dom element to get the input from.
  51376. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  51377. */
  51378. attachControl(noPreventDefault?: boolean): void;
  51379. /**
  51380. * Detach the current controls from the specified dom element.
  51381. */
  51382. detachControl(): void;
  51383. /**
  51384. * Gets the class name of the current input.
  51385. * @returns the class name
  51386. */
  51387. getClassName(): string;
  51388. /**
  51389. * Get the friendly name associated with the input class.
  51390. * @returns the input friendly name
  51391. */
  51392. getSimpleName(): string;
  51393. }
  51394. }
  51395. declare module BABYLON {
  51396. /**
  51397. * Manage the pointers inputs to control an follow camera.
  51398. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  51399. */
  51400. export class FollowCameraPointersInput extends BaseCameraPointersInput {
  51401. /**
  51402. * Defines the camera the input is attached to.
  51403. */
  51404. camera: FollowCamera;
  51405. /**
  51406. * Gets the class name of the current input.
  51407. * @returns the class name
  51408. */
  51409. getClassName(): string;
  51410. /**
  51411. * Defines the pointer angular sensibility along the X axis or how fast is
  51412. * the camera rotating.
  51413. * A negative number will reverse the axis direction.
  51414. */
  51415. angularSensibilityX: number;
  51416. /**
  51417. * Defines the pointer angular sensibility along the Y axis or how fast is
  51418. * the camera rotating.
  51419. * A negative number will reverse the axis direction.
  51420. */
  51421. angularSensibilityY: number;
  51422. /**
  51423. * Defines the pointer pinch precision or how fast is the camera zooming.
  51424. * A negative number will reverse the axis direction.
  51425. */
  51426. pinchPrecision: number;
  51427. /**
  51428. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  51429. * from 0.
  51430. * It defines the percentage of current camera.radius to use as delta when
  51431. * pinch zoom is used.
  51432. */
  51433. pinchDeltaPercentage: number;
  51434. /**
  51435. * Pointer X axis controls zoom. (X axis modifies camera.radius value.)
  51436. */
  51437. axisXControlRadius: boolean;
  51438. /**
  51439. * Pointer X axis controls height. (X axis modifies camera.heightOffset value.)
  51440. */
  51441. axisXControlHeight: boolean;
  51442. /**
  51443. * Pointer X axis controls angle. (X axis modifies camera.rotationOffset value.)
  51444. */
  51445. axisXControlRotation: boolean;
  51446. /**
  51447. * Pointer Y axis controls zoom. (Y axis modifies camera.radius value.)
  51448. */
  51449. axisYControlRadius: boolean;
  51450. /**
  51451. * Pointer Y axis controls height. (Y axis modifies camera.heightOffset value.)
  51452. */
  51453. axisYControlHeight: boolean;
  51454. /**
  51455. * Pointer Y axis controls angle. (Y axis modifies camera.rotationOffset value.)
  51456. */
  51457. axisYControlRotation: boolean;
  51458. /**
  51459. * Pinch controls zoom. (Pinch modifies camera.radius value.)
  51460. */
  51461. axisPinchControlRadius: boolean;
  51462. /**
  51463. * Pinch controls height. (Pinch modifies camera.heightOffset value.)
  51464. */
  51465. axisPinchControlHeight: boolean;
  51466. /**
  51467. * Pinch controls angle. (Pinch modifies camera.rotationOffset value.)
  51468. */
  51469. axisPinchControlRotation: boolean;
  51470. /**
  51471. * Log error messages if basic misconfiguration has occurred.
  51472. */
  51473. warningEnable: boolean;
  51474. protected onTouch(pointA: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  51475. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  51476. private _warningCounter;
  51477. private _warning;
  51478. }
  51479. }
  51480. declare module BABYLON {
  51481. /**
  51482. * Default Inputs manager for the FollowCamera.
  51483. * It groups all the default supported inputs for ease of use.
  51484. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  51485. */
  51486. export class FollowCameraInputsManager extends CameraInputsManager<FollowCamera> {
  51487. /**
  51488. * Instantiates a new FollowCameraInputsManager.
  51489. * @param camera Defines the camera the inputs belong to
  51490. */
  51491. constructor(camera: FollowCamera);
  51492. /**
  51493. * Add keyboard input support to the input manager.
  51494. * @returns the current input manager
  51495. */
  51496. addKeyboard(): FollowCameraInputsManager;
  51497. /**
  51498. * Add mouse wheel input support to the input manager.
  51499. * @returns the current input manager
  51500. */
  51501. addMouseWheel(): FollowCameraInputsManager;
  51502. /**
  51503. * Add pointers input support to the input manager.
  51504. * @returns the current input manager
  51505. */
  51506. addPointers(): FollowCameraInputsManager;
  51507. /**
  51508. * Add orientation input support to the input manager.
  51509. * @returns the current input manager
  51510. */
  51511. addVRDeviceOrientation(): FollowCameraInputsManager;
  51512. }
  51513. }
  51514. declare module BABYLON {
  51515. /**
  51516. * A follow camera takes a mesh as a target and follows it as it moves. Both a free camera version followCamera and
  51517. * an arc rotate version arcFollowCamera are available.
  51518. * @see https://doc.babylonjs.com/features/cameras#follow-camera
  51519. */
  51520. export class FollowCamera extends TargetCamera {
  51521. /**
  51522. * Distance the follow camera should follow an object at
  51523. */
  51524. radius: number;
  51525. /**
  51526. * Minimum allowed distance of the camera to the axis of rotation
  51527. * (The camera can not get closer).
  51528. * This can help limiting how the Camera is able to move in the scene.
  51529. */
  51530. lowerRadiusLimit: Nullable<number>;
  51531. /**
  51532. * Maximum allowed distance of the camera to the axis of rotation
  51533. * (The camera can not get further).
  51534. * This can help limiting how the Camera is able to move in the scene.
  51535. */
  51536. upperRadiusLimit: Nullable<number>;
  51537. /**
  51538. * Define a rotation offset between the camera and the object it follows
  51539. */
  51540. rotationOffset: number;
  51541. /**
  51542. * Minimum allowed angle to camera position relative to target object.
  51543. * This can help limiting how the Camera is able to move in the scene.
  51544. */
  51545. lowerRotationOffsetLimit: Nullable<number>;
  51546. /**
  51547. * Maximum allowed angle to camera position relative to target object.
  51548. * This can help limiting how the Camera is able to move in the scene.
  51549. */
  51550. upperRotationOffsetLimit: Nullable<number>;
  51551. /**
  51552. * Define a height offset between the camera and the object it follows.
  51553. * It can help following an object from the top (like a car chasing a plane)
  51554. */
  51555. heightOffset: number;
  51556. /**
  51557. * Minimum allowed height of camera position relative to target object.
  51558. * This can help limiting how the Camera is able to move in the scene.
  51559. */
  51560. lowerHeightOffsetLimit: Nullable<number>;
  51561. /**
  51562. * Maximum allowed height of camera position relative to target object.
  51563. * This can help limiting how the Camera is able to move in the scene.
  51564. */
  51565. upperHeightOffsetLimit: Nullable<number>;
  51566. /**
  51567. * Define how fast the camera can accelerate to follow it s target.
  51568. */
  51569. cameraAcceleration: number;
  51570. /**
  51571. * Define the speed limit of the camera following an object.
  51572. */
  51573. maxCameraSpeed: number;
  51574. /**
  51575. * Define the target of the camera.
  51576. */
  51577. lockedTarget: Nullable<AbstractMesh>;
  51578. /**
  51579. * Defines the input associated with the camera.
  51580. */
  51581. inputs: FollowCameraInputsManager;
  51582. /**
  51583. * Instantiates the follow camera.
  51584. * @see https://doc.babylonjs.com/features/cameras#follow-camera
  51585. * @param name Define the name of the camera in the scene
  51586. * @param position Define the position of the camera
  51587. * @param scene Define the scene the camera belong to
  51588. * @param lockedTarget Define the target of the camera
  51589. */
  51590. constructor(name: string, position: Vector3, scene: Scene, lockedTarget?: Nullable<AbstractMesh>);
  51591. private _follow;
  51592. /**
  51593. * Attach the input controls to a specific dom element to get the input from.
  51594. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  51595. */
  51596. attachControl(noPreventDefault?: boolean): void;
  51597. /**
  51598. * Detach the current controls from the specified dom element.
  51599. */
  51600. detachControl(): void;
  51601. /** @hidden */
  51602. _checkInputs(): void;
  51603. private _checkLimits;
  51604. /**
  51605. * Gets the camera class name.
  51606. * @returns the class name
  51607. */
  51608. getClassName(): string;
  51609. }
  51610. /**
  51611. * Arc Rotate version of the follow camera.
  51612. * It still follows a Defined mesh but in an Arc Rotate Camera fashion.
  51613. * @see https://doc.babylonjs.com/features/cameras#follow-camera
  51614. */
  51615. export class ArcFollowCamera extends TargetCamera {
  51616. /** The longitudinal angle of the camera */
  51617. alpha: number;
  51618. /** The latitudinal angle of the camera */
  51619. beta: number;
  51620. /** The radius of the camera from its target */
  51621. radius: number;
  51622. private _cartesianCoordinates;
  51623. /** Define the camera target (the mesh it should follow) */
  51624. private _meshTarget;
  51625. /**
  51626. * Instantiates a new ArcFollowCamera
  51627. * @see https://doc.babylonjs.com/features/cameras#follow-camera
  51628. * @param name Define the name of the camera
  51629. * @param alpha Define the rotation angle of the camera around the longitudinal axis
  51630. * @param beta Define the rotation angle of the camera around the elevation axis
  51631. * @param radius Define the radius of the camera from its target point
  51632. * @param target Define the target of the camera
  51633. * @param scene Define the scene the camera belongs to
  51634. */
  51635. constructor(name: string,
  51636. /** The longitudinal angle of the camera */
  51637. alpha: number,
  51638. /** The latitudinal angle of the camera */
  51639. beta: number,
  51640. /** The radius of the camera from its target */
  51641. radius: number,
  51642. /** Define the camera target (the mesh it should follow) */
  51643. target: Nullable<AbstractMesh>, scene: Scene);
  51644. private _follow;
  51645. /** @hidden */
  51646. _checkInputs(): void;
  51647. /**
  51648. * Returns the class name of the object.
  51649. * It is mostly used internally for serialization purposes.
  51650. */
  51651. getClassName(): string;
  51652. }
  51653. }
  51654. declare module BABYLON {
  51655. /**
  51656. * Manage the keyboard inputs to control the movement of a follow camera.
  51657. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  51658. */
  51659. export class FollowCameraKeyboardMoveInput implements ICameraInput<FollowCamera> {
  51660. /**
  51661. * Defines the camera the input is attached to.
  51662. */
  51663. camera: FollowCamera;
  51664. /**
  51665. * Defines the list of key codes associated with the up action (increase heightOffset)
  51666. */
  51667. keysHeightOffsetIncr: number[];
  51668. /**
  51669. * Defines the list of key codes associated with the down action (decrease heightOffset)
  51670. */
  51671. keysHeightOffsetDecr: number[];
  51672. /**
  51673. * Defines whether the Alt modifier key is required to move up/down (alter heightOffset)
  51674. */
  51675. keysHeightOffsetModifierAlt: boolean;
  51676. /**
  51677. * Defines whether the Ctrl modifier key is required to move up/down (alter heightOffset)
  51678. */
  51679. keysHeightOffsetModifierCtrl: boolean;
  51680. /**
  51681. * Defines whether the Shift modifier key is required to move up/down (alter heightOffset)
  51682. */
  51683. keysHeightOffsetModifierShift: boolean;
  51684. /**
  51685. * Defines the list of key codes associated with the left action (increase rotationOffset)
  51686. */
  51687. keysRotationOffsetIncr: number[];
  51688. /**
  51689. * Defines the list of key codes associated with the right action (decrease rotationOffset)
  51690. */
  51691. keysRotationOffsetDecr: number[];
  51692. /**
  51693. * Defines whether the Alt modifier key is required to move left/right (alter rotationOffset)
  51694. */
  51695. keysRotationOffsetModifierAlt: boolean;
  51696. /**
  51697. * Defines whether the Ctrl modifier key is required to move left/right (alter rotationOffset)
  51698. */
  51699. keysRotationOffsetModifierCtrl: boolean;
  51700. /**
  51701. * Defines whether the Shift modifier key is required to move left/right (alter rotationOffset)
  51702. */
  51703. keysRotationOffsetModifierShift: boolean;
  51704. /**
  51705. * Defines the list of key codes associated with the zoom-in action (decrease radius)
  51706. */
  51707. keysRadiusIncr: number[];
  51708. /**
  51709. * Defines the list of key codes associated with the zoom-out action (increase radius)
  51710. */
  51711. keysRadiusDecr: number[];
  51712. /**
  51713. * Defines whether the Alt modifier key is required to zoom in/out (alter radius value)
  51714. */
  51715. keysRadiusModifierAlt: boolean;
  51716. /**
  51717. * Defines whether the Ctrl modifier key is required to zoom in/out (alter radius value)
  51718. */
  51719. keysRadiusModifierCtrl: boolean;
  51720. /**
  51721. * Defines whether the Shift modifier key is required to zoom in/out (alter radius value)
  51722. */
  51723. keysRadiusModifierShift: boolean;
  51724. /**
  51725. * Defines the rate of change of heightOffset.
  51726. */
  51727. heightSensibility: number;
  51728. /**
  51729. * Defines the rate of change of rotationOffset.
  51730. */
  51731. rotationSensibility: number;
  51732. /**
  51733. * Defines the rate of change of radius.
  51734. */
  51735. radiusSensibility: number;
  51736. private _keys;
  51737. private _ctrlPressed;
  51738. private _altPressed;
  51739. private _shiftPressed;
  51740. private _onCanvasBlurObserver;
  51741. private _onKeyboardObserver;
  51742. private _engine;
  51743. private _scene;
  51744. /**
  51745. * Attach the input controls to a specific dom element to get the input from.
  51746. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  51747. */
  51748. attachControl(noPreventDefault?: boolean): void;
  51749. /**
  51750. * Detach the current controls from the specified dom element.
  51751. */
  51752. detachControl(): void;
  51753. /**
  51754. * Update the current camera state depending on the inputs that have been used this frame.
  51755. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  51756. */
  51757. checkInputs(): void;
  51758. /**
  51759. * Gets the class name of the current input.
  51760. * @returns the class name
  51761. */
  51762. getClassName(): string;
  51763. /**
  51764. * Get the friendly name associated with the input class.
  51765. * @returns the input friendly name
  51766. */
  51767. getSimpleName(): string;
  51768. /**
  51769. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  51770. * allow modification of the heightOffset value.
  51771. */
  51772. private _modifierHeightOffset;
  51773. /**
  51774. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  51775. * allow modification of the rotationOffset value.
  51776. */
  51777. private _modifierRotationOffset;
  51778. /**
  51779. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  51780. * allow modification of the radius value.
  51781. */
  51782. private _modifierRadius;
  51783. }
  51784. }
  51785. declare module BABYLON {
  51786. interface FreeCameraInputsManager {
  51787. /**
  51788. * @hidden
  51789. */
  51790. _deviceOrientationInput: Nullable<FreeCameraDeviceOrientationInput>;
  51791. /**
  51792. * Add orientation input support to the input manager.
  51793. * @returns the current input manager
  51794. */
  51795. addDeviceOrientation(): FreeCameraInputsManager;
  51796. }
  51797. /**
  51798. * Takes information about the orientation of the device as reported by the deviceorientation event to orient the camera.
  51799. * Screen rotation is taken into account.
  51800. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  51801. */
  51802. export class FreeCameraDeviceOrientationInput implements ICameraInput<FreeCamera> {
  51803. private _camera;
  51804. private _screenOrientationAngle;
  51805. private _constantTranform;
  51806. private _screenQuaternion;
  51807. private _alpha;
  51808. private _beta;
  51809. private _gamma;
  51810. /**
  51811. * Can be used to detect if a device orientation sensor is available on a device
  51812. * @param timeout amount of time in milliseconds to wait for a response from the sensor (default: infinite)
  51813. * @returns a promise that will resolve on orientation change
  51814. */
  51815. static WaitForOrientationChangeAsync(timeout?: number): Promise<void>;
  51816. /**
  51817. * @hidden
  51818. */
  51819. _onDeviceOrientationChangedObservable: Observable<void>;
  51820. /**
  51821. * Instantiates a new input
  51822. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  51823. */
  51824. constructor();
  51825. /**
  51826. * Define the camera controlled by the input.
  51827. */
  51828. get camera(): FreeCamera;
  51829. set camera(camera: FreeCamera);
  51830. /**
  51831. * Attach the input controls to a specific dom element to get the input from.
  51832. */
  51833. attachControl(): void;
  51834. private _orientationChanged;
  51835. private _deviceOrientation;
  51836. /**
  51837. * Detach the current controls from the specified dom element.
  51838. */
  51839. detachControl(): void;
  51840. /**
  51841. * Update the current camera state depending on the inputs that have been used this frame.
  51842. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  51843. */
  51844. checkInputs(): void;
  51845. /**
  51846. * Gets the class name of the current input.
  51847. * @returns the class name
  51848. */
  51849. getClassName(): string;
  51850. /**
  51851. * Get the friendly name associated with the input class.
  51852. * @returns the input friendly name
  51853. */
  51854. getSimpleName(): string;
  51855. }
  51856. }
  51857. declare module BABYLON {
  51858. /**
  51859. * Manage the gamepad inputs to control a free camera.
  51860. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  51861. */
  51862. export class FreeCameraGamepadInput implements ICameraInput<FreeCamera> {
  51863. /**
  51864. * Define the camera the input is attached to.
  51865. */
  51866. camera: FreeCamera;
  51867. /**
  51868. * Define the Gamepad controlling the input
  51869. */
  51870. gamepad: Nullable<Gamepad>;
  51871. /**
  51872. * Defines the gamepad rotation sensiblity.
  51873. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  51874. */
  51875. gamepadAngularSensibility: number;
  51876. /**
  51877. * Defines the gamepad move sensiblity.
  51878. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  51879. */
  51880. gamepadMoveSensibility: number;
  51881. private _yAxisScale;
  51882. /**
  51883. * Gets or sets a boolean indicating that Yaxis (for right stick) should be inverted
  51884. */
  51885. get invertYAxis(): boolean;
  51886. set invertYAxis(value: boolean);
  51887. private _onGamepadConnectedObserver;
  51888. private _onGamepadDisconnectedObserver;
  51889. private _cameraTransform;
  51890. private _deltaTransform;
  51891. private _vector3;
  51892. private _vector2;
  51893. /**
  51894. * Attach the input controls to a specific dom element to get the input from.
  51895. */
  51896. attachControl(): void;
  51897. /**
  51898. * Detach the current controls from the specified dom element.
  51899. */
  51900. detachControl(): void;
  51901. /**
  51902. * Update the current camera state depending on the inputs that have been used this frame.
  51903. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  51904. */
  51905. checkInputs(): void;
  51906. /**
  51907. * Gets the class name of the current input.
  51908. * @returns the class name
  51909. */
  51910. getClassName(): string;
  51911. /**
  51912. * Get the friendly name associated with the input class.
  51913. * @returns the input friendly name
  51914. */
  51915. getSimpleName(): string;
  51916. }
  51917. }
  51918. declare module BABYLON {
  51919. /**
  51920. * Defines the potential axis of a Joystick
  51921. */
  51922. export enum JoystickAxis {
  51923. /** X axis */
  51924. X = 0,
  51925. /** Y axis */
  51926. Y = 1,
  51927. /** Z axis */
  51928. Z = 2
  51929. }
  51930. /**
  51931. * Represents the different customization options available
  51932. * for VirtualJoystick
  51933. */
  51934. interface VirtualJoystickCustomizations {
  51935. /**
  51936. * Size of the joystick's puck
  51937. */
  51938. puckSize: number;
  51939. /**
  51940. * Size of the joystick's container
  51941. */
  51942. containerSize: number;
  51943. /**
  51944. * Color of the joystick && puck
  51945. */
  51946. color: string;
  51947. /**
  51948. * Image URL for the joystick's puck
  51949. */
  51950. puckImage?: string;
  51951. /**
  51952. * Image URL for the joystick's container
  51953. */
  51954. containerImage?: string;
  51955. /**
  51956. * Defines the unmoving position of the joystick container
  51957. */
  51958. position?: {
  51959. x: number;
  51960. y: number;
  51961. };
  51962. /**
  51963. * Defines whether or not the joystick container is always visible
  51964. */
  51965. alwaysVisible: boolean;
  51966. /**
  51967. * Defines whether or not to limit the movement of the puck to the joystick's container
  51968. */
  51969. limitToContainer: boolean;
  51970. }
  51971. /**
  51972. * Class used to define virtual joystick (used in touch mode)
  51973. */
  51974. export class VirtualJoystick {
  51975. /**
  51976. * Gets or sets a boolean indicating that left and right values must be inverted
  51977. */
  51978. reverseLeftRight: boolean;
  51979. /**
  51980. * Gets or sets a boolean indicating that up and down values must be inverted
  51981. */
  51982. reverseUpDown: boolean;
  51983. /**
  51984. * Gets the offset value for the position (ie. the change of the position value)
  51985. */
  51986. deltaPosition: Vector3;
  51987. /**
  51988. * Gets a boolean indicating if the virtual joystick was pressed
  51989. */
  51990. pressed: boolean;
  51991. /**
  51992. * Canvas the virtual joystick will render onto, default z-index of this is 5
  51993. */
  51994. static Canvas: Nullable<HTMLCanvasElement>;
  51995. /**
  51996. * boolean indicating whether or not the joystick's puck's movement should be limited to the joystick's container area
  51997. */
  51998. limitToContainer: boolean;
  51999. private static _globalJoystickIndex;
  52000. private static _alwaysVisibleSticks;
  52001. private static vjCanvasContext;
  52002. private static vjCanvasWidth;
  52003. private static vjCanvasHeight;
  52004. private static halfWidth;
  52005. private static _GetDefaultOptions;
  52006. private _action;
  52007. private _axisTargetedByLeftAndRight;
  52008. private _axisTargetedByUpAndDown;
  52009. private _joystickSensibility;
  52010. private _inversedSensibility;
  52011. private _joystickPointerID;
  52012. private _joystickColor;
  52013. private _joystickPointerPos;
  52014. private _joystickPreviousPointerPos;
  52015. private _joystickPointerStartPos;
  52016. private _deltaJoystickVector;
  52017. private _leftJoystick;
  52018. private _touches;
  52019. private _joystickPosition;
  52020. private _alwaysVisible;
  52021. private _puckImage;
  52022. private _containerImage;
  52023. private _joystickPuckSize;
  52024. private _joystickContainerSize;
  52025. private _clearPuckSize;
  52026. private _clearContainerSize;
  52027. private _clearPuckSizeOffset;
  52028. private _clearContainerSizeOffset;
  52029. private _onPointerDownHandlerRef;
  52030. private _onPointerMoveHandlerRef;
  52031. private _onPointerUpHandlerRef;
  52032. private _onResize;
  52033. /**
  52034. * Creates a new virtual joystick
  52035. * @param leftJoystick defines that the joystick is for left hand (false by default)
  52036. * @param customizations Defines the options we want to customize the VirtualJoystick
  52037. */
  52038. constructor(leftJoystick?: boolean, customizations?: Partial<VirtualJoystickCustomizations>);
  52039. /**
  52040. * Defines joystick sensibility (ie. the ratio between a physical move and virtual joystick position change)
  52041. * @param newJoystickSensibility defines the new sensibility
  52042. */
  52043. setJoystickSensibility(newJoystickSensibility: number): void;
  52044. private _onPointerDown;
  52045. private _onPointerMove;
  52046. private _onPointerUp;
  52047. /**
  52048. * Change the color of the virtual joystick
  52049. * @param newColor a string that must be a CSS color value (like "red") or the hexa value (like "#FF0000")
  52050. */
  52051. setJoystickColor(newColor: string): void;
  52052. /**
  52053. * Size of the joystick's container
  52054. */
  52055. set containerSize(newSize: number);
  52056. get containerSize(): number;
  52057. /**
  52058. * Size of the joystick's puck
  52059. */
  52060. set puckSize(newSize: number);
  52061. get puckSize(): number;
  52062. /**
  52063. * Clears the set position of the joystick
  52064. */
  52065. clearPosition(): void;
  52066. /**
  52067. * Defines whether or not the joystick container is always visible
  52068. */
  52069. set alwaysVisible(value: boolean);
  52070. get alwaysVisible(): boolean;
  52071. /**
  52072. * Sets the constant position of the Joystick container
  52073. * @param x X axis coordinate
  52074. * @param y Y axis coordinate
  52075. */
  52076. setPosition(x: number, y: number): void;
  52077. /**
  52078. * Defines a callback to call when the joystick is touched
  52079. * @param action defines the callback
  52080. */
  52081. setActionOnTouch(action: () => any): void;
  52082. /**
  52083. * Defines which axis you'd like to control for left & right
  52084. * @param axis defines the axis to use
  52085. */
  52086. setAxisForLeftRight(axis: JoystickAxis): void;
  52087. /**
  52088. * Defines which axis you'd like to control for up & down
  52089. * @param axis defines the axis to use
  52090. */
  52091. setAxisForUpDown(axis: JoystickAxis): void;
  52092. /**
  52093. * Clears the canvas from the previous puck / container draw
  52094. */
  52095. private _clearPreviousDraw;
  52096. /**
  52097. * Loads `urlPath` to be used for the container's image
  52098. * @param urlPath defines the urlPath of an image to use
  52099. */
  52100. setContainerImage(urlPath: string): void;
  52101. /**
  52102. * Loads `urlPath` to be used for the puck's image
  52103. * @param urlPath defines the urlPath of an image to use
  52104. */
  52105. setPuckImage(urlPath: string): void;
  52106. /**
  52107. * Draws the Virtual Joystick's container
  52108. */
  52109. private _drawContainer;
  52110. /**
  52111. * Draws the Virtual Joystick's puck
  52112. */
  52113. private _drawPuck;
  52114. private _drawVirtualJoystick;
  52115. /**
  52116. * Release internal HTML canvas
  52117. */
  52118. releaseCanvas(): void;
  52119. }
  52120. }
  52121. declare module BABYLON {
  52122. interface FreeCameraInputsManager {
  52123. /**
  52124. * Add virtual joystick input support to the input manager.
  52125. * @returns the current input manager
  52126. */
  52127. addVirtualJoystick(): FreeCameraInputsManager;
  52128. }
  52129. /**
  52130. * Manage the Virtual Joystick inputs to control the movement of a free camera.
  52131. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  52132. */
  52133. export class FreeCameraVirtualJoystickInput implements ICameraInput<FreeCamera> {
  52134. /**
  52135. * Defines the camera the input is attached to.
  52136. */
  52137. camera: FreeCamera;
  52138. private _leftjoystick;
  52139. private _rightjoystick;
  52140. /**
  52141. * Gets the left stick of the virtual joystick.
  52142. * @returns The virtual Joystick
  52143. */
  52144. getLeftJoystick(): VirtualJoystick;
  52145. /**
  52146. * Gets the right stick of the virtual joystick.
  52147. * @returns The virtual Joystick
  52148. */
  52149. getRightJoystick(): VirtualJoystick;
  52150. /**
  52151. * Update the current camera state depending on the inputs that have been used this frame.
  52152. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  52153. */
  52154. checkInputs(): void;
  52155. /**
  52156. * Attach the input controls to a specific dom element to get the input from.
  52157. */
  52158. attachControl(): void;
  52159. /**
  52160. * Detach the current controls from the specified dom element.
  52161. */
  52162. detachControl(): void;
  52163. /**
  52164. * Gets the class name of the current input.
  52165. * @returns the class name
  52166. */
  52167. getClassName(): string;
  52168. /**
  52169. * Get the friendly name associated with the input class.
  52170. * @returns the input friendly name
  52171. */
  52172. getSimpleName(): string;
  52173. }
  52174. }
  52175. declare module BABYLON {
  52176. /**
  52177. * This represents a FPS type of camera controlled by touch.
  52178. * This is like a universal camera minus the Gamepad controls.
  52179. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  52180. */
  52181. export class TouchCamera extends FreeCamera {
  52182. /**
  52183. * Defines the touch sensibility for rotation.
  52184. * The higher the faster.
  52185. */
  52186. get touchAngularSensibility(): number;
  52187. set touchAngularSensibility(value: number);
  52188. /**
  52189. * Defines the touch sensibility for move.
  52190. * The higher the faster.
  52191. */
  52192. get touchMoveSensibility(): number;
  52193. set touchMoveSensibility(value: number);
  52194. /**
  52195. * Instantiates a new touch camera.
  52196. * This represents a FPS type of camera controlled by touch.
  52197. * This is like a universal camera minus the Gamepad controls.
  52198. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  52199. * @param name Define the name of the camera in the scene
  52200. * @param position Define the start position of the camera in the scene
  52201. * @param scene Define the scene the camera belongs to
  52202. */
  52203. constructor(name: string, position: Vector3, scene: Scene);
  52204. /**
  52205. * Gets the current object class name.
  52206. * @return the class name
  52207. */
  52208. getClassName(): string;
  52209. /** @hidden */
  52210. _setupInputs(): void;
  52211. }
  52212. }
  52213. declare module BABYLON {
  52214. /**
  52215. * This is a camera specifically designed to react to device orientation events such as a modern mobile device
  52216. * being tilted forward or back and left or right.
  52217. */
  52218. export class DeviceOrientationCamera extends FreeCamera {
  52219. private _initialQuaternion;
  52220. private _quaternionCache;
  52221. private _tmpDragQuaternion;
  52222. private _disablePointerInputWhenUsingDeviceOrientation;
  52223. /**
  52224. * Creates a new device orientation camera
  52225. * @param name The name of the camera
  52226. * @param position The start position camera
  52227. * @param scene The scene the camera belongs to
  52228. */
  52229. constructor(name: string, position: Vector3, scene: Scene);
  52230. /**
  52231. * Gets or sets a boolean indicating that pointer input must be disabled on first orientation sensor update (Default: true)
  52232. */
  52233. get disablePointerInputWhenUsingDeviceOrientation(): boolean;
  52234. set disablePointerInputWhenUsingDeviceOrientation(value: boolean);
  52235. private _dragFactor;
  52236. /**
  52237. * Enabled turning on the y axis when the orientation sensor is active
  52238. * @param dragFactor the factor that controls the turn speed (default: 1/300)
  52239. */
  52240. enableHorizontalDragging(dragFactor?: number): void;
  52241. /**
  52242. * Gets the current instance class name ("DeviceOrientationCamera").
  52243. * This helps avoiding instanceof at run time.
  52244. * @returns the class name
  52245. */
  52246. getClassName(): string;
  52247. /**
  52248. * @hidden
  52249. * Checks and applies the current values of the inputs to the camera. (Internal use only)
  52250. */
  52251. _checkInputs(): void;
  52252. /**
  52253. * Reset the camera to its default orientation on the specified axis only.
  52254. * @param axis The axis to reset
  52255. */
  52256. resetToCurrentRotation(axis?: Axis): void;
  52257. }
  52258. }
  52259. declare module BABYLON {
  52260. /**
  52261. * Defines supported buttons for XBox360 compatible gamepads
  52262. */
  52263. export enum Xbox360Button {
  52264. /** A */
  52265. A = 0,
  52266. /** B */
  52267. B = 1,
  52268. /** X */
  52269. X = 2,
  52270. /** Y */
  52271. Y = 3,
  52272. /** Left button */
  52273. LB = 4,
  52274. /** Right button */
  52275. RB = 5,
  52276. /** Back */
  52277. Back = 8,
  52278. /** Start */
  52279. Start = 9,
  52280. /** Left stick */
  52281. LeftStick = 10,
  52282. /** Right stick */
  52283. RightStick = 11
  52284. }
  52285. /** Defines values for XBox360 DPad */
  52286. export enum Xbox360Dpad {
  52287. /** Up */
  52288. Up = 12,
  52289. /** Down */
  52290. Down = 13,
  52291. /** Left */
  52292. Left = 14,
  52293. /** Right */
  52294. Right = 15
  52295. }
  52296. /**
  52297. * Defines a XBox360 gamepad
  52298. */
  52299. export class Xbox360Pad extends Gamepad {
  52300. private _leftTrigger;
  52301. private _rightTrigger;
  52302. private _onlefttriggerchanged;
  52303. private _onrighttriggerchanged;
  52304. private _onbuttondown;
  52305. private _onbuttonup;
  52306. private _ondpaddown;
  52307. private _ondpadup;
  52308. /** Observable raised when a button is pressed */
  52309. onButtonDownObservable: Observable<Xbox360Button>;
  52310. /** Observable raised when a button is released */
  52311. onButtonUpObservable: Observable<Xbox360Button>;
  52312. /** Observable raised when a pad is pressed */
  52313. onPadDownObservable: Observable<Xbox360Dpad>;
  52314. /** Observable raised when a pad is released */
  52315. onPadUpObservable: Observable<Xbox360Dpad>;
  52316. private _buttonA;
  52317. private _buttonB;
  52318. private _buttonX;
  52319. private _buttonY;
  52320. private _buttonBack;
  52321. private _buttonStart;
  52322. private _buttonLB;
  52323. private _buttonRB;
  52324. private _buttonLeftStick;
  52325. private _buttonRightStick;
  52326. private _dPadUp;
  52327. private _dPadDown;
  52328. private _dPadLeft;
  52329. private _dPadRight;
  52330. private _isXboxOnePad;
  52331. /**
  52332. * Creates a new XBox360 gamepad object
  52333. * @param id defines the id of this gamepad
  52334. * @param index defines its index
  52335. * @param gamepad defines the internal HTML gamepad object
  52336. * @param xboxOne defines if it is a XBox One gamepad
  52337. */
  52338. constructor(id: string, index: number, gamepad: any, xboxOne?: boolean);
  52339. /**
  52340. * Defines the callback to call when left trigger is pressed
  52341. * @param callback defines the callback to use
  52342. */
  52343. onlefttriggerchanged(callback: (value: number) => void): void;
  52344. /**
  52345. * Defines the callback to call when right trigger is pressed
  52346. * @param callback defines the callback to use
  52347. */
  52348. onrighttriggerchanged(callback: (value: number) => void): void;
  52349. /**
  52350. * Gets the left trigger value
  52351. */
  52352. get leftTrigger(): number;
  52353. /**
  52354. * Sets the left trigger value
  52355. */
  52356. set leftTrigger(newValue: number);
  52357. /**
  52358. * Gets the right trigger value
  52359. */
  52360. get rightTrigger(): number;
  52361. /**
  52362. * Sets the right trigger value
  52363. */
  52364. set rightTrigger(newValue: number);
  52365. /**
  52366. * Defines the callback to call when a button is pressed
  52367. * @param callback defines the callback to use
  52368. */
  52369. onbuttondown(callback: (buttonPressed: Xbox360Button) => void): void;
  52370. /**
  52371. * Defines the callback to call when a button is released
  52372. * @param callback defines the callback to use
  52373. */
  52374. onbuttonup(callback: (buttonReleased: Xbox360Button) => void): void;
  52375. /**
  52376. * Defines the callback to call when a pad is pressed
  52377. * @param callback defines the callback to use
  52378. */
  52379. ondpaddown(callback: (dPadPressed: Xbox360Dpad) => void): void;
  52380. /**
  52381. * Defines the callback to call when a pad is released
  52382. * @param callback defines the callback to use
  52383. */
  52384. ondpadup(callback: (dPadReleased: Xbox360Dpad) => void): void;
  52385. private _setButtonValue;
  52386. private _setDPadValue;
  52387. /**
  52388. * Gets the value of the `A` button
  52389. */
  52390. get buttonA(): number;
  52391. /**
  52392. * Sets the value of the `A` button
  52393. */
  52394. set buttonA(value: number);
  52395. /**
  52396. * Gets the value of the `B` button
  52397. */
  52398. get buttonB(): number;
  52399. /**
  52400. * Sets the value of the `B` button
  52401. */
  52402. set buttonB(value: number);
  52403. /**
  52404. * Gets the value of the `X` button
  52405. */
  52406. get buttonX(): number;
  52407. /**
  52408. * Sets the value of the `X` button
  52409. */
  52410. set buttonX(value: number);
  52411. /**
  52412. * Gets the value of the `Y` button
  52413. */
  52414. get buttonY(): number;
  52415. /**
  52416. * Sets the value of the `Y` button
  52417. */
  52418. set buttonY(value: number);
  52419. /**
  52420. * Gets the value of the `Start` button
  52421. */
  52422. get buttonStart(): number;
  52423. /**
  52424. * Sets the value of the `Start` button
  52425. */
  52426. set buttonStart(value: number);
  52427. /**
  52428. * Gets the value of the `Back` button
  52429. */
  52430. get buttonBack(): number;
  52431. /**
  52432. * Sets the value of the `Back` button
  52433. */
  52434. set buttonBack(value: number);
  52435. /**
  52436. * Gets the value of the `Left` button
  52437. */
  52438. get buttonLB(): number;
  52439. /**
  52440. * Sets the value of the `Left` button
  52441. */
  52442. set buttonLB(value: number);
  52443. /**
  52444. * Gets the value of the `Right` button
  52445. */
  52446. get buttonRB(): number;
  52447. /**
  52448. * Sets the value of the `Right` button
  52449. */
  52450. set buttonRB(value: number);
  52451. /**
  52452. * Gets the value of the Left joystick
  52453. */
  52454. get buttonLeftStick(): number;
  52455. /**
  52456. * Sets the value of the Left joystick
  52457. */
  52458. set buttonLeftStick(value: number);
  52459. /**
  52460. * Gets the value of the Right joystick
  52461. */
  52462. get buttonRightStick(): number;
  52463. /**
  52464. * Sets the value of the Right joystick
  52465. */
  52466. set buttonRightStick(value: number);
  52467. /**
  52468. * Gets the value of D-pad up
  52469. */
  52470. get dPadUp(): number;
  52471. /**
  52472. * Sets the value of D-pad up
  52473. */
  52474. set dPadUp(value: number);
  52475. /**
  52476. * Gets the value of D-pad down
  52477. */
  52478. get dPadDown(): number;
  52479. /**
  52480. * Sets the value of D-pad down
  52481. */
  52482. set dPadDown(value: number);
  52483. /**
  52484. * Gets the value of D-pad left
  52485. */
  52486. get dPadLeft(): number;
  52487. /**
  52488. * Sets the value of D-pad left
  52489. */
  52490. set dPadLeft(value: number);
  52491. /**
  52492. * Gets the value of D-pad right
  52493. */
  52494. get dPadRight(): number;
  52495. /**
  52496. * Sets the value of D-pad right
  52497. */
  52498. set dPadRight(value: number);
  52499. /**
  52500. * Force the gamepad to synchronize with device values
  52501. */
  52502. update(): void;
  52503. /**
  52504. * Disposes the gamepad
  52505. */
  52506. dispose(): void;
  52507. }
  52508. }
  52509. declare module BABYLON {
  52510. /**
  52511. * Defines supported buttons for DualShock compatible gamepads
  52512. */
  52513. export enum DualShockButton {
  52514. /** Cross */
  52515. Cross = 0,
  52516. /** Circle */
  52517. Circle = 1,
  52518. /** Square */
  52519. Square = 2,
  52520. /** Triangle */
  52521. Triangle = 3,
  52522. /** L1 */
  52523. L1 = 4,
  52524. /** R1 */
  52525. R1 = 5,
  52526. /** Share */
  52527. Share = 8,
  52528. /** Options */
  52529. Options = 9,
  52530. /** Left stick */
  52531. LeftStick = 10,
  52532. /** Right stick */
  52533. RightStick = 11
  52534. }
  52535. /** Defines values for DualShock DPad */
  52536. export enum DualShockDpad {
  52537. /** Up */
  52538. Up = 12,
  52539. /** Down */
  52540. Down = 13,
  52541. /** Left */
  52542. Left = 14,
  52543. /** Right */
  52544. Right = 15
  52545. }
  52546. /**
  52547. * Defines a DualShock gamepad
  52548. */
  52549. export class DualShockPad extends Gamepad {
  52550. private _leftTrigger;
  52551. private _rightTrigger;
  52552. private _onlefttriggerchanged;
  52553. private _onrighttriggerchanged;
  52554. private _onbuttondown;
  52555. private _onbuttonup;
  52556. private _ondpaddown;
  52557. private _ondpadup;
  52558. /** Observable raised when a button is pressed */
  52559. onButtonDownObservable: Observable<DualShockButton>;
  52560. /** Observable raised when a button is released */
  52561. onButtonUpObservable: Observable<DualShockButton>;
  52562. /** Observable raised when a pad is pressed */
  52563. onPadDownObservable: Observable<DualShockDpad>;
  52564. /** Observable raised when a pad is released */
  52565. onPadUpObservable: Observable<DualShockDpad>;
  52566. private _buttonCross;
  52567. private _buttonCircle;
  52568. private _buttonSquare;
  52569. private _buttonTriangle;
  52570. private _buttonShare;
  52571. private _buttonOptions;
  52572. private _buttonL1;
  52573. private _buttonR1;
  52574. private _buttonLeftStick;
  52575. private _buttonRightStick;
  52576. private _dPadUp;
  52577. private _dPadDown;
  52578. private _dPadLeft;
  52579. private _dPadRight;
  52580. /**
  52581. * Creates a new DualShock gamepad object
  52582. * @param id defines the id of this gamepad
  52583. * @param index defines its index
  52584. * @param gamepad defines the internal HTML gamepad object
  52585. */
  52586. constructor(id: string, index: number, gamepad: any);
  52587. /**
  52588. * Defines the callback to call when left trigger is pressed
  52589. * @param callback defines the callback to use
  52590. */
  52591. onlefttriggerchanged(callback: (value: number) => void): void;
  52592. /**
  52593. * Defines the callback to call when right trigger is pressed
  52594. * @param callback defines the callback to use
  52595. */
  52596. onrighttriggerchanged(callback: (value: number) => void): void;
  52597. /**
  52598. * Gets the left trigger value
  52599. */
  52600. get leftTrigger(): number;
  52601. /**
  52602. * Sets the left trigger value
  52603. */
  52604. set leftTrigger(newValue: number);
  52605. /**
  52606. * Gets the right trigger value
  52607. */
  52608. get rightTrigger(): number;
  52609. /**
  52610. * Sets the right trigger value
  52611. */
  52612. set rightTrigger(newValue: number);
  52613. /**
  52614. * Defines the callback to call when a button is pressed
  52615. * @param callback defines the callback to use
  52616. */
  52617. onbuttondown(callback: (buttonPressed: DualShockButton) => void): void;
  52618. /**
  52619. * Defines the callback to call when a button is released
  52620. * @param callback defines the callback to use
  52621. */
  52622. onbuttonup(callback: (buttonReleased: DualShockButton) => void): void;
  52623. /**
  52624. * Defines the callback to call when a pad is pressed
  52625. * @param callback defines the callback to use
  52626. */
  52627. ondpaddown(callback: (dPadPressed: DualShockDpad) => void): void;
  52628. /**
  52629. * Defines the callback to call when a pad is released
  52630. * @param callback defines the callback to use
  52631. */
  52632. ondpadup(callback: (dPadReleased: DualShockDpad) => void): void;
  52633. private _setButtonValue;
  52634. private _setDPadValue;
  52635. /**
  52636. * Gets the value of the `Cross` button
  52637. */
  52638. get buttonCross(): number;
  52639. /**
  52640. * Sets the value of the `Cross` button
  52641. */
  52642. set buttonCross(value: number);
  52643. /**
  52644. * Gets the value of the `Circle` button
  52645. */
  52646. get buttonCircle(): number;
  52647. /**
  52648. * Sets the value of the `Circle` button
  52649. */
  52650. set buttonCircle(value: number);
  52651. /**
  52652. * Gets the value of the `Square` button
  52653. */
  52654. get buttonSquare(): number;
  52655. /**
  52656. * Sets the value of the `Square` button
  52657. */
  52658. set buttonSquare(value: number);
  52659. /**
  52660. * Gets the value of the `Triangle` button
  52661. */
  52662. get buttonTriangle(): number;
  52663. /**
  52664. * Sets the value of the `Triangle` button
  52665. */
  52666. set buttonTriangle(value: number);
  52667. /**
  52668. * Gets the value of the `Options` button
  52669. */
  52670. get buttonOptions(): number;
  52671. /**
  52672. * Sets the value of the `Options` button
  52673. */
  52674. set buttonOptions(value: number);
  52675. /**
  52676. * Gets the value of the `Share` button
  52677. */
  52678. get buttonShare(): number;
  52679. /**
  52680. * Sets the value of the `Share` button
  52681. */
  52682. set buttonShare(value: number);
  52683. /**
  52684. * Gets the value of the `L1` button
  52685. */
  52686. get buttonL1(): number;
  52687. /**
  52688. * Sets the value of the `L1` button
  52689. */
  52690. set buttonL1(value: number);
  52691. /**
  52692. * Gets the value of the `R1` button
  52693. */
  52694. get buttonR1(): number;
  52695. /**
  52696. * Sets the value of the `R1` button
  52697. */
  52698. set buttonR1(value: number);
  52699. /**
  52700. * Gets the value of the Left joystick
  52701. */
  52702. get buttonLeftStick(): number;
  52703. /**
  52704. * Sets the value of the Left joystick
  52705. */
  52706. set buttonLeftStick(value: number);
  52707. /**
  52708. * Gets the value of the Right joystick
  52709. */
  52710. get buttonRightStick(): number;
  52711. /**
  52712. * Sets the value of the Right joystick
  52713. */
  52714. set buttonRightStick(value: number);
  52715. /**
  52716. * Gets the value of D-pad up
  52717. */
  52718. get dPadUp(): number;
  52719. /**
  52720. * Sets the value of D-pad up
  52721. */
  52722. set dPadUp(value: number);
  52723. /**
  52724. * Gets the value of D-pad down
  52725. */
  52726. get dPadDown(): number;
  52727. /**
  52728. * Sets the value of D-pad down
  52729. */
  52730. set dPadDown(value: number);
  52731. /**
  52732. * Gets the value of D-pad left
  52733. */
  52734. get dPadLeft(): number;
  52735. /**
  52736. * Sets the value of D-pad left
  52737. */
  52738. set dPadLeft(value: number);
  52739. /**
  52740. * Gets the value of D-pad right
  52741. */
  52742. get dPadRight(): number;
  52743. /**
  52744. * Sets the value of D-pad right
  52745. */
  52746. set dPadRight(value: number);
  52747. /**
  52748. * Force the gamepad to synchronize with device values
  52749. */
  52750. update(): void;
  52751. /**
  52752. * Disposes the gamepad
  52753. */
  52754. dispose(): void;
  52755. }
  52756. }
  52757. declare module BABYLON {
  52758. /**
  52759. * Manager for handling gamepads
  52760. */
  52761. export class GamepadManager {
  52762. private _scene?;
  52763. private _babylonGamepads;
  52764. private _oneGamepadConnected;
  52765. /** @hidden */
  52766. _isMonitoring: boolean;
  52767. private _gamepadEventSupported;
  52768. private _gamepadSupport?;
  52769. /**
  52770. * observable to be triggered when the gamepad controller has been connected
  52771. */
  52772. onGamepadConnectedObservable: Observable<Gamepad>;
  52773. /**
  52774. * observable to be triggered when the gamepad controller has been disconnected
  52775. */
  52776. onGamepadDisconnectedObservable: Observable<Gamepad>;
  52777. private _onGamepadConnectedEvent;
  52778. private _onGamepadDisconnectedEvent;
  52779. /**
  52780. * Initializes the gamepad manager
  52781. * @param _scene BabylonJS scene
  52782. */
  52783. constructor(_scene?: Scene | undefined);
  52784. /**
  52785. * The gamepads in the game pad manager
  52786. */
  52787. get gamepads(): Gamepad[];
  52788. /**
  52789. * Get the gamepad controllers based on type
  52790. * @param type The type of gamepad controller
  52791. * @returns Nullable gamepad
  52792. */
  52793. getGamepadByType(type?: number): Nullable<Gamepad>;
  52794. /**
  52795. * Disposes the gamepad manager
  52796. */
  52797. dispose(): void;
  52798. private _addNewGamepad;
  52799. private _startMonitoringGamepads;
  52800. private _stopMonitoringGamepads;
  52801. /** @hidden */
  52802. _checkGamepadsStatus(): void;
  52803. private _updateGamepadObjects;
  52804. }
  52805. }
  52806. declare module BABYLON {
  52807. interface Scene {
  52808. /** @hidden */
  52809. _gamepadManager: Nullable<GamepadManager>;
  52810. /**
  52811. * Gets the gamepad manager associated with the scene
  52812. * @see https://doc.babylonjs.com/how_to/how_to_use_gamepads
  52813. */
  52814. gamepadManager: GamepadManager;
  52815. }
  52816. /**
  52817. * Interface representing a free camera inputs manager
  52818. */
  52819. interface FreeCameraInputsManager {
  52820. /**
  52821. * Adds gamepad input support to the FreeCameraInputsManager.
  52822. * @returns the FreeCameraInputsManager
  52823. */
  52824. addGamepad(): FreeCameraInputsManager;
  52825. }
  52826. /**
  52827. * Interface representing an arc rotate camera inputs manager
  52828. */
  52829. interface ArcRotateCameraInputsManager {
  52830. /**
  52831. * Adds gamepad input support to the ArcRotateCamera InputManager.
  52832. * @returns the camera inputs manager
  52833. */
  52834. addGamepad(): ArcRotateCameraInputsManager;
  52835. }
  52836. /**
  52837. * Defines the gamepad scene component responsible to manage gamepads in a given scene
  52838. */
  52839. export class GamepadSystemSceneComponent implements ISceneComponent {
  52840. /**
  52841. * The component name helpfull to identify the component in the list of scene components.
  52842. */
  52843. readonly name: string;
  52844. /**
  52845. * The scene the component belongs to.
  52846. */
  52847. scene: Scene;
  52848. /**
  52849. * Creates a new instance of the component for the given scene
  52850. * @param scene Defines the scene to register the component in
  52851. */
  52852. constructor(scene: Scene);
  52853. /**
  52854. * Registers the component in a given scene
  52855. */
  52856. register(): void;
  52857. /**
  52858. * Rebuilds the elements related to this component in case of
  52859. * context lost for instance.
  52860. */
  52861. rebuild(): void;
  52862. /**
  52863. * Disposes the component and the associated ressources
  52864. */
  52865. dispose(): void;
  52866. private _beforeCameraUpdate;
  52867. }
  52868. }
  52869. declare module BABYLON {
  52870. /**
  52871. * 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,
  52872. * which still works and will still be found in many Playgrounds.
  52873. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  52874. */
  52875. export class UniversalCamera extends TouchCamera {
  52876. /**
  52877. * Defines the gamepad rotation sensiblity.
  52878. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  52879. */
  52880. get gamepadAngularSensibility(): number;
  52881. set gamepadAngularSensibility(value: number);
  52882. /**
  52883. * Defines the gamepad move sensiblity.
  52884. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  52885. */
  52886. get gamepadMoveSensibility(): number;
  52887. set gamepadMoveSensibility(value: number);
  52888. /**
  52889. * 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,
  52890. * which still works and will still be found in many Playgrounds.
  52891. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  52892. * @param name Define the name of the camera in the scene
  52893. * @param position Define the start position of the camera in the scene
  52894. * @param scene Define the scene the camera belongs to
  52895. */
  52896. constructor(name: string, position: Vector3, scene: Scene);
  52897. /**
  52898. * Gets the current object class name.
  52899. * @return the class name
  52900. */
  52901. getClassName(): string;
  52902. }
  52903. }
  52904. declare module BABYLON {
  52905. /**
  52906. * This represents a FPS type of camera. This is only here for back compat purpose.
  52907. * Please use the UniversalCamera instead as both are identical.
  52908. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  52909. */
  52910. export class GamepadCamera extends UniversalCamera {
  52911. /**
  52912. * Instantiates a new Gamepad Camera
  52913. * This represents a FPS type of camera. This is only here for back compat purpose.
  52914. * Please use the UniversalCamera instead as both are identical.
  52915. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  52916. * @param name Define the name of the camera in the scene
  52917. * @param position Define the start position of the camera in the scene
  52918. * @param scene Define the scene the camera belongs to
  52919. */
  52920. constructor(name: string, position: Vector3, scene: Scene);
  52921. /**
  52922. * Gets the current object class name.
  52923. * @return the class name
  52924. */
  52925. getClassName(): string;
  52926. }
  52927. }
  52928. declare module BABYLON {
  52929. /** @hidden */
  52930. export var anaglyphPixelShader: {
  52931. name: string;
  52932. shader: string;
  52933. };
  52934. }
  52935. declare module BABYLON {
  52936. /**
  52937. * Postprocess used to generate anaglyphic rendering
  52938. */
  52939. export class AnaglyphPostProcess extends PostProcess {
  52940. private _passedProcess;
  52941. /**
  52942. * Gets a string identifying the name of the class
  52943. * @returns "AnaglyphPostProcess" string
  52944. */
  52945. getClassName(): string;
  52946. /**
  52947. * Creates a new AnaglyphPostProcess
  52948. * @param name defines postprocess name
  52949. * @param options defines creation options or target ratio scale
  52950. * @param rigCameras defines cameras using this postprocess
  52951. * @param samplingMode defines required sampling mode (BABYLON.Texture.NEAREST_SAMPLINGMODE by default)
  52952. * @param engine defines hosting engine
  52953. * @param reusable defines if the postprocess will be reused multiple times per frame
  52954. */
  52955. constructor(name: string, options: number | PostProcessOptions, rigCameras: Camera[], samplingMode?: number, engine?: Engine, reusable?: boolean);
  52956. }
  52957. }
  52958. declare module BABYLON {
  52959. /**
  52960. * Camera used to simulate anaglyphic rendering (based on ArcRotateCamera)
  52961. * @see https://doc.babylonjs.com/features/cameras#anaglyph-cameras
  52962. */
  52963. export class AnaglyphArcRotateCamera extends ArcRotateCamera {
  52964. /**
  52965. * Creates a new AnaglyphArcRotateCamera
  52966. * @param name defines camera name
  52967. * @param alpha defines alpha angle (in radians)
  52968. * @param beta defines beta angle (in radians)
  52969. * @param radius defines radius
  52970. * @param target defines camera target
  52971. * @param interaxialDistance defines distance between each color axis
  52972. * @param scene defines the hosting scene
  52973. */
  52974. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, scene: Scene);
  52975. /**
  52976. * Gets camera class name
  52977. * @returns AnaglyphArcRotateCamera
  52978. */
  52979. getClassName(): string;
  52980. }
  52981. }
  52982. declare module BABYLON {
  52983. /**
  52984. * Camera used to simulate anaglyphic rendering (based on FreeCamera)
  52985. * @see https://doc.babylonjs.com/features/cameras#anaglyph-cameras
  52986. */
  52987. export class AnaglyphFreeCamera extends FreeCamera {
  52988. /**
  52989. * Creates a new AnaglyphFreeCamera
  52990. * @param name defines camera name
  52991. * @param position defines initial position
  52992. * @param interaxialDistance defines distance between each color axis
  52993. * @param scene defines the hosting scene
  52994. */
  52995. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  52996. /**
  52997. * Gets camera class name
  52998. * @returns AnaglyphFreeCamera
  52999. */
  53000. getClassName(): string;
  53001. }
  53002. }
  53003. declare module BABYLON {
  53004. /**
  53005. * Camera used to simulate anaglyphic rendering (based on GamepadCamera)
  53006. * @see https://doc.babylonjs.com/features/cameras#anaglyph-cameras
  53007. */
  53008. export class AnaglyphGamepadCamera extends GamepadCamera {
  53009. /**
  53010. * Creates a new AnaglyphGamepadCamera
  53011. * @param name defines camera name
  53012. * @param position defines initial position
  53013. * @param interaxialDistance defines distance between each color axis
  53014. * @param scene defines the hosting scene
  53015. */
  53016. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  53017. /**
  53018. * Gets camera class name
  53019. * @returns AnaglyphGamepadCamera
  53020. */
  53021. getClassName(): string;
  53022. }
  53023. }
  53024. declare module BABYLON {
  53025. /**
  53026. * Camera used to simulate anaglyphic rendering (based on UniversalCamera)
  53027. * @see https://doc.babylonjs.com/features/cameras#anaglyph-cameras
  53028. */
  53029. export class AnaglyphUniversalCamera extends UniversalCamera {
  53030. /**
  53031. * Creates a new AnaglyphUniversalCamera
  53032. * @param name defines camera name
  53033. * @param position defines initial position
  53034. * @param interaxialDistance defines distance between each color axis
  53035. * @param scene defines the hosting scene
  53036. */
  53037. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  53038. /**
  53039. * Gets camera class name
  53040. * @returns AnaglyphUniversalCamera
  53041. */
  53042. getClassName(): string;
  53043. }
  53044. }
  53045. declare module BABYLON {
  53046. /** @hidden */
  53047. export var stereoscopicInterlacePixelShader: {
  53048. name: string;
  53049. shader: string;
  53050. };
  53051. }
  53052. declare module BABYLON {
  53053. /**
  53054. * StereoscopicInterlacePostProcessI used to render stereo views from a rigged camera with support for alternate line interlacing
  53055. */
  53056. export class StereoscopicInterlacePostProcessI extends PostProcess {
  53057. private _stepSize;
  53058. private _passedProcess;
  53059. /**
  53060. * Gets a string identifying the name of the class
  53061. * @returns "StereoscopicInterlacePostProcessI" string
  53062. */
  53063. getClassName(): string;
  53064. /**
  53065. * Initializes a StereoscopicInterlacePostProcessI
  53066. * @param name The name of the effect.
  53067. * @param rigCameras The rig cameras to be appled to the post process
  53068. * @param isStereoscopicHoriz If the rendered results are horizontal or vertical
  53069. * @param isStereoscopicInterlaced If the rendered results are alternate line interlaced
  53070. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  53071. * @param engine The engine which the post process will be applied. (default: current engine)
  53072. * @param reusable If the post process can be reused on the same frame. (default: false)
  53073. */
  53074. constructor(name: string, rigCameras: Camera[], isStereoscopicHoriz: boolean, isStereoscopicInterlaced: boolean, samplingMode?: number, engine?: Engine, reusable?: boolean);
  53075. }
  53076. /**
  53077. * StereoscopicInterlacePostProcess used to render stereo views from a rigged camera
  53078. */
  53079. export class StereoscopicInterlacePostProcess extends PostProcess {
  53080. private _stepSize;
  53081. private _passedProcess;
  53082. /**
  53083. * Gets a string identifying the name of the class
  53084. * @returns "StereoscopicInterlacePostProcess" string
  53085. */
  53086. getClassName(): string;
  53087. /**
  53088. * Initializes a StereoscopicInterlacePostProcess
  53089. * @param name The name of the effect.
  53090. * @param rigCameras The rig cameras to be appled to the post process
  53091. * @param isStereoscopicHoriz If the rendered results are horizontal or verticle
  53092. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  53093. * @param engine The engine which the post process will be applied. (default: current engine)
  53094. * @param reusable If the post process can be reused on the same frame. (default: false)
  53095. */
  53096. constructor(name: string, rigCameras: Camera[], isStereoscopicHoriz: boolean, samplingMode?: number, engine?: Engine, reusable?: boolean);
  53097. }
  53098. }
  53099. declare module BABYLON {
  53100. /**
  53101. * Camera used to simulate stereoscopic rendering (based on ArcRotateCamera)
  53102. * @see https://doc.babylonjs.com/features/cameras
  53103. */
  53104. export class StereoscopicArcRotateCamera extends ArcRotateCamera {
  53105. /**
  53106. * Creates a new StereoscopicArcRotateCamera
  53107. * @param name defines camera name
  53108. * @param alpha defines alpha angle (in radians)
  53109. * @param beta defines beta angle (in radians)
  53110. * @param radius defines radius
  53111. * @param target defines camera target
  53112. * @param interaxialDistance defines distance between each color axis
  53113. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  53114. * @param scene defines the hosting scene
  53115. */
  53116. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  53117. /**
  53118. * Gets camera class name
  53119. * @returns StereoscopicArcRotateCamera
  53120. */
  53121. getClassName(): string;
  53122. }
  53123. }
  53124. declare module BABYLON {
  53125. /**
  53126. * Camera used to simulate stereoscopic rendering (based on FreeCamera)
  53127. * @see https://doc.babylonjs.com/features/cameras
  53128. */
  53129. export class StereoscopicFreeCamera extends FreeCamera {
  53130. /**
  53131. * Creates a new StereoscopicFreeCamera
  53132. * @param name defines camera name
  53133. * @param position defines initial position
  53134. * @param interaxialDistance defines distance between each color axis
  53135. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  53136. * @param scene defines the hosting scene
  53137. */
  53138. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  53139. /**
  53140. * Gets camera class name
  53141. * @returns StereoscopicFreeCamera
  53142. */
  53143. getClassName(): string;
  53144. }
  53145. }
  53146. declare module BABYLON {
  53147. /**
  53148. * Camera used to simulate stereoscopic rendering (based on GamepadCamera)
  53149. * @see https://doc.babylonjs.com/features/cameras
  53150. */
  53151. export class StereoscopicGamepadCamera extends GamepadCamera {
  53152. /**
  53153. * Creates a new StereoscopicGamepadCamera
  53154. * @param name defines camera name
  53155. * @param position defines initial position
  53156. * @param interaxialDistance defines distance between each color axis
  53157. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  53158. * @param scene defines the hosting scene
  53159. */
  53160. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  53161. /**
  53162. * Gets camera class name
  53163. * @returns StereoscopicGamepadCamera
  53164. */
  53165. getClassName(): string;
  53166. }
  53167. }
  53168. declare module BABYLON {
  53169. /**
  53170. * Camera used to simulate stereoscopic rendering (based on UniversalCamera)
  53171. * @see https://doc.babylonjs.com/features/cameras
  53172. */
  53173. export class StereoscopicUniversalCamera extends UniversalCamera {
  53174. /**
  53175. * Creates a new StereoscopicUniversalCamera
  53176. * @param name defines camera name
  53177. * @param position defines initial position
  53178. * @param interaxialDistance defines distance between each color axis
  53179. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  53180. * @param scene defines the hosting scene
  53181. */
  53182. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  53183. /**
  53184. * Gets camera class name
  53185. * @returns StereoscopicUniversalCamera
  53186. */
  53187. getClassName(): string;
  53188. }
  53189. }
  53190. declare module BABYLON {
  53191. /**
  53192. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  53193. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  53194. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  53195. * @see https://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  53196. */
  53197. export class VirtualJoysticksCamera extends FreeCamera {
  53198. /**
  53199. * Instantiates a VirtualJoysticksCamera. It can be useful in First Person Shooter game for instance.
  53200. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  53201. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  53202. * @see https://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  53203. * @param name Define the name of the camera in the scene
  53204. * @param position Define the start position of the camera in the scene
  53205. * @param scene Define the scene the camera belongs to
  53206. */
  53207. constructor(name: string, position: Vector3, scene: Scene);
  53208. /**
  53209. * Gets the current object class name.
  53210. * @return the class name
  53211. */
  53212. getClassName(): string;
  53213. }
  53214. }
  53215. declare module BABYLON {
  53216. /**
  53217. * This represents all the required metrics to create a VR camera.
  53218. * @see https://doc.babylonjs.com/babylon101/cameras#device-orientation-camera
  53219. */
  53220. export class VRCameraMetrics {
  53221. /**
  53222. * Define the horizontal resolution off the screen.
  53223. */
  53224. hResolution: number;
  53225. /**
  53226. * Define the vertical resolution off the screen.
  53227. */
  53228. vResolution: number;
  53229. /**
  53230. * Define the horizontal screen size.
  53231. */
  53232. hScreenSize: number;
  53233. /**
  53234. * Define the vertical screen size.
  53235. */
  53236. vScreenSize: number;
  53237. /**
  53238. * Define the vertical screen center position.
  53239. */
  53240. vScreenCenter: number;
  53241. /**
  53242. * Define the distance of the eyes to the screen.
  53243. */
  53244. eyeToScreenDistance: number;
  53245. /**
  53246. * Define the distance between both lenses
  53247. */
  53248. lensSeparationDistance: number;
  53249. /**
  53250. * Define the distance between both viewer's eyes.
  53251. */
  53252. interpupillaryDistance: number;
  53253. /**
  53254. * Define the distortion factor of the VR postprocess.
  53255. * Please, touch with care.
  53256. */
  53257. distortionK: number[];
  53258. /**
  53259. * Define the chromatic aberration correction factors for the VR post process.
  53260. */
  53261. chromaAbCorrection: number[];
  53262. /**
  53263. * Define the scale factor of the post process.
  53264. * The smaller the better but the slower.
  53265. */
  53266. postProcessScaleFactor: number;
  53267. /**
  53268. * Define an offset for the lens center.
  53269. */
  53270. lensCenterOffset: number;
  53271. /**
  53272. * Define if the current vr camera should compensate the distortion of the lens or not.
  53273. */
  53274. compensateDistortion: boolean;
  53275. /**
  53276. * Defines if multiview should be enabled when rendering (Default: false)
  53277. */
  53278. multiviewEnabled: boolean;
  53279. /**
  53280. * Gets the rendering aspect ratio based on the provided resolutions.
  53281. */
  53282. get aspectRatio(): number;
  53283. /**
  53284. * Gets the aspect ratio based on the FOV, scale factors, and real screen sizes.
  53285. */
  53286. get aspectRatioFov(): number;
  53287. /**
  53288. * @hidden
  53289. */
  53290. get leftHMatrix(): Matrix;
  53291. /**
  53292. * @hidden
  53293. */
  53294. get rightHMatrix(): Matrix;
  53295. /**
  53296. * @hidden
  53297. */
  53298. get leftPreViewMatrix(): Matrix;
  53299. /**
  53300. * @hidden
  53301. */
  53302. get rightPreViewMatrix(): Matrix;
  53303. /**
  53304. * Get the default VRMetrics based on the most generic setup.
  53305. * @returns the default vr metrics
  53306. */
  53307. static GetDefault(): VRCameraMetrics;
  53308. }
  53309. }
  53310. declare module BABYLON {
  53311. /** @hidden */
  53312. export var vrDistortionCorrectionPixelShader: {
  53313. name: string;
  53314. shader: string;
  53315. };
  53316. }
  53317. declare module BABYLON {
  53318. /**
  53319. * VRDistortionCorrectionPostProcess used for mobile VR
  53320. */
  53321. export class VRDistortionCorrectionPostProcess extends PostProcess {
  53322. private _isRightEye;
  53323. private _distortionFactors;
  53324. private _postProcessScaleFactor;
  53325. private _lensCenterOffset;
  53326. private _scaleIn;
  53327. private _scaleFactor;
  53328. private _lensCenter;
  53329. /**
  53330. * Gets a string identifying the name of the class
  53331. * @returns "VRDistortionCorrectionPostProcess" string
  53332. */
  53333. getClassName(): string;
  53334. /**
  53335. * Initializes the VRDistortionCorrectionPostProcess
  53336. * @param name The name of the effect.
  53337. * @param camera The camera to apply the render pass to.
  53338. * @param isRightEye If this is for the right eye distortion
  53339. * @param vrMetrics All the required metrics for the VR camera
  53340. */
  53341. constructor(name: string, camera: Camera, isRightEye: boolean, vrMetrics: VRCameraMetrics);
  53342. }
  53343. }
  53344. declare module BABYLON {
  53345. /**
  53346. * Camera used to simulate VR rendering (based on ArcRotateCamera)
  53347. * @see https://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  53348. */
  53349. export class VRDeviceOrientationArcRotateCamera extends ArcRotateCamera {
  53350. /**
  53351. * Creates a new VRDeviceOrientationArcRotateCamera
  53352. * @param name defines camera name
  53353. * @param alpha defines the camera rotation along the longitudinal axis
  53354. * @param beta defines the camera rotation along the latitudinal axis
  53355. * @param radius defines the camera distance from its target
  53356. * @param target defines the camera target
  53357. * @param scene defines the scene the camera belongs to
  53358. * @param compensateDistortion defines if the camera needs to compensate the lens distortion
  53359. * @param vrCameraMetrics defines the vr metrics associated to the camera
  53360. */
  53361. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  53362. /**
  53363. * Gets camera class name
  53364. * @returns VRDeviceOrientationArcRotateCamera
  53365. */
  53366. getClassName(): string;
  53367. }
  53368. }
  53369. declare module BABYLON {
  53370. /**
  53371. * Camera used to simulate VR rendering (based on FreeCamera)
  53372. * @see https://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  53373. */
  53374. export class VRDeviceOrientationFreeCamera extends DeviceOrientationCamera {
  53375. /**
  53376. * Creates a new VRDeviceOrientationFreeCamera
  53377. * @param name defines camera name
  53378. * @param position defines the start position of the camera
  53379. * @param scene defines the scene the camera belongs to
  53380. * @param compensateDistortion defines if the camera needs to compensate the lens distortion
  53381. * @param vrCameraMetrics defines the vr metrics associated to the camera
  53382. */
  53383. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  53384. /**
  53385. * Gets camera class name
  53386. * @returns VRDeviceOrientationFreeCamera
  53387. */
  53388. getClassName(): string;
  53389. }
  53390. }
  53391. declare module BABYLON {
  53392. /**
  53393. * Camera used to simulate VR rendering (based on VRDeviceOrientationFreeCamera)
  53394. * @see https://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  53395. */
  53396. export class VRDeviceOrientationGamepadCamera extends VRDeviceOrientationFreeCamera {
  53397. /**
  53398. * Creates a new VRDeviceOrientationGamepadCamera
  53399. * @param name defines camera name
  53400. * @param position defines the start position of the camera
  53401. * @param scene defines the scene the camera belongs to
  53402. * @param compensateDistortion defines if the camera needs to compensate the lens distortion
  53403. * @param vrCameraMetrics defines the vr metrics associated to the camera
  53404. */
  53405. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  53406. /**
  53407. * Gets camera class name
  53408. * @returns VRDeviceOrientationGamepadCamera
  53409. */
  53410. getClassName(): string;
  53411. }
  53412. }
  53413. declare module BABYLON {
  53414. /**
  53415. * A class extending Texture allowing drawing on a texture
  53416. * @see https://doc.babylonjs.com/how_to/dynamictexture
  53417. */
  53418. export class DynamicTexture extends Texture {
  53419. private _generateMipMaps;
  53420. private _canvas;
  53421. private _context;
  53422. /**
  53423. * Creates a DynamicTexture
  53424. * @param name defines the name of the texture
  53425. * @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
  53426. * @param scene defines the scene where you want the texture
  53427. * @param generateMipMaps defines the use of MinMaps or not (default is false)
  53428. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  53429. * @param format defines the texture format to use (default is Engine.TEXTUREFORMAT_RGBA)
  53430. * @param invertY defines if the texture needs to be inverted on the y axis during loading
  53431. */
  53432. constructor(name: string, options: any, scene: Scene | null | undefined, generateMipMaps: boolean, samplingMode?: number, format?: number, invertY?: boolean);
  53433. /**
  53434. * Get the current class name of the texture useful for serialization or dynamic coding.
  53435. * @returns "DynamicTexture"
  53436. */
  53437. getClassName(): string;
  53438. /**
  53439. * Gets the current state of canRescale
  53440. */
  53441. get canRescale(): boolean;
  53442. private _recreate;
  53443. /**
  53444. * Scales the texture
  53445. * @param ratio the scale factor to apply to both width and height
  53446. */
  53447. scale(ratio: number): void;
  53448. /**
  53449. * Resizes the texture
  53450. * @param width the new width
  53451. * @param height the new height
  53452. */
  53453. scaleTo(width: number, height: number): void;
  53454. /**
  53455. * Gets the context of the canvas used by the texture
  53456. * @returns the canvas context of the dynamic texture
  53457. */
  53458. getContext(): CanvasRenderingContext2D;
  53459. /**
  53460. * Clears the texture
  53461. */
  53462. clear(): void;
  53463. /**
  53464. * Updates the texture
  53465. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  53466. * @param premulAlpha defines if alpha is stored as premultiplied (default is false)
  53467. */
  53468. update(invertY?: boolean, premulAlpha?: boolean): void;
  53469. /**
  53470. * Draws text onto the texture
  53471. * @param text defines the text to be drawn
  53472. * @param x defines the placement of the text from the left
  53473. * @param y defines the placement of the text from the top when invertY is true and from the bottom when false
  53474. * @param font defines the font to be used with font-style, font-size, font-name
  53475. * @param color defines the color used for the text
  53476. * @param clearColor defines the color for the canvas, use null to not overwrite canvas
  53477. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  53478. * @param update defines whether texture is immediately update (default is true)
  53479. */
  53480. drawText(text: string, x: number | null | undefined, y: number | null | undefined, font: string, color: string | null, clearColor: string, invertY?: boolean, update?: boolean): void;
  53481. /**
  53482. * Clones the texture
  53483. * @returns the clone of the texture.
  53484. */
  53485. clone(): DynamicTexture;
  53486. /**
  53487. * Serializes the dynamic texture. The scene should be ready before the dynamic texture is serialized
  53488. * @returns a serialized dynamic texture object
  53489. */
  53490. serialize(): any;
  53491. private _IsCanvasElement;
  53492. /** @hidden */
  53493. _rebuild(): void;
  53494. }
  53495. }
  53496. declare module BABYLON {
  53497. /**
  53498. * Class containing static functions to help procedurally build meshes
  53499. */
  53500. export class GroundBuilder {
  53501. /**
  53502. * Creates a ground mesh
  53503. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  53504. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  53505. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  53506. * @param name defines the name of the mesh
  53507. * @param options defines the options used to create the mesh
  53508. * @param scene defines the hosting scene
  53509. * @returns the ground mesh
  53510. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  53511. */
  53512. static CreateGround(name: string, options: {
  53513. width?: number;
  53514. height?: number;
  53515. subdivisions?: number;
  53516. subdivisionsX?: number;
  53517. subdivisionsY?: number;
  53518. updatable?: boolean;
  53519. }, scene: any): Mesh;
  53520. /**
  53521. * Creates a tiled ground mesh
  53522. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  53523. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  53524. * * 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
  53525. * * 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
  53526. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  53527. * @param name defines the name of the mesh
  53528. * @param options defines the options used to create the mesh
  53529. * @param scene defines the hosting scene
  53530. * @returns the tiled ground mesh
  53531. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  53532. */
  53533. static CreateTiledGround(name: string, options: {
  53534. xmin: number;
  53535. zmin: number;
  53536. xmax: number;
  53537. zmax: number;
  53538. subdivisions?: {
  53539. w: number;
  53540. h: number;
  53541. };
  53542. precision?: {
  53543. w: number;
  53544. h: number;
  53545. };
  53546. updatable?: boolean;
  53547. }, scene?: Nullable<Scene>): Mesh;
  53548. /**
  53549. * Creates a ground mesh from a height map
  53550. * * The parameter `url` sets the URL of the height map image resource.
  53551. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  53552. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  53553. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  53554. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  53555. * * 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.
  53556. * * 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).
  53557. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  53558. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  53559. * @param name defines the name of the mesh
  53560. * @param url defines the url to the height map
  53561. * @param options defines the options used to create the mesh
  53562. * @param scene defines the hosting scene
  53563. * @returns the ground mesh
  53564. * @see https://doc.babylonjs.com/babylon101/height_map
  53565. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  53566. */
  53567. static CreateGroundFromHeightMap(name: string, url: string, options: {
  53568. width?: number;
  53569. height?: number;
  53570. subdivisions?: number;
  53571. minHeight?: number;
  53572. maxHeight?: number;
  53573. colorFilter?: Color3;
  53574. alphaFilter?: number;
  53575. updatable?: boolean;
  53576. onReady?: (mesh: GroundMesh) => void;
  53577. }, scene?: Nullable<Scene>): GroundMesh;
  53578. }
  53579. }
  53580. declare module BABYLON {
  53581. /**
  53582. * Class containing static functions to help procedurally build meshes
  53583. */
  53584. export class TorusBuilder {
  53585. /**
  53586. * Creates a torus mesh
  53587. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  53588. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  53589. * * The parameter `tessellation` sets the number of torus sides (positive integer, default 16)
  53590. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  53591. * * 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
  53592. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  53593. * @param name defines the name of the mesh
  53594. * @param options defines the options used to create the mesh
  53595. * @param scene defines the hosting scene
  53596. * @returns the torus mesh
  53597. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  53598. */
  53599. static CreateTorus(name: string, options: {
  53600. diameter?: number;
  53601. thickness?: number;
  53602. tessellation?: number;
  53603. updatable?: boolean;
  53604. sideOrientation?: number;
  53605. frontUVs?: Vector4;
  53606. backUVs?: Vector4;
  53607. }, scene: any): Mesh;
  53608. }
  53609. }
  53610. declare module BABYLON {
  53611. /**
  53612. * Class containing static functions to help procedurally build meshes
  53613. */
  53614. export class CylinderBuilder {
  53615. /**
  53616. * Creates a cylinder or a cone mesh
  53617. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  53618. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  53619. * * 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.
  53620. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  53621. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  53622. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  53623. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  53624. * * 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).
  53625. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  53626. * * 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).
  53627. * * 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
  53628. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  53629. * * 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
  53630. * * 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.
  53631. * * If `enclose` is false, a ring surface is one element.
  53632. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  53633. * * 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
  53634. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  53635. * * 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
  53636. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  53637. * @param name defines the name of the mesh
  53638. * @param options defines the options used to create the mesh
  53639. * @param scene defines the hosting scene
  53640. * @returns the cylinder mesh
  53641. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  53642. */
  53643. static CreateCylinder(name: string, options: {
  53644. height?: number;
  53645. diameterTop?: number;
  53646. diameterBottom?: number;
  53647. diameter?: number;
  53648. tessellation?: number;
  53649. subdivisions?: number;
  53650. arc?: number;
  53651. faceColors?: Color4[];
  53652. faceUV?: Vector4[];
  53653. updatable?: boolean;
  53654. hasRings?: boolean;
  53655. enclose?: boolean;
  53656. cap?: number;
  53657. sideOrientation?: number;
  53658. frontUVs?: Vector4;
  53659. backUVs?: Vector4;
  53660. }, scene: any): Mesh;
  53661. }
  53662. }
  53663. declare module BABYLON {
  53664. /**
  53665. * States of the webXR experience
  53666. */
  53667. export enum WebXRState {
  53668. /**
  53669. * Transitioning to being in XR mode
  53670. */
  53671. ENTERING_XR = 0,
  53672. /**
  53673. * Transitioning to non XR mode
  53674. */
  53675. EXITING_XR = 1,
  53676. /**
  53677. * In XR mode and presenting
  53678. */
  53679. IN_XR = 2,
  53680. /**
  53681. * Not entered XR mode
  53682. */
  53683. NOT_IN_XR = 3
  53684. }
  53685. /**
  53686. * The state of the XR camera's tracking
  53687. */
  53688. export enum WebXRTrackingState {
  53689. /**
  53690. * No transformation received, device is not being tracked
  53691. */
  53692. NOT_TRACKING = 0,
  53693. /**
  53694. * Tracking lost - using emulated position
  53695. */
  53696. TRACKING_LOST = 1,
  53697. /**
  53698. * Transformation tracking works normally
  53699. */
  53700. TRACKING = 2
  53701. }
  53702. /**
  53703. * Abstraction of the XR render target
  53704. */
  53705. export interface WebXRRenderTarget extends IDisposable {
  53706. /**
  53707. * xrpresent context of the canvas which can be used to display/mirror xr content
  53708. */
  53709. canvasContext: WebGLRenderingContext;
  53710. /**
  53711. * xr layer for the canvas
  53712. */
  53713. xrLayer: Nullable<XRWebGLLayer>;
  53714. /**
  53715. * Initializes the xr layer for the session
  53716. * @param xrSession xr session
  53717. * @returns a promise that will resolve once the XR Layer has been created
  53718. */
  53719. initializeXRLayerAsync(xrSession: XRSession): Promise<XRWebGLLayer>;
  53720. }
  53721. }
  53722. declare module BABYLON {
  53723. /**
  53724. * COnfiguration object for WebXR output canvas
  53725. */
  53726. export class WebXRManagedOutputCanvasOptions {
  53727. /**
  53728. * An optional canvas in case you wish to create it yourself and provide it here.
  53729. * If not provided, a new canvas will be created
  53730. */
  53731. canvasElement?: HTMLCanvasElement;
  53732. /**
  53733. * Options for this XR Layer output
  53734. */
  53735. canvasOptions?: XRWebGLLayerInit;
  53736. /**
  53737. * CSS styling for a newly created canvas (if not provided)
  53738. */
  53739. newCanvasCssStyle?: string;
  53740. /**
  53741. * Get the default values of the configuration object
  53742. * @param engine defines the engine to use (can be null)
  53743. * @returns default values of this configuration object
  53744. */
  53745. static GetDefaults(engine?: ThinEngine): WebXRManagedOutputCanvasOptions;
  53746. }
  53747. /**
  53748. * Creates a canvas that is added/removed from the webpage when entering/exiting XR
  53749. */
  53750. export class WebXRManagedOutputCanvas implements WebXRRenderTarget {
  53751. private _options;
  53752. private _canvas;
  53753. private _engine;
  53754. private _originalCanvasSize;
  53755. /**
  53756. * Rendering context of the canvas which can be used to display/mirror xr content
  53757. */
  53758. canvasContext: WebGLRenderingContext;
  53759. /**
  53760. * xr layer for the canvas
  53761. */
  53762. xrLayer: Nullable<XRWebGLLayer>;
  53763. /**
  53764. * Obseervers registered here will be triggered when the xr layer was initialized
  53765. */
  53766. onXRLayerInitObservable: Observable<XRWebGLLayer>;
  53767. /**
  53768. * Initializes the canvas to be added/removed upon entering/exiting xr
  53769. * @param _xrSessionManager The XR Session manager
  53770. * @param _options optional configuration for this canvas output. defaults will be used if not provided
  53771. */
  53772. constructor(_xrSessionManager: WebXRSessionManager, _options?: WebXRManagedOutputCanvasOptions);
  53773. /**
  53774. * Disposes of the object
  53775. */
  53776. dispose(): void;
  53777. /**
  53778. * Initializes the xr layer for the session
  53779. * @param xrSession xr session
  53780. * @returns a promise that will resolve once the XR Layer has been created
  53781. */
  53782. initializeXRLayerAsync(xrSession: XRSession): Promise<XRWebGLLayer>;
  53783. private _addCanvas;
  53784. private _removeCanvas;
  53785. private _setCanvasSize;
  53786. private _setManagedOutputCanvas;
  53787. }
  53788. }
  53789. declare module BABYLON {
  53790. /**
  53791. * Manages an XRSession to work with Babylon's engine
  53792. * @see https://doc.babylonjs.com/how_to/webxr_session_manager
  53793. */
  53794. export class WebXRSessionManager implements IDisposable {
  53795. /** The scene which the session should be created for */
  53796. scene: Scene;
  53797. private _referenceSpace;
  53798. private _rttProvider;
  53799. private _sessionEnded;
  53800. private _xrNavigator;
  53801. private baseLayer;
  53802. /**
  53803. * The base reference space from which the session started. good if you want to reset your
  53804. * reference space
  53805. */
  53806. baseReferenceSpace: XRReferenceSpace;
  53807. /**
  53808. * Current XR frame
  53809. */
  53810. currentFrame: Nullable<XRFrame>;
  53811. /** WebXR timestamp updated every frame */
  53812. currentTimestamp: number;
  53813. /**
  53814. * Used just in case of a failure to initialize an immersive session.
  53815. * The viewer reference space is compensated using this height, creating a kind of "viewer-floor" reference space
  53816. */
  53817. defaultHeightCompensation: number;
  53818. /**
  53819. * Fires every time a new xrFrame arrives which can be used to update the camera
  53820. */
  53821. onXRFrameObservable: Observable<XRFrame>;
  53822. /**
  53823. * Fires when the reference space changed
  53824. */
  53825. onXRReferenceSpaceChanged: Observable<XRReferenceSpace>;
  53826. /**
  53827. * Fires when the xr session is ended either by the device or manually done
  53828. */
  53829. onXRSessionEnded: Observable<any>;
  53830. /**
  53831. * Fires when the xr session is ended either by the device or manually done
  53832. */
  53833. onXRSessionInit: Observable<XRSession>;
  53834. /**
  53835. * Underlying xr session
  53836. */
  53837. session: XRSession;
  53838. /**
  53839. * The viewer (head position) reference space. This can be used to get the XR world coordinates
  53840. * or get the offset the player is currently at.
  53841. */
  53842. viewerReferenceSpace: XRReferenceSpace;
  53843. /**
  53844. * Constructs a WebXRSessionManager, this must be initialized within a user action before usage
  53845. * @param scene The scene which the session should be created for
  53846. */
  53847. constructor(
  53848. /** The scene which the session should be created for */
  53849. scene: Scene);
  53850. /**
  53851. * The current reference space used in this session. This reference space can constantly change!
  53852. * It is mainly used to offset the camera's position.
  53853. */
  53854. get referenceSpace(): XRReferenceSpace;
  53855. /**
  53856. * Set a new reference space and triggers the observable
  53857. */
  53858. set referenceSpace(newReferenceSpace: XRReferenceSpace);
  53859. /**
  53860. * Disposes of the session manager
  53861. */
  53862. dispose(): void;
  53863. /**
  53864. * Stops the xrSession and restores the render loop
  53865. * @returns Promise which resolves after it exits XR
  53866. */
  53867. exitXRAsync(): Promise<void>;
  53868. /**
  53869. * Gets the correct render target texture to be rendered this frame for this eye
  53870. * @param eye the eye for which to get the render target
  53871. * @returns the render target for the specified eye
  53872. */
  53873. getRenderTargetTextureForEye(eye: XREye): RenderTargetTexture;
  53874. /**
  53875. * Creates a WebXRRenderTarget object for the XR session
  53876. * @param onStateChangedObservable optional, mechanism for enabling/disabling XR rendering canvas, used only on Web
  53877. * @param options optional options to provide when creating a new render target
  53878. * @returns a WebXR render target to which the session can render
  53879. */
  53880. getWebXRRenderTarget(options?: WebXRManagedOutputCanvasOptions): WebXRRenderTarget;
  53881. /**
  53882. * Initializes the manager
  53883. * After initialization enterXR can be called to start an XR session
  53884. * @returns Promise which resolves after it is initialized
  53885. */
  53886. initializeAsync(): Promise<void>;
  53887. /**
  53888. * Initializes an xr session
  53889. * @param xrSessionMode mode to initialize
  53890. * @param xrSessionInit defines optional and required values to pass to the session builder
  53891. * @returns a promise which will resolve once the session has been initialized
  53892. */
  53893. initializeSessionAsync(xrSessionMode?: XRSessionMode, xrSessionInit?: XRSessionInit): Promise<XRSession>;
  53894. /**
  53895. * Checks if a session would be supported for the creation options specified
  53896. * @param sessionMode session mode to check if supported eg. immersive-vr
  53897. * @returns A Promise that resolves to true if supported and false if not
  53898. */
  53899. isSessionSupportedAsync(sessionMode: XRSessionMode): Promise<boolean>;
  53900. /**
  53901. * Resets the reference space to the one started the session
  53902. */
  53903. resetReferenceSpace(): void;
  53904. /**
  53905. * Starts rendering to the xr layer
  53906. */
  53907. runXRRenderLoop(): void;
  53908. /**
  53909. * Sets the reference space on the xr session
  53910. * @param referenceSpaceType space to set
  53911. * @returns a promise that will resolve once the reference space has been set
  53912. */
  53913. setReferenceSpaceTypeAsync(referenceSpaceType?: XRReferenceSpaceType): Promise<XRReferenceSpace>;
  53914. /**
  53915. * Updates the render state of the session
  53916. * @param state state to set
  53917. * @returns a promise that resolves once the render state has been updated
  53918. */
  53919. updateRenderStateAsync(state: XRRenderState): Promise<void>;
  53920. /**
  53921. * Returns a promise that resolves with a boolean indicating if the provided session mode is supported by this browser
  53922. * @param sessionMode defines the session to test
  53923. * @returns a promise with boolean as final value
  53924. */
  53925. static IsSessionSupportedAsync(sessionMode: XRSessionMode): Promise<boolean>;
  53926. /**
  53927. * Returns true if Babylon.js is using the BabylonNative backend, otherwise false
  53928. */
  53929. get isNative(): boolean;
  53930. private _createRenderTargetTexture;
  53931. }
  53932. }
  53933. declare module BABYLON {
  53934. /**
  53935. * WebXR Camera which holds the views for the xrSession
  53936. * @see https://doc.babylonjs.com/how_to/webxr_camera
  53937. */
  53938. export class WebXRCamera extends FreeCamera {
  53939. private _xrSessionManager;
  53940. private _firstFrame;
  53941. private _referenceQuaternion;
  53942. private _referencedPosition;
  53943. private _xrInvPositionCache;
  53944. private _xrInvQuaternionCache;
  53945. private _trackingState;
  53946. /**
  53947. * Observable raised before camera teleportation
  53948. */
  53949. onBeforeCameraTeleport: Observable<Vector3>;
  53950. /**
  53951. * Observable raised after camera teleportation
  53952. */
  53953. onAfterCameraTeleport: Observable<Vector3>;
  53954. /**
  53955. * Notifies when the camera's tracking state has changed.
  53956. * Notice - will also be triggered when tracking has started (at the beginning of the session)
  53957. */
  53958. onTrackingStateChanged: Observable<WebXRTrackingState>;
  53959. /**
  53960. * Should position compensation execute on first frame.
  53961. * This is used when copying the position from a native (non XR) camera
  53962. */
  53963. compensateOnFirstFrame: boolean;
  53964. /**
  53965. * Creates a new webXRCamera, this should only be set at the camera after it has been updated by the xrSessionManager
  53966. * @param name the name of the camera
  53967. * @param scene the scene to add the camera to
  53968. * @param _xrSessionManager a constructed xr session manager
  53969. */
  53970. constructor(name: string, scene: Scene, _xrSessionManager: WebXRSessionManager);
  53971. /**
  53972. * Get the current XR tracking state of the camera
  53973. */
  53974. get trackingState(): WebXRTrackingState;
  53975. private _setTrackingState;
  53976. /**
  53977. * Return the user's height, unrelated to the current ground.
  53978. * This will be the y position of this camera, when ground level is 0.
  53979. */
  53980. get realWorldHeight(): number;
  53981. /** @hidden */
  53982. _updateForDualEyeDebugging(): void;
  53983. /**
  53984. * Sets this camera's transformation based on a non-vr camera
  53985. * @param otherCamera the non-vr camera to copy the transformation from
  53986. * @param resetToBaseReferenceSpace should XR reset to the base reference space
  53987. */
  53988. setTransformationFromNonVRCamera(otherCamera?: Camera, resetToBaseReferenceSpace?: boolean): void;
  53989. /**
  53990. * Gets the current instance class name ("WebXRCamera").
  53991. * @returns the class name
  53992. */
  53993. getClassName(): string;
  53994. private _rotate180;
  53995. private _updateFromXRSession;
  53996. private _updateNumberOfRigCameras;
  53997. private _updateReferenceSpace;
  53998. private _updateReferenceSpaceOffset;
  53999. }
  54000. }
  54001. declare module BABYLON {
  54002. /**
  54003. * Defining the interface required for a (webxr) feature
  54004. */
  54005. export interface IWebXRFeature extends IDisposable {
  54006. /**
  54007. * Is this feature attached
  54008. */
  54009. attached: boolean;
  54010. /**
  54011. * Should auto-attach be disabled?
  54012. */
  54013. disableAutoAttach: boolean;
  54014. /**
  54015. * Attach the feature to the session
  54016. * Will usually be called by the features manager
  54017. *
  54018. * @param force should attachment be forced (even when already attached)
  54019. * @returns true if successful.
  54020. */
  54021. attach(force?: boolean): boolean;
  54022. /**
  54023. * Detach the feature from the session
  54024. * Will usually be called by the features manager
  54025. *
  54026. * @returns true if successful.
  54027. */
  54028. detach(): boolean;
  54029. /**
  54030. * This function will be executed during before enabling the feature and can be used to not-allow enabling it.
  54031. * Note that at this point the session has NOT started, so this is purely checking if the browser supports it
  54032. *
  54033. * @returns whether or not the feature is compatible in this environment
  54034. */
  54035. isCompatible(): boolean;
  54036. /**
  54037. * Was this feature disposed;
  54038. */
  54039. isDisposed: boolean;
  54040. /**
  54041. * The name of the native xr feature name, if applicable (like anchor, hit-test, or hand-tracking)
  54042. */
  54043. xrNativeFeatureName?: string;
  54044. /**
  54045. * A list of (Babylon WebXR) features this feature depends on
  54046. */
  54047. dependsOn?: string[];
  54048. /**
  54049. * If this feature requires to extend the XRSessionInit object, this function will return the partial XR session init object
  54050. */
  54051. getXRSessionInitExtension?: () => Promise<Partial<XRSessionInit>>;
  54052. }
  54053. /**
  54054. * A list of the currently available features without referencing them
  54055. */
  54056. export class WebXRFeatureName {
  54057. /**
  54058. * The name of the anchor system feature
  54059. */
  54060. static readonly ANCHOR_SYSTEM: string;
  54061. /**
  54062. * The name of the background remover feature
  54063. */
  54064. static readonly BACKGROUND_REMOVER: string;
  54065. /**
  54066. * The name of the hit test feature
  54067. */
  54068. static readonly HIT_TEST: string;
  54069. /**
  54070. * The name of the mesh detection feature
  54071. */
  54072. static readonly MESH_DETECTION: string;
  54073. /**
  54074. * physics impostors for xr controllers feature
  54075. */
  54076. static readonly PHYSICS_CONTROLLERS: string;
  54077. /**
  54078. * The name of the plane detection feature
  54079. */
  54080. static readonly PLANE_DETECTION: string;
  54081. /**
  54082. * The name of the pointer selection feature
  54083. */
  54084. static readonly POINTER_SELECTION: string;
  54085. /**
  54086. * The name of the teleportation feature
  54087. */
  54088. static readonly TELEPORTATION: string;
  54089. /**
  54090. * The name of the feature points feature.
  54091. */
  54092. static readonly FEATURE_POINTS: string;
  54093. /**
  54094. * The name of the hand tracking feature.
  54095. */
  54096. static readonly HAND_TRACKING: string;
  54097. /**
  54098. * The name of the image tracking feature
  54099. */
  54100. static readonly IMAGE_TRACKING: string;
  54101. }
  54102. /**
  54103. * Defining the constructor of a feature. Used to register the modules.
  54104. */
  54105. export type WebXRFeatureConstructor = (xrSessionManager: WebXRSessionManager, options?: any) => () => IWebXRFeature;
  54106. /**
  54107. * The WebXR features manager is responsible of enabling or disabling features required for the current XR session.
  54108. * It is mainly used in AR sessions.
  54109. *
  54110. * A feature can have a version that is defined by Babylon (and does not correspond with the webxr version).
  54111. */
  54112. export class WebXRFeaturesManager implements IDisposable {
  54113. private _xrSessionManager;
  54114. private static readonly _AvailableFeatures;
  54115. private _features;
  54116. /**
  54117. * constructs a new features manages.
  54118. *
  54119. * @param _xrSessionManager an instance of WebXRSessionManager
  54120. */
  54121. constructor(_xrSessionManager: WebXRSessionManager);
  54122. /**
  54123. * Used to register a module. After calling this function a developer can use this feature in the scene.
  54124. * Mainly used internally.
  54125. *
  54126. * @param featureName the name of the feature to register
  54127. * @param constructorFunction the function used to construct the module
  54128. * @param version the (babylon) version of the module
  54129. * @param stable is that a stable version of this module
  54130. */
  54131. static AddWebXRFeature(featureName: string, constructorFunction: WebXRFeatureConstructor, version?: number, stable?: boolean): void;
  54132. /**
  54133. * Returns a constructor of a specific feature.
  54134. *
  54135. * @param featureName the name of the feature to construct
  54136. * @param version the version of the feature to load
  54137. * @param xrSessionManager the xrSessionManager. Used to construct the module
  54138. * @param options optional options provided to the module.
  54139. * @returns a function that, when called, will return a new instance of this feature
  54140. */
  54141. static ConstructFeature(featureName: string, version: number | undefined, xrSessionManager: WebXRSessionManager, options?: any): () => IWebXRFeature;
  54142. /**
  54143. * Can be used to return the list of features currently registered
  54144. *
  54145. * @returns an Array of available features
  54146. */
  54147. static GetAvailableFeatures(): string[];
  54148. /**
  54149. * Gets the versions available for a specific feature
  54150. * @param featureName the name of the feature
  54151. * @returns an array with the available versions
  54152. */
  54153. static GetAvailableVersions(featureName: string): string[];
  54154. /**
  54155. * Return the latest unstable version of this feature
  54156. * @param featureName the name of the feature to search
  54157. * @returns the version number. if not found will return -1
  54158. */
  54159. static GetLatestVersionOfFeature(featureName: string): number;
  54160. /**
  54161. * Return the latest stable version of this feature
  54162. * @param featureName the name of the feature to search
  54163. * @returns the version number. if not found will return -1
  54164. */
  54165. static GetStableVersionOfFeature(featureName: string): number;
  54166. /**
  54167. * Attach a feature to the current session. Mainly used when session started to start the feature effect.
  54168. * Can be used during a session to start a feature
  54169. * @param featureName the name of feature to attach
  54170. */
  54171. attachFeature(featureName: string): void;
  54172. /**
  54173. * Can be used inside a session or when the session ends to detach a specific feature
  54174. * @param featureName the name of the feature to detach
  54175. */
  54176. detachFeature(featureName: string): void;
  54177. /**
  54178. * Used to disable an already-enabled feature
  54179. * The feature will be disposed and will be recreated once enabled.
  54180. * @param featureName the feature to disable
  54181. * @returns true if disable was successful
  54182. */
  54183. disableFeature(featureName: string | {
  54184. Name: string;
  54185. }): boolean;
  54186. /**
  54187. * dispose this features manager
  54188. */
  54189. dispose(): void;
  54190. /**
  54191. * 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.
  54192. * 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.
  54193. *
  54194. * @param featureName the name of the feature to load or the class of the feature
  54195. * @param version optional version to load. if not provided the latest version will be enabled
  54196. * @param moduleOptions options provided to the module. Ses the module documentation / constructor
  54197. * @param attachIfPossible if set to true (default) the feature will be automatically attached, if it is currently possible
  54198. * @param required is this feature required to the app. If set to true the session init will fail if the feature is not available.
  54199. * @returns a new constructed feature or throws an error if feature not found.
  54200. */
  54201. enableFeature(featureName: string | {
  54202. Name: string;
  54203. }, version?: number | string, moduleOptions?: any, attachIfPossible?: boolean, required?: boolean): IWebXRFeature;
  54204. /**
  54205. * get the implementation of an enabled feature.
  54206. * @param featureName the name of the feature to load
  54207. * @returns the feature class, if found
  54208. */
  54209. getEnabledFeature(featureName: string): IWebXRFeature;
  54210. /**
  54211. * Get the list of enabled features
  54212. * @returns an array of enabled features
  54213. */
  54214. getEnabledFeatures(): string[];
  54215. /**
  54216. * This function will extend the session creation configuration object with enabled features.
  54217. * If, for example, the anchors feature is enabled, it will be automatically added to the optional or required features list,
  54218. * according to the defined "required" variable, provided during enableFeature call
  54219. * @param xrSessionInit the xr Session init object to extend
  54220. *
  54221. * @returns an extended XRSessionInit object
  54222. */
  54223. _extendXRSessionInitObject(xrSessionInit: XRSessionInit): Promise<XRSessionInit>;
  54224. }
  54225. }
  54226. declare module BABYLON {
  54227. /**
  54228. * Base set of functionality needed to create an XR experience (WebXRSessionManager, Camera, StateManagement, etc.)
  54229. * @see https://doc.babylonjs.com/how_to/webxr_experience_helpers
  54230. */
  54231. export class WebXRExperienceHelper implements IDisposable {
  54232. private scene;
  54233. private _nonVRCamera;
  54234. private _originalSceneAutoClear;
  54235. private _supported;
  54236. /**
  54237. * Camera used to render xr content
  54238. */
  54239. camera: WebXRCamera;
  54240. /** A features manager for this xr session */
  54241. featuresManager: WebXRFeaturesManager;
  54242. /**
  54243. * Observers registered here will be triggered after the camera's initial transformation is set
  54244. * This can be used to set a different ground level or an extra rotation.
  54245. *
  54246. * Note that ground level is considered to be at 0. The height defined by the XR camera will be added
  54247. * to the position set after this observable is done executing.
  54248. */
  54249. onInitialXRPoseSetObservable: Observable<WebXRCamera>;
  54250. /**
  54251. * Fires when the state of the experience helper has changed
  54252. */
  54253. onStateChangedObservable: Observable<WebXRState>;
  54254. /** Session manager used to keep track of xr session */
  54255. sessionManager: WebXRSessionManager;
  54256. /**
  54257. * The current state of the XR experience (eg. transitioning, in XR or not in XR)
  54258. */
  54259. state: WebXRState;
  54260. /**
  54261. * Creates a WebXRExperienceHelper
  54262. * @param scene The scene the helper should be created in
  54263. */
  54264. private constructor();
  54265. /**
  54266. * Creates the experience helper
  54267. * @param scene the scene to attach the experience helper to
  54268. * @returns a promise for the experience helper
  54269. */
  54270. static CreateAsync(scene: Scene): Promise<WebXRExperienceHelper>;
  54271. /**
  54272. * Disposes of the experience helper
  54273. */
  54274. dispose(): void;
  54275. /**
  54276. * Enters XR mode (This must be done within a user interaction in most browsers eg. button click)
  54277. * @param sessionMode options for the XR session
  54278. * @param referenceSpaceType frame of reference of the XR session
  54279. * @param renderTarget the output canvas that will be used to enter XR mode
  54280. * @param sessionCreationOptions optional XRSessionInit object to init the session with
  54281. * @returns promise that resolves after xr mode has entered
  54282. */
  54283. enterXRAsync(sessionMode: XRSessionMode, referenceSpaceType: XRReferenceSpaceType, renderTarget?: WebXRRenderTarget, sessionCreationOptions?: XRSessionInit): Promise<WebXRSessionManager>;
  54284. /**
  54285. * Exits XR mode and returns the scene to its original state
  54286. * @returns promise that resolves after xr mode has exited
  54287. */
  54288. exitXRAsync(): Promise<void>;
  54289. private _nonXRToXRCamera;
  54290. private _setState;
  54291. }
  54292. }
  54293. declare module BABYLON {
  54294. /**
  54295. * X-Y values for axes in WebXR
  54296. */
  54297. export interface IWebXRMotionControllerAxesValue {
  54298. /**
  54299. * The value of the x axis
  54300. */
  54301. x: number;
  54302. /**
  54303. * The value of the y-axis
  54304. */
  54305. y: number;
  54306. }
  54307. /**
  54308. * changed / previous values for the values of this component
  54309. */
  54310. export interface IWebXRMotionControllerComponentChangesValues<T> {
  54311. /**
  54312. * current (this frame) value
  54313. */
  54314. current: T;
  54315. /**
  54316. * previous (last change) value
  54317. */
  54318. previous: T;
  54319. }
  54320. /**
  54321. * Represents changes in the component between current frame and last values recorded
  54322. */
  54323. export interface IWebXRMotionControllerComponentChanges {
  54324. /**
  54325. * will be populated with previous and current values if axes changed
  54326. */
  54327. axes?: IWebXRMotionControllerComponentChangesValues<IWebXRMotionControllerAxesValue>;
  54328. /**
  54329. * will be populated with previous and current values if pressed changed
  54330. */
  54331. pressed?: IWebXRMotionControllerComponentChangesValues<boolean>;
  54332. /**
  54333. * will be populated with previous and current values if touched changed
  54334. */
  54335. touched?: IWebXRMotionControllerComponentChangesValues<boolean>;
  54336. /**
  54337. * will be populated with previous and current values if value changed
  54338. */
  54339. value?: IWebXRMotionControllerComponentChangesValues<number>;
  54340. }
  54341. /**
  54342. * This class represents a single component (for example button or thumbstick) of a motion controller
  54343. */
  54344. export class WebXRControllerComponent implements IDisposable {
  54345. /**
  54346. * the id of this component
  54347. */
  54348. id: string;
  54349. /**
  54350. * the type of the component
  54351. */
  54352. type: MotionControllerComponentType;
  54353. private _buttonIndex;
  54354. private _axesIndices;
  54355. private _axes;
  54356. private _changes;
  54357. private _currentValue;
  54358. private _hasChanges;
  54359. private _pressed;
  54360. private _touched;
  54361. /**
  54362. * button component type
  54363. */
  54364. static BUTTON_TYPE: MotionControllerComponentType;
  54365. /**
  54366. * squeeze component type
  54367. */
  54368. static SQUEEZE_TYPE: MotionControllerComponentType;
  54369. /**
  54370. * Thumbstick component type
  54371. */
  54372. static THUMBSTICK_TYPE: MotionControllerComponentType;
  54373. /**
  54374. * Touchpad component type
  54375. */
  54376. static TOUCHPAD_TYPE: MotionControllerComponentType;
  54377. /**
  54378. * trigger component type
  54379. */
  54380. static TRIGGER_TYPE: MotionControllerComponentType;
  54381. /**
  54382. * If axes are available for this component (like a touchpad or thumbstick) the observers will be notified when
  54383. * the axes data changes
  54384. */
  54385. onAxisValueChangedObservable: Observable<{
  54386. x: number;
  54387. y: number;
  54388. }>;
  54389. /**
  54390. * Observers registered here will be triggered when the state of a button changes
  54391. * State change is either pressed / touched / value
  54392. */
  54393. onButtonStateChangedObservable: Observable<WebXRControllerComponent>;
  54394. /**
  54395. * Creates a new component for a motion controller.
  54396. * It is created by the motion controller itself
  54397. *
  54398. * @param id the id of this component
  54399. * @param type the type of the component
  54400. * @param _buttonIndex index in the buttons array of the gamepad
  54401. * @param _axesIndices indices of the values in the axes array of the gamepad
  54402. */
  54403. constructor(
  54404. /**
  54405. * the id of this component
  54406. */
  54407. id: string,
  54408. /**
  54409. * the type of the component
  54410. */
  54411. type: MotionControllerComponentType, _buttonIndex?: number, _axesIndices?: number[]);
  54412. /**
  54413. * The current axes data. If this component has no axes it will still return an object { x: 0, y: 0 }
  54414. */
  54415. get axes(): IWebXRMotionControllerAxesValue;
  54416. /**
  54417. * Get the changes. Elements will be populated only if they changed with their previous and current value
  54418. */
  54419. get changes(): IWebXRMotionControllerComponentChanges;
  54420. /**
  54421. * Return whether or not the component changed the last frame
  54422. */
  54423. get hasChanges(): boolean;
  54424. /**
  54425. * is the button currently pressed
  54426. */
  54427. get pressed(): boolean;
  54428. /**
  54429. * is the button currently touched
  54430. */
  54431. get touched(): boolean;
  54432. /**
  54433. * Get the current value of this component
  54434. */
  54435. get value(): number;
  54436. /**
  54437. * Dispose this component
  54438. */
  54439. dispose(): void;
  54440. /**
  54441. * Are there axes correlating to this component
  54442. * @return true is axes data is available
  54443. */
  54444. isAxes(): boolean;
  54445. /**
  54446. * Is this component a button (hence - pressable)
  54447. * @returns true if can be pressed
  54448. */
  54449. isButton(): boolean;
  54450. /**
  54451. * update this component using the gamepad object it is in. Called on every frame
  54452. * @param nativeController the native gamepad controller object
  54453. */
  54454. update(nativeController: IMinimalMotionControllerObject): void;
  54455. }
  54456. }
  54457. declare module BABYLON {
  54458. /**
  54459. * Type used for the success callback of ImportMesh
  54460. */
  54461. export type SceneLoaderSuccessCallback = (meshes: AbstractMesh[], particleSystems: IParticleSystem[], skeletons: Skeleton[], animationGroups: AnimationGroup[], transformNodes: TransformNode[], geometries: Geometry[], lights: Light[]) => void;
  54462. /**
  54463. * Interface used for the result of ImportMeshAsync
  54464. */
  54465. export interface ISceneLoaderAsyncResult {
  54466. /**
  54467. * The array of loaded meshes
  54468. */
  54469. readonly meshes: AbstractMesh[];
  54470. /**
  54471. * The array of loaded particle systems
  54472. */
  54473. readonly particleSystems: IParticleSystem[];
  54474. /**
  54475. * The array of loaded skeletons
  54476. */
  54477. readonly skeletons: Skeleton[];
  54478. /**
  54479. * The array of loaded animation groups
  54480. */
  54481. readonly animationGroups: AnimationGroup[];
  54482. /**
  54483. * The array of loaded transform nodes
  54484. */
  54485. readonly transformNodes: TransformNode[];
  54486. /**
  54487. * The array of loaded geometries
  54488. */
  54489. readonly geometries: Geometry[];
  54490. /**
  54491. * The array of loaded lights
  54492. */
  54493. readonly lights: Light[];
  54494. }
  54495. /**
  54496. * Interface used to represent data loading progression
  54497. */
  54498. export interface ISceneLoaderProgressEvent {
  54499. /**
  54500. * Defines if data length to load can be evaluated
  54501. */
  54502. readonly lengthComputable: boolean;
  54503. /**
  54504. * Defines the loaded data length
  54505. */
  54506. readonly loaded: number;
  54507. /**
  54508. * Defines the data length to load
  54509. */
  54510. readonly total: number;
  54511. }
  54512. /**
  54513. * Interface used by SceneLoader plugins to define supported file extensions
  54514. */
  54515. export interface ISceneLoaderPluginExtensions {
  54516. /**
  54517. * Defines the list of supported extensions
  54518. */
  54519. [extension: string]: {
  54520. isBinary: boolean;
  54521. };
  54522. }
  54523. /**
  54524. * Interface used by SceneLoader plugin factory
  54525. */
  54526. export interface ISceneLoaderPluginFactory {
  54527. /**
  54528. * Defines the name of the factory
  54529. */
  54530. name: string;
  54531. /**
  54532. * Function called to create a new plugin
  54533. * @return the new plugin
  54534. */
  54535. createPlugin(): ISceneLoaderPlugin | ISceneLoaderPluginAsync;
  54536. /**
  54537. * The callback that returns true if the data can be directly loaded.
  54538. * @param data string containing the file data
  54539. * @returns if the data can be loaded directly
  54540. */
  54541. canDirectLoad?(data: string): boolean;
  54542. }
  54543. /**
  54544. * Interface used to define the base of ISceneLoaderPlugin and ISceneLoaderPluginAsync
  54545. */
  54546. export interface ISceneLoaderPluginBase {
  54547. /**
  54548. * The friendly name of this plugin.
  54549. */
  54550. name: string;
  54551. /**
  54552. * The file extensions supported by this plugin.
  54553. */
  54554. extensions: string | ISceneLoaderPluginExtensions;
  54555. /**
  54556. * The callback called when loading from a url.
  54557. * @param scene scene loading this url
  54558. * @param url url to load
  54559. * @param onSuccess callback called when the file successfully loads
  54560. * @param onProgress callback called while file is loading (if the server supports this mode)
  54561. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  54562. * @param onError callback called when the file fails to load
  54563. * @returns a file request object
  54564. */
  54565. requestFile?(scene: Scene, url: string, onSuccess: (data: any, request?: WebRequest) => void, onProgress?: (ev: ISceneLoaderProgressEvent) => void, useArrayBuffer?: boolean, onError?: (error: any) => void): IFileRequest;
  54566. /**
  54567. * The callback called when loading from a file object.
  54568. * @param scene scene loading this file
  54569. * @param file defines the file to load
  54570. * @param onSuccess defines the callback to call when data is loaded
  54571. * @param onProgress defines the callback to call during loading process
  54572. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  54573. * @param onError defines the callback to call when an error occurs
  54574. * @returns a file request object
  54575. */
  54576. readFile?(scene: Scene, file: File, onSuccess: (data: any) => void, onProgress?: (ev: ISceneLoaderProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: any) => void): IFileRequest;
  54577. /**
  54578. * The callback that returns true if the data can be directly loaded.
  54579. * @param data string containing the file data
  54580. * @returns if the data can be loaded directly
  54581. */
  54582. canDirectLoad?(data: string): boolean;
  54583. /**
  54584. * The callback that returns the data to pass to the plugin if the data can be directly loaded.
  54585. * @param scene scene loading this data
  54586. * @param data string containing the data
  54587. * @returns data to pass to the plugin
  54588. */
  54589. directLoad?(scene: Scene, data: string): any;
  54590. /**
  54591. * The callback that allows custom handling of the root url based on the response url.
  54592. * @param rootUrl the original root url
  54593. * @param responseURL the response url if available
  54594. * @returns the new root url
  54595. */
  54596. rewriteRootURL?(rootUrl: string, responseURL?: string): string;
  54597. }
  54598. /**
  54599. * Interface used to define a SceneLoader plugin
  54600. */
  54601. export interface ISceneLoaderPlugin extends ISceneLoaderPluginBase {
  54602. /**
  54603. * Import meshes into a scene.
  54604. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  54605. * @param scene The scene to import into
  54606. * @param data The data to import
  54607. * @param rootUrl The root url for scene and resources
  54608. * @param meshes The meshes array to import into
  54609. * @param particleSystems The particle systems array to import into
  54610. * @param skeletons The skeletons array to import into
  54611. * @param onError The callback when import fails
  54612. * @returns True if successful or false otherwise
  54613. */
  54614. importMesh(meshesNames: any, scene: Scene, data: any, rootUrl: string, meshes: AbstractMesh[], particleSystems: IParticleSystem[], skeletons: Skeleton[], onError?: (message: string, exception?: any) => void): boolean;
  54615. /**
  54616. * Load into a scene.
  54617. * @param scene The scene to load into
  54618. * @param data The data to import
  54619. * @param rootUrl The root url for scene and resources
  54620. * @param onError The callback when import fails
  54621. * @returns True if successful or false otherwise
  54622. */
  54623. load(scene: Scene, data: any, rootUrl: string, onError?: (message: string, exception?: any) => void): boolean;
  54624. /**
  54625. * Load into an asset container.
  54626. * @param scene The scene to load into
  54627. * @param data The data to import
  54628. * @param rootUrl The root url for scene and resources
  54629. * @param onError The callback when import fails
  54630. * @returns The loaded asset container
  54631. */
  54632. loadAssetContainer(scene: Scene, data: any, rootUrl: string, onError?: (message: string, exception?: any) => void): AssetContainer;
  54633. }
  54634. /**
  54635. * Interface used to define an async SceneLoader plugin
  54636. */
  54637. export interface ISceneLoaderPluginAsync extends ISceneLoaderPluginBase {
  54638. /**
  54639. * Import meshes into a scene.
  54640. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  54641. * @param scene The scene to import into
  54642. * @param data The data to import
  54643. * @param rootUrl The root url for scene and resources
  54644. * @param onProgress The callback when the load progresses
  54645. * @param fileName Defines the name of the file to load
  54646. * @returns The loaded objects (e.g. meshes, particle systems, skeletons, animation groups, etc.)
  54647. */
  54648. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string): Promise<ISceneLoaderAsyncResult>;
  54649. /**
  54650. * Load into a scene.
  54651. * @param scene The scene to load into
  54652. * @param data The data to import
  54653. * @param rootUrl The root url for scene and resources
  54654. * @param onProgress The callback when the load progresses
  54655. * @param fileName Defines the name of the file to load
  54656. * @returns Nothing
  54657. */
  54658. loadAsync(scene: Scene, data: any, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  54659. /**
  54660. * Load into an asset container.
  54661. * @param scene The scene to load into
  54662. * @param data The data to import
  54663. * @param rootUrl The root url for scene and resources
  54664. * @param onProgress The callback when the load progresses
  54665. * @param fileName Defines the name of the file to load
  54666. * @returns The loaded asset container
  54667. */
  54668. loadAssetContainerAsync(scene: Scene, data: any, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  54669. }
  54670. /**
  54671. * Mode that determines how to handle old animation groups before loading new ones.
  54672. */
  54673. export enum SceneLoaderAnimationGroupLoadingMode {
  54674. /**
  54675. * Reset all old animations to initial state then dispose them.
  54676. */
  54677. Clean = 0,
  54678. /**
  54679. * Stop all old animations.
  54680. */
  54681. Stop = 1,
  54682. /**
  54683. * Restart old animations from first frame.
  54684. */
  54685. Sync = 2,
  54686. /**
  54687. * Old animations remains untouched.
  54688. */
  54689. NoSync = 3
  54690. }
  54691. /**
  54692. * Defines a plugin registered by the SceneLoader
  54693. */
  54694. interface IRegisteredPlugin {
  54695. /**
  54696. * Defines the plugin to use
  54697. */
  54698. plugin: ISceneLoaderPlugin | ISceneLoaderPluginAsync | ISceneLoaderPluginFactory;
  54699. /**
  54700. * Defines if the plugin supports binary data
  54701. */
  54702. isBinary: boolean;
  54703. }
  54704. /**
  54705. * Class used to load scene from various file formats using registered plugins
  54706. * @see https://doc.babylonjs.com/how_to/load_from_any_file_type
  54707. */
  54708. export class SceneLoader {
  54709. /**
  54710. * No logging while loading
  54711. */
  54712. static readonly NO_LOGGING: number;
  54713. /**
  54714. * Minimal logging while loading
  54715. */
  54716. static readonly MINIMAL_LOGGING: number;
  54717. /**
  54718. * Summary logging while loading
  54719. */
  54720. static readonly SUMMARY_LOGGING: number;
  54721. /**
  54722. * Detailed logging while loading
  54723. */
  54724. static readonly DETAILED_LOGGING: number;
  54725. /**
  54726. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  54727. */
  54728. static get ForceFullSceneLoadingForIncremental(): boolean;
  54729. static set ForceFullSceneLoadingForIncremental(value: boolean);
  54730. /**
  54731. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  54732. */
  54733. static get ShowLoadingScreen(): boolean;
  54734. static set ShowLoadingScreen(value: boolean);
  54735. /**
  54736. * Defines the current logging level (while loading the scene)
  54737. * @ignorenaming
  54738. */
  54739. static get loggingLevel(): number;
  54740. static set loggingLevel(value: number);
  54741. /**
  54742. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  54743. */
  54744. static get CleanBoneMatrixWeights(): boolean;
  54745. static set CleanBoneMatrixWeights(value: boolean);
  54746. /**
  54747. * Event raised when a plugin is used to load a scene
  54748. */
  54749. static OnPluginActivatedObservable: Observable<ISceneLoaderPlugin | ISceneLoaderPluginAsync>;
  54750. private static _registeredPlugins;
  54751. private static _showingLoadingScreen;
  54752. /**
  54753. * Gets the default plugin (used to load Babylon files)
  54754. * @returns the .babylon plugin
  54755. */
  54756. static GetDefaultPlugin(): IRegisteredPlugin;
  54757. private static _GetPluginForExtension;
  54758. private static _GetPluginForDirectLoad;
  54759. private static _GetPluginForFilename;
  54760. private static _GetDirectLoad;
  54761. private static _LoadData;
  54762. private static _GetFileInfo;
  54763. /**
  54764. * Gets a plugin that can load the given extension
  54765. * @param extension defines the extension to load
  54766. * @returns a plugin or null if none works
  54767. */
  54768. static GetPluginForExtension(extension: string): ISceneLoaderPlugin | ISceneLoaderPluginAsync | ISceneLoaderPluginFactory;
  54769. /**
  54770. * Gets a boolean indicating that the given extension can be loaded
  54771. * @param extension defines the extension to load
  54772. * @returns true if the extension is supported
  54773. */
  54774. static IsPluginForExtensionAvailable(extension: string): boolean;
  54775. /**
  54776. * Adds a new plugin to the list of registered plugins
  54777. * @param plugin defines the plugin to add
  54778. */
  54779. static RegisterPlugin(plugin: ISceneLoaderPlugin | ISceneLoaderPluginAsync): void;
  54780. /**
  54781. * Import meshes into a scene
  54782. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  54783. * @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)
  54784. * @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)
  54785. * @param scene the instance of BABYLON.Scene to append to
  54786. * @param onSuccess a callback with a list of imported meshes, particleSystems, skeletons, and animationGroups when import succeeds
  54787. * @param onProgress a callback with a progress event for each file being loaded
  54788. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  54789. * @param pluginExtension the extension used to determine the plugin
  54790. * @returns The loaded plugin
  54791. */
  54792. 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>;
  54793. /**
  54794. * Import meshes into a scene
  54795. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  54796. * @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)
  54797. * @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)
  54798. * @param scene the instance of BABYLON.Scene to append to
  54799. * @param onProgress a callback with a progress event for each file being loaded
  54800. * @param pluginExtension the extension used to determine the plugin
  54801. * @returns The loaded list of imported meshes, particle systems, skeletons, and animation groups
  54802. */
  54803. static ImportMeshAsync(meshNames: any, rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: ISceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<ISceneLoaderAsyncResult>;
  54804. /**
  54805. * Load a scene
  54806. * @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)
  54807. * @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)
  54808. * @param engine is the instance of BABYLON.Engine to use to create the scene
  54809. * @param onSuccess a callback with the scene when import succeeds
  54810. * @param onProgress a callback with a progress event for each file being loaded
  54811. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  54812. * @param pluginExtension the extension used to determine the plugin
  54813. * @returns The loaded plugin
  54814. */
  54815. 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>;
  54816. /**
  54817. * Load a scene
  54818. * @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)
  54819. * @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)
  54820. * @param engine is the instance of BABYLON.Engine to use to create the scene
  54821. * @param onProgress a callback with a progress event for each file being loaded
  54822. * @param pluginExtension the extension used to determine the plugin
  54823. * @returns The loaded scene
  54824. */
  54825. static LoadAsync(rootUrl: string, sceneFilename?: string | File, engine?: Nullable<Engine>, onProgress?: Nullable<(event: ISceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  54826. /**
  54827. * Append a scene
  54828. * @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)
  54829. * @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)
  54830. * @param scene is the instance of BABYLON.Scene to append to
  54831. * @param onSuccess a callback with the scene when import succeeds
  54832. * @param onProgress a callback with a progress event for each file being loaded
  54833. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  54834. * @param pluginExtension the extension used to determine the plugin
  54835. * @returns The loaded plugin
  54836. */
  54837. 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>;
  54838. /**
  54839. * Append a scene
  54840. * @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)
  54841. * @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)
  54842. * @param scene is the instance of BABYLON.Scene to append to
  54843. * @param onProgress a callback with a progress event for each file being loaded
  54844. * @param pluginExtension the extension used to determine the plugin
  54845. * @returns The given scene
  54846. */
  54847. static AppendAsync(rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: ISceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  54848. /**
  54849. * Load a scene into an asset container
  54850. * @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)
  54851. * @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)
  54852. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  54853. * @param onSuccess a callback with the scene when import succeeds
  54854. * @param onProgress a callback with a progress event for each file being loaded
  54855. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  54856. * @param pluginExtension the extension used to determine the plugin
  54857. * @returns The loaded plugin
  54858. */
  54859. 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>;
  54860. /**
  54861. * Load a scene into an asset container
  54862. * @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)
  54863. * @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)
  54864. * @param scene is the instance of Scene to append to
  54865. * @param onProgress a callback with a progress event for each file being loaded
  54866. * @param pluginExtension the extension used to determine the plugin
  54867. * @returns The loaded asset container
  54868. */
  54869. static LoadAssetContainerAsync(rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: ISceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<AssetContainer>;
  54870. /**
  54871. * Import animations from a file into a scene
  54872. * @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)
  54873. * @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)
  54874. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  54875. * @param overwriteAnimations when true, animations are cleaned before importing new ones. Animations are appended otherwise
  54876. * @param animationGroupLoadingMode defines how to handle old animations groups before importing new ones
  54877. * @param targetConverter defines a function used to convert animation targets from loaded scene to current scene (default: search node by name)
  54878. * @param onSuccess a callback with the scene when import succeeds
  54879. * @param onProgress a callback with a progress event for each file being loaded
  54880. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  54881. * @param pluginExtension the extension used to determine the plugin
  54882. */
  54883. 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;
  54884. /**
  54885. * Import animations from a file into a scene
  54886. * @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)
  54887. * @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)
  54888. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  54889. * @param overwriteAnimations when true, animations are cleaned before importing new ones. Animations are appended otherwise
  54890. * @param animationGroupLoadingMode defines how to handle old animations groups before importing new ones
  54891. * @param targetConverter defines a function used to convert animation targets from loaded scene to current scene (default: search node by name)
  54892. * @param onSuccess a callback with the scene when import succeeds
  54893. * @param onProgress a callback with a progress event for each file being loaded
  54894. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  54895. * @param pluginExtension the extension used to determine the plugin
  54896. * @returns the updated scene with imported animations
  54897. */
  54898. 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>;
  54899. }
  54900. }
  54901. declare module BABYLON {
  54902. /**
  54903. * Handedness type in xrInput profiles. These can be used to define layouts in the Layout Map.
  54904. */
  54905. export type MotionControllerHandedness = "none" | "left" | "right";
  54906. /**
  54907. * The type of components available in motion controllers.
  54908. * This is not the name of the component.
  54909. */
  54910. export type MotionControllerComponentType = "trigger" | "squeeze" | "touchpad" | "thumbstick" | "button";
  54911. /**
  54912. * The state of a controller component
  54913. */
  54914. export type MotionControllerComponentStateType = "default" | "touched" | "pressed";
  54915. /**
  54916. * The schema of motion controller layout.
  54917. * No object will be initialized using this interface
  54918. * This is used just to define the profile.
  54919. */
  54920. export interface IMotionControllerLayout {
  54921. /**
  54922. * Path to load the assets. Usually relative to the base path
  54923. */
  54924. assetPath: string;
  54925. /**
  54926. * Available components (unsorted)
  54927. */
  54928. components: {
  54929. /**
  54930. * A map of component Ids
  54931. */
  54932. [componentId: string]: {
  54933. /**
  54934. * The type of input the component outputs
  54935. */
  54936. type: MotionControllerComponentType;
  54937. /**
  54938. * The indices of this component in the gamepad object
  54939. */
  54940. gamepadIndices: {
  54941. /**
  54942. * Index of button
  54943. */
  54944. button?: number;
  54945. /**
  54946. * If available, index of x-axis
  54947. */
  54948. xAxis?: number;
  54949. /**
  54950. * If available, index of y-axis
  54951. */
  54952. yAxis?: number;
  54953. };
  54954. /**
  54955. * The mesh's root node name
  54956. */
  54957. rootNodeName: string;
  54958. /**
  54959. * Animation definitions for this model
  54960. */
  54961. visualResponses: {
  54962. [stateKey: string]: {
  54963. /**
  54964. * What property will be animated
  54965. */
  54966. componentProperty: "xAxis" | "yAxis" | "button" | "state";
  54967. /**
  54968. * What states influence this visual response
  54969. */
  54970. states: MotionControllerComponentStateType[];
  54971. /**
  54972. * Type of animation - movement or visibility
  54973. */
  54974. valueNodeProperty: "transform" | "visibility";
  54975. /**
  54976. * Base node name to move. Its position will be calculated according to the min and max nodes
  54977. */
  54978. valueNodeName?: string;
  54979. /**
  54980. * Minimum movement node
  54981. */
  54982. minNodeName?: string;
  54983. /**
  54984. * Max movement node
  54985. */
  54986. maxNodeName?: string;
  54987. };
  54988. };
  54989. /**
  54990. * If touch enabled, what is the name of node to display user feedback
  54991. */
  54992. touchPointNodeName?: string;
  54993. };
  54994. };
  54995. /**
  54996. * Is it xr standard mapping or not
  54997. */
  54998. gamepadMapping: "" | "xr-standard";
  54999. /**
  55000. * Base root node of this entire model
  55001. */
  55002. rootNodeName: string;
  55003. /**
  55004. * Defines the main button component id
  55005. */
  55006. selectComponentId: string;
  55007. }
  55008. /**
  55009. * A definition for the layout map in the input profile
  55010. */
  55011. export interface IMotionControllerLayoutMap {
  55012. /**
  55013. * Layouts with handedness type as a key
  55014. */
  55015. [handedness: string]: IMotionControllerLayout;
  55016. }
  55017. /**
  55018. * The XR Input profile schema
  55019. * Profiles can be found here:
  55020. * https://github.com/immersive-web/webxr-input-profiles/tree/master/packages/registry/profiles
  55021. */
  55022. export interface IMotionControllerProfile {
  55023. /**
  55024. * fallback profiles for this profileId
  55025. */
  55026. fallbackProfileIds: string[];
  55027. /**
  55028. * The layout map, with handedness as key
  55029. */
  55030. layouts: IMotionControllerLayoutMap;
  55031. /**
  55032. * The id of this profile
  55033. * correlates to the profile(s) in the xrInput.profiles array
  55034. */
  55035. profileId: string;
  55036. }
  55037. /**
  55038. * A helper-interface for the 3 meshes needed for controller button animation
  55039. * The meshes are provided to the _lerpButtonTransform function to calculate the current position of the value mesh
  55040. */
  55041. export interface IMotionControllerButtonMeshMap {
  55042. /**
  55043. * the mesh that defines the pressed value mesh position.
  55044. * This is used to find the max-position of this button
  55045. */
  55046. pressedMesh: AbstractMesh;
  55047. /**
  55048. * the mesh that defines the unpressed value mesh position.
  55049. * This is used to find the min (or initial) position of this button
  55050. */
  55051. unpressedMesh: AbstractMesh;
  55052. /**
  55053. * The mesh that will be changed when value changes
  55054. */
  55055. valueMesh: AbstractMesh;
  55056. }
  55057. /**
  55058. * A helper-interface for the 3 meshes needed for controller axis animation.
  55059. * This will be expanded when touchpad animations are fully supported
  55060. * The meshes are provided to the _lerpAxisTransform function to calculate the current position of the value mesh
  55061. */
  55062. export interface IMotionControllerMeshMap {
  55063. /**
  55064. * the mesh that defines the maximum value mesh position.
  55065. */
  55066. maxMesh?: AbstractMesh;
  55067. /**
  55068. * the mesh that defines the minimum value mesh position.
  55069. */
  55070. minMesh?: AbstractMesh;
  55071. /**
  55072. * The mesh that will be changed when axis value changes
  55073. */
  55074. valueMesh?: AbstractMesh;
  55075. }
  55076. /**
  55077. * The elements needed for change-detection of the gamepad objects in motion controllers
  55078. */
  55079. export interface IMinimalMotionControllerObject {
  55080. /**
  55081. * Available axes of this controller
  55082. */
  55083. axes: number[];
  55084. /**
  55085. * An array of available buttons
  55086. */
  55087. buttons: Array<{
  55088. /**
  55089. * Value of the button/trigger
  55090. */
  55091. value: number;
  55092. /**
  55093. * If the button/trigger is currently touched
  55094. */
  55095. touched: boolean;
  55096. /**
  55097. * If the button/trigger is currently pressed
  55098. */
  55099. pressed: boolean;
  55100. }>;
  55101. /**
  55102. * EXPERIMENTAL haptic support.
  55103. */
  55104. hapticActuators?: Array<{
  55105. pulse: (value: number, duration: number) => Promise<boolean>;
  55106. }>;
  55107. }
  55108. /**
  55109. * An Abstract Motion controller
  55110. * This class receives an xrInput and a profile layout and uses those to initialize the components
  55111. * Each component has an observable to check for changes in value and state
  55112. */
  55113. export abstract class WebXRAbstractMotionController implements IDisposable {
  55114. protected scene: Scene;
  55115. protected layout: IMotionControllerLayout;
  55116. /**
  55117. * The gamepad object correlating to this controller
  55118. */
  55119. gamepadObject: IMinimalMotionControllerObject;
  55120. /**
  55121. * handedness (left/right/none) of this controller
  55122. */
  55123. handedness: MotionControllerHandedness;
  55124. private _initComponent;
  55125. private _modelReady;
  55126. /**
  55127. * A map of components (WebXRControllerComponent) in this motion controller
  55128. * Components have a ComponentType and can also have both button and axis definitions
  55129. */
  55130. readonly components: {
  55131. [id: string]: WebXRControllerComponent;
  55132. };
  55133. /**
  55134. * Disable the model's animation. Can be set at any time.
  55135. */
  55136. disableAnimation: boolean;
  55137. /**
  55138. * Observers registered here will be triggered when the model of this controller is done loading
  55139. */
  55140. onModelLoadedObservable: Observable<WebXRAbstractMotionController>;
  55141. /**
  55142. * The profile id of this motion controller
  55143. */
  55144. abstract profileId: string;
  55145. /**
  55146. * The root mesh of the model. It is null if the model was not yet initialized
  55147. */
  55148. rootMesh: Nullable<AbstractMesh>;
  55149. /**
  55150. * constructs a new abstract motion controller
  55151. * @param scene the scene to which the model of the controller will be added
  55152. * @param layout The profile layout to load
  55153. * @param gamepadObject The gamepad object correlating to this controller
  55154. * @param handedness handedness (left/right/none) of this controller
  55155. * @param _doNotLoadControllerMesh set this flag to ignore the mesh loading
  55156. */
  55157. constructor(scene: Scene, layout: IMotionControllerLayout,
  55158. /**
  55159. * The gamepad object correlating to this controller
  55160. */
  55161. gamepadObject: IMinimalMotionControllerObject,
  55162. /**
  55163. * handedness (left/right/none) of this controller
  55164. */
  55165. handedness: MotionControllerHandedness, _doNotLoadControllerMesh?: boolean);
  55166. /**
  55167. * Dispose this controller, the model mesh and all its components
  55168. */
  55169. dispose(): void;
  55170. /**
  55171. * Returns all components of specific type
  55172. * @param type the type to search for
  55173. * @return an array of components with this type
  55174. */
  55175. getAllComponentsOfType(type: MotionControllerComponentType): WebXRControllerComponent[];
  55176. /**
  55177. * get a component based an its component id as defined in layout.components
  55178. * @param id the id of the component
  55179. * @returns the component correlates to the id or undefined if not found
  55180. */
  55181. getComponent(id: string): WebXRControllerComponent;
  55182. /**
  55183. * Get the list of components available in this motion controller
  55184. * @returns an array of strings correlating to available components
  55185. */
  55186. getComponentIds(): string[];
  55187. /**
  55188. * Get the first component of specific type
  55189. * @param type type of component to find
  55190. * @return a controller component or null if not found
  55191. */
  55192. getComponentOfType(type: MotionControllerComponentType): Nullable<WebXRControllerComponent>;
  55193. /**
  55194. * Get the main (Select) component of this controller as defined in the layout
  55195. * @returns the main component of this controller
  55196. */
  55197. getMainComponent(): WebXRControllerComponent;
  55198. /**
  55199. * Loads the model correlating to this controller
  55200. * When the mesh is loaded, the onModelLoadedObservable will be triggered
  55201. * @returns A promise fulfilled with the result of the model loading
  55202. */
  55203. loadModel(): Promise<boolean>;
  55204. /**
  55205. * Update this model using the current XRFrame
  55206. * @param xrFrame the current xr frame to use and update the model
  55207. */
  55208. updateFromXRFrame(xrFrame: XRFrame): void;
  55209. /**
  55210. * Backwards compatibility due to a deeply-integrated typo
  55211. */
  55212. get handness(): XREye;
  55213. /**
  55214. * Pulse (vibrate) this controller
  55215. * If the controller does not support pulses, this function will fail silently and return Promise<false> directly after called
  55216. * Consecutive calls to this function will cancel the last pulse call
  55217. *
  55218. * @param value the strength of the pulse in 0.0...1.0 range
  55219. * @param duration Duration of the pulse in milliseconds
  55220. * @param hapticActuatorIndex optional index of actuator (will usually be 0)
  55221. * @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
  55222. */
  55223. pulse(value: number, duration: number, hapticActuatorIndex?: number): Promise<boolean>;
  55224. protected _getChildByName(node: AbstractMesh, name: string): AbstractMesh | undefined;
  55225. protected _getImmediateChildByName(node: AbstractMesh, name: string): AbstractMesh | undefined;
  55226. /**
  55227. * Moves the axis on the controller mesh based on its current state
  55228. * @param axis the index of the axis
  55229. * @param axisValue the value of the axis which determines the meshes new position
  55230. * @hidden
  55231. */
  55232. protected _lerpTransform(axisMap: IMotionControllerMeshMap, axisValue: number, fixValueCoordinates?: boolean): void;
  55233. /**
  55234. * Update the model itself with the current frame data
  55235. * @param xrFrame the frame to use for updating the model mesh
  55236. */
  55237. protected updateModel(xrFrame: XRFrame): void;
  55238. /**
  55239. * Get the filename and path for this controller's model
  55240. * @returns a map of filename and path
  55241. */
  55242. protected abstract _getFilenameAndPath(): {
  55243. filename: string;
  55244. path: string;
  55245. };
  55246. /**
  55247. * This function is called before the mesh is loaded. It checks for loading constraints.
  55248. * For example, this function can check if the GLB loader is available
  55249. * If this function returns false, the generic controller will be loaded instead
  55250. * @returns Is the client ready to load the mesh
  55251. */
  55252. protected abstract _getModelLoadingConstraints(): boolean;
  55253. /**
  55254. * This function will be called after the model was successfully loaded and can be used
  55255. * for mesh transformations before it is available for the user
  55256. * @param meshes the loaded meshes
  55257. */
  55258. protected abstract _processLoadedModel(meshes: AbstractMesh[]): void;
  55259. /**
  55260. * Set the root mesh for this controller. Important for the WebXR controller class
  55261. * @param meshes the loaded meshes
  55262. */
  55263. protected abstract _setRootMesh(meshes: AbstractMesh[]): void;
  55264. /**
  55265. * A function executed each frame that updates the mesh (if needed)
  55266. * @param xrFrame the current xrFrame
  55267. */
  55268. protected abstract _updateModel(xrFrame: XRFrame): void;
  55269. private _getGenericFilenameAndPath;
  55270. private _getGenericParentMesh;
  55271. }
  55272. }
  55273. declare module BABYLON {
  55274. /**
  55275. * A generic trigger-only motion controller for WebXR
  55276. */
  55277. export class WebXRGenericTriggerMotionController extends WebXRAbstractMotionController {
  55278. /**
  55279. * Static version of the profile id of this controller
  55280. */
  55281. static ProfileId: string;
  55282. profileId: string;
  55283. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handedness: MotionControllerHandedness);
  55284. protected _getFilenameAndPath(): {
  55285. filename: string;
  55286. path: string;
  55287. };
  55288. protected _getModelLoadingConstraints(): boolean;
  55289. protected _processLoadedModel(meshes: AbstractMesh[]): void;
  55290. protected _setRootMesh(meshes: AbstractMesh[]): void;
  55291. protected _updateModel(): void;
  55292. }
  55293. }
  55294. declare module BABYLON {
  55295. /**
  55296. * Class containing static functions to help procedurally build meshes
  55297. */
  55298. export class SphereBuilder {
  55299. /**
  55300. * Creates a sphere mesh
  55301. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  55302. * * 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`)
  55303. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  55304. * * 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
  55305. * * 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)
  55306. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  55307. * * 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
  55308. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  55309. * @param name defines the name of the mesh
  55310. * @param options defines the options used to create the mesh
  55311. * @param scene defines the hosting scene
  55312. * @returns the sphere mesh
  55313. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  55314. */
  55315. static CreateSphere(name: string, options: {
  55316. segments?: number;
  55317. diameter?: number;
  55318. diameterX?: number;
  55319. diameterY?: number;
  55320. diameterZ?: number;
  55321. arc?: number;
  55322. slice?: number;
  55323. sideOrientation?: number;
  55324. frontUVs?: Vector4;
  55325. backUVs?: Vector4;
  55326. updatable?: boolean;
  55327. }, scene?: Nullable<Scene>): Mesh;
  55328. }
  55329. }
  55330. declare module BABYLON {
  55331. /**
  55332. * A profiled motion controller has its profile loaded from an online repository.
  55333. * The class is responsible of loading the model, mapping the keys and enabling model-animations
  55334. */
  55335. export class WebXRProfiledMotionController extends WebXRAbstractMotionController {
  55336. private _repositoryUrl;
  55337. private _buttonMeshMapping;
  55338. private _touchDots;
  55339. /**
  55340. * The profile ID of this controller. Will be populated when the controller initializes.
  55341. */
  55342. profileId: string;
  55343. constructor(scene: Scene, xrInput: XRInputSource, _profile: IMotionControllerProfile, _repositoryUrl: string);
  55344. dispose(): void;
  55345. protected _getFilenameAndPath(): {
  55346. filename: string;
  55347. path: string;
  55348. };
  55349. protected _getModelLoadingConstraints(): boolean;
  55350. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  55351. protected _setRootMesh(meshes: AbstractMesh[]): void;
  55352. protected _updateModel(_xrFrame: XRFrame): void;
  55353. }
  55354. }
  55355. declare module BABYLON {
  55356. /**
  55357. * A construction function type to create a new controller based on an xrInput object
  55358. */
  55359. export type MotionControllerConstructor = (xrInput: XRInputSource, scene: Scene) => WebXRAbstractMotionController;
  55360. /**
  55361. * The MotionController Manager manages all registered motion controllers and loads the right one when needed.
  55362. *
  55363. * When this repository is complete: https://github.com/immersive-web/webxr-input-profiles/tree/master/packages/assets
  55364. * it should be replaced with auto-loaded controllers.
  55365. *
  55366. * When using a model try to stay as generic as possible. Eventually there will be no need in any of the controller classes
  55367. */
  55368. export class WebXRMotionControllerManager {
  55369. private static _AvailableControllers;
  55370. private static _Fallbacks;
  55371. private static _ProfileLoadingPromises;
  55372. private static _ProfilesList;
  55373. /**
  55374. * The base URL of the online controller repository. Can be changed at any time.
  55375. */
  55376. static BaseRepositoryUrl: string;
  55377. /**
  55378. * Which repository gets priority - local or online
  55379. */
  55380. static PrioritizeOnlineRepository: boolean;
  55381. /**
  55382. * Use the online repository, or use only locally-defined controllers
  55383. */
  55384. static UseOnlineRepository: boolean;
  55385. /**
  55386. * Clear the cache used for profile loading and reload when requested again
  55387. */
  55388. static ClearProfilesCache(): void;
  55389. /**
  55390. * Register the default fallbacks.
  55391. * This function is called automatically when this file is imported.
  55392. */
  55393. static DefaultFallbacks(): void;
  55394. /**
  55395. * Find a fallback profile if the profile was not found. There are a few predefined generic profiles.
  55396. * @param profileId the profile to which a fallback needs to be found
  55397. * @return an array with corresponding fallback profiles
  55398. */
  55399. static FindFallbackWithProfileId(profileId: string): string[];
  55400. /**
  55401. * When acquiring a new xrInput object (usually by the WebXRInput class), match it with the correct profile.
  55402. * The order of search:
  55403. *
  55404. * 1) Iterate the profiles array of the xr input and try finding a corresponding motion controller
  55405. * 2) (If not found) search in the gamepad id and try using it (legacy versions only)
  55406. * 3) search for registered fallbacks (should be redundant, nonetheless it makes sense to check)
  55407. * 4) return the generic trigger controller if none were found
  55408. *
  55409. * @param xrInput the xrInput to which a new controller is initialized
  55410. * @param scene the scene to which the model will be added
  55411. * @param forceProfile force a certain profile for this controller
  55412. * @return A promise that fulfils with the motion controller class for this profile id or the generic standard class if none was found
  55413. */
  55414. static GetMotionControllerWithXRInput(xrInput: XRInputSource, scene: Scene, forceProfile?: string): Promise<WebXRAbstractMotionController>;
  55415. /**
  55416. * Register a new controller based on its profile. This function will be called by the controller classes themselves.
  55417. *
  55418. * If you are missing a profile, make sure it is imported in your source, otherwise it will not register.
  55419. *
  55420. * @param type the profile type to register
  55421. * @param constructFunction the function to be called when loading this profile
  55422. */
  55423. static RegisterController(type: string, constructFunction: MotionControllerConstructor): void;
  55424. /**
  55425. * Register a fallback to a specific profile.
  55426. * @param profileId the profileId that will receive the fallbacks
  55427. * @param fallbacks A list of fallback profiles
  55428. */
  55429. static RegisterFallbacksForProfileId(profileId: string, fallbacks: string[]): void;
  55430. /**
  55431. * Will update the list of profiles available in the repository
  55432. * @return a promise that resolves to a map of profiles available online
  55433. */
  55434. static UpdateProfilesList(): Promise<{
  55435. [profile: string]: string;
  55436. }>;
  55437. private static _LoadProfileFromRepository;
  55438. private static _LoadProfilesFromAvailableControllers;
  55439. }
  55440. }
  55441. declare module BABYLON {
  55442. /**
  55443. * Configuration options for the WebXR controller creation
  55444. */
  55445. export interface IWebXRControllerOptions {
  55446. /**
  55447. * Should the controller mesh be animated when a user interacts with it
  55448. * The pressed buttons / thumbstick and touchpad animations will be disabled
  55449. */
  55450. disableMotionControllerAnimation?: boolean;
  55451. /**
  55452. * Do not load the controller mesh, in case a different mesh needs to be loaded.
  55453. */
  55454. doNotLoadControllerMesh?: boolean;
  55455. /**
  55456. * Force a specific controller type for this controller.
  55457. * This can be used when creating your own profile or when testing different controllers
  55458. */
  55459. forceControllerProfile?: string;
  55460. /**
  55461. * Defines a rendering group ID for meshes that will be loaded.
  55462. * This is for the default controllers only.
  55463. */
  55464. renderingGroupId?: number;
  55465. }
  55466. /**
  55467. * Represents an XR controller
  55468. */
  55469. export class WebXRInputSource {
  55470. private _scene;
  55471. /** The underlying input source for the controller */
  55472. inputSource: XRInputSource;
  55473. private _options;
  55474. private _tmpVector;
  55475. private _uniqueId;
  55476. private _disposed;
  55477. /**
  55478. * 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
  55479. */
  55480. grip?: AbstractMesh;
  55481. /**
  55482. * If available, this is the gamepad object related to this controller.
  55483. * Using this object it is possible to get click events and trackpad changes of the
  55484. * webxr controller that is currently being used.
  55485. */
  55486. motionController?: WebXRAbstractMotionController;
  55487. /**
  55488. * Event that fires when the controller is removed/disposed.
  55489. * The object provided as event data is this controller, after associated assets were disposed.
  55490. * uniqueId is still available.
  55491. */
  55492. onDisposeObservable: Observable<WebXRInputSource>;
  55493. /**
  55494. * Will be triggered when the mesh associated with the motion controller is done loading.
  55495. * It is also possible that this will never trigger (!) if no mesh was loaded, or if the developer decides to load a different mesh
  55496. * A shortened version of controller -> motion controller -> on mesh loaded.
  55497. */
  55498. onMeshLoadedObservable: Observable<AbstractMesh>;
  55499. /**
  55500. * Observers registered here will trigger when a motion controller profile was assigned to this xr controller
  55501. */
  55502. onMotionControllerInitObservable: Observable<WebXRAbstractMotionController>;
  55503. /**
  55504. * Pointer which can be used to select objects or attach a visible laser to
  55505. */
  55506. pointer: AbstractMesh;
  55507. /**
  55508. * Creates the input source object
  55509. * @see https://doc.babylonjs.com/how_to/webxr_controllers_support
  55510. * @param _scene the scene which the controller should be associated to
  55511. * @param inputSource the underlying input source for the controller
  55512. * @param _options options for this controller creation
  55513. */
  55514. constructor(_scene: Scene,
  55515. /** The underlying input source for the controller */
  55516. inputSource: XRInputSource, _options?: IWebXRControllerOptions);
  55517. /**
  55518. * Get this controllers unique id
  55519. */
  55520. get uniqueId(): string;
  55521. /**
  55522. * Disposes of the object
  55523. */
  55524. dispose(): void;
  55525. /**
  55526. * Gets a world space ray coming from the pointer or grip
  55527. * @param result the resulting ray
  55528. * @param gripIfAvailable use the grip mesh instead of the pointer, if available
  55529. */
  55530. getWorldPointerRayToRef(result: Ray, gripIfAvailable?: boolean): void;
  55531. /**
  55532. * Updates the controller pose based on the given XRFrame
  55533. * @param xrFrame xr frame to update the pose with
  55534. * @param referenceSpace reference space to use
  55535. */
  55536. updateFromXRFrame(xrFrame: XRFrame, referenceSpace: XRReferenceSpace): void;
  55537. }
  55538. }
  55539. declare module BABYLON {
  55540. /**
  55541. * The schema for initialization options of the XR Input class
  55542. */
  55543. export interface IWebXRInputOptions {
  55544. /**
  55545. * If set to true no model will be automatically loaded
  55546. */
  55547. doNotLoadControllerMeshes?: boolean;
  55548. /**
  55549. * If set, this profile will be used for all controllers loaded (for example "microsoft-mixed-reality")
  55550. * If not found, the xr input profile data will be used.
  55551. * Profiles are defined here - https://github.com/immersive-web/webxr-input-profiles/
  55552. */
  55553. forceInputProfile?: string;
  55554. /**
  55555. * Do not send a request to the controller repository to load the profile.
  55556. *
  55557. * Instead, use the controllers available in babylon itself.
  55558. */
  55559. disableOnlineControllerRepository?: boolean;
  55560. /**
  55561. * A custom URL for the controllers repository
  55562. */
  55563. customControllersRepositoryURL?: string;
  55564. /**
  55565. * Should the controller model's components not move according to the user input
  55566. */
  55567. disableControllerAnimation?: boolean;
  55568. /**
  55569. * Optional options to pass to the controller. Will be overridden by the Input options where applicable
  55570. */
  55571. controllerOptions?: IWebXRControllerOptions;
  55572. }
  55573. /**
  55574. * XR input used to track XR inputs such as controllers/rays
  55575. */
  55576. export class WebXRInput implements IDisposable {
  55577. /**
  55578. * the xr session manager for this session
  55579. */
  55580. xrSessionManager: WebXRSessionManager;
  55581. /**
  55582. * the WebXR camera for this session. Mainly used for teleportation
  55583. */
  55584. xrCamera: WebXRCamera;
  55585. private readonly options;
  55586. /**
  55587. * XR controllers being tracked
  55588. */
  55589. controllers: Array<WebXRInputSource>;
  55590. private _frameObserver;
  55591. private _sessionEndedObserver;
  55592. private _sessionInitObserver;
  55593. /**
  55594. * Event when a controller has been connected/added
  55595. */
  55596. onControllerAddedObservable: Observable<WebXRInputSource>;
  55597. /**
  55598. * Event when a controller has been removed/disconnected
  55599. */
  55600. onControllerRemovedObservable: Observable<WebXRInputSource>;
  55601. /**
  55602. * Initializes the WebXRInput
  55603. * @param xrSessionManager the xr session manager for this session
  55604. * @param xrCamera the WebXR camera for this session. Mainly used for teleportation
  55605. * @param options = initialization options for this xr input
  55606. */
  55607. constructor(
  55608. /**
  55609. * the xr session manager for this session
  55610. */
  55611. xrSessionManager: WebXRSessionManager,
  55612. /**
  55613. * the WebXR camera for this session. Mainly used for teleportation
  55614. */
  55615. xrCamera: WebXRCamera, options?: IWebXRInputOptions);
  55616. private _onInputSourcesChange;
  55617. private _addAndRemoveControllers;
  55618. /**
  55619. * Disposes of the object
  55620. */
  55621. dispose(): void;
  55622. }
  55623. }
  55624. declare module BABYLON {
  55625. /**
  55626. * This is the base class for all WebXR features.
  55627. * Since most features require almost the same resources and callbacks, this class can be used to simplify the development
  55628. * Note that since the features manager is using the `IWebXRFeature` you are in no way obligated to use this class
  55629. */
  55630. export abstract class WebXRAbstractFeature implements IWebXRFeature {
  55631. protected _xrSessionManager: WebXRSessionManager;
  55632. private _attached;
  55633. private _removeOnDetach;
  55634. /**
  55635. * Is this feature disposed?
  55636. */
  55637. isDisposed: boolean;
  55638. /**
  55639. * Should auto-attach be disabled?
  55640. */
  55641. disableAutoAttach: boolean;
  55642. /**
  55643. * The name of the native xr feature name (like anchor, hit-test, or hand-tracking)
  55644. */
  55645. xrNativeFeatureName: string;
  55646. /**
  55647. * Construct a new (abstract) WebXR feature
  55648. * @param _xrSessionManager the xr session manager for this feature
  55649. */
  55650. constructor(_xrSessionManager: WebXRSessionManager);
  55651. /**
  55652. * Is this feature attached
  55653. */
  55654. get attached(): boolean;
  55655. /**
  55656. * attach this feature
  55657. *
  55658. * @param force should attachment be forced (even when already attached)
  55659. * @returns true if successful, false is failed or already attached
  55660. */
  55661. attach(force?: boolean): boolean;
  55662. /**
  55663. * detach this feature.
  55664. *
  55665. * @returns true if successful, false if failed or already detached
  55666. */
  55667. detach(): boolean;
  55668. /**
  55669. * Dispose this feature and all of the resources attached
  55670. */
  55671. dispose(): void;
  55672. /**
  55673. * This function will be executed during before enabling the feature and can be used to not-allow enabling it.
  55674. * Note that at this point the session has NOT started, so this is purely checking if the browser supports it
  55675. *
  55676. * @returns whether or not the feature is compatible in this environment
  55677. */
  55678. isCompatible(): boolean;
  55679. /**
  55680. * This is used to register callbacks that will automatically be removed when detach is called.
  55681. * @param observable the observable to which the observer will be attached
  55682. * @param callback the callback to register
  55683. */
  55684. protected _addNewAttachObserver<T>(observable: Observable<T>, callback: (eventData: T, eventState: EventState) => void): void;
  55685. /**
  55686. * Code in this function will be executed on each xrFrame received from the browser.
  55687. * This function will not execute after the feature is detached.
  55688. * @param _xrFrame the current frame
  55689. */
  55690. protected abstract _onXRFrame(_xrFrame: XRFrame): void;
  55691. }
  55692. }
  55693. declare module BABYLON {
  55694. /**
  55695. * Renders a layer on top of an existing scene
  55696. */
  55697. export class UtilityLayerRenderer implements IDisposable {
  55698. /** the original scene that will be rendered on top of */
  55699. originalScene: Scene;
  55700. private _pointerCaptures;
  55701. private _lastPointerEvents;
  55702. private static _DefaultUtilityLayer;
  55703. private static _DefaultKeepDepthUtilityLayer;
  55704. private _sharedGizmoLight;
  55705. private _renderCamera;
  55706. /**
  55707. * Gets the camera that is used to render the utility layer (when not set, this will be the last active camera)
  55708. * @param getRigParentIfPossible if the current active camera is a rig camera, should its parent camera be returned
  55709. * @returns the camera that is used when rendering the utility layer
  55710. */
  55711. getRenderCamera(getRigParentIfPossible?: boolean): Camera;
  55712. /**
  55713. * Sets the camera that should be used when rendering the utility layer (If set to null the last active camera will be used)
  55714. * @param cam the camera that should be used when rendering the utility layer
  55715. */
  55716. setRenderCamera(cam: Nullable<Camera>): void;
  55717. /**
  55718. * @hidden
  55719. * Light which used by gizmos to get light shading
  55720. */
  55721. _getSharedGizmoLight(): HemisphericLight;
  55722. /**
  55723. * If the picking should be done on the utility layer prior to the actual scene (Default: true)
  55724. */
  55725. pickUtilitySceneFirst: boolean;
  55726. /**
  55727. * 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)
  55728. */
  55729. static get DefaultUtilityLayer(): UtilityLayerRenderer;
  55730. /**
  55731. * 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)
  55732. */
  55733. static get DefaultKeepDepthUtilityLayer(): UtilityLayerRenderer;
  55734. /**
  55735. * The scene that is rendered on top of the original scene
  55736. */
  55737. utilityLayerScene: Scene;
  55738. /**
  55739. * If the utility layer should automatically be rendered on top of existing scene
  55740. */
  55741. shouldRender: boolean;
  55742. /**
  55743. * If set to true, only pointer down onPointerObservable events will be blocked when picking is occluded by original scene
  55744. */
  55745. onlyCheckPointerDownEvents: boolean;
  55746. /**
  55747. * If set to false, only pointerUp, pointerDown and pointerMove will be sent to the utilityLayerScene (false by default)
  55748. */
  55749. processAllEvents: boolean;
  55750. /**
  55751. * Observable raised when the pointer move from the utility layer scene to the main scene
  55752. */
  55753. onPointerOutObservable: Observable<number>;
  55754. /** Gets or sets a predicate that will be used to indicate utility meshes present in the main scene */
  55755. mainSceneTrackerPredicate: (mesh: Nullable<AbstractMesh>) => boolean;
  55756. private _afterRenderObserver;
  55757. private _sceneDisposeObserver;
  55758. private _originalPointerObserver;
  55759. /**
  55760. * Instantiates a UtilityLayerRenderer
  55761. * @param originalScene the original scene that will be rendered on top of
  55762. * @param handleEvents boolean indicating if the utility layer should handle events
  55763. */
  55764. constructor(
  55765. /** the original scene that will be rendered on top of */
  55766. originalScene: Scene, handleEvents?: boolean);
  55767. private _notifyObservers;
  55768. /**
  55769. * Renders the utility layers scene on top of the original scene
  55770. */
  55771. render(): void;
  55772. /**
  55773. * Disposes of the renderer
  55774. */
  55775. dispose(): void;
  55776. private _updateCamera;
  55777. }
  55778. }
  55779. declare module BABYLON {
  55780. /**
  55781. * Options interface for the pointer selection module
  55782. */
  55783. export interface IWebXRControllerPointerSelectionOptions {
  55784. /**
  55785. * if provided, this scene will be used to render meshes.
  55786. */
  55787. customUtilityLayerScene?: Scene;
  55788. /**
  55789. * 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)
  55790. * If not disabled, the last picked point will be used to execute a pointer up event
  55791. * If disabled, pointer up event will be triggered right after the pointer down event.
  55792. * Used in screen and gaze target ray mode only
  55793. */
  55794. disablePointerUpOnTouchOut: boolean;
  55795. /**
  55796. * For gaze mode for tracked-pointer / controllers (time to select instead of button press)
  55797. */
  55798. forceGazeMode: boolean;
  55799. /**
  55800. * 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
  55801. * to start a new countdown to the pointer down event.
  55802. * Defaults to 1.
  55803. */
  55804. gazeModePointerMovedFactor?: number;
  55805. /**
  55806. * Different button type to use instead of the main component
  55807. */
  55808. overrideButtonId?: string;
  55809. /**
  55810. * use this rendering group id for the meshes (optional)
  55811. */
  55812. renderingGroupId?: number;
  55813. /**
  55814. * The amount of time in milliseconds it takes between pick found something to a pointer down event.
  55815. * Used in gaze modes. Tracked pointer uses the trigger, screen uses touch events
  55816. * 3000 means 3 seconds between pointing at something and selecting it
  55817. */
  55818. timeToSelect?: number;
  55819. /**
  55820. * Should meshes created here be added to a utility layer or the main scene
  55821. */
  55822. useUtilityLayer?: boolean;
  55823. /**
  55824. * Optional WebXR camera to be used for gaze selection
  55825. */
  55826. gazeCamera?: WebXRCamera;
  55827. /**
  55828. * the xr input to use with this pointer selection
  55829. */
  55830. xrInput: WebXRInput;
  55831. /**
  55832. * Should the scene pointerX and pointerY update be disabled
  55833. * This is required for fullscreen AR GUI, but might slow down other experiences.
  55834. * Disable in VR, if not needed.
  55835. * The first rig camera (left eye) will be used to calculate the projection
  55836. */
  55837. disableScenePointerVectorUpdate: boolean;
  55838. /**
  55839. * Enable pointer selection on all controllers instead of switching between them
  55840. */
  55841. enablePointerSelectionOnAllControllers?: boolean;
  55842. /**
  55843. * The preferred hand to give the pointer selection to. This will be prioritized when the controller initialize.
  55844. * If switch is enabled, it will still allow the user to switch between the different controllers
  55845. */
  55846. preferredHandedness?: XRHandedness;
  55847. /**
  55848. * Disable switching the pointer selection from one controller to the other.
  55849. * 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
  55850. */
  55851. disableSwitchOnClick?: boolean;
  55852. /**
  55853. * The maximum distance of the pointer selection feature. Defaults to 100.
  55854. */
  55855. maxPointerDistance?: number;
  55856. }
  55857. /**
  55858. * A module that will enable pointer selection for motion controllers of XR Input Sources
  55859. */
  55860. export class WebXRControllerPointerSelection extends WebXRAbstractFeature {
  55861. private readonly _options;
  55862. private static _idCounter;
  55863. private _attachController;
  55864. private _controllers;
  55865. private _scene;
  55866. private _tmpVectorForPickCompare;
  55867. private _attachedController;
  55868. /**
  55869. * The module's name
  55870. */
  55871. static readonly Name: string;
  55872. /**
  55873. * The (Babylon) version of this module.
  55874. * This is an integer representing the implementation version.
  55875. * This number does not correspond to the WebXR specs version
  55876. */
  55877. static readonly Version: number;
  55878. /**
  55879. * Disable lighting on the laser pointer (so it will always be visible)
  55880. */
  55881. disablePointerLighting: boolean;
  55882. /**
  55883. * Disable lighting on the selection mesh (so it will always be visible)
  55884. */
  55885. disableSelectionMeshLighting: boolean;
  55886. /**
  55887. * Should the laser pointer be displayed
  55888. */
  55889. displayLaserPointer: boolean;
  55890. /**
  55891. * Should the selection mesh be displayed (The ring at the end of the laser pointer)
  55892. */
  55893. displaySelectionMesh: boolean;
  55894. /**
  55895. * This color will be set to the laser pointer when selection is triggered
  55896. */
  55897. laserPointerPickedColor: Color3;
  55898. /**
  55899. * Default color of the laser pointer
  55900. */
  55901. laserPointerDefaultColor: Color3;
  55902. /**
  55903. * default color of the selection ring
  55904. */
  55905. selectionMeshDefaultColor: Color3;
  55906. /**
  55907. * This color will be applied to the selection ring when selection is triggered
  55908. */
  55909. selectionMeshPickedColor: Color3;
  55910. /**
  55911. * Optional filter to be used for ray selection. This predicate shares behavior with
  55912. * scene.pointerMovePredicate which takes priority if it is also assigned.
  55913. */
  55914. raySelectionPredicate: (mesh: AbstractMesh) => boolean;
  55915. /**
  55916. * constructs a new background remover module
  55917. * @param _xrSessionManager the session manager for this module
  55918. * @param _options read-only options to be used in this module
  55919. */
  55920. constructor(_xrSessionManager: WebXRSessionManager, _options: IWebXRControllerPointerSelectionOptions);
  55921. /**
  55922. * attach this feature
  55923. * Will usually be called by the features manager
  55924. *
  55925. * @returns true if successful.
  55926. */
  55927. attach(): boolean;
  55928. /**
  55929. * detach this feature.
  55930. * Will usually be called by the features manager
  55931. *
  55932. * @returns true if successful.
  55933. */
  55934. detach(): boolean;
  55935. /**
  55936. * Will get the mesh under a specific pointer.
  55937. * `scene.meshUnderPointer` will only return one mesh - either left or right.
  55938. * @param controllerId the controllerId to check
  55939. * @returns The mesh under pointer or null if no mesh is under the pointer
  55940. */
  55941. getMeshUnderPointer(controllerId: string): Nullable<AbstractMesh>;
  55942. /**
  55943. * Get the xr controller that correlates to the pointer id in the pointer event
  55944. *
  55945. * @param id the pointer id to search for
  55946. * @returns the controller that correlates to this id or null if not found
  55947. */
  55948. getXRControllerByPointerId(id: number): Nullable<WebXRInputSource>;
  55949. private _identityMatrix;
  55950. private _screenCoordinatesRef;
  55951. private _viewportRef;
  55952. protected _onXRFrame(_xrFrame: XRFrame): void;
  55953. private _attachGazeMode;
  55954. private _attachScreenRayMode;
  55955. private _attachTrackedPointerRayMode;
  55956. private _convertNormalToDirectionOfRay;
  55957. private _detachController;
  55958. private _generateNewMeshPair;
  55959. private _pickingMoved;
  55960. private _updatePointerDistance;
  55961. /** @hidden */
  55962. get lasterPointerDefaultColor(): Color3;
  55963. }
  55964. }
  55965. declare module BABYLON {
  55966. /**
  55967. * Button which can be used to enter a different mode of XR
  55968. */
  55969. export class WebXREnterExitUIButton {
  55970. /** button element */
  55971. element: HTMLElement;
  55972. /** XR initialization options for the button */
  55973. sessionMode: XRSessionMode;
  55974. /** Reference space type */
  55975. referenceSpaceType: XRReferenceSpaceType;
  55976. /**
  55977. * Creates a WebXREnterExitUIButton
  55978. * @param element button element
  55979. * @param sessionMode XR initialization session mode
  55980. * @param referenceSpaceType the type of reference space to be used
  55981. */
  55982. constructor(
  55983. /** button element */
  55984. element: HTMLElement,
  55985. /** XR initialization options for the button */
  55986. sessionMode: XRSessionMode,
  55987. /** Reference space type */
  55988. referenceSpaceType: XRReferenceSpaceType);
  55989. /**
  55990. * Extendable function which can be used to update the button's visuals when the state changes
  55991. * @param activeButton the current active button in the UI
  55992. */
  55993. update(activeButton: Nullable<WebXREnterExitUIButton>): void;
  55994. }
  55995. /**
  55996. * Options to create the webXR UI
  55997. */
  55998. export class WebXREnterExitUIOptions {
  55999. /**
  56000. * User provided buttons to enable/disable WebXR. The system will provide default if not set
  56001. */
  56002. customButtons?: Array<WebXREnterExitUIButton>;
  56003. /**
  56004. * A reference space type to use when creating the default button.
  56005. * Default is local-floor
  56006. */
  56007. referenceSpaceType?: XRReferenceSpaceType;
  56008. /**
  56009. * Context to enter xr with
  56010. */
  56011. renderTarget?: Nullable<WebXRRenderTarget>;
  56012. /**
  56013. * A session mode to use when creating the default button.
  56014. * Default is immersive-vr
  56015. */
  56016. sessionMode?: XRSessionMode;
  56017. /**
  56018. * A list of optional features to init the session with
  56019. */
  56020. optionalFeatures?: string[];
  56021. /**
  56022. * A list of optional features to init the session with
  56023. */
  56024. requiredFeatures?: string[];
  56025. /**
  56026. * If defined, this function will be executed if the UI encounters an error when entering XR
  56027. */
  56028. onError?: (error: any) => void;
  56029. }
  56030. /**
  56031. * UI to allow the user to enter/exit XR mode
  56032. */
  56033. export class WebXREnterExitUI implements IDisposable {
  56034. private scene;
  56035. /** version of the options passed to this UI */
  56036. options: WebXREnterExitUIOptions;
  56037. private _activeButton;
  56038. private _buttons;
  56039. /**
  56040. * The HTML Div Element to which buttons are added.
  56041. */
  56042. readonly overlay: HTMLDivElement;
  56043. /**
  56044. * Fired every time the active button is changed.
  56045. *
  56046. * When xr is entered via a button that launches xr that button will be the callback parameter
  56047. *
  56048. * When exiting xr the callback parameter will be null)
  56049. */
  56050. activeButtonChangedObservable: Observable<Nullable<WebXREnterExitUIButton>>;
  56051. /**
  56052. *
  56053. * @param scene babylon scene object to use
  56054. * @param options (read-only) version of the options passed to this UI
  56055. */
  56056. private constructor();
  56057. /**
  56058. * Creates UI to allow the user to enter/exit XR mode
  56059. * @param scene the scene to add the ui to
  56060. * @param helper the xr experience helper to enter/exit xr with
  56061. * @param options options to configure the UI
  56062. * @returns the created ui
  56063. */
  56064. static CreateAsync(scene: Scene, helper: WebXRExperienceHelper, options: WebXREnterExitUIOptions): Promise<WebXREnterExitUI>;
  56065. /**
  56066. * Disposes of the XR UI component
  56067. */
  56068. dispose(): void;
  56069. private _updateButtons;
  56070. }
  56071. }
  56072. declare module BABYLON {
  56073. /**
  56074. * Class containing static functions to help procedurally build meshes
  56075. */
  56076. export class LinesBuilder {
  56077. /**
  56078. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  56079. * * 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
  56080. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  56081. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  56082. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  56083. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  56084. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  56085. * * 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
  56086. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  56087. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  56088. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  56089. * @param name defines the name of the new line system
  56090. * @param options defines the options used to create the line system
  56091. * @param scene defines the hosting scene
  56092. * @returns a new line system mesh
  56093. */
  56094. static CreateLineSystem(name: string, options: {
  56095. lines: Vector3[][];
  56096. updatable?: boolean;
  56097. instance?: Nullable<LinesMesh>;
  56098. colors?: Nullable<Color4[][]>;
  56099. useVertexAlpha?: boolean;
  56100. }, scene: Nullable<Scene>): LinesMesh;
  56101. /**
  56102. * Creates a line mesh
  56103. * 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
  56104. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  56105. * * The parameter `points` is an array successive Vector3
  56106. * * 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
  56107. * * The optional parameter `colors` is an array of successive Color4, one per line point
  56108. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  56109. * * When updating an instance, remember that only point positions can change, not the number of points
  56110. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  56111. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  56112. * @param name defines the name of the new line system
  56113. * @param options defines the options used to create the line system
  56114. * @param scene defines the hosting scene
  56115. * @returns a new line mesh
  56116. */
  56117. static CreateLines(name: string, options: {
  56118. points: Vector3[];
  56119. updatable?: boolean;
  56120. instance?: Nullable<LinesMesh>;
  56121. colors?: Color4[];
  56122. useVertexAlpha?: boolean;
  56123. }, scene?: Nullable<Scene>): LinesMesh;
  56124. /**
  56125. * Creates a dashed line mesh
  56126. * * 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
  56127. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  56128. * * The parameter `points` is an array successive Vector3
  56129. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  56130. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  56131. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  56132. * * 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
  56133. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  56134. * * When updating an instance, remember that only point positions can change, not the number of points
  56135. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  56136. * @param name defines the name of the mesh
  56137. * @param options defines the options used to create the mesh
  56138. * @param scene defines the hosting scene
  56139. * @returns the dashed line mesh
  56140. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  56141. */
  56142. static CreateDashedLines(name: string, options: {
  56143. points: Vector3[];
  56144. dashSize?: number;
  56145. gapSize?: number;
  56146. dashNb?: number;
  56147. updatable?: boolean;
  56148. instance?: LinesMesh;
  56149. useVertexAlpha?: boolean;
  56150. }, scene?: Nullable<Scene>): LinesMesh;
  56151. }
  56152. }
  56153. declare module BABYLON {
  56154. /**
  56155. * Construction options for a timer
  56156. */
  56157. export interface ITimerOptions<T> {
  56158. /**
  56159. * Time-to-end
  56160. */
  56161. timeout: number;
  56162. /**
  56163. * The context observable is used to calculate time deltas and provides the context of the timer's callbacks. Will usually be OnBeforeRenderObservable.
  56164. * Countdown calculation is done ONLY when the observable is notifying its observers, meaning that if
  56165. * you choose an observable that doesn't trigger too often, the wait time might extend further than the requested max time
  56166. */
  56167. contextObservable: Observable<T>;
  56168. /**
  56169. * Optional parameters when adding an observer to the observable
  56170. */
  56171. observableParameters?: {
  56172. mask?: number;
  56173. insertFirst?: boolean;
  56174. scope?: any;
  56175. };
  56176. /**
  56177. * An optional break condition that will stop the times prematurely. In this case onEnded will not be triggered!
  56178. */
  56179. breakCondition?: (data?: ITimerData<T>) => boolean;
  56180. /**
  56181. * Will be triggered when the time condition has met
  56182. */
  56183. onEnded?: (data: ITimerData<any>) => void;
  56184. /**
  56185. * Will be triggered when the break condition has met (prematurely ended)
  56186. */
  56187. onAborted?: (data: ITimerData<any>) => void;
  56188. /**
  56189. * Optional function to execute on each tick (or count)
  56190. */
  56191. onTick?: (data: ITimerData<any>) => void;
  56192. }
  56193. /**
  56194. * An interface defining the data sent by the timer
  56195. */
  56196. export interface ITimerData<T> {
  56197. /**
  56198. * When did it start
  56199. */
  56200. startTime: number;
  56201. /**
  56202. * Time now
  56203. */
  56204. currentTime: number;
  56205. /**
  56206. * Time passed since started
  56207. */
  56208. deltaTime: number;
  56209. /**
  56210. * How much is completed, in [0.0...1.0].
  56211. * Note that this CAN be higher than 1 due to the fact that we don't actually measure time but delta between observable calls
  56212. */
  56213. completeRate: number;
  56214. /**
  56215. * What the registered observable sent in the last count
  56216. */
  56217. payload: T;
  56218. }
  56219. /**
  56220. * The current state of the timer
  56221. */
  56222. export enum TimerState {
  56223. /**
  56224. * Timer initialized, not yet started
  56225. */
  56226. INIT = 0,
  56227. /**
  56228. * Timer started and counting
  56229. */
  56230. STARTED = 1,
  56231. /**
  56232. * Timer ended (whether aborted or time reached)
  56233. */
  56234. ENDED = 2
  56235. }
  56236. /**
  56237. * A simple version of the timer. Will take options and start the timer immediately after calling it
  56238. *
  56239. * @param options options with which to initialize this timer
  56240. */
  56241. export function setAndStartTimer(options: ITimerOptions<any>): Nullable<Observer<any>>;
  56242. /**
  56243. * An advanced implementation of a timer class
  56244. */
  56245. export class AdvancedTimer<T = any> implements IDisposable {
  56246. /**
  56247. * Will notify each time the timer calculates the remaining time
  56248. */
  56249. onEachCountObservable: Observable<ITimerData<T>>;
  56250. /**
  56251. * Will trigger when the timer was aborted due to the break condition
  56252. */
  56253. onTimerAbortedObservable: Observable<ITimerData<T>>;
  56254. /**
  56255. * Will trigger when the timer ended successfully
  56256. */
  56257. onTimerEndedObservable: Observable<ITimerData<T>>;
  56258. /**
  56259. * Will trigger when the timer state has changed
  56260. */
  56261. onStateChangedObservable: Observable<TimerState>;
  56262. private _observer;
  56263. private _contextObservable;
  56264. private _observableParameters;
  56265. private _startTime;
  56266. private _timer;
  56267. private _state;
  56268. private _breakCondition;
  56269. private _timeToEnd;
  56270. private _breakOnNextTick;
  56271. /**
  56272. * Will construct a new advanced timer based on the options provided. Timer will not start until start() is called.
  56273. * @param options construction options for this advanced timer
  56274. */
  56275. constructor(options: ITimerOptions<T>);
  56276. /**
  56277. * set a breaking condition for this timer. Default is to never break during count
  56278. * @param predicate the new break condition. Returns true to break, false otherwise
  56279. */
  56280. set breakCondition(predicate: (data: ITimerData<T>) => boolean);
  56281. /**
  56282. * Reset ALL associated observables in this advanced timer
  56283. */
  56284. clearObservables(): void;
  56285. /**
  56286. * Will start a new iteration of this timer. Only one instance of this timer can run at a time.
  56287. *
  56288. * @param timeToEnd how much time to measure until timer ended
  56289. */
  56290. start(timeToEnd?: number): void;
  56291. /**
  56292. * Will force a stop on the next tick.
  56293. */
  56294. stop(): void;
  56295. /**
  56296. * Dispose this timer, clearing all resources
  56297. */
  56298. dispose(): void;
  56299. private _setState;
  56300. private _tick;
  56301. private _stop;
  56302. }
  56303. }
  56304. declare module BABYLON {
  56305. /**
  56306. * The options container for the teleportation module
  56307. */
  56308. export interface IWebXRTeleportationOptions {
  56309. /**
  56310. * if provided, this scene will be used to render meshes.
  56311. */
  56312. customUtilityLayerScene?: Scene;
  56313. /**
  56314. * Values to configure the default target mesh
  56315. */
  56316. defaultTargetMeshOptions?: {
  56317. /**
  56318. * Fill color of the teleportation area
  56319. */
  56320. teleportationFillColor?: string;
  56321. /**
  56322. * Border color for the teleportation area
  56323. */
  56324. teleportationBorderColor?: string;
  56325. /**
  56326. * Disable the mesh's animation sequence
  56327. */
  56328. disableAnimation?: boolean;
  56329. /**
  56330. * Disable lighting on the material or the ring and arrow
  56331. */
  56332. disableLighting?: boolean;
  56333. /**
  56334. * Override the default material of the torus and arrow
  56335. */
  56336. torusArrowMaterial?: Material;
  56337. };
  56338. /**
  56339. * A list of meshes to use as floor meshes.
  56340. * Meshes can be added and removed after initializing the feature using the
  56341. * addFloorMesh and removeFloorMesh functions
  56342. * If empty, rotation will still work
  56343. */
  56344. floorMeshes?: AbstractMesh[];
  56345. /**
  56346. * use this rendering group id for the meshes (optional)
  56347. */
  56348. renderingGroupId?: number;
  56349. /**
  56350. * Should teleportation move only to snap points
  56351. */
  56352. snapPointsOnly?: boolean;
  56353. /**
  56354. * An array of points to which the teleportation will snap to.
  56355. * If the teleportation ray is in the proximity of one of those points, it will be corrected to this point.
  56356. */
  56357. snapPositions?: Vector3[];
  56358. /**
  56359. * How close should the teleportation ray be in order to snap to position.
  56360. * Default to 0.8 units (meters)
  56361. */
  56362. snapToPositionRadius?: number;
  56363. /**
  56364. * Provide your own teleportation mesh instead of babylon's wonderful doughnut.
  56365. * If you want to support rotation, make sure your mesh has a direction indicator.
  56366. *
  56367. * When left untouched, the default mesh will be initialized.
  56368. */
  56369. teleportationTargetMesh?: AbstractMesh;
  56370. /**
  56371. * If main component is used (no thumbstick), how long should the "long press" take before teleport
  56372. */
  56373. timeToTeleport?: number;
  56374. /**
  56375. * Disable using the thumbstick and use the main component (usually trigger) on long press.
  56376. * This will be automatically true if the controller doesn't have a thumbstick or touchpad.
  56377. */
  56378. useMainComponentOnly?: boolean;
  56379. /**
  56380. * Should meshes created here be added to a utility layer or the main scene
  56381. */
  56382. useUtilityLayer?: boolean;
  56383. /**
  56384. * Babylon XR Input class for controller
  56385. */
  56386. xrInput: WebXRInput;
  56387. /**
  56388. * Meshes that the teleportation ray cannot go through
  56389. */
  56390. pickBlockerMeshes?: AbstractMesh[];
  56391. /**
  56392. * Should teleport work only on a specific hand?
  56393. */
  56394. forceHandedness?: XRHandedness;
  56395. /**
  56396. * If provided, this function will be used to generate the ray mesh instead of the lines mesh being used per default
  56397. */
  56398. generateRayPathMesh?: (points: Vector3[]) => AbstractMesh;
  56399. }
  56400. /**
  56401. * This is a teleportation feature to be used with WebXR-enabled motion controllers.
  56402. * When enabled and attached, the feature will allow a user to move around and rotate in the scene using
  56403. * the input of the attached controllers.
  56404. */
  56405. export class WebXRMotionControllerTeleportation extends WebXRAbstractFeature {
  56406. private _options;
  56407. private _controllers;
  56408. private _currentTeleportationControllerId;
  56409. private _floorMeshes;
  56410. private _quadraticBezierCurve;
  56411. private _selectionFeature;
  56412. private _snapToPositions;
  56413. private _snappedToPoint;
  56414. private _teleportationRingMaterial?;
  56415. private _tmpRay;
  56416. private _tmpVector;
  56417. private _tmpQuaternion;
  56418. /**
  56419. * The module's name
  56420. */
  56421. static readonly Name: string;
  56422. /**
  56423. * The (Babylon) version of this module.
  56424. * This is an integer representing the implementation version.
  56425. * This number does not correspond to the webxr specs version
  56426. */
  56427. static readonly Version: number;
  56428. /**
  56429. * Is movement backwards enabled
  56430. */
  56431. backwardsMovementEnabled: boolean;
  56432. /**
  56433. * Distance to travel when moving backwards
  56434. */
  56435. backwardsTeleportationDistance: number;
  56436. /**
  56437. * The distance from the user to the inspection point in the direction of the controller
  56438. * A higher number will allow the user to move further
  56439. * defaults to 5 (meters, in xr units)
  56440. */
  56441. parabolicCheckRadius: number;
  56442. /**
  56443. * Should the module support parabolic ray on top of direct ray
  56444. * If enabled, the user will be able to point "at the sky" and move according to predefined radius distance
  56445. * Very helpful when moving between floors / different heights
  56446. */
  56447. parabolicRayEnabled: boolean;
  56448. /**
  56449. * The second type of ray - straight line.
  56450. * Should it be enabled or should the parabolic line be the only one.
  56451. */
  56452. straightRayEnabled: boolean;
  56453. /**
  56454. * How much rotation should be applied when rotating right and left
  56455. */
  56456. rotationAngle: number;
  56457. private _rotationEnabled;
  56458. /**
  56459. * Is rotation enabled when moving forward?
  56460. * Disabling this feature will prevent the user from deciding the direction when teleporting
  56461. */
  56462. get rotationEnabled(): boolean;
  56463. /**
  56464. * Sets wether rotation is enabled or not
  56465. * @param enabled is rotation enabled when teleportation is shown
  56466. */
  56467. set rotationEnabled(enabled: boolean);
  56468. /**
  56469. * Exposes the currently set teleportation target mesh.
  56470. */
  56471. get teleportationTargetMesh(): Nullable<AbstractMesh>;
  56472. /**
  56473. * constructs a new anchor system
  56474. * @param _xrSessionManager an instance of WebXRSessionManager
  56475. * @param _options configuration object for this feature
  56476. */
  56477. constructor(_xrSessionManager: WebXRSessionManager, _options: IWebXRTeleportationOptions);
  56478. /**
  56479. * Get the snapPointsOnly flag
  56480. */
  56481. get snapPointsOnly(): boolean;
  56482. /**
  56483. * Sets the snapPointsOnly flag
  56484. * @param snapToPoints should teleportation be exclusively to snap points
  56485. */
  56486. set snapPointsOnly(snapToPoints: boolean);
  56487. /**
  56488. * Add a new mesh to the floor meshes array
  56489. * @param mesh the mesh to use as floor mesh
  56490. */
  56491. addFloorMesh(mesh: AbstractMesh): void;
  56492. /**
  56493. * Add a new snap-to point to fix teleportation to this position
  56494. * @param newSnapPoint The new Snap-To point
  56495. */
  56496. addSnapPoint(newSnapPoint: Vector3): void;
  56497. attach(): boolean;
  56498. detach(): boolean;
  56499. dispose(): void;
  56500. /**
  56501. * Remove a mesh from the floor meshes array
  56502. * @param mesh the mesh to remove
  56503. */
  56504. removeFloorMesh(mesh: AbstractMesh): void;
  56505. /**
  56506. * Remove a mesh from the floor meshes array using its name
  56507. * @param name the mesh name to remove
  56508. */
  56509. removeFloorMeshByName(name: string): void;
  56510. /**
  56511. * 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
  56512. * @param snapPointToRemove the point (or a clone of it) to be removed from the array
  56513. * @returns was the point found and removed or not
  56514. */
  56515. removeSnapPoint(snapPointToRemove: Vector3): boolean;
  56516. /**
  56517. * This function sets a selection feature that will be disabled when
  56518. * the forward ray is shown and will be reattached when hidden.
  56519. * This is used to remove the selection rays when moving.
  56520. * @param selectionFeature the feature to disable when forward movement is enabled
  56521. */
  56522. setSelectionFeature(selectionFeature: Nullable<IWebXRFeature>): void;
  56523. protected _onXRFrame(_xrFrame: XRFrame): void;
  56524. private _attachController;
  56525. private _createDefaultTargetMesh;
  56526. private _detachController;
  56527. private _findClosestSnapPointWithRadius;
  56528. private _setTargetMeshPosition;
  56529. private _setTargetMeshVisibility;
  56530. private _showParabolicPath;
  56531. private _teleportForward;
  56532. }
  56533. }
  56534. declare module BABYLON {
  56535. /**
  56536. * Options for the default xr helper
  56537. */
  56538. export class WebXRDefaultExperienceOptions {
  56539. /**
  56540. * Enable or disable default UI to enter XR
  56541. */
  56542. disableDefaultUI?: boolean;
  56543. /**
  56544. * Should teleportation not initialize. defaults to false.
  56545. */
  56546. disableTeleportation?: boolean;
  56547. /**
  56548. * Floor meshes that will be used for teleport
  56549. */
  56550. floorMeshes?: Array<AbstractMesh>;
  56551. /**
  56552. * If set to true, the first frame will not be used to reset position
  56553. * The first frame is mainly used when copying transformation from the old camera
  56554. * Mainly used in AR
  56555. */
  56556. ignoreNativeCameraTransformation?: boolean;
  56557. /**
  56558. * Disable the controller mesh-loading. Can be used if you want to load your own meshes
  56559. */
  56560. inputOptions?: IWebXRInputOptions;
  56561. /**
  56562. * optional configuration for the output canvas
  56563. */
  56564. outputCanvasOptions?: WebXRManagedOutputCanvasOptions;
  56565. /**
  56566. * optional UI options. This can be used among other to change session mode and reference space type
  56567. */
  56568. uiOptions?: WebXREnterExitUIOptions;
  56569. /**
  56570. * When loading teleportation and pointer select, use stable versions instead of latest.
  56571. */
  56572. useStablePlugins?: boolean;
  56573. /**
  56574. * An optional rendering group id that will be set globally for teleportation, pointer selection and default controller meshes
  56575. */
  56576. renderingGroupId?: number;
  56577. /**
  56578. * A list of optional features to init the session with
  56579. * If set to true, all features we support will be added
  56580. */
  56581. optionalFeatures?: boolean | string[];
  56582. }
  56583. /**
  56584. * Default experience which provides a similar setup to the previous webVRExperience
  56585. */
  56586. export class WebXRDefaultExperience {
  56587. /**
  56588. * Base experience
  56589. */
  56590. baseExperience: WebXRExperienceHelper;
  56591. /**
  56592. * Enables ui for entering/exiting xr
  56593. */
  56594. enterExitUI: WebXREnterExitUI;
  56595. /**
  56596. * Input experience extension
  56597. */
  56598. input: WebXRInput;
  56599. /**
  56600. * Enables laser pointer and selection
  56601. */
  56602. pointerSelection: WebXRControllerPointerSelection;
  56603. /**
  56604. * Default target xr should render to
  56605. */
  56606. renderTarget: WebXRRenderTarget;
  56607. /**
  56608. * Enables teleportation
  56609. */
  56610. teleportation: WebXRMotionControllerTeleportation;
  56611. private constructor();
  56612. /**
  56613. * Creates the default xr experience
  56614. * @param scene scene
  56615. * @param options options for basic configuration
  56616. * @returns resulting WebXRDefaultExperience
  56617. */
  56618. static CreateAsync(scene: Scene, options?: WebXRDefaultExperienceOptions): Promise<WebXRDefaultExperience>;
  56619. /**
  56620. * DIsposes of the experience helper
  56621. */
  56622. dispose(): void;
  56623. }
  56624. }
  56625. declare module BABYLON {
  56626. /**
  56627. * Options to modify the vr teleportation behavior.
  56628. */
  56629. export interface VRTeleportationOptions {
  56630. /**
  56631. * The name of the mesh which should be used as the teleportation floor. (default: null)
  56632. */
  56633. floorMeshName?: string;
  56634. /**
  56635. * A list of meshes to be used as the teleportation floor. (default: empty)
  56636. */
  56637. floorMeshes?: Mesh[];
  56638. /**
  56639. * The teleportation mode. (default: TELEPORTATIONMODE_CONSTANTTIME)
  56640. */
  56641. teleportationMode?: number;
  56642. /**
  56643. * The duration of the animation in ms, apply when animationMode is TELEPORTATIONMODE_CONSTANTTIME. (default 122ms)
  56644. */
  56645. teleportationTime?: number;
  56646. /**
  56647. * The speed of the animation in distance/sec, apply when animationMode is TELEPORTATIONMODE_CONSTANTSPEED. (default 20 units / sec)
  56648. */
  56649. teleportationSpeed?: number;
  56650. /**
  56651. * The easing function used in the animation or null for Linear. (default CircleEase)
  56652. */
  56653. easingFunction?: EasingFunction;
  56654. }
  56655. /**
  56656. * Options to modify the vr experience helper's behavior.
  56657. */
  56658. export interface VRExperienceHelperOptions extends WebVROptions {
  56659. /**
  56660. * Create a DeviceOrientationCamera to be used as your out of vr camera. (default: true)
  56661. */
  56662. createDeviceOrientationCamera?: boolean;
  56663. /**
  56664. * Create a VRDeviceOrientationFreeCamera to be used for VR when no external HMD is found. (default: true)
  56665. */
  56666. createFallbackVRDeviceOrientationFreeCamera?: boolean;
  56667. /**
  56668. * Uses the main button on the controller to toggle the laser casted. (default: true)
  56669. */
  56670. laserToggle?: boolean;
  56671. /**
  56672. * A list of meshes to be used as the teleportation floor. If specified, teleportation will be enabled (default: undefined)
  56673. */
  56674. floorMeshes?: Mesh[];
  56675. /**
  56676. * Distortion metrics for the fallback vrDeviceOrientationCamera (default: VRCameraMetrics.Default)
  56677. */
  56678. vrDeviceOrientationCameraMetrics?: VRCameraMetrics;
  56679. /**
  56680. * Defines if WebXR should be used instead of WebVR (if available)
  56681. */
  56682. useXR?: boolean;
  56683. }
  56684. /**
  56685. * Event containing information after VR has been entered
  56686. */
  56687. export class OnAfterEnteringVRObservableEvent {
  56688. /**
  56689. * If entering vr was successful
  56690. */
  56691. success: boolean;
  56692. }
  56693. /**
  56694. * Helps to quickly add VR support to an existing scene.
  56695. * See https://doc.babylonjs.com/how_to/webvr_helper
  56696. */
  56697. export class VRExperienceHelper {
  56698. /** Options to modify the vr experience helper's behavior. */
  56699. webVROptions: VRExperienceHelperOptions;
  56700. private _scene;
  56701. private _position;
  56702. private _btnVR;
  56703. private _btnVRDisplayed;
  56704. private _webVRsupported;
  56705. private _webVRready;
  56706. private _webVRrequesting;
  56707. private _webVRpresenting;
  56708. private _hasEnteredVR;
  56709. private _fullscreenVRpresenting;
  56710. private _inputElement;
  56711. private _webVRCamera;
  56712. private _vrDeviceOrientationCamera;
  56713. private _deviceOrientationCamera;
  56714. private _existingCamera;
  56715. private _onKeyDown;
  56716. private _onVrDisplayPresentChange;
  56717. private _onVRDisplayChanged;
  56718. private _onVRRequestPresentStart;
  56719. private _onVRRequestPresentComplete;
  56720. /**
  56721. * 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)
  56722. */
  56723. enableGazeEvenWhenNoPointerLock: boolean;
  56724. /**
  56725. * Gets or sets a boolean indicating that the VREXperienceHelper will exit VR if double tap is detected
  56726. */
  56727. exitVROnDoubleTap: boolean;
  56728. /**
  56729. * Observable raised right before entering VR.
  56730. */
  56731. onEnteringVRObservable: Observable<VRExperienceHelper>;
  56732. /**
  56733. * Observable raised when entering VR has completed.
  56734. */
  56735. onAfterEnteringVRObservable: Observable<OnAfterEnteringVRObservableEvent>;
  56736. /**
  56737. * Observable raised when exiting VR.
  56738. */
  56739. onExitingVRObservable: Observable<VRExperienceHelper>;
  56740. /**
  56741. * Observable raised when controller mesh is loaded.
  56742. */
  56743. onControllerMeshLoadedObservable: Observable<WebVRController>;
  56744. /** Return this.onEnteringVRObservable
  56745. * Note: This one is for backward compatibility. Please use onEnteringVRObservable directly
  56746. */
  56747. get onEnteringVR(): Observable<VRExperienceHelper>;
  56748. /** Return this.onExitingVRObservable
  56749. * Note: This one is for backward compatibility. Please use onExitingVRObservable directly
  56750. */
  56751. get onExitingVR(): Observable<VRExperienceHelper>;
  56752. /** Return this.onControllerMeshLoadedObservable
  56753. * Note: This one is for backward compatibility. Please use onControllerMeshLoadedObservable directly
  56754. */
  56755. get onControllerMeshLoaded(): Observable<WebVRController>;
  56756. private _rayLength;
  56757. private _useCustomVRButton;
  56758. private _teleportationRequested;
  56759. private _teleportActive;
  56760. private _floorMeshName;
  56761. private _floorMeshesCollection;
  56762. private _teleportationMode;
  56763. private _teleportationTime;
  56764. private _teleportationSpeed;
  56765. private _teleportationEasing;
  56766. private _rotationAllowed;
  56767. private _teleportBackwardsVector;
  56768. private _teleportationTarget;
  56769. private _isDefaultTeleportationTarget;
  56770. private _postProcessMove;
  56771. private _teleportationFillColor;
  56772. private _teleportationBorderColor;
  56773. private _rotationAngle;
  56774. private _haloCenter;
  56775. private _cameraGazer;
  56776. private _padSensibilityUp;
  56777. private _padSensibilityDown;
  56778. private _leftController;
  56779. private _rightController;
  56780. private _gazeColor;
  56781. private _laserColor;
  56782. private _pickedLaserColor;
  56783. private _pickedGazeColor;
  56784. /**
  56785. * Observable raised when a new mesh is selected based on meshSelectionPredicate
  56786. */
  56787. onNewMeshSelected: Observable<AbstractMesh>;
  56788. /**
  56789. * Observable raised when a new mesh is selected based on meshSelectionPredicate.
  56790. * This observable will provide the mesh and the controller used to select the mesh
  56791. */
  56792. onMeshSelectedWithController: Observable<{
  56793. mesh: AbstractMesh;
  56794. controller: WebVRController;
  56795. }>;
  56796. /**
  56797. * Observable raised when a new mesh is picked based on meshSelectionPredicate
  56798. */
  56799. onNewMeshPicked: Observable<PickingInfo>;
  56800. private _circleEase;
  56801. /**
  56802. * Observable raised before camera teleportation
  56803. */
  56804. onBeforeCameraTeleport: Observable<Vector3>;
  56805. /**
  56806. * Observable raised after camera teleportation
  56807. */
  56808. onAfterCameraTeleport: Observable<Vector3>;
  56809. /**
  56810. * Observable raised when current selected mesh gets unselected
  56811. */
  56812. onSelectedMeshUnselected: Observable<AbstractMesh>;
  56813. private _raySelectionPredicate;
  56814. /**
  56815. * To be optionally changed by user to define custom ray selection
  56816. */
  56817. raySelectionPredicate: (mesh: AbstractMesh) => boolean;
  56818. /**
  56819. * To be optionally changed by user to define custom selection logic (after ray selection)
  56820. */
  56821. meshSelectionPredicate: (mesh: AbstractMesh) => boolean;
  56822. /**
  56823. * Set teleportation enabled. If set to false camera teleportation will be disabled but camera rotation will be kept.
  56824. */
  56825. teleportationEnabled: boolean;
  56826. private _defaultHeight;
  56827. private _teleportationInitialized;
  56828. private _interactionsEnabled;
  56829. private _interactionsRequested;
  56830. private _displayGaze;
  56831. private _displayLaserPointer;
  56832. /**
  56833. * The mesh used to display where the user is going to teleport.
  56834. */
  56835. get teleportationTarget(): Mesh;
  56836. /**
  56837. * Sets the mesh to be used to display where the user is going to teleport.
  56838. */
  56839. set teleportationTarget(value: Mesh);
  56840. /**
  56841. * 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
  56842. * when set bakeCurrentTransformIntoVertices will be called on the mesh.
  56843. * See https://doc.babylonjs.com/resources/baking_transformations
  56844. */
  56845. get gazeTrackerMesh(): Mesh;
  56846. set gazeTrackerMesh(value: Mesh);
  56847. /**
  56848. * If the gaze trackers scale should be updated to be constant size when pointing at near/far meshes
  56849. */
  56850. updateGazeTrackerScale: boolean;
  56851. /**
  56852. * If the gaze trackers color should be updated when selecting meshes
  56853. */
  56854. updateGazeTrackerColor: boolean;
  56855. /**
  56856. * If the controller laser color should be updated when selecting meshes
  56857. */
  56858. updateControllerLaserColor: boolean;
  56859. /**
  56860. * The gaze tracking mesh corresponding to the left controller
  56861. */
  56862. get leftControllerGazeTrackerMesh(): Nullable<Mesh>;
  56863. /**
  56864. * The gaze tracking mesh corresponding to the right controller
  56865. */
  56866. get rightControllerGazeTrackerMesh(): Nullable<Mesh>;
  56867. /**
  56868. * If the ray of the gaze should be displayed.
  56869. */
  56870. get displayGaze(): boolean;
  56871. /**
  56872. * Sets if the ray of the gaze should be displayed.
  56873. */
  56874. set displayGaze(value: boolean);
  56875. /**
  56876. * If the ray of the LaserPointer should be displayed.
  56877. */
  56878. get displayLaserPointer(): boolean;
  56879. /**
  56880. * Sets if the ray of the LaserPointer should be displayed.
  56881. */
  56882. set displayLaserPointer(value: boolean);
  56883. /**
  56884. * The deviceOrientationCamera used as the camera when not in VR.
  56885. */
  56886. get deviceOrientationCamera(): Nullable<DeviceOrientationCamera>;
  56887. /**
  56888. * Based on the current WebVR support, returns the current VR camera used.
  56889. */
  56890. get currentVRCamera(): Nullable<Camera>;
  56891. /**
  56892. * The webVRCamera which is used when in VR.
  56893. */
  56894. get webVRCamera(): WebVRFreeCamera;
  56895. /**
  56896. * The deviceOrientationCamera that is used as a fallback when vr device is not connected.
  56897. */
  56898. get vrDeviceOrientationCamera(): Nullable<VRDeviceOrientationFreeCamera>;
  56899. /**
  56900. * The html button that is used to trigger entering into VR.
  56901. */
  56902. get vrButton(): Nullable<HTMLButtonElement>;
  56903. private get _teleportationRequestInitiated();
  56904. /**
  56905. * Defines whether or not Pointer lock should be requested when switching to
  56906. * full screen.
  56907. */
  56908. requestPointerLockOnFullScreen: boolean;
  56909. /**
  56910. * If asking to force XR, this will be populated with the default xr experience
  56911. */
  56912. xr: WebXRDefaultExperience;
  56913. /**
  56914. * Was the XR test done already. If this is true AND this.xr exists, xr is initialized.
  56915. * If this is true and no this.xr, xr exists but is not supported, using WebVR.
  56916. */
  56917. xrTestDone: boolean;
  56918. /**
  56919. * Instantiates a VRExperienceHelper.
  56920. * Helps to quickly add VR support to an existing scene.
  56921. * @param scene The scene the VRExperienceHelper belongs to.
  56922. * @param webVROptions Options to modify the vr experience helper's behavior.
  56923. */
  56924. constructor(scene: Scene,
  56925. /** Options to modify the vr experience helper's behavior. */
  56926. webVROptions?: VRExperienceHelperOptions);
  56927. private completeVRInit;
  56928. private _onDefaultMeshLoaded;
  56929. private _onResize;
  56930. private _onFullscreenChange;
  56931. /**
  56932. * Gets a value indicating if we are currently in VR mode.
  56933. */
  56934. get isInVRMode(): boolean;
  56935. private onVrDisplayPresentChange;
  56936. private onVRDisplayChanged;
  56937. private moveButtonToBottomRight;
  56938. private displayVRButton;
  56939. private updateButtonVisibility;
  56940. private _cachedAngularSensibility;
  56941. /**
  56942. * Attempt to enter VR. If a headset is connected and ready, will request present on that.
  56943. * Otherwise, will use the fullscreen API.
  56944. */
  56945. enterVR(): void;
  56946. /**
  56947. * Attempt to exit VR, or fullscreen.
  56948. */
  56949. exitVR(): void;
  56950. /**
  56951. * The position of the vr experience helper.
  56952. */
  56953. get position(): Vector3;
  56954. /**
  56955. * Sets the position of the vr experience helper.
  56956. */
  56957. set position(value: Vector3);
  56958. /**
  56959. * Enables controllers and user interactions such as selecting and object or clicking on an object.
  56960. */
  56961. enableInteractions(): void;
  56962. private get _noControllerIsActive();
  56963. private beforeRender;
  56964. private _isTeleportationFloor;
  56965. /**
  56966. * Adds a floor mesh to be used for teleportation.
  56967. * @param floorMesh the mesh to be used for teleportation.
  56968. */
  56969. addFloorMesh(floorMesh: Mesh): void;
  56970. /**
  56971. * Removes a floor mesh from being used for teleportation.
  56972. * @param floorMesh the mesh to be removed.
  56973. */
  56974. removeFloorMesh(floorMesh: Mesh): void;
  56975. /**
  56976. * Enables interactions and teleportation using the VR controllers and gaze.
  56977. * @param vrTeleportationOptions options to modify teleportation behavior.
  56978. */
  56979. enableTeleportation(vrTeleportationOptions?: VRTeleportationOptions): void;
  56980. private _onNewGamepadConnected;
  56981. private _tryEnableInteractionOnController;
  56982. private _onNewGamepadDisconnected;
  56983. private _enableInteractionOnController;
  56984. private _checkTeleportWithRay;
  56985. private _checkRotate;
  56986. private _checkTeleportBackwards;
  56987. private _enableTeleportationOnController;
  56988. private _createTeleportationCircles;
  56989. private _displayTeleportationTarget;
  56990. private _hideTeleportationTarget;
  56991. private _rotateCamera;
  56992. private _moveTeleportationSelectorTo;
  56993. private _workingVector;
  56994. private _workingQuaternion;
  56995. private _workingMatrix;
  56996. /**
  56997. * Time Constant Teleportation Mode
  56998. */
  56999. static readonly TELEPORTATIONMODE_CONSTANTTIME: number;
  57000. /**
  57001. * Speed Constant Teleportation Mode
  57002. */
  57003. static readonly TELEPORTATIONMODE_CONSTANTSPEED: number;
  57004. /**
  57005. * Teleports the users feet to the desired location
  57006. * @param location The location where the user's feet should be placed
  57007. */
  57008. teleportCamera(location: Vector3): void;
  57009. private _convertNormalToDirectionOfRay;
  57010. private _castRayAndSelectObject;
  57011. private _notifySelectedMeshUnselected;
  57012. /**
  57013. * Permanently set new colors for the laser pointer
  57014. * @param color the new laser color
  57015. * @param pickedColor the new laser color when picked mesh detected
  57016. */
  57017. setLaserColor(color: Color3, pickedColor?: Color3): void;
  57018. /**
  57019. * Set lighting enabled / disabled on the laser pointer of both controllers
  57020. * @param enabled should the lighting be enabled on the laser pointer
  57021. */
  57022. setLaserLightingState(enabled?: boolean): void;
  57023. /**
  57024. * Permanently set new colors for the gaze pointer
  57025. * @param color the new gaze color
  57026. * @param pickedColor the new gaze color when picked mesh detected
  57027. */
  57028. setGazeColor(color: Color3, pickedColor?: Color3): void;
  57029. /**
  57030. * Sets the color of the laser ray from the vr controllers.
  57031. * @param color new color for the ray.
  57032. */
  57033. changeLaserColor(color: Color3): void;
  57034. /**
  57035. * Sets the color of the ray from the vr headsets gaze.
  57036. * @param color new color for the ray.
  57037. */
  57038. changeGazeColor(color: Color3): void;
  57039. /**
  57040. * Exits VR and disposes of the vr experience helper
  57041. */
  57042. dispose(): void;
  57043. /**
  57044. * Gets the name of the VRExperienceHelper class
  57045. * @returns "VRExperienceHelper"
  57046. */
  57047. getClassName(): string;
  57048. }
  57049. }
  57050. declare module BABYLON {
  57051. /**
  57052. * Contains an array of blocks representing the octree
  57053. */
  57054. export interface IOctreeContainer<T> {
  57055. /**
  57056. * Blocks within the octree
  57057. */
  57058. blocks: Array<OctreeBlock<T>>;
  57059. }
  57060. /**
  57061. * Class used to store a cell in an octree
  57062. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  57063. */
  57064. export class OctreeBlock<T> {
  57065. /**
  57066. * Gets the content of the current block
  57067. */
  57068. entries: T[];
  57069. /**
  57070. * Gets the list of block children
  57071. */
  57072. blocks: Array<OctreeBlock<T>>;
  57073. private _depth;
  57074. private _maxDepth;
  57075. private _capacity;
  57076. private _minPoint;
  57077. private _maxPoint;
  57078. private _boundingVectors;
  57079. private _creationFunc;
  57080. /**
  57081. * Creates a new block
  57082. * @param minPoint defines the minimum vector (in world space) of the block's bounding box
  57083. * @param maxPoint defines the maximum vector (in world space) of the block's bounding box
  57084. * @param capacity defines the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  57085. * @param depth defines the current depth of this block in the octree
  57086. * @param maxDepth defines the maximal depth allowed (beyond this value, the capacity is ignored)
  57087. * @param creationFunc defines a callback to call when an element is added to the block
  57088. */
  57089. constructor(minPoint: Vector3, maxPoint: Vector3, capacity: number, depth: number, maxDepth: number, creationFunc: (entry: T, block: OctreeBlock<T>) => void);
  57090. /**
  57091. * Gets the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  57092. */
  57093. get capacity(): number;
  57094. /**
  57095. * Gets the minimum vector (in world space) of the block's bounding box
  57096. */
  57097. get minPoint(): Vector3;
  57098. /**
  57099. * Gets the maximum vector (in world space) of the block's bounding box
  57100. */
  57101. get maxPoint(): Vector3;
  57102. /**
  57103. * Add a new element to this block
  57104. * @param entry defines the element to add
  57105. */
  57106. addEntry(entry: T): void;
  57107. /**
  57108. * Remove an element from this block
  57109. * @param entry defines the element to remove
  57110. */
  57111. removeEntry(entry: T): void;
  57112. /**
  57113. * Add an array of elements to this block
  57114. * @param entries defines the array of elements to add
  57115. */
  57116. addEntries(entries: T[]): void;
  57117. /**
  57118. * Test if the current block intersects the frustum planes and if yes, then add its content to the selection array
  57119. * @param frustumPlanes defines the frustum planes to test
  57120. * @param selection defines the array to store current content if selection is positive
  57121. * @param allowDuplicate defines if the selection array can contains duplicated entries
  57122. */
  57123. select(frustumPlanes: Plane[], selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  57124. /**
  57125. * Test if the current block intersect with the given bounding sphere and if yes, then add its content to the selection array
  57126. * @param sphereCenter defines the bounding sphere center
  57127. * @param sphereRadius defines the bounding sphere radius
  57128. * @param selection defines the array to store current content if selection is positive
  57129. * @param allowDuplicate defines if the selection array can contains duplicated entries
  57130. */
  57131. intersects(sphereCenter: Vector3, sphereRadius: number, selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  57132. /**
  57133. * Test if the current block intersect with the given ray and if yes, then add its content to the selection array
  57134. * @param ray defines the ray to test with
  57135. * @param selection defines the array to store current content if selection is positive
  57136. */
  57137. intersectsRay(ray: Ray, selection: SmartArrayNoDuplicate<T>): void;
  57138. /**
  57139. * Subdivide the content into child blocks (this block will then be empty)
  57140. */
  57141. createInnerBlocks(): void;
  57142. /**
  57143. * @hidden
  57144. */
  57145. 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;
  57146. }
  57147. }
  57148. declare module BABYLON {
  57149. /**
  57150. * Octrees are a really powerful data structure that can quickly select entities based on space coordinates.
  57151. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  57152. */
  57153. export class Octree<T> {
  57154. /** 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.) */
  57155. maxDepth: number;
  57156. /**
  57157. * Blocks within the octree containing objects
  57158. */
  57159. blocks: Array<OctreeBlock<T>>;
  57160. /**
  57161. * Content stored in the octree
  57162. */
  57163. dynamicContent: T[];
  57164. private _maxBlockCapacity;
  57165. private _selectionContent;
  57166. private _creationFunc;
  57167. /**
  57168. * Creates a octree
  57169. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  57170. * @param creationFunc function to be used to instantiate the octree
  57171. * @param maxBlockCapacity defines the maximum number of meshes you want on your octree's leaves (default: 64)
  57172. * @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.)
  57173. */
  57174. constructor(creationFunc: (entry: T, block: OctreeBlock<T>) => void, maxBlockCapacity?: number,
  57175. /** 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.) */
  57176. maxDepth?: number);
  57177. /**
  57178. * Updates the octree by adding blocks for the passed in meshes within the min and max world parameters
  57179. * @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);
  57180. * @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);
  57181. * @param entries meshes to be added to the octree blocks
  57182. */
  57183. update(worldMin: Vector3, worldMax: Vector3, entries: T[]): void;
  57184. /**
  57185. * Adds a mesh to the octree
  57186. * @param entry Mesh to add to the octree
  57187. */
  57188. addMesh(entry: T): void;
  57189. /**
  57190. * Remove an element from the octree
  57191. * @param entry defines the element to remove
  57192. */
  57193. removeMesh(entry: T): void;
  57194. /**
  57195. * Selects an array of meshes within the frustum
  57196. * @param frustumPlanes The frustum planes to use which will select all meshes within it
  57197. * @param allowDuplicate If duplicate objects are allowed in the resulting object array
  57198. * @returns array of meshes within the frustum
  57199. */
  57200. select(frustumPlanes: Plane[], allowDuplicate?: boolean): SmartArray<T>;
  57201. /**
  57202. * Test if the octree intersect with the given bounding sphere and if yes, then add its content to the selection array
  57203. * @param sphereCenter defines the bounding sphere center
  57204. * @param sphereRadius defines the bounding sphere radius
  57205. * @param allowDuplicate defines if the selection array can contains duplicated entries
  57206. * @returns an array of objects that intersect the sphere
  57207. */
  57208. intersects(sphereCenter: Vector3, sphereRadius: number, allowDuplicate?: boolean): SmartArray<T>;
  57209. /**
  57210. * Test if the octree intersect with the given ray and if yes, then add its content to resulting array
  57211. * @param ray defines the ray to test with
  57212. * @returns array of intersected objects
  57213. */
  57214. intersectsRay(ray: Ray): SmartArray<T>;
  57215. /**
  57216. * Adds a mesh into the octree block if it intersects the block
  57217. */
  57218. static CreationFuncForMeshes: (entry: AbstractMesh, block: OctreeBlock<AbstractMesh>) => void;
  57219. /**
  57220. * Adds a submesh into the octree block if it intersects the block
  57221. */
  57222. static CreationFuncForSubMeshes: (entry: SubMesh, block: OctreeBlock<SubMesh>) => void;
  57223. }
  57224. }
  57225. declare module BABYLON {
  57226. interface Scene {
  57227. /**
  57228. * @hidden
  57229. * Backing Filed
  57230. */
  57231. _selectionOctree: Octree<AbstractMesh>;
  57232. /**
  57233. * Gets the octree used to boost mesh selection (picking)
  57234. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  57235. */
  57236. selectionOctree: Octree<AbstractMesh>;
  57237. /**
  57238. * Creates or updates the octree used to boost selection (picking)
  57239. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  57240. * @param maxCapacity defines the maximum capacity per leaf
  57241. * @param maxDepth defines the maximum depth of the octree
  57242. * @returns an octree of AbstractMesh
  57243. */
  57244. createOrUpdateSelectionOctree(maxCapacity?: number, maxDepth?: number): Octree<AbstractMesh>;
  57245. }
  57246. interface AbstractMesh {
  57247. /**
  57248. * @hidden
  57249. * Backing Field
  57250. */
  57251. _submeshesOctree: Octree<SubMesh>;
  57252. /**
  57253. * This function will create an octree to help to select the right submeshes for rendering, picking and collision computations.
  57254. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  57255. * @param maxCapacity defines the maximum size of each block (64 by default)
  57256. * @param maxDepth defines the maximum depth to use (no more than 2 levels by default)
  57257. * @returns the new octree
  57258. * @see https://www.babylonjs-playground.com/#NA4OQ#12
  57259. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  57260. */
  57261. createOrUpdateSubmeshesOctree(maxCapacity?: number, maxDepth?: number): Octree<SubMesh>;
  57262. }
  57263. /**
  57264. * Defines the octree scene component responsible to manage any octrees
  57265. * in a given scene.
  57266. */
  57267. export class OctreeSceneComponent {
  57268. /**
  57269. * The component name help to identify the component in the list of scene components.
  57270. */
  57271. readonly name: string;
  57272. /**
  57273. * The scene the component belongs to.
  57274. */
  57275. scene: Scene;
  57276. /**
  57277. * Indicates if the meshes have been checked to make sure they are isEnabled()
  57278. */
  57279. readonly checksIsEnabled: boolean;
  57280. /**
  57281. * Creates a new instance of the component for the given scene
  57282. * @param scene Defines the scene to register the component in
  57283. */
  57284. constructor(scene: Scene);
  57285. /**
  57286. * Registers the component in a given scene
  57287. */
  57288. register(): void;
  57289. /**
  57290. * Return the list of active meshes
  57291. * @returns the list of active meshes
  57292. */
  57293. getActiveMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  57294. /**
  57295. * Return the list of active sub meshes
  57296. * @param mesh The mesh to get the candidates sub meshes from
  57297. * @returns the list of active sub meshes
  57298. */
  57299. getActiveSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  57300. private _tempRay;
  57301. /**
  57302. * Return the list of sub meshes intersecting with a given local ray
  57303. * @param mesh defines the mesh to find the submesh for
  57304. * @param localRay defines the ray in local space
  57305. * @returns the list of intersecting sub meshes
  57306. */
  57307. getIntersectingSubMeshCandidates(mesh: AbstractMesh, localRay: Ray): ISmartArrayLike<SubMesh>;
  57308. /**
  57309. * Return the list of sub meshes colliding with a collider
  57310. * @param mesh defines the mesh to find the submesh for
  57311. * @param collider defines the collider to evaluate the collision against
  57312. * @returns the list of colliding sub meshes
  57313. */
  57314. getCollidingSubMeshCandidates(mesh: AbstractMesh, collider: Collider): ISmartArrayLike<SubMesh>;
  57315. /**
  57316. * Rebuilds the elements related to this component in case of
  57317. * context lost for instance.
  57318. */
  57319. rebuild(): void;
  57320. /**
  57321. * Disposes the component and the associated resources.
  57322. */
  57323. dispose(): void;
  57324. }
  57325. }
  57326. declare module BABYLON {
  57327. /**
  57328. * Cache built by each axis. Used for managing state between all elements of gizmo for enhanced UI
  57329. */
  57330. export interface GizmoAxisCache {
  57331. /** Mesh used to render the Gizmo */
  57332. gizmoMeshes: Mesh[];
  57333. /** Mesh used to detect user interaction with Gizmo */
  57334. colliderMeshes: Mesh[];
  57335. /** Material used to indicate color of gizmo mesh */
  57336. material: StandardMaterial;
  57337. /** Material used to indicate hover state of the Gizmo */
  57338. hoverMaterial: StandardMaterial;
  57339. /** Material used to indicate disabled state of the Gizmo */
  57340. disableMaterial: StandardMaterial;
  57341. /** Used to indicate Active state of the Gizmo */
  57342. active: boolean;
  57343. }
  57344. /**
  57345. * Renders gizmos on top of an existing scene which provide controls for position, rotation, etc.
  57346. */
  57347. export class Gizmo implements IDisposable {
  57348. /** The utility layer the gizmo will be added to */
  57349. gizmoLayer: UtilityLayerRenderer;
  57350. /**
  57351. * The root mesh of the gizmo
  57352. */
  57353. _rootMesh: Mesh;
  57354. private _attachedMesh;
  57355. private _attachedNode;
  57356. /**
  57357. * Ratio for the scale of the gizmo (Default: 1)
  57358. */
  57359. protected _scaleRatio: number;
  57360. /**
  57361. * boolean updated by pointermove when a gizmo mesh is hovered
  57362. */
  57363. protected _isHovered: boolean;
  57364. /**
  57365. * Ratio for the scale of the gizmo (Default: 1)
  57366. */
  57367. set scaleRatio(value: number);
  57368. get scaleRatio(): number;
  57369. /**
  57370. * True when the mouse pointer is hovered a gizmo mesh
  57371. */
  57372. get isHovered(): boolean;
  57373. /**
  57374. * If a custom mesh has been set (Default: false)
  57375. */
  57376. protected _customMeshSet: boolean;
  57377. /**
  57378. * Mesh that the gizmo will be attached to. (eg. on a drag gizmo the mesh that will be dragged)
  57379. * * When set, interactions will be enabled
  57380. */
  57381. get attachedMesh(): Nullable<AbstractMesh>;
  57382. set attachedMesh(value: Nullable<AbstractMesh>);
  57383. /**
  57384. * Node that the gizmo will be attached to. (eg. on a drag gizmo the mesh, bone or NodeTransform that will be dragged)
  57385. * * When set, interactions will be enabled
  57386. */
  57387. get attachedNode(): Nullable<Node>;
  57388. set attachedNode(value: Nullable<Node>);
  57389. /**
  57390. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  57391. * @param mesh The mesh to replace the default mesh of the gizmo
  57392. */
  57393. setCustomMesh(mesh: Mesh): void;
  57394. protected _updateGizmoRotationToMatchAttachedMesh: boolean;
  57395. /**
  57396. * If set the gizmo's rotation will be updated to match the attached mesh each frame (Default: true)
  57397. */
  57398. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  57399. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  57400. /**
  57401. * If set the gizmo's position will be updated to match the attached mesh each frame (Default: true)
  57402. */
  57403. updateGizmoPositionToMatchAttachedMesh: boolean;
  57404. /**
  57405. * When set, the gizmo will always appear the same size no matter where the camera is (default: true)
  57406. */
  57407. updateScale: boolean;
  57408. protected _interactionsEnabled: boolean;
  57409. protected _attachedNodeChanged(value: Nullable<Node>): void;
  57410. private _beforeRenderObserver;
  57411. private _tempQuaternion;
  57412. private _tempVector;
  57413. private _tempVector2;
  57414. private _tempMatrix1;
  57415. private _tempMatrix2;
  57416. private _rightHandtoLeftHandMatrix;
  57417. /**
  57418. * Creates a gizmo
  57419. * @param gizmoLayer The utility layer the gizmo will be added to
  57420. */
  57421. constructor(
  57422. /** The utility layer the gizmo will be added to */
  57423. gizmoLayer?: UtilityLayerRenderer);
  57424. /**
  57425. * Updates the gizmo to match the attached mesh's position/rotation
  57426. */
  57427. protected _update(): void;
  57428. /**
  57429. * computes the rotation/scaling/position of the transform once the Node world matrix has changed.
  57430. * @param value Node, TransformNode or mesh
  57431. */
  57432. protected _matrixChanged(): void;
  57433. /**
  57434. * Subscribes to pointer up, down, and hover events. Used for responsive gizmos.
  57435. * @param gizmoLayer The utility layer the gizmo will be added to
  57436. * @param gizmoAxisCache Gizmo axis definition used for reactive gizmo UI
  57437. * @returns {Observer<PointerInfo>} pointerObserver
  57438. */
  57439. static GizmoAxisPointerObserver(gizmoLayer: UtilityLayerRenderer, gizmoAxisCache: Map<Mesh, GizmoAxisCache>): Observer<PointerInfo>;
  57440. /**
  57441. * Disposes of the gizmo
  57442. */
  57443. dispose(): void;
  57444. }
  57445. }
  57446. declare module BABYLON {
  57447. /**
  57448. * Single plane drag gizmo
  57449. */
  57450. export class PlaneDragGizmo extends Gizmo {
  57451. /**
  57452. * Drag behavior responsible for the gizmos dragging interactions
  57453. */
  57454. dragBehavior: PointerDragBehavior;
  57455. private _pointerObserver;
  57456. /**
  57457. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  57458. */
  57459. snapDistance: number;
  57460. /**
  57461. * Event that fires each time the gizmo snaps to a new location.
  57462. * * snapDistance is the the change in distance
  57463. */
  57464. onSnapObservable: Observable<{
  57465. snapDistance: number;
  57466. }>;
  57467. private _gizmoMesh;
  57468. private _coloredMaterial;
  57469. private _hoverMaterial;
  57470. private _disableMaterial;
  57471. private _isEnabled;
  57472. private _parent;
  57473. private _dragging;
  57474. /** @hidden */
  57475. static _CreatePlane(scene: Scene, material: StandardMaterial): TransformNode;
  57476. /**
  57477. * Creates a PlaneDragGizmo
  57478. * @param gizmoLayer The utility layer the gizmo will be added to
  57479. * @param dragPlaneNormal The axis normal to which the gizmo will be able to drag on
  57480. * @param color The color of the gizmo
  57481. */
  57482. constructor(dragPlaneNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>);
  57483. protected _attachedNodeChanged(value: Nullable<Node>): void;
  57484. /**
  57485. * If the gizmo is enabled
  57486. */
  57487. set isEnabled(value: boolean);
  57488. get isEnabled(): boolean;
  57489. /**
  57490. * Disposes of the gizmo
  57491. */
  57492. dispose(): void;
  57493. }
  57494. }
  57495. declare module BABYLON {
  57496. /**
  57497. * Single plane rotation gizmo
  57498. */
  57499. export class PlaneRotationGizmo extends Gizmo {
  57500. /**
  57501. * Drag behavior responsible for the gizmos dragging interactions
  57502. */
  57503. dragBehavior: PointerDragBehavior;
  57504. private _pointerObserver;
  57505. /**
  57506. * Rotation distance in radians that the gizmo will snap to (Default: 0)
  57507. */
  57508. snapDistance: number;
  57509. /**
  57510. * Event that fires each time the gizmo snaps to a new location.
  57511. * * snapDistance is the the change in distance
  57512. */
  57513. onSnapObservable: Observable<{
  57514. snapDistance: number;
  57515. }>;
  57516. private _isEnabled;
  57517. private _parent;
  57518. private _coloredMaterial;
  57519. private _hoverMaterial;
  57520. private _disableMaterial;
  57521. private _gizmoMesh;
  57522. private _rotationCircle;
  57523. private _dragging;
  57524. private static _CircleConstants;
  57525. /**
  57526. * Creates a PlaneRotationGizmo
  57527. * @param gizmoLayer The utility layer the gizmo will be added to
  57528. * @param planeNormal The normal of the plane which the gizmo will be able to rotate on
  57529. * @param color The color of the gizmo
  57530. * @param tessellation Amount of tessellation to be used when creating rotation circles
  57531. * @param useEulerRotation Use and update Euler angle instead of quaternion
  57532. * @param thickness display gizmo axis thickness
  57533. */
  57534. constructor(planeNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, tessellation?: number, parent?: Nullable<RotationGizmo>, useEulerRotation?: boolean, thickness?: number);
  57535. /** Create Geometry for Gizmo */
  57536. private _createGizmoMesh;
  57537. protected _attachedNodeChanged(value: Nullable<Node>): void;
  57538. private setupRotationCircle;
  57539. private updateRotationPath;
  57540. private updateRotationCircle;
  57541. /**
  57542. * If the gizmo is enabled
  57543. */
  57544. set isEnabled(value: boolean);
  57545. get isEnabled(): boolean;
  57546. /**
  57547. * Disposes of the gizmo
  57548. */
  57549. dispose(): void;
  57550. }
  57551. }
  57552. declare module BABYLON {
  57553. /**
  57554. * Gizmo that enables rotating a mesh along 3 axis
  57555. */
  57556. export class RotationGizmo extends Gizmo {
  57557. /**
  57558. * Internal gizmo used for interactions on the x axis
  57559. */
  57560. xGizmo: PlaneRotationGizmo;
  57561. /**
  57562. * Internal gizmo used for interactions on the y axis
  57563. */
  57564. yGizmo: PlaneRotationGizmo;
  57565. /**
  57566. * Internal gizmo used for interactions on the z axis
  57567. */
  57568. zGizmo: PlaneRotationGizmo;
  57569. /** Fires an event when any of it's sub gizmos are dragged */
  57570. onDragStartObservable: Observable<unknown>;
  57571. /** Fires an event when any of it's sub gizmos are released from dragging */
  57572. onDragEndObservable: Observable<unknown>;
  57573. private _meshAttached;
  57574. private _nodeAttached;
  57575. private _observables;
  57576. /** Node Caching for quick lookup */
  57577. private _gizmoAxisCache;
  57578. get attachedMesh(): Nullable<AbstractMesh>;
  57579. set attachedMesh(mesh: Nullable<AbstractMesh>);
  57580. get attachedNode(): Nullable<Node>;
  57581. set attachedNode(node: Nullable<Node>);
  57582. protected _checkBillboardTransform(): void;
  57583. /**
  57584. * True when the mouse pointer is hovering a gizmo mesh
  57585. */
  57586. get isHovered(): boolean;
  57587. /**
  57588. * Creates a RotationGizmo
  57589. * @param gizmoLayer The utility layer the gizmo will be added to
  57590. * @param tessellation Amount of tessellation to be used when creating rotation circles
  57591. * @param useEulerRotation Use and update Euler angle instead of quaternion
  57592. * @param thickness display gizmo axis thickness
  57593. */
  57594. constructor(gizmoLayer?: UtilityLayerRenderer, tessellation?: number, useEulerRotation?: boolean, thickness?: number, gizmoManager?: GizmoManager);
  57595. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  57596. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  57597. /**
  57598. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  57599. */
  57600. set snapDistance(value: number);
  57601. get snapDistance(): number;
  57602. /**
  57603. * Ratio for the scale of the gizmo (Default: 1)
  57604. */
  57605. set scaleRatio(value: number);
  57606. get scaleRatio(): number;
  57607. /**
  57608. * Builds Gizmo Axis Cache to enable features such as hover state preservation and graying out other axis during manipulation
  57609. * @param mesh Axis gizmo mesh
  57610. * @param cache Gizmo axis definition used for reactive gizmo UI
  57611. */
  57612. addToAxisCache(mesh: Mesh, cache: GizmoAxisCache): void;
  57613. /**
  57614. * Disposes of the gizmo
  57615. */
  57616. dispose(): void;
  57617. /**
  57618. * CustomMeshes are not supported by this gizmo
  57619. * @param mesh The mesh to replace the default mesh of the gizmo
  57620. */
  57621. setCustomMesh(mesh: Mesh): void;
  57622. }
  57623. }
  57624. declare module BABYLON {
  57625. /**
  57626. * Class containing static functions to help procedurally build meshes
  57627. */
  57628. export class PolyhedronBuilder {
  57629. /**
  57630. * Creates a polyhedron mesh
  57631. * * 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
  57632. * * The parameter `size` (positive float, default 1) sets the polygon size
  57633. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  57634. * * You can build other polyhedron types than the 15 embbeded ones by setting the parameter `custom` (`polyhedronObject`, default null). If you set the parameter `custom`, this overrides the parameter `type`
  57635. * * 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
  57636. * * 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)`)
  57637. * * 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
  57638. * * 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
  57639. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  57640. * * 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
  57641. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  57642. * @param name defines the name of the mesh
  57643. * @param options defines the options used to create the mesh
  57644. * @param scene defines the hosting scene
  57645. * @returns the polyhedron mesh
  57646. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  57647. */
  57648. static CreatePolyhedron(name: string, options: {
  57649. type?: number;
  57650. size?: number;
  57651. sizeX?: number;
  57652. sizeY?: number;
  57653. sizeZ?: number;
  57654. custom?: any;
  57655. faceUV?: Vector4[];
  57656. faceColors?: Color4[];
  57657. flat?: boolean;
  57658. updatable?: boolean;
  57659. sideOrientation?: number;
  57660. frontUVs?: Vector4;
  57661. backUVs?: Vector4;
  57662. }, scene?: Nullable<Scene>): Mesh;
  57663. }
  57664. }
  57665. declare module BABYLON {
  57666. /**
  57667. * Class containing static functions to help procedurally build meshes
  57668. */
  57669. export class BoxBuilder {
  57670. /**
  57671. * Creates a box mesh
  57672. * * The parameter `size` sets the size (float) of each box side (default 1)
  57673. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  57674. * * 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)
  57675. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  57676. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  57677. * * 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
  57678. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  57679. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  57680. * @param name defines the name of the mesh
  57681. * @param options defines the options used to create the mesh
  57682. * @param scene defines the hosting scene
  57683. * @returns the box mesh
  57684. */
  57685. static CreateBox(name: string, options: {
  57686. size?: number;
  57687. width?: number;
  57688. height?: number;
  57689. depth?: number;
  57690. faceUV?: Vector4[];
  57691. faceColors?: Color4[];
  57692. sideOrientation?: number;
  57693. frontUVs?: Vector4;
  57694. backUVs?: Vector4;
  57695. wrap?: boolean;
  57696. topBaseAt?: number;
  57697. bottomBaseAt?: number;
  57698. updatable?: boolean;
  57699. }, scene?: Nullable<Scene>): Mesh;
  57700. }
  57701. }
  57702. declare module BABYLON {
  57703. /**
  57704. * Single axis scale gizmo
  57705. */
  57706. export class AxisScaleGizmo extends Gizmo {
  57707. /**
  57708. * Drag behavior responsible for the gizmos dragging interactions
  57709. */
  57710. dragBehavior: PointerDragBehavior;
  57711. private _pointerObserver;
  57712. /**
  57713. * Scale distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  57714. */
  57715. snapDistance: number;
  57716. /**
  57717. * Event that fires each time the gizmo snaps to a new location.
  57718. * * snapDistance is the the change in distance
  57719. */
  57720. onSnapObservable: Observable<{
  57721. snapDistance: number;
  57722. }>;
  57723. /**
  57724. * If the scaling operation should be done on all axis (default: false)
  57725. */
  57726. uniformScaling: boolean;
  57727. /**
  57728. * Custom sensitivity value for the drag strength
  57729. */
  57730. sensitivity: number;
  57731. private _isEnabled;
  57732. private _parent;
  57733. private _gizmoMesh;
  57734. private _coloredMaterial;
  57735. private _hoverMaterial;
  57736. private _disableMaterial;
  57737. private _dragging;
  57738. private _tmpVector;
  57739. private _tmpMatrix;
  57740. private _tmpMatrix2;
  57741. /**
  57742. * Creates an AxisScaleGizmo
  57743. * @param gizmoLayer The utility layer the gizmo will be added to
  57744. * @param dragAxis The axis which the gizmo will be able to scale on
  57745. * @param color The color of the gizmo
  57746. * @param thickness display gizmo axis thickness
  57747. */
  57748. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<ScaleGizmo>, thickness?: number);
  57749. /** Create Geometry for Gizmo */
  57750. private _createGizmoMesh;
  57751. protected _attachedNodeChanged(value: Nullable<Node>): void;
  57752. /**
  57753. * If the gizmo is enabled
  57754. */
  57755. set isEnabled(value: boolean);
  57756. get isEnabled(): boolean;
  57757. /**
  57758. * Disposes of the gizmo
  57759. */
  57760. dispose(): void;
  57761. /**
  57762. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  57763. * @param mesh The mesh to replace the default mesh of the gizmo
  57764. * @param useGizmoMaterial If the gizmo's default material should be used (default: false)
  57765. */
  57766. setCustomMesh(mesh: Mesh, useGizmoMaterial?: boolean): void;
  57767. }
  57768. }
  57769. declare module BABYLON {
  57770. /**
  57771. * Gizmo that enables scaling a mesh along 3 axis
  57772. */
  57773. export class ScaleGizmo extends Gizmo {
  57774. /**
  57775. * Internal gizmo used for interactions on the x axis
  57776. */
  57777. xGizmo: AxisScaleGizmo;
  57778. /**
  57779. * Internal gizmo used for interactions on the y axis
  57780. */
  57781. yGizmo: AxisScaleGizmo;
  57782. /**
  57783. * Internal gizmo used for interactions on the z axis
  57784. */
  57785. zGizmo: AxisScaleGizmo;
  57786. /**
  57787. * Internal gizmo used to scale all axis equally
  57788. */
  57789. uniformScaleGizmo: AxisScaleGizmo;
  57790. private _meshAttached;
  57791. private _nodeAttached;
  57792. private _snapDistance;
  57793. private _uniformScalingMesh;
  57794. private _octahedron;
  57795. private _sensitivity;
  57796. private _coloredMaterial;
  57797. private _hoverMaterial;
  57798. private _disableMaterial;
  57799. private _observables;
  57800. /** Node Caching for quick lookup */
  57801. private _gizmoAxisCache;
  57802. /** Fires an event when any of it's sub gizmos are dragged */
  57803. onDragStartObservable: Observable<unknown>;
  57804. /** Fires an event when any of it's sub gizmos are released from dragging */
  57805. onDragEndObservable: Observable<unknown>;
  57806. get attachedMesh(): Nullable<AbstractMesh>;
  57807. set attachedMesh(mesh: Nullable<AbstractMesh>);
  57808. get attachedNode(): Nullable<Node>;
  57809. set attachedNode(node: Nullable<Node>);
  57810. /**
  57811. * True when the mouse pointer is hovering a gizmo mesh
  57812. */
  57813. get isHovered(): boolean;
  57814. /**
  57815. * Creates a ScaleGizmo
  57816. * @param gizmoLayer The utility layer the gizmo will be added to
  57817. * @param thickness display gizmo axis thickness
  57818. */
  57819. constructor(gizmoLayer?: UtilityLayerRenderer, thickness?: number, gizmoManager?: GizmoManager);
  57820. /** Create Geometry for Gizmo */
  57821. private _createUniformScaleMesh;
  57822. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  57823. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  57824. /**
  57825. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  57826. */
  57827. set snapDistance(value: number);
  57828. get snapDistance(): number;
  57829. /**
  57830. * Ratio for the scale of the gizmo (Default: 1)
  57831. */
  57832. set scaleRatio(value: number);
  57833. get scaleRatio(): number;
  57834. /**
  57835. * Sensitivity factor for dragging (Default: 1)
  57836. */
  57837. set sensitivity(value: number);
  57838. get sensitivity(): number;
  57839. /**
  57840. * Builds Gizmo Axis Cache to enable features such as hover state preservation and graying out other axis during manipulation
  57841. * @param mesh Axis gizmo mesh
  57842. * @param cache Gizmo axis definition used for reactive gizmo UI
  57843. */
  57844. addToAxisCache(mesh: Mesh, cache: GizmoAxisCache): void;
  57845. /**
  57846. * Disposes of the gizmo
  57847. */
  57848. dispose(): void;
  57849. }
  57850. }
  57851. declare module BABYLON {
  57852. /**
  57853. * Bounding box gizmo
  57854. */
  57855. export class BoundingBoxGizmo extends Gizmo {
  57856. private _lineBoundingBox;
  57857. private _rotateSpheresParent;
  57858. private _scaleBoxesParent;
  57859. private _boundingDimensions;
  57860. private _renderObserver;
  57861. private _pointerObserver;
  57862. private _scaleDragSpeed;
  57863. private _tmpQuaternion;
  57864. private _tmpVector;
  57865. private _tmpRotationMatrix;
  57866. /**
  57867. * If child meshes should be ignored when calculating the bounding box. This should be set to true to avoid perf hits with heavily nested meshes (Default: false)
  57868. */
  57869. ignoreChildren: boolean;
  57870. /**
  57871. * 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)
  57872. */
  57873. includeChildPredicate: Nullable<(abstractMesh: AbstractMesh) => boolean>;
  57874. /**
  57875. * The size of the rotation spheres attached to the bounding box (Default: 0.1)
  57876. */
  57877. rotationSphereSize: number;
  57878. /**
  57879. * The size of the scale boxes attached to the bounding box (Default: 0.1)
  57880. */
  57881. scaleBoxSize: number;
  57882. /**
  57883. * 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)
  57884. * Note : fixedDragMeshScreenSize takes precedence over fixedDragMeshBoundsSize if both are true
  57885. */
  57886. fixedDragMeshScreenSize: boolean;
  57887. /**
  57888. * If set, the rotation spheres and scale boxes will increase in size based on the size of the bounding box
  57889. * Note : fixedDragMeshScreenSize takes precedence over fixedDragMeshBoundsSize if both are true
  57890. */
  57891. fixedDragMeshBoundsSize: boolean;
  57892. /**
  57893. * The distance away from the object which the draggable meshes should appear world sized when fixedDragMeshScreenSize is set to true (default: 10)
  57894. */
  57895. fixedDragMeshScreenSizeDistanceFactor: number;
  57896. /**
  57897. * Fired when a rotation sphere or scale box is dragged
  57898. */
  57899. onDragStartObservable: Observable<{}>;
  57900. /**
  57901. * Fired when a scale box is dragged
  57902. */
  57903. onScaleBoxDragObservable: Observable<{}>;
  57904. /**
  57905. * Fired when a scale box drag is ended
  57906. */
  57907. onScaleBoxDragEndObservable: Observable<{}>;
  57908. /**
  57909. * Fired when a rotation sphere is dragged
  57910. */
  57911. onRotationSphereDragObservable: Observable<{}>;
  57912. /**
  57913. * Fired when a rotation sphere drag is ended
  57914. */
  57915. onRotationSphereDragEndObservable: Observable<{}>;
  57916. /**
  57917. * 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)
  57918. */
  57919. scalePivot: Nullable<Vector3>;
  57920. /**
  57921. * Mesh used as a pivot to rotate the attached node
  57922. */
  57923. private _anchorMesh;
  57924. private _existingMeshScale;
  57925. private _dragMesh;
  57926. private pointerDragBehavior;
  57927. private coloredMaterial;
  57928. private hoverColoredMaterial;
  57929. /**
  57930. * Sets the color of the bounding box gizmo
  57931. * @param color the color to set
  57932. */
  57933. setColor(color: Color3): void;
  57934. /**
  57935. * Creates an BoundingBoxGizmo
  57936. * @param gizmoLayer The utility layer the gizmo will be added to
  57937. * @param color The color of the gizmo
  57938. */
  57939. constructor(color?: Color3, gizmoLayer?: UtilityLayerRenderer);
  57940. protected _attachedNodeChanged(value: Nullable<AbstractMesh>): void;
  57941. private _selectNode;
  57942. /**
  57943. * Updates the bounding box information for the Gizmo
  57944. */
  57945. updateBoundingBox(): void;
  57946. private _updateRotationSpheres;
  57947. private _updateScaleBoxes;
  57948. /**
  57949. * Enables rotation on the specified axis and disables rotation on the others
  57950. * @param axis The list of axis that should be enabled (eg. "xy" or "xyz")
  57951. */
  57952. setEnabledRotationAxis(axis: string): void;
  57953. /**
  57954. * Enables/disables scaling
  57955. * @param enable if scaling should be enabled
  57956. * @param homogeneousScaling defines if scaling should only be homogeneous
  57957. */
  57958. setEnabledScaling(enable: boolean, homogeneousScaling?: boolean): void;
  57959. private _updateDummy;
  57960. /**
  57961. * Enables a pointer drag behavior on the bounding box of the gizmo
  57962. */
  57963. enableDragBehavior(): void;
  57964. /**
  57965. * Disposes of the gizmo
  57966. */
  57967. dispose(): void;
  57968. /**
  57969. * 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)
  57970. * @param mesh the mesh to wrap in the bounding box mesh and make not pickable
  57971. * @returns the bounding box mesh with the passed in mesh as a child
  57972. */
  57973. static MakeNotPickableAndWrapInBoundingBox(mesh: Mesh): Mesh;
  57974. /**
  57975. * CustomMeshes are not supported by this gizmo
  57976. * @param mesh The mesh to replace the default mesh of the gizmo
  57977. */
  57978. setCustomMesh(mesh: Mesh): void;
  57979. }
  57980. }
  57981. declare module BABYLON {
  57982. /**
  57983. * Helps setup gizmo's in the scene to rotate/scale/position nodes
  57984. */
  57985. export class GizmoManager implements IDisposable {
  57986. private scene;
  57987. /**
  57988. * Gizmo's created by the gizmo manager, gizmo will be null until gizmo has been enabled for the first time
  57989. */
  57990. gizmos: {
  57991. positionGizmo: Nullable<PositionGizmo>;
  57992. rotationGizmo: Nullable<RotationGizmo>;
  57993. scaleGizmo: Nullable<ScaleGizmo>;
  57994. boundingBoxGizmo: Nullable<BoundingBoxGizmo>;
  57995. };
  57996. /** When true, the gizmo will be detached from the current object when a pointer down occurs with an empty picked mesh */
  57997. clearGizmoOnEmptyPointerEvent: boolean;
  57998. /** Fires an event when the manager is attached to a mesh */
  57999. onAttachedToMeshObservable: Observable<Nullable<AbstractMesh>>;
  58000. /** Fires an event when the manager is attached to a node */
  58001. onAttachedToNodeObservable: Observable<Nullable<Node>>;
  58002. private _gizmosEnabled;
  58003. private _pointerObservers;
  58004. private _attachedMesh;
  58005. private _attachedNode;
  58006. private _boundingBoxColor;
  58007. private _defaultUtilityLayer;
  58008. private _defaultKeepDepthUtilityLayer;
  58009. private _thickness;
  58010. /** Node Caching for quick lookup */
  58011. private _gizmoAxisCache;
  58012. /**
  58013. * When bounding box gizmo is enabled, this can be used to track drag/end events
  58014. */
  58015. boundingBoxDragBehavior: SixDofDragBehavior;
  58016. /**
  58017. * Array of meshes which will have the gizmo attached when a pointer selected them. If null, all meshes are attachable. (Default: null)
  58018. */
  58019. attachableMeshes: Nullable<Array<AbstractMesh>>;
  58020. /**
  58021. * Array of nodes which will have the gizmo attached when a pointer selected them. If null, all nodes are attachable. (Default: null)
  58022. */
  58023. attachableNodes: Nullable<Array<Node>>;
  58024. /**
  58025. * If pointer events should perform attaching/detaching a gizmo, if false this can be done manually via attachToMesh/attachToNode. (Default: true)
  58026. */
  58027. usePointerToAttachGizmos: boolean;
  58028. /**
  58029. * Utility layer that the bounding box gizmo belongs to
  58030. */
  58031. get keepDepthUtilityLayer(): UtilityLayerRenderer;
  58032. /**
  58033. * Utility layer that all gizmos besides bounding box belong to
  58034. */
  58035. get utilityLayer(): UtilityLayerRenderer;
  58036. /**
  58037. * True when the mouse pointer is hovering a gizmo mesh
  58038. */
  58039. get isHovered(): boolean;
  58040. /**
  58041. * Instantiates a gizmo manager
  58042. * @param scene the scene to overlay the gizmos on top of
  58043. * @param thickness display gizmo axis thickness
  58044. * @param utilityLayer the layer where gizmos are rendered
  58045. * @param keepDepthUtilityLayer the layer where occluded gizmos are rendered
  58046. */
  58047. constructor(scene: Scene, thickness?: number, utilityLayer?: UtilityLayerRenderer, keepDepthUtilityLayer?: UtilityLayerRenderer);
  58048. /**
  58049. * Subscribes to pointer down events, for attaching and detaching mesh
  58050. * @param scene The scene layer the observer will be added to
  58051. */
  58052. private _attachToMeshPointerObserver;
  58053. /**
  58054. * Attaches a set of gizmos to the specified mesh
  58055. * @param mesh The mesh the gizmo's should be attached to
  58056. */
  58057. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  58058. /**
  58059. * Attaches a set of gizmos to the specified node
  58060. * @param node The node the gizmo's should be attached to
  58061. */
  58062. attachToNode(node: Nullable<Node>): void;
  58063. /**
  58064. * If the position gizmo is enabled
  58065. */
  58066. set positionGizmoEnabled(value: boolean);
  58067. get positionGizmoEnabled(): boolean;
  58068. /**
  58069. * If the rotation gizmo is enabled
  58070. */
  58071. set rotationGizmoEnabled(value: boolean);
  58072. get rotationGizmoEnabled(): boolean;
  58073. /**
  58074. * If the scale gizmo is enabled
  58075. */
  58076. set scaleGizmoEnabled(value: boolean);
  58077. get scaleGizmoEnabled(): boolean;
  58078. /**
  58079. * If the boundingBox gizmo is enabled
  58080. */
  58081. set boundingBoxGizmoEnabled(value: boolean);
  58082. get boundingBoxGizmoEnabled(): boolean;
  58083. /**
  58084. * Builds Gizmo Axis Cache to enable features such as hover state preservation and graying out other axis during manipulation
  58085. * @param gizmoAxisCache Gizmo axis definition used for reactive gizmo UI
  58086. */
  58087. addToAxisCache(gizmoAxisCache: Map<Mesh, GizmoAxisCache>): void;
  58088. /**
  58089. * Disposes of the gizmo manager
  58090. */
  58091. dispose(): void;
  58092. }
  58093. }
  58094. declare module BABYLON {
  58095. /**
  58096. * Gizmo that enables dragging a mesh along 3 axis
  58097. */
  58098. export class PositionGizmo extends Gizmo {
  58099. /**
  58100. * Internal gizmo used for interactions on the x axis
  58101. */
  58102. xGizmo: AxisDragGizmo;
  58103. /**
  58104. * Internal gizmo used for interactions on the y axis
  58105. */
  58106. yGizmo: AxisDragGizmo;
  58107. /**
  58108. * Internal gizmo used for interactions on the z axis
  58109. */
  58110. zGizmo: AxisDragGizmo;
  58111. /**
  58112. * Internal gizmo used for interactions on the yz plane
  58113. */
  58114. xPlaneGizmo: PlaneDragGizmo;
  58115. /**
  58116. * Internal gizmo used for interactions on the xz plane
  58117. */
  58118. yPlaneGizmo: PlaneDragGizmo;
  58119. /**
  58120. * Internal gizmo used for interactions on the xy plane
  58121. */
  58122. zPlaneGizmo: PlaneDragGizmo;
  58123. /**
  58124. * private variables
  58125. */
  58126. private _meshAttached;
  58127. private _nodeAttached;
  58128. private _snapDistance;
  58129. private _observables;
  58130. /** Node Caching for quick lookup */
  58131. private _gizmoAxisCache;
  58132. /** Fires an event when any of it's sub gizmos are dragged */
  58133. onDragStartObservable: Observable<unknown>;
  58134. /** Fires an event when any of it's sub gizmos are released from dragging */
  58135. onDragEndObservable: Observable<unknown>;
  58136. /**
  58137. * If set to true, planar drag is enabled
  58138. */
  58139. private _planarGizmoEnabled;
  58140. get attachedMesh(): Nullable<AbstractMesh>;
  58141. set attachedMesh(mesh: Nullable<AbstractMesh>);
  58142. get attachedNode(): Nullable<Node>;
  58143. set attachedNode(node: Nullable<Node>);
  58144. /**
  58145. * True when the mouse pointer is hovering a gizmo mesh
  58146. */
  58147. get isHovered(): boolean;
  58148. /**
  58149. * Creates a PositionGizmo
  58150. * @param gizmoLayer The utility layer the gizmo will be added to
  58151. @param thickness display gizmo axis thickness
  58152. */
  58153. constructor(gizmoLayer?: UtilityLayerRenderer, thickness?: number, gizmoManager?: GizmoManager);
  58154. /**
  58155. * If the planar drag gizmo is enabled
  58156. * setting this will enable/disable XY, XZ and YZ planes regardless of individual gizmo settings.
  58157. */
  58158. set planarGizmoEnabled(value: boolean);
  58159. get planarGizmoEnabled(): boolean;
  58160. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  58161. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  58162. /**
  58163. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  58164. */
  58165. set snapDistance(value: number);
  58166. get snapDistance(): number;
  58167. /**
  58168. * Ratio for the scale of the gizmo (Default: 1)
  58169. */
  58170. set scaleRatio(value: number);
  58171. get scaleRatio(): number;
  58172. /**
  58173. * Builds Gizmo Axis Cache to enable features such as hover state preservation and graying out other axis during manipulation
  58174. * @param mesh Axis gizmo mesh
  58175. * @param cache Gizmo axis definition used for reactive gizmo UI
  58176. */
  58177. addToAxisCache(mesh: Mesh, cache: GizmoAxisCache): void;
  58178. /**
  58179. * Disposes of the gizmo
  58180. */
  58181. dispose(): void;
  58182. /**
  58183. * CustomMeshes are not supported by this gizmo
  58184. * @param mesh The mesh to replace the default mesh of the gizmo
  58185. */
  58186. setCustomMesh(mesh: Mesh): void;
  58187. }
  58188. }
  58189. declare module BABYLON {
  58190. /**
  58191. * Single axis drag gizmo
  58192. */
  58193. export class AxisDragGizmo extends Gizmo {
  58194. /**
  58195. * Drag behavior responsible for the gizmos dragging interactions
  58196. */
  58197. dragBehavior: PointerDragBehavior;
  58198. private _pointerObserver;
  58199. /**
  58200. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  58201. */
  58202. snapDistance: number;
  58203. /**
  58204. * Event that fires each time the gizmo snaps to a new location.
  58205. * * snapDistance is the the change in distance
  58206. */
  58207. onSnapObservable: Observable<{
  58208. snapDistance: number;
  58209. }>;
  58210. private _isEnabled;
  58211. private _parent;
  58212. private _gizmoMesh;
  58213. private _coloredMaterial;
  58214. private _hoverMaterial;
  58215. private _disableMaterial;
  58216. private _dragging;
  58217. /** @hidden */
  58218. static _CreateArrow(scene: Scene, material: StandardMaterial, thickness?: number, isCollider?: boolean): TransformNode;
  58219. /** @hidden */
  58220. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  58221. /**
  58222. * Creates an AxisDragGizmo
  58223. * @param gizmoLayer The utility layer the gizmo will be added to
  58224. * @param dragAxis The axis which the gizmo will be able to drag on
  58225. * @param color The color of the gizmo
  58226. * @param thickness display gizmo axis thickness
  58227. */
  58228. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>, thickness?: number);
  58229. protected _attachedNodeChanged(value: Nullable<Node>): void;
  58230. /**
  58231. * If the gizmo is enabled
  58232. */
  58233. set isEnabled(value: boolean);
  58234. get isEnabled(): boolean;
  58235. /**
  58236. * Disposes of the gizmo
  58237. */
  58238. dispose(): void;
  58239. }
  58240. }
  58241. declare module BABYLON.Debug {
  58242. /**
  58243. * The Axes viewer will show 3 axes in a specific point in space
  58244. */
  58245. export class AxesViewer {
  58246. private _xAxis;
  58247. private _yAxis;
  58248. private _zAxis;
  58249. private _scaleLinesFactor;
  58250. private _instanced;
  58251. /**
  58252. * Gets the hosting scene
  58253. */
  58254. scene: Nullable<Scene>;
  58255. /**
  58256. * Gets or sets a number used to scale line length
  58257. */
  58258. scaleLines: number;
  58259. /** Gets the node hierarchy used to render x-axis */
  58260. get xAxis(): TransformNode;
  58261. /** Gets the node hierarchy used to render y-axis */
  58262. get yAxis(): TransformNode;
  58263. /** Gets the node hierarchy used to render z-axis */
  58264. get zAxis(): TransformNode;
  58265. /**
  58266. * Creates a new AxesViewer
  58267. * @param scene defines the hosting scene
  58268. * @param scaleLines defines a number used to scale line length (1 by default)
  58269. * @param renderingGroupId defines a number used to set the renderingGroupId of the meshes (2 by default)
  58270. * @param xAxis defines the node hierarchy used to render the x-axis
  58271. * @param yAxis defines the node hierarchy used to render the y-axis
  58272. * @param zAxis defines the node hierarchy used to render the z-axis
  58273. */
  58274. constructor(scene: Scene, scaleLines?: number, renderingGroupId?: Nullable<number>, xAxis?: TransformNode, yAxis?: TransformNode, zAxis?: TransformNode);
  58275. /**
  58276. * Force the viewer to update
  58277. * @param position defines the position of the viewer
  58278. * @param xaxis defines the x axis of the viewer
  58279. * @param yaxis defines the y axis of the viewer
  58280. * @param zaxis defines the z axis of the viewer
  58281. */
  58282. update(position: Vector3, xaxis: Vector3, yaxis: Vector3, zaxis: Vector3): void;
  58283. /**
  58284. * Creates an instance of this axes viewer.
  58285. * @returns a new axes viewer with instanced meshes
  58286. */
  58287. createInstance(): AxesViewer;
  58288. /** Releases resources */
  58289. dispose(): void;
  58290. private static _SetRenderingGroupId;
  58291. }
  58292. }
  58293. declare module BABYLON.Debug {
  58294. /**
  58295. * The BoneAxesViewer will attach 3 axes to a specific bone of a specific mesh
  58296. * @see demo here: https://www.babylonjs-playground.com/#0DE8F4#8
  58297. */
  58298. export class BoneAxesViewer extends AxesViewer {
  58299. /**
  58300. * Gets or sets the target mesh where to display the axes viewer
  58301. */
  58302. mesh: Nullable<Mesh>;
  58303. /**
  58304. * Gets or sets the target bone where to display the axes viewer
  58305. */
  58306. bone: Nullable<Bone>;
  58307. /** Gets current position */
  58308. pos: Vector3;
  58309. /** Gets direction of X axis */
  58310. xaxis: Vector3;
  58311. /** Gets direction of Y axis */
  58312. yaxis: Vector3;
  58313. /** Gets direction of Z axis */
  58314. zaxis: Vector3;
  58315. /**
  58316. * Creates a new BoneAxesViewer
  58317. * @param scene defines the hosting scene
  58318. * @param bone defines the target bone
  58319. * @param mesh defines the target mesh
  58320. * @param scaleLines defines a scaling factor for line length (1 by default)
  58321. */
  58322. constructor(scene: Scene, bone: Bone, mesh: Mesh, scaleLines?: number);
  58323. /**
  58324. * Force the viewer to update
  58325. */
  58326. update(): void;
  58327. /** Releases resources */
  58328. dispose(): void;
  58329. }
  58330. }
  58331. declare module BABYLON {
  58332. /**
  58333. * Interface used to define scene explorer extensibility option
  58334. */
  58335. export interface IExplorerExtensibilityOption {
  58336. /**
  58337. * Define the option label
  58338. */
  58339. label: string;
  58340. /**
  58341. * Defines the action to execute on click
  58342. */
  58343. action: (entity: any) => void;
  58344. }
  58345. /**
  58346. * Defines a group of actions associated with a predicate to use when extending the Inspector scene explorer
  58347. */
  58348. export interface IExplorerExtensibilityGroup {
  58349. /**
  58350. * Defines a predicate to test if a given type mut be extended
  58351. */
  58352. predicate: (entity: any) => boolean;
  58353. /**
  58354. * Gets the list of options added to a type
  58355. */
  58356. entries: IExplorerExtensibilityOption[];
  58357. }
  58358. /**
  58359. * Interface used to define the options to use to create the Inspector
  58360. */
  58361. export interface IInspectorOptions {
  58362. /**
  58363. * Display in overlay mode (default: false)
  58364. */
  58365. overlay?: boolean;
  58366. /**
  58367. * HTML element to use as root (the parent of the rendering canvas will be used as default value)
  58368. */
  58369. globalRoot?: HTMLElement;
  58370. /**
  58371. * Display the Scene explorer
  58372. */
  58373. showExplorer?: boolean;
  58374. /**
  58375. * Display the property inspector
  58376. */
  58377. showInspector?: boolean;
  58378. /**
  58379. * Display in embed mode (both panes on the right)
  58380. */
  58381. embedMode?: boolean;
  58382. /**
  58383. * let the Inspector handles resize of the canvas when panes are resized (default to true)
  58384. */
  58385. handleResize?: boolean;
  58386. /**
  58387. * Allow the panes to popup (default: true)
  58388. */
  58389. enablePopup?: boolean;
  58390. /**
  58391. * Allow the panes to be closed by users (default: true)
  58392. */
  58393. enableClose?: boolean;
  58394. /**
  58395. * Optional list of extensibility entries
  58396. */
  58397. explorerExtensibility?: IExplorerExtensibilityGroup[];
  58398. /**
  58399. * Optional URL to get the inspector script from (by default it uses the babylonjs CDN).
  58400. */
  58401. inspectorURL?: string;
  58402. /**
  58403. * Optional initial tab (default to DebugLayerTab.Properties)
  58404. */
  58405. initialTab?: DebugLayerTab;
  58406. }
  58407. interface Scene {
  58408. /**
  58409. * @hidden
  58410. * Backing field
  58411. */
  58412. _debugLayer: DebugLayer;
  58413. /**
  58414. * Gets the debug layer (aka Inspector) associated with the scene
  58415. * @see https://doc.babylonjs.com/features/playground_debuglayer
  58416. */
  58417. debugLayer: DebugLayer;
  58418. }
  58419. /**
  58420. * Enum of inspector action tab
  58421. */
  58422. export enum DebugLayerTab {
  58423. /**
  58424. * Properties tag (default)
  58425. */
  58426. Properties = 0,
  58427. /**
  58428. * Debug tab
  58429. */
  58430. Debug = 1,
  58431. /**
  58432. * Statistics tab
  58433. */
  58434. Statistics = 2,
  58435. /**
  58436. * Tools tab
  58437. */
  58438. Tools = 3,
  58439. /**
  58440. * Settings tab
  58441. */
  58442. Settings = 4
  58443. }
  58444. /**
  58445. * The debug layer (aka Inspector) is the go to tool in order to better understand
  58446. * what is happening in your scene
  58447. * @see https://doc.babylonjs.com/features/playground_debuglayer
  58448. */
  58449. export class DebugLayer {
  58450. /**
  58451. * Define the url to get the inspector script from.
  58452. * By default it uses the babylonjs CDN.
  58453. * @ignoreNaming
  58454. */
  58455. static InspectorURL: string;
  58456. private _scene;
  58457. private BJSINSPECTOR;
  58458. private _onPropertyChangedObservable?;
  58459. /**
  58460. * Observable triggered when a property is changed through the inspector.
  58461. */
  58462. get onPropertyChangedObservable(): any;
  58463. /**
  58464. * Instantiates a new debug layer.
  58465. * The debug layer (aka Inspector) is the go to tool in order to better understand
  58466. * what is happening in your scene
  58467. * @see https://doc.babylonjs.com/features/playground_debuglayer
  58468. * @param scene Defines the scene to inspect
  58469. */
  58470. constructor(scene: Scene);
  58471. /** Creates the inspector window. */
  58472. private _createInspector;
  58473. /**
  58474. * Select a specific entity in the scene explorer and highlight a specific block in that entity property grid
  58475. * @param entity defines the entity to select
  58476. * @param lineContainerTitles defines the specific blocks to highlight (could be a string or an array of strings)
  58477. */
  58478. select(entity: any, lineContainerTitles?: string | string[]): void;
  58479. /** Get the inspector from bundle or global */
  58480. private _getGlobalInspector;
  58481. /**
  58482. * Get if the inspector is visible or not.
  58483. * @returns true if visible otherwise, false
  58484. */
  58485. isVisible(): boolean;
  58486. /**
  58487. * Hide the inspector and close its window.
  58488. */
  58489. hide(): void;
  58490. /**
  58491. * Update the scene in the inspector
  58492. */
  58493. setAsActiveScene(): void;
  58494. /**
  58495. * Launch the debugLayer.
  58496. * @param config Define the configuration of the inspector
  58497. * @return a promise fulfilled when the debug layer is visible
  58498. */
  58499. show(config?: IInspectorOptions): Promise<DebugLayer>;
  58500. }
  58501. }
  58502. declare module BABYLON.Debug {
  58503. /**
  58504. * Used to show the physics impostor around the specific mesh
  58505. */
  58506. export class PhysicsViewer {
  58507. /** @hidden */
  58508. protected _impostors: Array<Nullable<PhysicsImpostor>>;
  58509. /** @hidden */
  58510. protected _meshes: Array<Nullable<AbstractMesh>>;
  58511. /** @hidden */
  58512. protected _scene: Nullable<Scene>;
  58513. /** @hidden */
  58514. protected _numMeshes: number;
  58515. /** @hidden */
  58516. protected _physicsEnginePlugin: Nullable<IPhysicsEnginePlugin>;
  58517. private _renderFunction;
  58518. private _utilityLayer;
  58519. private _debugBoxMesh;
  58520. private _debugSphereMesh;
  58521. private _debugCylinderMesh;
  58522. private _debugMaterial;
  58523. private _debugMeshMeshes;
  58524. /**
  58525. * Creates a new PhysicsViewer
  58526. * @param scene defines the hosting scene
  58527. */
  58528. constructor(scene: Scene);
  58529. /** @hidden */
  58530. protected _updateDebugMeshes(): void;
  58531. /**
  58532. * Renders a specified physic impostor
  58533. * @param impostor defines the impostor to render
  58534. * @param targetMesh defines the mesh represented by the impostor
  58535. * @returns the new debug mesh used to render the impostor
  58536. */
  58537. showImpostor(impostor: PhysicsImpostor, targetMesh?: Mesh): Nullable<AbstractMesh>;
  58538. /**
  58539. * Hides a specified physic impostor
  58540. * @param impostor defines the impostor to hide
  58541. */
  58542. hideImpostor(impostor: Nullable<PhysicsImpostor>): void;
  58543. private _getDebugMaterial;
  58544. private _getDebugBoxMesh;
  58545. private _getDebugSphereMesh;
  58546. private _getDebugCylinderMesh;
  58547. private _getDebugMeshMesh;
  58548. private _getDebugMesh;
  58549. /** Releases all resources */
  58550. dispose(): void;
  58551. }
  58552. }
  58553. declare module BABYLON {
  58554. /**
  58555. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  58556. * in order to better appreciate the issue one might have.
  58557. * @see https://doc.babylonjs.com/babylon101/raycasts#debugging
  58558. */
  58559. export class RayHelper {
  58560. /**
  58561. * Defines the ray we are currently tryin to visualize.
  58562. */
  58563. ray: Nullable<Ray>;
  58564. private _renderPoints;
  58565. private _renderLine;
  58566. private _renderFunction;
  58567. private _scene;
  58568. private _onAfterRenderObserver;
  58569. private _onAfterStepObserver;
  58570. private _attachedToMesh;
  58571. private _meshSpaceDirection;
  58572. private _meshSpaceOrigin;
  58573. /**
  58574. * Helper function to create a colored helper in a scene in one line.
  58575. * @param ray Defines the ray we are currently tryin to visualize
  58576. * @param scene Defines the scene the ray is used in
  58577. * @param color Defines the color we want to see the ray in
  58578. * @returns The newly created ray helper.
  58579. */
  58580. static CreateAndShow(ray: Ray, scene: Scene, color: Color3): RayHelper;
  58581. /**
  58582. * Instantiate a new ray helper.
  58583. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  58584. * in order to better appreciate the issue one might have.
  58585. * @see https://doc.babylonjs.com/babylon101/raycasts#debugging
  58586. * @param ray Defines the ray we are currently tryin to visualize
  58587. */
  58588. constructor(ray: Ray);
  58589. /**
  58590. * Shows the ray we are willing to debug.
  58591. * @param scene Defines the scene the ray needs to be rendered in
  58592. * @param color Defines the color the ray needs to be rendered in
  58593. */
  58594. show(scene: Scene, color?: Color3): void;
  58595. /**
  58596. * Hides the ray we are debugging.
  58597. */
  58598. hide(): void;
  58599. private _render;
  58600. /**
  58601. * Attach a ray helper to a mesh so that we can easily see its orientation for instance or information like its normals.
  58602. * @param mesh Defines the mesh we want the helper attached to
  58603. * @param meshSpaceDirection Defines the direction of the Ray in mesh space (local space of the mesh node)
  58604. * @param meshSpaceOrigin Defines the origin of the Ray in mesh space (local space of the mesh node)
  58605. * @param length Defines the length of the ray
  58606. */
  58607. attachToMesh(mesh: AbstractMesh, meshSpaceDirection?: Vector3, meshSpaceOrigin?: Vector3, length?: number): void;
  58608. /**
  58609. * Detach the ray helper from the mesh it has previously been attached to.
  58610. */
  58611. detachFromMesh(): void;
  58612. private _updateToMesh;
  58613. /**
  58614. * Dispose the helper and release its associated resources.
  58615. */
  58616. dispose(): void;
  58617. }
  58618. }
  58619. declare module BABYLON {
  58620. /**
  58621. * Defines the options associated with the creation of a SkeletonViewer.
  58622. */
  58623. export interface ISkeletonViewerOptions {
  58624. /** Should the system pause animations before building the Viewer? */
  58625. pauseAnimations: boolean;
  58626. /** Should the system return the skeleton to rest before building? */
  58627. returnToRest: boolean;
  58628. /** public Display Mode of the Viewer */
  58629. displayMode: number;
  58630. /** Flag to toggle if the Viewer should use the CPU for animations or not? */
  58631. displayOptions: ISkeletonViewerDisplayOptions;
  58632. /** Flag to toggle if the Viewer should use the CPU for animations or not? */
  58633. computeBonesUsingShaders: boolean;
  58634. /** Flag ignore non weighted bones */
  58635. useAllBones: boolean;
  58636. }
  58637. /**
  58638. * Defines how to display the various bone meshes for the viewer.
  58639. */
  58640. export interface ISkeletonViewerDisplayOptions {
  58641. /** How far down to start tapering the bone spurs */
  58642. midStep?: number;
  58643. /** How big is the midStep? */
  58644. midStepFactor?: number;
  58645. /** Base for the Sphere Size */
  58646. sphereBaseSize?: number;
  58647. /** The ratio of the sphere to the longest bone in units */
  58648. sphereScaleUnit?: number;
  58649. /** Ratio for the Sphere Size */
  58650. sphereFactor?: number;
  58651. /** Whether a spur should attach its far end to the child bone position */
  58652. spurFollowsChild?: boolean;
  58653. /** Whether to show local axes or not */
  58654. showLocalAxes?: boolean;
  58655. /** Length of each local axis */
  58656. localAxesSize?: number;
  58657. }
  58658. /**
  58659. * Defines the constructor options for the BoneWeight Shader.
  58660. */
  58661. export interface IBoneWeightShaderOptions {
  58662. /** Skeleton to Map */
  58663. skeleton: Skeleton;
  58664. /** Colors for Uninfluenced bones */
  58665. colorBase?: Color3;
  58666. /** Colors for 0.0-0.25 Weight bones */
  58667. colorZero?: Color3;
  58668. /** Color for 0.25-0.5 Weight Influence */
  58669. colorQuarter?: Color3;
  58670. /** Color for 0.5-0.75 Weight Influence */
  58671. colorHalf?: Color3;
  58672. /** Color for 0.75-1 Weight Influence */
  58673. colorFull?: Color3;
  58674. /** Color for Zero Weight Influence */
  58675. targetBoneIndex?: number;
  58676. }
  58677. /**
  58678. * Simple structure of the gradient steps for the Color Map.
  58679. */
  58680. export interface ISkeletonMapShaderColorMapKnot {
  58681. /** Color of the Knot */
  58682. color: Color3;
  58683. /** Location of the Knot */
  58684. location: number;
  58685. }
  58686. /**
  58687. * Defines the constructor options for the SkeletonMap Shader.
  58688. */
  58689. export interface ISkeletonMapShaderOptions {
  58690. /** Skeleton to Map */
  58691. skeleton: Skeleton;
  58692. /** Array of ColorMapKnots that make the gradient must be ordered with knot[i].location < knot[i+1].location*/
  58693. colorMap?: ISkeletonMapShaderColorMapKnot[];
  58694. }
  58695. }
  58696. declare module BABYLON {
  58697. /**
  58698. * Class containing static functions to help procedurally build meshes
  58699. */
  58700. export class RibbonBuilder {
  58701. /**
  58702. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  58703. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  58704. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  58705. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  58706. * * 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
  58707. * * 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
  58708. * * 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
  58709. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  58710. * * 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
  58711. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  58712. * * 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
  58713. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  58714. * * 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
  58715. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  58716. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  58717. * @param name defines the name of the mesh
  58718. * @param options defines the options used to create the mesh
  58719. * @param scene defines the hosting scene
  58720. * @returns the ribbon mesh
  58721. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  58722. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  58723. */
  58724. static CreateRibbon(name: string, options: {
  58725. pathArray: Vector3[][];
  58726. closeArray?: boolean;
  58727. closePath?: boolean;
  58728. offset?: number;
  58729. updatable?: boolean;
  58730. sideOrientation?: number;
  58731. frontUVs?: Vector4;
  58732. backUVs?: Vector4;
  58733. instance?: Mesh;
  58734. invertUV?: boolean;
  58735. uvs?: Vector2[];
  58736. colors?: Color4[];
  58737. }, scene?: Nullable<Scene>): Mesh;
  58738. }
  58739. }
  58740. declare module BABYLON {
  58741. /**
  58742. * Class containing static functions to help procedurally build meshes
  58743. */
  58744. export class ShapeBuilder {
  58745. /**
  58746. * 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.
  58747. * * 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.
  58748. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  58749. * * 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.
  58750. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  58751. * * 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
  58752. * * 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
  58753. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  58754. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  58755. * * 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
  58756. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  58757. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  58758. * @param name defines the name of the mesh
  58759. * @param options defines the options used to create the mesh
  58760. * @param scene defines the hosting scene
  58761. * @returns the extruded shape mesh
  58762. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  58763. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  58764. */
  58765. static ExtrudeShape(name: string, options: {
  58766. shape: Vector3[];
  58767. path: Vector3[];
  58768. scale?: number;
  58769. rotation?: number;
  58770. cap?: number;
  58771. updatable?: boolean;
  58772. sideOrientation?: number;
  58773. frontUVs?: Vector4;
  58774. backUVs?: Vector4;
  58775. instance?: Mesh;
  58776. invertUV?: boolean;
  58777. }, scene?: Nullable<Scene>): Mesh;
  58778. /**
  58779. * Creates an custom extruded shape mesh.
  58780. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  58781. * * 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.
  58782. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  58783. * * The parameter `rotationFunction` (JS function) is a custom Javascript function called on each path point. This function is passed the position i of the point in the path and the distance of this point from the beginning of the path
  58784. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  58785. * * The parameter `scaleFunction` (JS function) is a custom Javascript function called on each path point. This function is passed the position i of the point in the path and the distance of this point from the beginning of the path
  58786. * * It must returns a float value that will be the scale value applied to the shape on each path point
  58787. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  58788. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  58789. * * 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
  58790. * * 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
  58791. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  58792. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  58793. * * 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
  58794. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  58795. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  58796. * @param name defines the name of the mesh
  58797. * @param options defines the options used to create the mesh
  58798. * @param scene defines the hosting scene
  58799. * @returns the custom extruded shape mesh
  58800. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  58801. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  58802. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  58803. */
  58804. static ExtrudeShapeCustom(name: string, options: {
  58805. shape: Vector3[];
  58806. path: Vector3[];
  58807. scaleFunction?: any;
  58808. rotationFunction?: any;
  58809. ribbonCloseArray?: boolean;
  58810. ribbonClosePath?: boolean;
  58811. cap?: number;
  58812. updatable?: boolean;
  58813. sideOrientation?: number;
  58814. frontUVs?: Vector4;
  58815. backUVs?: Vector4;
  58816. instance?: Mesh;
  58817. invertUV?: boolean;
  58818. }, scene?: Nullable<Scene>): Mesh;
  58819. private static _ExtrudeShapeGeneric;
  58820. }
  58821. }
  58822. declare module BABYLON.Debug {
  58823. /**
  58824. * Class used to render a debug view of a given skeleton
  58825. * @see http://www.babylonjs-playground.com/#1BZJVJ#8
  58826. */
  58827. export class SkeletonViewer {
  58828. /** defines the skeleton to render */
  58829. skeleton: Skeleton;
  58830. /** defines the mesh attached to the skeleton */
  58831. mesh: AbstractMesh;
  58832. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  58833. autoUpdateBonesMatrices: boolean;
  58834. /** defines the rendering group id to use with the viewer */
  58835. renderingGroupId: number;
  58836. /** is the options for the viewer */
  58837. options: Partial<ISkeletonViewerOptions>;
  58838. /** public Display constants BABYLON.SkeletonViewer.DISPLAY_LINES */
  58839. static readonly DISPLAY_LINES: number;
  58840. /** public Display constants BABYLON.SkeletonViewer.DISPLAY_SPHERES */
  58841. static readonly DISPLAY_SPHERES: number;
  58842. /** public Display constants BABYLON.SkeletonViewer.DISPLAY_SPHERE_AND_SPURS */
  58843. static readonly DISPLAY_SPHERE_AND_SPURS: number;
  58844. /** public static method to create a BoneWeight Shader
  58845. * @param options The constructor options
  58846. * @param scene The scene that the shader is scoped to
  58847. * @returns The created ShaderMaterial
  58848. * @see http://www.babylonjs-playground.com/#1BZJVJ#395
  58849. */
  58850. static CreateBoneWeightShader(options: IBoneWeightShaderOptions, scene: Scene): ShaderMaterial;
  58851. /** public static method to create a BoneWeight Shader
  58852. * @param options The constructor options
  58853. * @param scene The scene that the shader is scoped to
  58854. * @returns The created ShaderMaterial
  58855. */
  58856. static CreateSkeletonMapShader(options: ISkeletonMapShaderOptions, scene: Scene): ShaderMaterial;
  58857. /** private static method to create a BoneWeight Shader
  58858. * @param size The size of the buffer to create (usually the bone count)
  58859. * @param colorMap The gradient data to generate
  58860. * @param scene The scene that the shader is scoped to
  58861. * @returns an Array of floats from the color gradient values
  58862. */
  58863. private static _CreateBoneMapColorBuffer;
  58864. /** If SkeletonViewer scene scope. */
  58865. private _scene;
  58866. /** Gets or sets the color used to render the skeleton */
  58867. color: Color3;
  58868. /** Array of the points of the skeleton fo the line view. */
  58869. private _debugLines;
  58870. /** The SkeletonViewers Mesh. */
  58871. private _debugMesh;
  58872. /** The local axes Meshes. */
  58873. private _localAxes;
  58874. /** If SkeletonViewer is enabled. */
  58875. private _isEnabled;
  58876. /** If SkeletonViewer is ready. */
  58877. private _ready;
  58878. /** SkeletonViewer render observable. */
  58879. private _obs;
  58880. /** The Utility Layer to render the gizmos in. */
  58881. private _utilityLayer;
  58882. private _boneIndices;
  58883. /** Gets the Scene. */
  58884. get scene(): Scene;
  58885. /** Gets the utilityLayer. */
  58886. get utilityLayer(): Nullable<UtilityLayerRenderer>;
  58887. /** Checks Ready Status. */
  58888. get isReady(): Boolean;
  58889. /** Sets Ready Status. */
  58890. set ready(value: boolean);
  58891. /** Gets the debugMesh */
  58892. get debugMesh(): Nullable<AbstractMesh> | Nullable<LinesMesh>;
  58893. /** Sets the debugMesh */
  58894. set debugMesh(value: Nullable<AbstractMesh> | Nullable<LinesMesh>);
  58895. /** Gets the displayMode */
  58896. get displayMode(): number;
  58897. /** Sets the displayMode */
  58898. set displayMode(value: number);
  58899. /**
  58900. * Creates a new SkeletonViewer
  58901. * @param skeleton defines the skeleton to render
  58902. * @param mesh defines the mesh attached to the skeleton
  58903. * @param scene defines the hosting scene
  58904. * @param autoUpdateBonesMatrices defines a boolean indicating if bones matrices must be forced to update before rendering (true by default)
  58905. * @param renderingGroupId defines the rendering group id to use with the viewer
  58906. * @param options All of the extra constructor options for the SkeletonViewer
  58907. */
  58908. constructor(
  58909. /** defines the skeleton to render */
  58910. skeleton: Skeleton,
  58911. /** defines the mesh attached to the skeleton */
  58912. mesh: AbstractMesh,
  58913. /** The Scene scope*/
  58914. scene: Scene,
  58915. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  58916. autoUpdateBonesMatrices?: boolean,
  58917. /** defines the rendering group id to use with the viewer */
  58918. renderingGroupId?: number,
  58919. /** is the options for the viewer */
  58920. options?: Partial<ISkeletonViewerOptions>);
  58921. /** The Dynamic bindings for the update functions */
  58922. private _bindObs;
  58923. /** Update the viewer to sync with current skeleton state, only used to manually update. */
  58924. update(): void;
  58925. /** Gets or sets a boolean indicating if the viewer is enabled */
  58926. set isEnabled(value: boolean);
  58927. get isEnabled(): boolean;
  58928. private _getBonePosition;
  58929. private _getLinesForBonesWithLength;
  58930. private _getLinesForBonesNoLength;
  58931. /** function to revert the mesh and scene back to the initial state. */
  58932. private _revert;
  58933. /** function to get the absolute bind pose of a bone by accumulating transformations up the bone hierarchy. */
  58934. private _getAbsoluteBindPoseToRef;
  58935. /** function to build and bind sphere joint points and spur bone representations. */
  58936. private _buildSpheresAndSpurs;
  58937. private _buildLocalAxes;
  58938. /** Update the viewer to sync with current skeleton state, only used for the line display. */
  58939. private _displayLinesUpdate;
  58940. /** Changes the displayMode of the skeleton viewer
  58941. * @param mode The displayMode numerical value
  58942. */
  58943. changeDisplayMode(mode: number): void;
  58944. /** Sets a display option of the skeleton viewer
  58945. *
  58946. * | Option | Type | Default | Description |
  58947. * | ---------------- | ------- | ------- | ----------- |
  58948. * | 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`. |
  58949. * | 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`. |
  58950. * | sphereBaseSize | float | 2 | Sphere base size. Only used when `displayMode` is set to `DISPLAY_SPHERE_AND_SPURS`. |
  58951. * | 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`. |
  58952. * | spurFollowsChild | boolean | false | Whether a spur should attach its far end to the child bone. |
  58953. * | showLocalAxes | boolean | false | Displays local axes on all bones. |
  58954. * | localAxesSize | float | 0.075 | Determines the length of each local axis. |
  58955. *
  58956. * @param option String of the option name
  58957. * @param value The numerical option value
  58958. */
  58959. changeDisplayOptions(option: string, value: number): void;
  58960. /** Release associated resources */
  58961. dispose(): void;
  58962. }
  58963. }
  58964. declare module BABYLON {
  58965. /**
  58966. * Enum for Device Types
  58967. */
  58968. export enum DeviceType {
  58969. /** Generic */
  58970. Generic = 0,
  58971. /** Keyboard */
  58972. Keyboard = 1,
  58973. /** Mouse */
  58974. Mouse = 2,
  58975. /** Touch Pointers */
  58976. Touch = 3,
  58977. /** PS4 Dual Shock */
  58978. DualShock = 4,
  58979. /** Xbox */
  58980. Xbox = 5,
  58981. /** Switch Controller */
  58982. Switch = 6
  58983. }
  58984. /**
  58985. * Enum for All Pointers (Touch/Mouse)
  58986. */
  58987. export enum PointerInput {
  58988. /** Horizontal Axis */
  58989. Horizontal = 0,
  58990. /** Vertical Axis */
  58991. Vertical = 1,
  58992. /** Left Click or Touch */
  58993. LeftClick = 2,
  58994. /** Middle Click */
  58995. MiddleClick = 3,
  58996. /** Right Click */
  58997. RightClick = 4,
  58998. /** Browser Back */
  58999. BrowserBack = 5,
  59000. /** Browser Forward */
  59001. BrowserForward = 6
  59002. }
  59003. /**
  59004. * Enum for Dual Shock Gamepad
  59005. */
  59006. export enum DualShockInput {
  59007. /** Cross */
  59008. Cross = 0,
  59009. /** Circle */
  59010. Circle = 1,
  59011. /** Square */
  59012. Square = 2,
  59013. /** Triangle */
  59014. Triangle = 3,
  59015. /** L1 */
  59016. L1 = 4,
  59017. /** R1 */
  59018. R1 = 5,
  59019. /** L2 */
  59020. L2 = 6,
  59021. /** R2 */
  59022. R2 = 7,
  59023. /** Share */
  59024. Share = 8,
  59025. /** Options */
  59026. Options = 9,
  59027. /** L3 */
  59028. L3 = 10,
  59029. /** R3 */
  59030. R3 = 11,
  59031. /** DPadUp */
  59032. DPadUp = 12,
  59033. /** DPadDown */
  59034. DPadDown = 13,
  59035. /** DPadLeft */
  59036. DPadLeft = 14,
  59037. /** DRight */
  59038. DPadRight = 15,
  59039. /** Home */
  59040. Home = 16,
  59041. /** TouchPad */
  59042. TouchPad = 17,
  59043. /** LStickXAxis */
  59044. LStickXAxis = 18,
  59045. /** LStickYAxis */
  59046. LStickYAxis = 19,
  59047. /** RStickXAxis */
  59048. RStickXAxis = 20,
  59049. /** RStickYAxis */
  59050. RStickYAxis = 21
  59051. }
  59052. /**
  59053. * Enum for Xbox Gamepad
  59054. */
  59055. export enum XboxInput {
  59056. /** A */
  59057. A = 0,
  59058. /** B */
  59059. B = 1,
  59060. /** X */
  59061. X = 2,
  59062. /** Y */
  59063. Y = 3,
  59064. /** LB */
  59065. LB = 4,
  59066. /** RB */
  59067. RB = 5,
  59068. /** LT */
  59069. LT = 6,
  59070. /** RT */
  59071. RT = 7,
  59072. /** Back */
  59073. Back = 8,
  59074. /** Start */
  59075. Start = 9,
  59076. /** LS */
  59077. LS = 10,
  59078. /** RS */
  59079. RS = 11,
  59080. /** DPadUp */
  59081. DPadUp = 12,
  59082. /** DPadDown */
  59083. DPadDown = 13,
  59084. /** DPadLeft */
  59085. DPadLeft = 14,
  59086. /** DRight */
  59087. DPadRight = 15,
  59088. /** Home */
  59089. Home = 16,
  59090. /** LStickXAxis */
  59091. LStickXAxis = 17,
  59092. /** LStickYAxis */
  59093. LStickYAxis = 18,
  59094. /** RStickXAxis */
  59095. RStickXAxis = 19,
  59096. /** RStickYAxis */
  59097. RStickYAxis = 20
  59098. }
  59099. /**
  59100. * Enum for Switch (Pro/JoyCon L+R) Gamepad
  59101. */
  59102. export enum SwitchInput {
  59103. /** B */
  59104. B = 0,
  59105. /** A */
  59106. A = 1,
  59107. /** Y */
  59108. Y = 2,
  59109. /** X */
  59110. X = 3,
  59111. /** L */
  59112. L = 4,
  59113. /** R */
  59114. R = 5,
  59115. /** ZL */
  59116. ZL = 6,
  59117. /** ZR */
  59118. ZR = 7,
  59119. /** Minus */
  59120. Minus = 8,
  59121. /** Plus */
  59122. Plus = 9,
  59123. /** LS */
  59124. LS = 10,
  59125. /** RS */
  59126. RS = 11,
  59127. /** DPadUp */
  59128. DPadUp = 12,
  59129. /** DPadDown */
  59130. DPadDown = 13,
  59131. /** DPadLeft */
  59132. DPadLeft = 14,
  59133. /** DRight */
  59134. DPadRight = 15,
  59135. /** Home */
  59136. Home = 16,
  59137. /** Capture */
  59138. Capture = 17,
  59139. /** LStickXAxis */
  59140. LStickXAxis = 18,
  59141. /** LStickYAxis */
  59142. LStickYAxis = 19,
  59143. /** RStickXAxis */
  59144. RStickXAxis = 20,
  59145. /** RStickYAxis */
  59146. RStickYAxis = 21
  59147. }
  59148. }
  59149. declare module BABYLON {
  59150. /**
  59151. * This class will take all inputs from Keyboard, Pointer, and
  59152. * any Gamepads and provide a polling system that all devices
  59153. * will use. This class assumes that there will only be one
  59154. * pointer device and one keyboard.
  59155. */
  59156. export class DeviceInputSystem implements IDisposable {
  59157. /**
  59158. * Returns onDeviceConnected callback property
  59159. * @returns Callback with function to execute when a device is connected
  59160. */
  59161. get onDeviceConnected(): (deviceType: DeviceType, deviceSlot: number) => void;
  59162. /**
  59163. * Sets callback function when a device is connected and executes against all connected devices
  59164. * @param callback Function to execute when a device is connected
  59165. */
  59166. set onDeviceConnected(callback: (deviceType: DeviceType, deviceSlot: number) => void);
  59167. /**
  59168. * Callback to be triggered when a device is disconnected
  59169. */
  59170. onDeviceDisconnected: (deviceType: DeviceType, deviceSlot: number) => void;
  59171. /**
  59172. * Callback to be triggered when event driven input is updated
  59173. */
  59174. onInputChanged: (deviceType: DeviceType, deviceSlot: number, inputIndex: number, previousState: Nullable<number>, currentState: Nullable<number>) => void;
  59175. private _inputs;
  59176. private _gamepads;
  59177. private _keyboardActive;
  59178. private _pointerActive;
  59179. private _elementToAttachTo;
  59180. private _keyboardDownEvent;
  59181. private _keyboardUpEvent;
  59182. private _pointerMoveEvent;
  59183. private _pointerDownEvent;
  59184. private _pointerUpEvent;
  59185. private _gamepadConnectedEvent;
  59186. private _gamepadDisconnectedEvent;
  59187. private _onDeviceConnected;
  59188. private static _MAX_KEYCODES;
  59189. private static _MAX_POINTER_INPUTS;
  59190. private constructor();
  59191. /**
  59192. * Creates a new DeviceInputSystem instance
  59193. * @param engine Engine to pull input element from
  59194. * @returns The new instance
  59195. */
  59196. static Create(engine: Engine): DeviceInputSystem;
  59197. /**
  59198. * Checks for current device input value, given an id and input index
  59199. * @param deviceName Id of connected device
  59200. * @param inputIndex Index of device input
  59201. * @returns Current value of input
  59202. */
  59203. /**
  59204. * Checks for current device input value, given an id and input index. Throws exception if requested device not initialized.
  59205. * @param deviceType Enum specifiying device type
  59206. * @param deviceSlot "Slot" or index that device is referenced in
  59207. * @param inputIndex Id of input to be checked
  59208. * @returns Current value of input
  59209. */
  59210. pollInput(deviceType: DeviceType, deviceSlot: number, inputIndex: number): number;
  59211. /**
  59212. * Dispose of all the eventlisteners
  59213. */
  59214. dispose(): void;
  59215. /**
  59216. * Checks for existing connections to devices and register them, if necessary
  59217. * Currently handles gamepads and mouse
  59218. */
  59219. private _checkForConnectedDevices;
  59220. /**
  59221. * Add a gamepad to the DeviceInputSystem
  59222. * @param gamepad A single DOM Gamepad object
  59223. */
  59224. private _addGamePad;
  59225. /**
  59226. * Add pointer device to DeviceInputSystem
  59227. * @param deviceType Type of Pointer to add
  59228. * @param deviceSlot Pointer ID (0 for mouse, pointerId for Touch)
  59229. * @param currentX Current X at point of adding
  59230. * @param currentY Current Y at point of adding
  59231. */
  59232. private _addPointerDevice;
  59233. /**
  59234. * Add device and inputs to device array
  59235. * @param deviceType Enum specifiying device type
  59236. * @param deviceSlot "Slot" or index that device is referenced in
  59237. * @param numberOfInputs Number of input entries to create for given device
  59238. */
  59239. private _registerDevice;
  59240. /**
  59241. * Given a specific device name, remove that device from the device map
  59242. * @param deviceType Enum specifiying device type
  59243. * @param deviceSlot "Slot" or index that device is referenced in
  59244. */
  59245. private _unregisterDevice;
  59246. /**
  59247. * Handle all actions that come from keyboard interaction
  59248. */
  59249. private _handleKeyActions;
  59250. /**
  59251. * Handle all actions that come from pointer interaction
  59252. */
  59253. private _handlePointerActions;
  59254. /**
  59255. * Handle all actions that come from gamepad interaction
  59256. */
  59257. private _handleGamepadActions;
  59258. /**
  59259. * Update all non-event based devices with each frame
  59260. * @param deviceType Enum specifiying device type
  59261. * @param deviceSlot "Slot" or index that device is referenced in
  59262. * @param inputIndex Id of input to be checked
  59263. */
  59264. private _updateDevice;
  59265. /**
  59266. * Gets DeviceType from the device name
  59267. * @param deviceName Name of Device from DeviceInputSystem
  59268. * @returns DeviceType enum value
  59269. */
  59270. private _getGamepadDeviceType;
  59271. }
  59272. }
  59273. declare module BABYLON {
  59274. /**
  59275. * Type to handle enforcement of inputs
  59276. */
  59277. 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;
  59278. }
  59279. declare module BABYLON {
  59280. /**
  59281. * Class that handles all input for a specific device
  59282. */
  59283. export class DeviceSource<T extends DeviceType> {
  59284. /** Type of device */
  59285. readonly deviceType: DeviceType;
  59286. /** "Slot" or index that device is referenced in */
  59287. readonly deviceSlot: number;
  59288. /**
  59289. * Observable to handle device input changes per device
  59290. */
  59291. readonly onInputChangedObservable: Observable<{
  59292. inputIndex: DeviceInput<T>;
  59293. previousState: Nullable<number>;
  59294. currentState: Nullable<number>;
  59295. }>;
  59296. private readonly _deviceInputSystem;
  59297. /**
  59298. * Default Constructor
  59299. * @param deviceInputSystem Reference to DeviceInputSystem
  59300. * @param deviceType Type of device
  59301. * @param deviceSlot "Slot" or index that device is referenced in
  59302. */
  59303. constructor(deviceInputSystem: DeviceInputSystem,
  59304. /** Type of device */
  59305. deviceType: DeviceType,
  59306. /** "Slot" or index that device is referenced in */
  59307. deviceSlot?: number);
  59308. /**
  59309. * Get input for specific input
  59310. * @param inputIndex index of specific input on device
  59311. * @returns Input value from DeviceInputSystem
  59312. */
  59313. getInput(inputIndex: DeviceInput<T>): number;
  59314. }
  59315. /**
  59316. * Class to keep track of devices
  59317. */
  59318. export class DeviceSourceManager implements IDisposable {
  59319. /**
  59320. * Observable to be triggered when after a device is connected, any new observers added will be triggered against already connected devices
  59321. */
  59322. readonly onDeviceConnectedObservable: Observable<DeviceSource<DeviceType>>;
  59323. /**
  59324. * Observable to be triggered when after a device is disconnected
  59325. */
  59326. readonly onDeviceDisconnectedObservable: Observable<DeviceSource<DeviceType>>;
  59327. private readonly _devices;
  59328. private readonly _firstDevice;
  59329. private readonly _deviceInputSystem;
  59330. /**
  59331. * Default Constructor
  59332. * @param engine engine to pull input element from
  59333. */
  59334. constructor(engine: Engine);
  59335. /**
  59336. * Gets a DeviceSource, given a type and slot
  59337. * @param deviceType Enum specifying device type
  59338. * @param deviceSlot "Slot" or index that device is referenced in
  59339. * @returns DeviceSource object
  59340. */
  59341. getDeviceSource<T extends DeviceType>(deviceType: T, deviceSlot?: number): Nullable<DeviceSource<T>>;
  59342. /**
  59343. * Gets an array of DeviceSource objects for a given device type
  59344. * @param deviceType Enum specifying device type
  59345. * @returns Array of DeviceSource objects
  59346. */
  59347. getDeviceSources<T extends DeviceType>(deviceType: T): ReadonlyArray<DeviceSource<T>>;
  59348. /**
  59349. * Returns a read-only list of all available devices
  59350. * @returns Read-only array with active devices
  59351. */
  59352. getDevices(): ReadonlyArray<DeviceSource<DeviceType>>;
  59353. /**
  59354. * Dispose of DeviceInputSystem and other parts
  59355. */
  59356. dispose(): void;
  59357. /**
  59358. * Function to add device name to device list
  59359. * @param deviceType Enum specifying device type
  59360. * @param deviceSlot "Slot" or index that device is referenced in
  59361. */
  59362. private _addDevice;
  59363. /**
  59364. * Function to remove device name to device list
  59365. * @param deviceType Enum specifying device type
  59366. * @param deviceSlot "Slot" or index that device is referenced in
  59367. */
  59368. private _removeDevice;
  59369. /**
  59370. * Updates array storing first connected device of each type
  59371. * @param type Type of Device
  59372. */
  59373. private _updateFirstDevices;
  59374. }
  59375. }
  59376. declare module BABYLON {
  59377. /**
  59378. * Options to create the null engine
  59379. */
  59380. export class NullEngineOptions {
  59381. /**
  59382. * Render width (Default: 512)
  59383. */
  59384. renderWidth: number;
  59385. /**
  59386. * Render height (Default: 256)
  59387. */
  59388. renderHeight: number;
  59389. /**
  59390. * Texture size (Default: 512)
  59391. */
  59392. textureSize: number;
  59393. /**
  59394. * If delta time between frames should be constant
  59395. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  59396. */
  59397. deterministicLockstep: boolean;
  59398. /**
  59399. * Maximum about of steps between frames (Default: 4)
  59400. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  59401. */
  59402. lockstepMaxSteps: number;
  59403. /**
  59404. * Make the matrix computations to be performed in 64 bits instead of 32 bits. False by default
  59405. */
  59406. useHighPrecisionMatrix?: boolean;
  59407. }
  59408. /**
  59409. * The null engine class provides support for headless version of babylon.js.
  59410. * This can be used in server side scenario or for testing purposes
  59411. */
  59412. export class NullEngine extends Engine {
  59413. private _options;
  59414. /**
  59415. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  59416. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  59417. * @returns true if engine is in deterministic lock step mode
  59418. */
  59419. isDeterministicLockStep(): boolean;
  59420. /**
  59421. * Gets the max steps when engine is running in deterministic lock step
  59422. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  59423. * @returns the max steps
  59424. */
  59425. getLockstepMaxSteps(): number;
  59426. /**
  59427. * Gets the current hardware scaling level.
  59428. * By default the hardware scaling level is computed from the window device ratio.
  59429. * 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.
  59430. * @returns a number indicating the current hardware scaling level
  59431. */
  59432. getHardwareScalingLevel(): number;
  59433. constructor(options?: NullEngineOptions);
  59434. /**
  59435. * Creates a vertex buffer
  59436. * @param vertices the data for the vertex buffer
  59437. * @returns the new WebGL static buffer
  59438. */
  59439. createVertexBuffer(vertices: FloatArray): DataBuffer;
  59440. /**
  59441. * Creates a new index buffer
  59442. * @param indices defines the content of the index buffer
  59443. * @param updatable defines if the index buffer must be updatable
  59444. * @returns a new webGL buffer
  59445. */
  59446. createIndexBuffer(indices: IndicesArray): DataBuffer;
  59447. /**
  59448. * Clear the current render buffer or the current render target (if any is set up)
  59449. * @param color defines the color to use
  59450. * @param backBuffer defines if the back buffer must be cleared
  59451. * @param depth defines if the depth buffer must be cleared
  59452. * @param stencil defines if the stencil buffer must be cleared
  59453. */
  59454. clear(color: IColor4Like, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  59455. /**
  59456. * Gets the current render width
  59457. * @param useScreen defines if screen size must be used (or the current render target if any)
  59458. * @returns a number defining the current render width
  59459. */
  59460. getRenderWidth(useScreen?: boolean): number;
  59461. /**
  59462. * Gets the current render height
  59463. * @param useScreen defines if screen size must be used (or the current render target if any)
  59464. * @returns a number defining the current render height
  59465. */
  59466. getRenderHeight(useScreen?: boolean): number;
  59467. /**
  59468. * Set the WebGL's viewport
  59469. * @param viewport defines the viewport element to be used
  59470. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  59471. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  59472. */
  59473. setViewport(viewport: IViewportLike, requiredWidth?: number, requiredHeight?: number): void;
  59474. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: string, context?: WebGLRenderingContext): WebGLProgram;
  59475. /**
  59476. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  59477. * @param pipelineContext defines the pipeline context to use
  59478. * @param uniformsNames defines the list of uniform names
  59479. * @returns an array of webGL uniform locations
  59480. */
  59481. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  59482. /**
  59483. * Gets the lsit of active attributes for a given webGL program
  59484. * @param pipelineContext defines the pipeline context to use
  59485. * @param attributesNames defines the list of attribute names to get
  59486. * @returns an array of indices indicating the offset of each attribute
  59487. */
  59488. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  59489. /**
  59490. * Binds an effect to the webGL context
  59491. * @param effect defines the effect to bind
  59492. */
  59493. bindSamplers(effect: Effect): void;
  59494. /**
  59495. * Activates an effect, making it the current one (ie. the one used for rendering)
  59496. * @param effect defines the effect to activate
  59497. */
  59498. enableEffect(effect: Effect): void;
  59499. /**
  59500. * Set various states to the webGL context
  59501. * @param culling defines backface culling state
  59502. * @param zOffset defines the value to apply to zOffset (0 by default)
  59503. * @param force defines if states must be applied even if cache is up to date
  59504. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  59505. */
  59506. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  59507. /**
  59508. * Set the value of an uniform to an array of int32
  59509. * @param uniform defines the webGL uniform location where to store the value
  59510. * @param array defines the array of int32 to store
  59511. * @returns true if value was set
  59512. */
  59513. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): boolean;
  59514. /**
  59515. * Set the value of an uniform to an array of int32 (stored as vec2)
  59516. * @param uniform defines the webGL uniform location where to store the value
  59517. * @param array defines the array of int32 to store
  59518. * @returns true if value was set
  59519. */
  59520. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): boolean;
  59521. /**
  59522. * Set the value of an uniform to an array of int32 (stored as vec3)
  59523. * @param uniform defines the webGL uniform location where to store the value
  59524. * @param array defines the array of int32 to store
  59525. * @returns true if value was set
  59526. */
  59527. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): boolean;
  59528. /**
  59529. * Set the value of an uniform to an array of int32 (stored as vec4)
  59530. * @param uniform defines the webGL uniform location where to store the value
  59531. * @param array defines the array of int32 to store
  59532. * @returns true if value was set
  59533. */
  59534. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): boolean;
  59535. /**
  59536. * Set the value of an uniform to an array of float32
  59537. * @param uniform defines the webGL uniform location where to store the value
  59538. * @param array defines the array of float32 to store
  59539. * @returns true if value was set
  59540. */
  59541. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): boolean;
  59542. /**
  59543. * Set the value of an uniform to an array of float32 (stored as vec2)
  59544. * @param uniform defines the webGL uniform location where to store the value
  59545. * @param array defines the array of float32 to store
  59546. * @returns true if value was set
  59547. */
  59548. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): boolean;
  59549. /**
  59550. * Set the value of an uniform to an array of float32 (stored as vec3)
  59551. * @param uniform defines the webGL uniform location where to store the value
  59552. * @param array defines the array of float32 to store
  59553. * @returns true if value was set
  59554. */
  59555. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): boolean;
  59556. /**
  59557. * Set the value of an uniform to an array of float32 (stored as vec4)
  59558. * @param uniform defines the webGL uniform location where to store the value
  59559. * @param array defines the array of float32 to store
  59560. * @returns true if value was set
  59561. */
  59562. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): boolean;
  59563. /**
  59564. * Set the value of an uniform to an array of number
  59565. * @param uniform defines the webGL uniform location where to store the value
  59566. * @param array defines the array of number to store
  59567. * @returns true if value was set
  59568. */
  59569. setArray(uniform: WebGLUniformLocation, array: number[]): boolean;
  59570. /**
  59571. * Set the value of an uniform to an array of number (stored as vec2)
  59572. * @param uniform defines the webGL uniform location where to store the value
  59573. * @param array defines the array of number to store
  59574. * @returns true if value was set
  59575. */
  59576. setArray2(uniform: WebGLUniformLocation, array: number[]): boolean;
  59577. /**
  59578. * Set the value of an uniform to an array of number (stored as vec3)
  59579. * @param uniform defines the webGL uniform location where to store the value
  59580. * @param array defines the array of number to store
  59581. * @returns true if value was set
  59582. */
  59583. setArray3(uniform: WebGLUniformLocation, array: number[]): boolean;
  59584. /**
  59585. * Set the value of an uniform to an array of number (stored as vec4)
  59586. * @param uniform defines the webGL uniform location where to store the value
  59587. * @param array defines the array of number to store
  59588. * @returns true if value was set
  59589. */
  59590. setArray4(uniform: WebGLUniformLocation, array: number[]): boolean;
  59591. /**
  59592. * Set the value of an uniform to an array of float32 (stored as matrices)
  59593. * @param uniform defines the webGL uniform location where to store the value
  59594. * @param matrices defines the array of float32 to store
  59595. * @returns true if value was set
  59596. */
  59597. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): boolean;
  59598. /**
  59599. * Set the value of an uniform to a matrix (3x3)
  59600. * @param uniform defines the webGL uniform location where to store the value
  59601. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  59602. * @returns true if value was set
  59603. */
  59604. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): boolean;
  59605. /**
  59606. * Set the value of an uniform to a matrix (2x2)
  59607. * @param uniform defines the webGL uniform location where to store the value
  59608. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  59609. * @returns true if value was set
  59610. */
  59611. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): boolean;
  59612. /**
  59613. * Set the value of an uniform to a number (float)
  59614. * @param uniform defines the webGL uniform location where to store the value
  59615. * @param value defines the float number to store
  59616. * @returns true if value was set
  59617. */
  59618. setFloat(uniform: WebGLUniformLocation, value: number): boolean;
  59619. /**
  59620. * Set the value of an uniform to a vec2
  59621. * @param uniform defines the webGL uniform location where to store the value
  59622. * @param x defines the 1st component of the value
  59623. * @param y defines the 2nd component of the value
  59624. * @returns true if value was set
  59625. */
  59626. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): boolean;
  59627. /**
  59628. * Set the value of an uniform to a vec3
  59629. * @param uniform defines the webGL uniform location where to store the value
  59630. * @param x defines the 1st component of the value
  59631. * @param y defines the 2nd component of the value
  59632. * @param z defines the 3rd component of the value
  59633. * @returns true if value was set
  59634. */
  59635. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): boolean;
  59636. /**
  59637. * Set the value of an uniform to a boolean
  59638. * @param uniform defines the webGL uniform location where to store the value
  59639. * @param bool defines the boolean to store
  59640. * @returns true if value was set
  59641. */
  59642. setBool(uniform: WebGLUniformLocation, bool: number): boolean;
  59643. /**
  59644. * Set the value of an uniform to a vec4
  59645. * @param uniform defines the webGL uniform location where to store the value
  59646. * @param x defines the 1st component of the value
  59647. * @param y defines the 2nd component of the value
  59648. * @param z defines the 3rd component of the value
  59649. * @param w defines the 4th component of the value
  59650. * @returns true if value was set
  59651. */
  59652. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): boolean;
  59653. /**
  59654. * Sets the current alpha mode
  59655. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  59656. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  59657. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  59658. */
  59659. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  59660. /**
  59661. * Bind webGl buffers directly to the webGL context
  59662. * @param vertexBuffers defines the vertex buffer to bind
  59663. * @param indexBuffer defines the index buffer to bind
  59664. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  59665. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  59666. * @param effect defines the effect associated with the vertex buffer
  59667. */
  59668. bindBuffers(vertexBuffers: {
  59669. [key: string]: VertexBuffer;
  59670. }, indexBuffer: DataBuffer, effect: Effect): void;
  59671. /**
  59672. * Force the entire cache to be cleared
  59673. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  59674. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  59675. */
  59676. wipeCaches(bruteForce?: boolean): void;
  59677. /**
  59678. * Send a draw order
  59679. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  59680. * @param indexStart defines the starting index
  59681. * @param indexCount defines the number of index to draw
  59682. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  59683. */
  59684. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  59685. /**
  59686. * Draw a list of indexed primitives
  59687. * @param fillMode defines the primitive to use
  59688. * @param indexStart defines the starting index
  59689. * @param indexCount defines the number of index to draw
  59690. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  59691. */
  59692. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  59693. /**
  59694. * Draw a list of unindexed primitives
  59695. * @param fillMode defines the primitive to use
  59696. * @param verticesStart defines the index of first vertex to draw
  59697. * @param verticesCount defines the count of vertices to draw
  59698. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  59699. */
  59700. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  59701. /** @hidden */
  59702. protected _createTexture(): WebGLTexture;
  59703. /** @hidden */
  59704. _releaseTexture(texture: InternalTexture): void;
  59705. /**
  59706. * Usually called from Texture.ts.
  59707. * Passed information to create a WebGLTexture
  59708. * @param urlArg defines a value which contains one of the following:
  59709. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  59710. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  59711. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  59712. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  59713. * @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)
  59714. * @param scene needed for loading to the correct scene
  59715. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  59716. * @param onLoad optional callback to be called upon successful completion
  59717. * @param onError optional callback to be called upon failure
  59718. * @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
  59719. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  59720. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  59721. * @param forcedExtension defines the extension to use to pick the right loader
  59722. * @param mimeType defines an optional mime type
  59723. * @returns a InternalTexture for assignment back into BABYLON.Texture
  59724. */
  59725. 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;
  59726. /**
  59727. * Creates a new render target texture
  59728. * @param size defines the size of the texture
  59729. * @param options defines the options used to create the texture
  59730. * @returns a new render target texture stored in an InternalTexture
  59731. */
  59732. createRenderTargetTexture(size: any, options: boolean | RenderTargetCreationOptions): InternalTexture;
  59733. /**
  59734. * Update the sampling mode of a given texture
  59735. * @param samplingMode defines the required sampling mode
  59736. * @param texture defines the texture to update
  59737. */
  59738. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  59739. /**
  59740. * Binds the frame buffer to the specified texture.
  59741. * @param texture The texture to render to or null for the default canvas
  59742. * @param faceIndex The face of the texture to render to in case of cube texture
  59743. * @param requiredWidth The width of the target to render to
  59744. * @param requiredHeight The height of the target to render to
  59745. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  59746. * @param lodLevel defines le lod level to bind to the frame buffer
  59747. */
  59748. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  59749. /**
  59750. * Unbind the current render target texture from the webGL context
  59751. * @param texture defines the render target texture to unbind
  59752. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  59753. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  59754. */
  59755. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  59756. /**
  59757. * Creates a dynamic vertex buffer
  59758. * @param vertices the data for the dynamic vertex buffer
  59759. * @returns the new WebGL dynamic buffer
  59760. */
  59761. createDynamicVertexBuffer(vertices: FloatArray): DataBuffer;
  59762. /**
  59763. * Update the content of a dynamic texture
  59764. * @param texture defines the texture to update
  59765. * @param canvas defines the canvas containing the source
  59766. * @param invertY defines if data must be stored with Y axis inverted
  59767. * @param premulAlpha defines if alpha is stored as premultiplied
  59768. * @param format defines the format of the data
  59769. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  59770. */
  59771. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number): void;
  59772. /**
  59773. * Gets a boolean indicating if all created effects are ready
  59774. * @returns true if all effects are ready
  59775. */
  59776. areAllEffectsReady(): boolean;
  59777. /**
  59778. * @hidden
  59779. * Get the current error code of the webGL context
  59780. * @returns the error code
  59781. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  59782. */
  59783. getError(): number;
  59784. /** @hidden */
  59785. _getUnpackAlignement(): number;
  59786. /** @hidden */
  59787. _unpackFlipY(value: boolean): void;
  59788. /**
  59789. * Update a dynamic index buffer
  59790. * @param indexBuffer defines the target index buffer
  59791. * @param indices defines the data to update
  59792. * @param offset defines the offset in the target index buffer where update should start
  59793. */
  59794. updateDynamicIndexBuffer(indexBuffer: WebGLBuffer, indices: IndicesArray, offset?: number): void;
  59795. /**
  59796. * Updates a dynamic vertex buffer.
  59797. * @param vertexBuffer the vertex buffer to update
  59798. * @param vertices the data used to update the vertex buffer
  59799. * @param byteOffset the byte offset of the data (optional)
  59800. * @param byteLength the byte length of the data (optional)
  59801. */
  59802. updateDynamicVertexBuffer(vertexBuffer: WebGLBuffer, vertices: FloatArray, byteOffset?: number, byteLength?: number): void;
  59803. /** @hidden */
  59804. _bindTextureDirectly(target: number, texture: InternalTexture): boolean;
  59805. /** @hidden */
  59806. _bindTexture(channel: number, texture: InternalTexture): void;
  59807. protected _deleteBuffer(buffer: WebGLBuffer): void;
  59808. /**
  59809. * 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
  59810. */
  59811. releaseEffects(): void;
  59812. displayLoadingUI(): void;
  59813. hideLoadingUI(): void;
  59814. /** @hidden */
  59815. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  59816. /** @hidden */
  59817. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  59818. /** @hidden */
  59819. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  59820. /** @hidden */
  59821. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  59822. }
  59823. }
  59824. declare module BABYLON {
  59825. /** @hidden */
  59826. export class _OcclusionDataStorage {
  59827. /** @hidden */
  59828. occlusionInternalRetryCounter: number;
  59829. /** @hidden */
  59830. isOcclusionQueryInProgress: boolean;
  59831. /** @hidden */
  59832. isOccluded: boolean;
  59833. /** @hidden */
  59834. occlusionRetryCount: number;
  59835. /** @hidden */
  59836. occlusionType: number;
  59837. /** @hidden */
  59838. occlusionQueryAlgorithmType: number;
  59839. }
  59840. interface Engine {
  59841. /**
  59842. * Create a new webGL query (you must be sure that queries are supported by checking getCaps() function)
  59843. * @return the new query
  59844. */
  59845. createQuery(): WebGLQuery;
  59846. /**
  59847. * Delete and release a webGL query
  59848. * @param query defines the query to delete
  59849. * @return the current engine
  59850. */
  59851. deleteQuery(query: WebGLQuery): Engine;
  59852. /**
  59853. * Check if a given query has resolved and got its value
  59854. * @param query defines the query to check
  59855. * @returns true if the query got its value
  59856. */
  59857. isQueryResultAvailable(query: WebGLQuery): boolean;
  59858. /**
  59859. * Gets the value of a given query
  59860. * @param query defines the query to check
  59861. * @returns the value of the query
  59862. */
  59863. getQueryResult(query: WebGLQuery): number;
  59864. /**
  59865. * Initiates an occlusion query
  59866. * @param algorithmType defines the algorithm to use
  59867. * @param query defines the query to use
  59868. * @returns the current engine
  59869. * @see https://doc.babylonjs.com/features/occlusionquery
  59870. */
  59871. beginOcclusionQuery(algorithmType: number, query: WebGLQuery): Engine;
  59872. /**
  59873. * Ends an occlusion query
  59874. * @see https://doc.babylonjs.com/features/occlusionquery
  59875. * @param algorithmType defines the algorithm to use
  59876. * @returns the current engine
  59877. */
  59878. endOcclusionQuery(algorithmType: number): Engine;
  59879. /**
  59880. * Starts a time query (used to measure time spent by the GPU on a specific frame)
  59881. * Please note that only one query can be issued at a time
  59882. * @returns a time token used to track the time span
  59883. */
  59884. startTimeQuery(): Nullable<_TimeToken>;
  59885. /**
  59886. * Ends a time query
  59887. * @param token defines the token used to measure the time span
  59888. * @returns the time spent (in ns)
  59889. */
  59890. endTimeQuery(token: _TimeToken): int;
  59891. /** @hidden */
  59892. _currentNonTimestampToken: Nullable<_TimeToken>;
  59893. /** @hidden */
  59894. _createTimeQuery(): WebGLQuery;
  59895. /** @hidden */
  59896. _deleteTimeQuery(query: WebGLQuery): void;
  59897. /** @hidden */
  59898. _getGlAlgorithmType(algorithmType: number): number;
  59899. /** @hidden */
  59900. _getTimeQueryResult(query: WebGLQuery): any;
  59901. /** @hidden */
  59902. _getTimeQueryAvailability(query: WebGLQuery): any;
  59903. }
  59904. interface AbstractMesh {
  59905. /**
  59906. * Backing filed
  59907. * @hidden
  59908. */
  59909. __occlusionDataStorage: _OcclusionDataStorage;
  59910. /**
  59911. * Access property
  59912. * @hidden
  59913. */
  59914. _occlusionDataStorage: _OcclusionDataStorage;
  59915. /**
  59916. * This number indicates the number of allowed retries before stop the occlusion query, this is useful if the occlusion query is taking long time before to the query result is retireved, the query result indicates if the object is visible within the scene or not and based on that Babylon.Js engine decides to show or hide the object.
  59917. * The default value is -1 which means don't break the query and wait till the result
  59918. * @see https://doc.babylonjs.com/features/occlusionquery
  59919. */
  59920. occlusionRetryCount: number;
  59921. /**
  59922. * 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:
  59923. * * OCCLUSION_TYPE_NONE (Default Value): this option means no occlusion query within the Mesh.
  59924. * * OCCLUSION_TYPE_OPTIMISTIC: this option is means use occlusion query and if occlusionRetryCount is reached and the query is broken show the mesh.
  59925. * * 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.
  59926. * @see https://doc.babylonjs.com/features/occlusionquery
  59927. */
  59928. occlusionType: number;
  59929. /**
  59930. * This property determines the type of occlusion query algorithm to run in WebGl, you can use:
  59931. * * AbstractMesh.OCCLUSION_ALGORITHM_TYPE_ACCURATE which is mapped to GL_ANY_SAMPLES_PASSED.
  59932. * * 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.
  59933. * @see https://doc.babylonjs.com/features/occlusionquery
  59934. */
  59935. occlusionQueryAlgorithmType: number;
  59936. /**
  59937. * Gets or sets whether the mesh is occluded or not, it is used also to set the initial state of the mesh to be occluded or not
  59938. * @see https://doc.babylonjs.com/features/occlusionquery
  59939. */
  59940. isOccluded: boolean;
  59941. /**
  59942. * Flag to check the progress status of the query
  59943. * @see https://doc.babylonjs.com/features/occlusionquery
  59944. */
  59945. isOcclusionQueryInProgress: boolean;
  59946. }
  59947. }
  59948. declare module BABYLON {
  59949. /** @hidden */
  59950. export var _forceTransformFeedbackToBundle: boolean;
  59951. interface Engine {
  59952. /**
  59953. * Creates a webGL transform feedback object
  59954. * Please makes sure to check webGLVersion property to check if you are running webGL 2+
  59955. * @returns the webGL transform feedback object
  59956. */
  59957. createTransformFeedback(): WebGLTransformFeedback;
  59958. /**
  59959. * Delete a webGL transform feedback object
  59960. * @param value defines the webGL transform feedback object to delete
  59961. */
  59962. deleteTransformFeedback(value: WebGLTransformFeedback): void;
  59963. /**
  59964. * Bind a webGL transform feedback object to the webgl context
  59965. * @param value defines the webGL transform feedback object to bind
  59966. */
  59967. bindTransformFeedback(value: Nullable<WebGLTransformFeedback>): void;
  59968. /**
  59969. * Begins a transform feedback operation
  59970. * @param usePoints defines if points or triangles must be used
  59971. */
  59972. beginTransformFeedback(usePoints: boolean): void;
  59973. /**
  59974. * Ends a transform feedback operation
  59975. */
  59976. endTransformFeedback(): void;
  59977. /**
  59978. * Specify the varyings to use with transform feedback
  59979. * @param program defines the associated webGL program
  59980. * @param value defines the list of strings representing the varying names
  59981. */
  59982. setTranformFeedbackVaryings(program: WebGLProgram, value: string[]): void;
  59983. /**
  59984. * Bind a webGL buffer for a transform feedback operation
  59985. * @param value defines the webGL buffer to bind
  59986. */
  59987. bindTransformFeedbackBuffer(value: Nullable<DataBuffer>): void;
  59988. }
  59989. }
  59990. declare module BABYLON {
  59991. /**
  59992. * Class used to define an additional view for the engine
  59993. * @see https://doc.babylonjs.com/how_to/multi_canvases
  59994. */
  59995. export class EngineView {
  59996. /** Defines the canvas where to render the view */
  59997. target: HTMLCanvasElement;
  59998. /** Defines an optional camera used to render the view (will use active camera else) */
  59999. camera?: Camera;
  60000. }
  60001. interface Engine {
  60002. /**
  60003. * Gets or sets the HTML element to use for attaching events
  60004. */
  60005. inputElement: Nullable<HTMLElement>;
  60006. /**
  60007. * Gets the current engine view
  60008. * @see https://doc.babylonjs.com/how_to/multi_canvases
  60009. */
  60010. activeView: Nullable<EngineView>;
  60011. /** Gets or sets the list of views */
  60012. views: EngineView[];
  60013. /**
  60014. * Register a new child canvas
  60015. * @param canvas defines the canvas to register
  60016. * @param camera defines an optional camera to use with this canvas (it will overwrite the scene.camera for this view)
  60017. * @returns the associated view
  60018. */
  60019. registerView(canvas: HTMLCanvasElement, camera?: Camera): EngineView;
  60020. /**
  60021. * Remove a registered child canvas
  60022. * @param canvas defines the canvas to remove
  60023. * @returns the current engine
  60024. */
  60025. unRegisterView(canvas: HTMLCanvasElement): Engine;
  60026. }
  60027. }
  60028. declare module BABYLON {
  60029. interface Engine {
  60030. /** @hidden */
  60031. _excludedCompressedTextures: string[];
  60032. /** @hidden */
  60033. _textureFormatInUse: string;
  60034. /**
  60035. * Gets the list of texture formats supported
  60036. */
  60037. readonly texturesSupported: Array<string>;
  60038. /**
  60039. * Gets the texture format in use
  60040. */
  60041. readonly textureFormatInUse: Nullable<string>;
  60042. /**
  60043. * Set the compressed texture extensions or file names to skip.
  60044. *
  60045. * @param skippedFiles defines the list of those texture files you want to skip
  60046. * Example: [".dds", ".env", "myfile.png"]
  60047. */
  60048. setCompressedTextureExclusions(skippedFiles: Array<string>): void;
  60049. /**
  60050. * Set the compressed texture format to use, based on the formats you have, and the formats
  60051. * supported by the hardware / browser.
  60052. *
  60053. * Khronos Texture Container (.ktx) files are used to support this. This format has the
  60054. * advantage of being specifically designed for OpenGL. Header elements directly correspond
  60055. * to API arguments needed to compressed textures. This puts the burden on the container
  60056. * generator to house the arcane code for determining these for current & future formats.
  60057. *
  60058. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  60059. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  60060. *
  60061. * Note: The result of this call is not taken into account when a texture is base64.
  60062. *
  60063. * @param formatsAvailable defines the list of those format families you have created
  60064. * on your server. Syntax: '-' + format family + '.ktx'. (Case and order do not matter.)
  60065. *
  60066. * Current families are astc, dxt, pvrtc, etc2, & etc1.
  60067. * @returns The extension selected.
  60068. */
  60069. setTextureFormatToUse(formatsAvailable: Array<string>): Nullable<string>;
  60070. }
  60071. }
  60072. declare module BABYLON {
  60073. /** @hidden */
  60074. export var rgbdEncodePixelShader: {
  60075. name: string;
  60076. shader: string;
  60077. };
  60078. }
  60079. declare module BABYLON {
  60080. /**
  60081. * Raw texture data and descriptor sufficient for WebGL texture upload
  60082. */
  60083. export interface EnvironmentTextureInfo {
  60084. /**
  60085. * Version of the environment map
  60086. */
  60087. version: number;
  60088. /**
  60089. * Width of image
  60090. */
  60091. width: number;
  60092. /**
  60093. * Irradiance information stored in the file.
  60094. */
  60095. irradiance: any;
  60096. /**
  60097. * Specular information stored in the file.
  60098. */
  60099. specular: any;
  60100. }
  60101. /**
  60102. * Defines One Image in the file. It requires only the position in the file
  60103. * as well as the length.
  60104. */
  60105. interface BufferImageData {
  60106. /**
  60107. * Length of the image data.
  60108. */
  60109. length: number;
  60110. /**
  60111. * Position of the data from the null terminator delimiting the end of the JSON.
  60112. */
  60113. position: number;
  60114. }
  60115. /**
  60116. * Defines the specular data enclosed in the file.
  60117. * This corresponds to the version 1 of the data.
  60118. */
  60119. export interface EnvironmentTextureSpecularInfoV1 {
  60120. /**
  60121. * Defines where the specular Payload is located. It is a runtime value only not stored in the file.
  60122. */
  60123. specularDataPosition?: number;
  60124. /**
  60125. * This contains all the images data needed to reconstruct the cubemap.
  60126. */
  60127. mipmaps: Array<BufferImageData>;
  60128. /**
  60129. * Defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness.
  60130. */
  60131. lodGenerationScale: number;
  60132. }
  60133. /**
  60134. * Sets of helpers addressing the serialization and deserialization of environment texture
  60135. * stored in a BabylonJS env file.
  60136. * Those files are usually stored as .env files.
  60137. */
  60138. export class EnvironmentTextureTools {
  60139. /**
  60140. * Magic number identifying the env file.
  60141. */
  60142. private static _MagicBytes;
  60143. /**
  60144. * Gets the environment info from an env file.
  60145. * @param data The array buffer containing the .env bytes.
  60146. * @returns the environment file info (the json header) if successfully parsed.
  60147. */
  60148. static GetEnvInfo(data: ArrayBufferView): Nullable<EnvironmentTextureInfo>;
  60149. /**
  60150. * Creates an environment texture from a loaded cube texture.
  60151. * @param texture defines the cube texture to convert in env file
  60152. * @return a promise containing the environment data if successful.
  60153. */
  60154. static CreateEnvTextureAsync(texture: BaseTexture): Promise<ArrayBuffer>;
  60155. /**
  60156. * Creates a JSON representation of the spherical data.
  60157. * @param texture defines the texture containing the polynomials
  60158. * @return the JSON representation of the spherical info
  60159. */
  60160. private static _CreateEnvTextureIrradiance;
  60161. /**
  60162. * Creates the ArrayBufferViews used for initializing environment texture image data.
  60163. * @param data the image data
  60164. * @param info parameters that determine what views will be created for accessing the underlying buffer
  60165. * @return the views described by info providing access to the underlying buffer
  60166. */
  60167. static CreateImageDataArrayBufferViews(data: ArrayBufferView, info: EnvironmentTextureInfo): Array<Array<ArrayBufferView>>;
  60168. /**
  60169. * Uploads the texture info contained in the env file to the GPU.
  60170. * @param texture defines the internal texture to upload to
  60171. * @param data defines the data to load
  60172. * @param info defines the texture info retrieved through the GetEnvInfo method
  60173. * @returns a promise
  60174. */
  60175. static UploadEnvLevelsAsync(texture: InternalTexture, data: ArrayBufferView, info: EnvironmentTextureInfo): Promise<void>;
  60176. private static _OnImageReadyAsync;
  60177. /**
  60178. * Uploads the levels of image data to the GPU.
  60179. * @param texture defines the internal texture to upload to
  60180. * @param imageData defines the array buffer views of image data [mipmap][face]
  60181. * @returns a promise
  60182. */
  60183. static UploadLevelsAsync(texture: InternalTexture, imageData: ArrayBufferView[][]): Promise<void>;
  60184. /**
  60185. * Uploads spherical polynomials information to the texture.
  60186. * @param texture defines the texture we are trying to upload the information to
  60187. * @param info defines the environment texture info retrieved through the GetEnvInfo method
  60188. */
  60189. static UploadEnvSpherical(texture: InternalTexture, info: EnvironmentTextureInfo): void;
  60190. /** @hidden */
  60191. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  60192. }
  60193. }
  60194. declare module BABYLON {
  60195. /**
  60196. * Container for accessors for natively-stored mesh data buffers.
  60197. */
  60198. class NativeDataBuffer extends DataBuffer {
  60199. /**
  60200. * Accessor value used to identify/retrieve a natively-stored index buffer.
  60201. */
  60202. nativeIndexBuffer?: any;
  60203. /**
  60204. * Accessor value used to identify/retrieve a natively-stored vertex buffer.
  60205. */
  60206. nativeVertexBuffer?: any;
  60207. }
  60208. /** @hidden */
  60209. class NativeTexture extends InternalTexture {
  60210. getInternalTexture(): InternalTexture;
  60211. getViewCount(): number;
  60212. }
  60213. /** @hidden */
  60214. export class NativeEngine extends Engine {
  60215. private readonly _native;
  60216. /** Defines the invalid handle returned by bgfx when resource creation goes wrong */
  60217. private readonly INVALID_HANDLE;
  60218. private _boundBuffersVertexArray;
  60219. private _currentDepthTest;
  60220. getHardwareScalingLevel(): number;
  60221. constructor();
  60222. dispose(): void;
  60223. /**
  60224. * Can be used to override the current requestAnimationFrame requester.
  60225. * @hidden
  60226. */
  60227. protected _queueNewFrame(bindedRenderFunction: any, requester?: any): number;
  60228. /**
  60229. * Override default engine behavior.
  60230. * @param color
  60231. * @param backBuffer
  60232. * @param depth
  60233. * @param stencil
  60234. */
  60235. _bindUnboundFramebuffer(framebuffer: Nullable<WebGLFramebuffer>): void;
  60236. /**
  60237. * Gets host document
  60238. * @returns the host document object
  60239. */
  60240. getHostDocument(): Nullable<Document>;
  60241. clear(color: Nullable<IColor4Like>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  60242. createIndexBuffer(indices: IndicesArray, updateable?: boolean): NativeDataBuffer;
  60243. createVertexBuffer(data: DataArray, updateable?: boolean): NativeDataBuffer;
  60244. protected _recordVertexArrayObject(vertexArray: any, vertexBuffers: {
  60245. [key: string]: VertexBuffer;
  60246. }, indexBuffer: Nullable<NativeDataBuffer>, effect: Effect): void;
  60247. bindBuffers(vertexBuffers: {
  60248. [key: string]: VertexBuffer;
  60249. }, indexBuffer: Nullable<NativeDataBuffer>, effect: Effect): void;
  60250. recordVertexArrayObject(vertexBuffers: {
  60251. [key: string]: VertexBuffer;
  60252. }, indexBuffer: Nullable<NativeDataBuffer>, effect: Effect): WebGLVertexArrayObject;
  60253. bindVertexArrayObject(vertexArray: WebGLVertexArrayObject): void;
  60254. releaseVertexArrayObject(vertexArray: WebGLVertexArrayObject): void;
  60255. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  60256. /**
  60257. * Draw a list of indexed primitives
  60258. * @param fillMode defines the primitive to use
  60259. * @param indexStart defines the starting index
  60260. * @param indexCount defines the number of index to draw
  60261. * @param instancesCount defines the number of instances to draw (if instantiation is enabled)
  60262. */
  60263. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  60264. /**
  60265. * Draw a list of unindexed primitives
  60266. * @param fillMode defines the primitive to use
  60267. * @param verticesStart defines the index of first vertex to draw
  60268. * @param verticesCount defines the count of vertices to draw
  60269. * @param instancesCount defines the number of instances to draw (if instantiation is enabled)
  60270. */
  60271. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  60272. createPipelineContext(): IPipelineContext;
  60273. _preparePipelineContext(pipelineContext: IPipelineContext, vertexSourceCode: string, fragmentSourceCode: string, createAsRaw: boolean, rawVertexSourceCode: string, rawFragmentSourceCode: string, rebuildRebind: any, defines: Nullable<string>, transformFeedbackVaryings: Nullable<string[]>): void;
  60274. /** @hidden */
  60275. _isRenderingStateCompiled(pipelineContext: IPipelineContext): boolean;
  60276. /** @hidden */
  60277. _executeWhenRenderingStateIsCompiled(pipelineContext: IPipelineContext, action: () => void): void;
  60278. createRawShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): any;
  60279. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): any;
  60280. protected _setProgram(program: WebGLProgram): void;
  60281. _releaseEffect(effect: Effect): void;
  60282. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  60283. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): WebGLUniformLocation[];
  60284. bindUniformBlock(pipelineContext: IPipelineContext, blockName: string, index: number): void;
  60285. bindSamplers(effect: Effect): void;
  60286. setMatrix(uniform: WebGLUniformLocation, matrix: IMatrixLike): void;
  60287. getRenderWidth(useScreen?: boolean): number;
  60288. getRenderHeight(useScreen?: boolean): number;
  60289. setViewport(viewport: IViewportLike, requiredWidth?: number, requiredHeight?: number): void;
  60290. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  60291. /**
  60292. * Set the z offset to apply to current rendering
  60293. * @param value defines the offset to apply
  60294. */
  60295. setZOffset(value: number): void;
  60296. /**
  60297. * Gets the current value of the zOffset
  60298. * @returns the current zOffset state
  60299. */
  60300. getZOffset(): number;
  60301. /**
  60302. * Enable or disable depth buffering
  60303. * @param enable defines the state to set
  60304. */
  60305. setDepthBuffer(enable: boolean): void;
  60306. /**
  60307. * Gets a boolean indicating if depth writing is enabled
  60308. * @returns the current depth writing state
  60309. */
  60310. getDepthWrite(): boolean;
  60311. setDepthFunctionToGreater(): void;
  60312. setDepthFunctionToGreaterOrEqual(): void;
  60313. setDepthFunctionToLess(): void;
  60314. setDepthFunctionToLessOrEqual(): void;
  60315. /**
  60316. * Enable or disable depth writing
  60317. * @param enable defines the state to set
  60318. */
  60319. setDepthWrite(enable: boolean): void;
  60320. /**
  60321. * Enable or disable color writing
  60322. * @param enable defines the state to set
  60323. */
  60324. setColorWrite(enable: boolean): void;
  60325. /**
  60326. * Gets a boolean indicating if color writing is enabled
  60327. * @returns the current color writing state
  60328. */
  60329. getColorWrite(): boolean;
  60330. /**
  60331. * Sets alpha constants used by some alpha blending modes
  60332. * @param r defines the red component
  60333. * @param g defines the green component
  60334. * @param b defines the blue component
  60335. * @param a defines the alpha component
  60336. */
  60337. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  60338. /**
  60339. * Sets the current alpha mode
  60340. * @param mode defines the mode to use (one of the BABYLON.Constants.ALPHA_XXX)
  60341. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  60342. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  60343. */
  60344. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  60345. /**
  60346. * Gets the current alpha mode
  60347. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  60348. * @returns the current alpha mode
  60349. */
  60350. getAlphaMode(): number;
  60351. setInt(uniform: WebGLUniformLocation, int: number): boolean;
  60352. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): boolean;
  60353. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): boolean;
  60354. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): boolean;
  60355. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): boolean;
  60356. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): boolean;
  60357. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): boolean;
  60358. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): boolean;
  60359. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): boolean;
  60360. setArray(uniform: WebGLUniformLocation, array: number[]): boolean;
  60361. setArray2(uniform: WebGLUniformLocation, array: number[]): boolean;
  60362. setArray3(uniform: WebGLUniformLocation, array: number[]): boolean;
  60363. setArray4(uniform: WebGLUniformLocation, array: number[]): boolean;
  60364. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): boolean;
  60365. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): boolean;
  60366. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): boolean;
  60367. setFloat(uniform: WebGLUniformLocation, value: number): boolean;
  60368. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): boolean;
  60369. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): boolean;
  60370. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): boolean;
  60371. setColor3(uniform: WebGLUniformLocation, color3: IColor3Like): boolean;
  60372. setColor4(uniform: WebGLUniformLocation, color3: IColor3Like, alpha: number): boolean;
  60373. wipeCaches(bruteForce?: boolean): void;
  60374. protected _createTexture(): WebGLTexture;
  60375. protected _deleteTexture(texture: Nullable<WebGLTexture>): void;
  60376. /**
  60377. * Update the content of a dynamic texture
  60378. * @param texture defines the texture to update
  60379. * @param canvas defines the canvas containing the source
  60380. * @param invertY defines if data must be stored with Y axis inverted
  60381. * @param premulAlpha defines if alpha is stored as premultiplied
  60382. * @param format defines the format of the data
  60383. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  60384. */
  60385. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number): void;
  60386. createRawTexture(data: Nullable<ArrayBufferView>, width: number, height: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>, type?: number): InternalTexture;
  60387. updateRawTexture(texture: Nullable<InternalTexture>, bufferView: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression?: Nullable<string>, type?: number): void;
  60388. /**
  60389. * Usually called from Texture.ts.
  60390. * Passed information to create a WebGLTexture
  60391. * @param url defines a value which contains one of the following:
  60392. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  60393. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  60394. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  60395. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  60396. * @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)
  60397. * @param scene needed for loading to the correct scene
  60398. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  60399. * @param onLoad optional callback to be called upon successful completion
  60400. * @param onError optional callback to be called upon failure
  60401. * @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
  60402. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  60403. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  60404. * @param forcedExtension defines the extension to use to pick the right loader
  60405. * @param mimeType defines an optional mime type
  60406. * @param loaderOptions options to be passed to the loader
  60407. * @returns a InternalTexture for assignment back into BABYLON.Texture
  60408. */
  60409. 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;
  60410. _createDepthStencilTexture(size: RenderTargetTextureSize, options: DepthTextureCreationOptions): NativeTexture;
  60411. _releaseFramebufferObjects(texture: InternalTexture): void;
  60412. /**
  60413. * Creates a cube texture
  60414. * @param rootUrl defines the url where the files to load is located
  60415. * @param scene defines the current scene
  60416. * @param files defines the list of files to load (1 per face)
  60417. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  60418. * @param onLoad defines an optional callback raised when the texture is loaded
  60419. * @param onError defines an optional callback raised if there is an issue to load the texture
  60420. * @param format defines the format of the data
  60421. * @param forcedExtension defines the extension to use to pick the right loader
  60422. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  60423. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  60424. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  60425. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  60426. * @returns the cube texture as an InternalTexture
  60427. */
  60428. 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;
  60429. createRenderTargetTexture(size: number | {
  60430. width: number;
  60431. height: number;
  60432. }, options: boolean | RenderTargetCreationOptions): NativeTexture;
  60433. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  60434. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  60435. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  60436. createDynamicVertexBuffer(data: DataArray): DataBuffer;
  60437. updateDynamicIndexBuffer(indexBuffer: DataBuffer, indices: IndicesArray, offset?: number): void;
  60438. /**
  60439. * Updates a dynamic vertex buffer.
  60440. * @param vertexBuffer the vertex buffer to update
  60441. * @param data the data used to update the vertex buffer
  60442. * @param byteOffset the byte offset of the data (optional)
  60443. * @param byteLength the byte length of the data (optional)
  60444. */
  60445. updateDynamicVertexBuffer(vertexBuffer: DataBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  60446. protected _setTexture(channel: number, texture: Nullable<BaseTexture>, isPartOfTextureArray?: boolean, depthStencilTexture?: boolean): boolean;
  60447. private _updateAnisotropicLevel;
  60448. private _getAddressMode;
  60449. /** @hidden */
  60450. _bindTexture(channel: number, texture: InternalTexture): void;
  60451. protected _deleteBuffer(buffer: NativeDataBuffer): void;
  60452. releaseEffects(): void;
  60453. /** @hidden */
  60454. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  60455. /** @hidden */
  60456. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  60457. /** @hidden */
  60458. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  60459. /** @hidden */
  60460. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  60461. private _getNativeSamplingMode;
  60462. private _getNativeTextureFormat;
  60463. private _getNativeAlphaMode;
  60464. private _getNativeAttribType;
  60465. }
  60466. }
  60467. declare module BABYLON {
  60468. /**
  60469. * Helper class to create the best engine depending on the current hardware
  60470. */
  60471. export class EngineFactory {
  60472. /**
  60473. * Creates an engine based on the capabilities of the underlying hardware
  60474. * @param canvas Defines the canvas to use to display the result
  60475. * @param options Defines the options passed to the engine to create the context dependencies
  60476. * @returns a promise that resolves with the created engine
  60477. */
  60478. static CreateAsync(canvas: HTMLCanvasElement, options: any): Promise<ThinEngine>;
  60479. }
  60480. }
  60481. declare module BABYLON {
  60482. /**
  60483. * Gather the list of clipboard event types as constants.
  60484. */
  60485. export class ClipboardEventTypes {
  60486. /**
  60487. * The clipboard event is fired when a copy command is active (pressed).
  60488. */
  60489. static readonly COPY: number;
  60490. /**
  60491. * The clipboard event is fired when a cut command is active (pressed).
  60492. */
  60493. static readonly CUT: number;
  60494. /**
  60495. * The clipboard event is fired when a paste command is active (pressed).
  60496. */
  60497. static readonly PASTE: number;
  60498. }
  60499. /**
  60500. * This class is used to store clipboard related info for the onClipboardObservable event.
  60501. */
  60502. export class ClipboardInfo {
  60503. /**
  60504. * Defines the type of event (BABYLON.ClipboardEventTypes)
  60505. */
  60506. type: number;
  60507. /**
  60508. * Defines the related dom event
  60509. */
  60510. event: ClipboardEvent;
  60511. /**
  60512. *Creates an instance of ClipboardInfo.
  60513. * @param type Defines the type of event (BABYLON.ClipboardEventTypes)
  60514. * @param event Defines the related dom event
  60515. */
  60516. constructor(
  60517. /**
  60518. * Defines the type of event (BABYLON.ClipboardEventTypes)
  60519. */
  60520. type: number,
  60521. /**
  60522. * Defines the related dom event
  60523. */
  60524. event: ClipboardEvent);
  60525. /**
  60526. * Get the clipboard event's type from the keycode.
  60527. * @param keyCode Defines the keyCode for the current keyboard event.
  60528. * @return {number}
  60529. */
  60530. static GetTypeFromCharacter(keyCode: number): number;
  60531. }
  60532. }
  60533. declare module BABYLON {
  60534. /**
  60535. * Google Daydream controller
  60536. */
  60537. export class DaydreamController extends WebVRController {
  60538. /**
  60539. * Base Url for the controller model.
  60540. */
  60541. static MODEL_BASE_URL: string;
  60542. /**
  60543. * File name for the controller model.
  60544. */
  60545. static MODEL_FILENAME: string;
  60546. /**
  60547. * Gamepad Id prefix used to identify Daydream Controller.
  60548. */
  60549. static readonly GAMEPAD_ID_PREFIX: string;
  60550. /**
  60551. * Creates a new DaydreamController from a gamepad
  60552. * @param vrGamepad the gamepad that the controller should be created from
  60553. */
  60554. constructor(vrGamepad: any);
  60555. /**
  60556. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  60557. * @param scene scene in which to add meshes
  60558. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  60559. */
  60560. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  60561. /**
  60562. * Called once for each button that changed state since the last frame
  60563. * @param buttonIdx Which button index changed
  60564. * @param state New state of the button
  60565. * @param changes Which properties on the state changed since last frame
  60566. */
  60567. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  60568. }
  60569. }
  60570. declare module BABYLON {
  60571. /**
  60572. * Gear VR Controller
  60573. */
  60574. export class GearVRController extends WebVRController {
  60575. /**
  60576. * Base Url for the controller model.
  60577. */
  60578. static MODEL_BASE_URL: string;
  60579. /**
  60580. * File name for the controller model.
  60581. */
  60582. static MODEL_FILENAME: string;
  60583. /**
  60584. * Gamepad Id prefix used to identify this controller.
  60585. */
  60586. static readonly GAMEPAD_ID_PREFIX: string;
  60587. private readonly _buttonIndexToObservableNameMap;
  60588. /**
  60589. * Creates a new GearVRController from a gamepad
  60590. * @param vrGamepad the gamepad that the controller should be created from
  60591. */
  60592. constructor(vrGamepad: any);
  60593. /**
  60594. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  60595. * @param scene scene in which to add meshes
  60596. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  60597. */
  60598. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  60599. /**
  60600. * Called once for each button that changed state since the last frame
  60601. * @param buttonIdx Which button index changed
  60602. * @param state New state of the button
  60603. * @param changes Which properties on the state changed since last frame
  60604. */
  60605. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  60606. }
  60607. }
  60608. declare module BABYLON {
  60609. /**
  60610. * Generic Controller
  60611. */
  60612. export class GenericController extends WebVRController {
  60613. /**
  60614. * Base Url for the controller model.
  60615. */
  60616. static readonly MODEL_BASE_URL: string;
  60617. /**
  60618. * File name for the controller model.
  60619. */
  60620. static readonly MODEL_FILENAME: string;
  60621. /**
  60622. * Creates a new GenericController from a gamepad
  60623. * @param vrGamepad the gamepad that the controller should be created from
  60624. */
  60625. constructor(vrGamepad: any);
  60626. /**
  60627. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  60628. * @param scene scene in which to add meshes
  60629. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  60630. */
  60631. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  60632. /**
  60633. * Called once for each button that changed state since the last frame
  60634. * @param buttonIdx Which button index changed
  60635. * @param state New state of the button
  60636. * @param changes Which properties on the state changed since last frame
  60637. */
  60638. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  60639. }
  60640. }
  60641. declare module BABYLON {
  60642. /**
  60643. * Oculus Touch Controller
  60644. */
  60645. export class OculusTouchController extends WebVRController {
  60646. /**
  60647. * Base Url for the controller model.
  60648. */
  60649. static MODEL_BASE_URL: string;
  60650. /**
  60651. * File name for the left controller model.
  60652. */
  60653. static MODEL_LEFT_FILENAME: string;
  60654. /**
  60655. * File name for the right controller model.
  60656. */
  60657. static MODEL_RIGHT_FILENAME: string;
  60658. /**
  60659. * Base Url for the Quest controller model.
  60660. */
  60661. static QUEST_MODEL_BASE_URL: string;
  60662. /**
  60663. * @hidden
  60664. * If the controllers are running on a device that needs the updated Quest controller models
  60665. */
  60666. static _IsQuest: boolean;
  60667. /**
  60668. * Fired when the secondary trigger on this controller is modified
  60669. */
  60670. onSecondaryTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  60671. /**
  60672. * Fired when the thumb rest on this controller is modified
  60673. */
  60674. onThumbRestChangedObservable: Observable<ExtendedGamepadButton>;
  60675. /**
  60676. * Creates a new OculusTouchController from a gamepad
  60677. * @param vrGamepad the gamepad that the controller should be created from
  60678. */
  60679. constructor(vrGamepad: any);
  60680. /**
  60681. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  60682. * @param scene scene in which to add meshes
  60683. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  60684. */
  60685. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  60686. /**
  60687. * Fired when the A button on this controller is modified
  60688. */
  60689. get onAButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  60690. /**
  60691. * Fired when the B button on this controller is modified
  60692. */
  60693. get onBButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  60694. /**
  60695. * Fired when the X button on this controller is modified
  60696. */
  60697. get onXButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  60698. /**
  60699. * Fired when the Y button on this controller is modified
  60700. */
  60701. get onYButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  60702. /**
  60703. * Called once for each button that changed state since the last frame
  60704. * 0) thumb stick (touch, press, value = pressed (0,1)). value is in this.leftStick
  60705. * 1) index trigger (touch (?), press (only when value > 0.1), value 0 to 1)
  60706. * 2) secondary trigger (same)
  60707. * 3) A (right) X (left), touch, pressed = value
  60708. * 4) B / Y
  60709. * 5) thumb rest
  60710. * @param buttonIdx Which button index changed
  60711. * @param state New state of the button
  60712. * @param changes Which properties on the state changed since last frame
  60713. */
  60714. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  60715. }
  60716. }
  60717. declare module BABYLON {
  60718. /**
  60719. * Vive Controller
  60720. */
  60721. export class ViveController extends WebVRController {
  60722. /**
  60723. * Base Url for the controller model.
  60724. */
  60725. static MODEL_BASE_URL: string;
  60726. /**
  60727. * File name for the controller model.
  60728. */
  60729. static MODEL_FILENAME: string;
  60730. /**
  60731. * Creates a new ViveController from a gamepad
  60732. * @param vrGamepad the gamepad that the controller should be created from
  60733. */
  60734. constructor(vrGamepad: any);
  60735. /**
  60736. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  60737. * @param scene scene in which to add meshes
  60738. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  60739. */
  60740. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  60741. /**
  60742. * Fired when the left button on this controller is modified
  60743. */
  60744. get onLeftButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  60745. /**
  60746. * Fired when the right button on this controller is modified
  60747. */
  60748. get onRightButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  60749. /**
  60750. * Fired when the menu button on this controller is modified
  60751. */
  60752. get onMenuButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  60753. /**
  60754. * Called once for each button that changed state since the last frame
  60755. * Vive mapping:
  60756. * 0: touchpad
  60757. * 1: trigger
  60758. * 2: left AND right buttons
  60759. * 3: menu button
  60760. * @param buttonIdx Which button index changed
  60761. * @param state New state of the button
  60762. * @param changes Which properties on the state changed since last frame
  60763. */
  60764. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  60765. }
  60766. }
  60767. declare module BABYLON {
  60768. /**
  60769. * Defines the WindowsMotionController object that the state of the windows motion controller
  60770. */
  60771. export class WindowsMotionController extends WebVRController {
  60772. /**
  60773. * The base url used to load the left and right controller models
  60774. */
  60775. static MODEL_BASE_URL: string;
  60776. /**
  60777. * The name of the left controller model file
  60778. */
  60779. static MODEL_LEFT_FILENAME: string;
  60780. /**
  60781. * The name of the right controller model file
  60782. */
  60783. static MODEL_RIGHT_FILENAME: string;
  60784. /**
  60785. * The controller name prefix for this controller type
  60786. */
  60787. static readonly GAMEPAD_ID_PREFIX: string;
  60788. /**
  60789. * The controller id pattern for this controller type
  60790. */
  60791. private static readonly GAMEPAD_ID_PATTERN;
  60792. private _loadedMeshInfo;
  60793. protected readonly _mapping: {
  60794. buttons: string[];
  60795. buttonMeshNames: {
  60796. trigger: string;
  60797. menu: string;
  60798. grip: string;
  60799. thumbstick: string;
  60800. trackpad: string;
  60801. };
  60802. buttonObservableNames: {
  60803. trigger: string;
  60804. menu: string;
  60805. grip: string;
  60806. thumbstick: string;
  60807. trackpad: string;
  60808. };
  60809. axisMeshNames: string[];
  60810. pointingPoseMeshName: string;
  60811. };
  60812. /**
  60813. * Fired when the trackpad on this controller is clicked
  60814. */
  60815. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  60816. /**
  60817. * Fired when the trackpad on this controller is modified
  60818. */
  60819. onTrackpadValuesChangedObservable: Observable<StickValues>;
  60820. /**
  60821. * The current x and y values of this controller's trackpad
  60822. */
  60823. trackpad: StickValues;
  60824. /**
  60825. * Creates a new WindowsMotionController from a gamepad
  60826. * @param vrGamepad the gamepad that the controller should be created from
  60827. */
  60828. constructor(vrGamepad: any);
  60829. /**
  60830. * Fired when the trigger on this controller is modified
  60831. */
  60832. get onTriggerButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  60833. /**
  60834. * Fired when the menu button on this controller is modified
  60835. */
  60836. get onMenuButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  60837. /**
  60838. * Fired when the grip button on this controller is modified
  60839. */
  60840. get onGripButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  60841. /**
  60842. * Fired when the thumbstick button on this controller is modified
  60843. */
  60844. get onThumbstickButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  60845. /**
  60846. * Fired when the touchpad button on this controller is modified
  60847. */
  60848. get onTouchpadButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  60849. /**
  60850. * Fired when the touchpad values on this controller are modified
  60851. */
  60852. get onTouchpadValuesChangedObservable(): Observable<StickValues>;
  60853. protected _updateTrackpad(): void;
  60854. /**
  60855. * Called once per frame by the engine.
  60856. */
  60857. update(): void;
  60858. /**
  60859. * Called once for each button that changed state since the last frame
  60860. * @param buttonIdx Which button index changed
  60861. * @param state New state of the button
  60862. * @param changes Which properties on the state changed since last frame
  60863. */
  60864. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  60865. /**
  60866. * Moves the buttons on the controller mesh based on their current state
  60867. * @param buttonName the name of the button to move
  60868. * @param buttonValue the value of the button which determines the buttons new position
  60869. */
  60870. protected _lerpButtonTransform(buttonName: string, buttonValue: number): void;
  60871. /**
  60872. * Moves the axis on the controller mesh based on its current state
  60873. * @param axis the index of the axis
  60874. * @param axisValue the value of the axis which determines the meshes new position
  60875. * @hidden
  60876. */
  60877. protected _lerpAxisTransform(axis: number, axisValue: number): void;
  60878. /**
  60879. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  60880. * @param scene scene in which to add meshes
  60881. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  60882. */
  60883. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void, forceDefault?: boolean): void;
  60884. /**
  60885. * Takes a list of meshes (as loaded from the glTF file) and finds the root node, as well as nodes that
  60886. * can be transformed by button presses and axes values, based on this._mapping.
  60887. *
  60888. * @param scene scene in which the meshes exist
  60889. * @param meshes list of meshes that make up the controller model to process
  60890. * @return structured view of the given meshes, with mapping of buttons and axes to meshes that can be transformed.
  60891. */
  60892. private processModel;
  60893. private createMeshInfo;
  60894. /**
  60895. * Gets the ray of the controller in the direction the controller is pointing
  60896. * @param length the length the resulting ray should be
  60897. * @returns a ray in the direction the controller is pointing
  60898. */
  60899. getForwardRay(length?: number): Ray;
  60900. /**
  60901. * Disposes of the controller
  60902. */
  60903. dispose(): void;
  60904. }
  60905. /**
  60906. * This class represents a new windows motion controller in XR.
  60907. */
  60908. export class XRWindowsMotionController extends WindowsMotionController {
  60909. /**
  60910. * Changing the original WIndowsMotionController mapping to fir the new mapping
  60911. */
  60912. protected readonly _mapping: {
  60913. buttons: string[];
  60914. buttonMeshNames: {
  60915. trigger: string;
  60916. menu: string;
  60917. grip: string;
  60918. thumbstick: string;
  60919. trackpad: string;
  60920. };
  60921. buttonObservableNames: {
  60922. trigger: string;
  60923. menu: string;
  60924. grip: string;
  60925. thumbstick: string;
  60926. trackpad: string;
  60927. };
  60928. axisMeshNames: string[];
  60929. pointingPoseMeshName: string;
  60930. };
  60931. /**
  60932. * Construct a new XR-Based windows motion controller
  60933. *
  60934. * @param gamepadInfo the gamepad object from the browser
  60935. */
  60936. constructor(gamepadInfo: any);
  60937. /**
  60938. * holds the thumbstick values (X,Y)
  60939. */
  60940. thumbstickValues: StickValues;
  60941. /**
  60942. * Fired when the thumbstick on this controller is clicked
  60943. */
  60944. onThumbstickStateChangedObservable: Observable<ExtendedGamepadButton>;
  60945. /**
  60946. * Fired when the thumbstick on this controller is modified
  60947. */
  60948. onThumbstickValuesChangedObservable: Observable<StickValues>;
  60949. /**
  60950. * Fired when the touchpad button on this controller is modified
  60951. */
  60952. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  60953. /**
  60954. * Fired when the touchpad values on this controller are modified
  60955. */
  60956. onTrackpadValuesChangedObservable: Observable<StickValues>;
  60957. /**
  60958. * Fired when the thumbstick button on this controller is modified
  60959. * here to prevent breaking changes
  60960. */
  60961. get onThumbstickButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  60962. /**
  60963. * updating the thumbstick(!) and not the trackpad.
  60964. * This is named this way due to the difference between WebVR and XR and to avoid
  60965. * changing the parent class.
  60966. */
  60967. protected _updateTrackpad(): void;
  60968. /**
  60969. * Disposes the class with joy
  60970. */
  60971. dispose(): void;
  60972. }
  60973. }
  60974. declare module BABYLON {
  60975. /**
  60976. * A directional light is defined by a direction (what a surprise!).
  60977. * The light is emitted from everywhere in the specified direction, and has an infinite range.
  60978. * 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.
  60979. * Documentation: https://doc.babylonjs.com/babylon101/lights
  60980. */
  60981. export class DirectionalLight extends ShadowLight {
  60982. private _shadowFrustumSize;
  60983. /**
  60984. * Fix frustum size for the shadow generation. This is disabled if the value is 0.
  60985. */
  60986. get shadowFrustumSize(): number;
  60987. /**
  60988. * Specifies a fix frustum size for the shadow generation.
  60989. */
  60990. set shadowFrustumSize(value: number);
  60991. private _shadowOrthoScale;
  60992. /**
  60993. * Gets the shadow projection scale against the optimal computed one.
  60994. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  60995. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  60996. */
  60997. get shadowOrthoScale(): number;
  60998. /**
  60999. * Sets the shadow projection scale against the optimal computed one.
  61000. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  61001. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  61002. */
  61003. set shadowOrthoScale(value: number);
  61004. /**
  61005. * Automatically compute the projection matrix to best fit (including all the casters)
  61006. * on each frame.
  61007. */
  61008. autoUpdateExtends: boolean;
  61009. /**
  61010. * Automatically compute the shadowMinZ and shadowMaxZ for the projection matrix to best fit (including all the casters)
  61011. * on each frame. autoUpdateExtends must be set to true for this to work
  61012. */
  61013. autoCalcShadowZBounds: boolean;
  61014. private _orthoLeft;
  61015. private _orthoRight;
  61016. private _orthoTop;
  61017. private _orthoBottom;
  61018. /**
  61019. * Creates a DirectionalLight object in the scene, oriented towards the passed direction (Vector3).
  61020. * The directional light is emitted from everywhere in the given direction.
  61021. * It can cast shadows.
  61022. * Documentation : https://doc.babylonjs.com/babylon101/lights
  61023. * @param name The friendly name of the light
  61024. * @param direction The direction of the light
  61025. * @param scene The scene the light belongs to
  61026. */
  61027. constructor(name: string, direction: Vector3, scene: Scene);
  61028. /**
  61029. * Returns the string "DirectionalLight".
  61030. * @return The class name
  61031. */
  61032. getClassName(): string;
  61033. /**
  61034. * Returns the integer 1.
  61035. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  61036. */
  61037. getTypeID(): number;
  61038. /**
  61039. * Sets the passed matrix "matrix" as projection matrix for the shadows cast by the light according to the passed view matrix.
  61040. * Returns the DirectionalLight Shadow projection matrix.
  61041. */
  61042. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  61043. /**
  61044. * Sets the passed matrix "matrix" as fixed frustum projection matrix for the shadows cast by the light according to the passed view matrix.
  61045. * Returns the DirectionalLight Shadow projection matrix.
  61046. */
  61047. protected _setDefaultFixedFrustumShadowProjectionMatrix(matrix: Matrix): void;
  61048. /**
  61049. * Sets the passed matrix "matrix" as auto extend projection matrix for the shadows cast by the light according to the passed view matrix.
  61050. * Returns the DirectionalLight Shadow projection matrix.
  61051. */
  61052. protected _setDefaultAutoExtendShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  61053. protected _buildUniformLayout(): void;
  61054. /**
  61055. * Sets the passed Effect object with the DirectionalLight transformed position (or position if not parented) and the passed name.
  61056. * @param effect The effect to update
  61057. * @param lightIndex The index of the light in the effect to update
  61058. * @returns The directional light
  61059. */
  61060. transferToEffect(effect: Effect, lightIndex: string): DirectionalLight;
  61061. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): Light;
  61062. /**
  61063. * Gets the minZ used for shadow according to both the scene and the light.
  61064. *
  61065. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  61066. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  61067. * @param activeCamera The camera we are returning the min for
  61068. * @returns the depth min z
  61069. */
  61070. getDepthMinZ(activeCamera: Camera): number;
  61071. /**
  61072. * Gets the maxZ used for shadow according to both the scene and the light.
  61073. *
  61074. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  61075. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  61076. * @param activeCamera The camera we are returning the max for
  61077. * @returns the depth max z
  61078. */
  61079. getDepthMaxZ(activeCamera: Camera): number;
  61080. /**
  61081. * Prepares the list of defines specific to the light type.
  61082. * @param defines the list of defines
  61083. * @param lightIndex defines the index of the light for the effect
  61084. */
  61085. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  61086. }
  61087. }
  61088. declare module BABYLON {
  61089. /**
  61090. * Class containing static functions to help procedurally build meshes
  61091. */
  61092. export class HemisphereBuilder {
  61093. /**
  61094. * Creates a hemisphere mesh
  61095. * @param name defines the name of the mesh
  61096. * @param options defines the options used to create the mesh
  61097. * @param scene defines the hosting scene
  61098. * @returns the hemisphere mesh
  61099. */
  61100. static CreateHemisphere(name: string, options: {
  61101. segments?: number;
  61102. diameter?: number;
  61103. sideOrientation?: number;
  61104. }, scene: any): Mesh;
  61105. }
  61106. }
  61107. declare module BABYLON {
  61108. /**
  61109. * A spot light is defined by a position, a direction, an angle, and an exponent.
  61110. * These values define a cone of light starting from the position, emitting toward the direction.
  61111. * The angle, in radians, defines the size (field of illumination) of the spotlight's conical beam,
  61112. * and the exponent defines the speed of the decay of the light with distance (reach).
  61113. * Documentation: https://doc.babylonjs.com/babylon101/lights
  61114. */
  61115. export class SpotLight extends ShadowLight {
  61116. private _angle;
  61117. private _innerAngle;
  61118. private _cosHalfAngle;
  61119. private _lightAngleScale;
  61120. private _lightAngleOffset;
  61121. /**
  61122. * Gets the cone angle of the spot light in Radians.
  61123. */
  61124. get angle(): number;
  61125. /**
  61126. * Sets the cone angle of the spot light in Radians.
  61127. */
  61128. set angle(value: number);
  61129. /**
  61130. * Only used in gltf falloff mode, this defines the angle where
  61131. * the directional falloff will start before cutting at angle which could be seen
  61132. * as outer angle.
  61133. */
  61134. get innerAngle(): number;
  61135. /**
  61136. * Only used in gltf falloff mode, this defines the angle where
  61137. * the directional falloff will start before cutting at angle which could be seen
  61138. * as outer angle.
  61139. */
  61140. set innerAngle(value: number);
  61141. private _shadowAngleScale;
  61142. /**
  61143. * Allows scaling the angle of the light for shadow generation only.
  61144. */
  61145. get shadowAngleScale(): number;
  61146. /**
  61147. * Allows scaling the angle of the light for shadow generation only.
  61148. */
  61149. set shadowAngleScale(value: number);
  61150. /**
  61151. * The light decay speed with the distance from the emission spot.
  61152. */
  61153. exponent: number;
  61154. private _projectionTextureMatrix;
  61155. /**
  61156. * Allows reading the projection texture
  61157. */
  61158. get projectionTextureMatrix(): Matrix;
  61159. protected _projectionTextureLightNear: number;
  61160. /**
  61161. * Gets the near clip of the Spotlight for texture projection.
  61162. */
  61163. get projectionTextureLightNear(): number;
  61164. /**
  61165. * Sets the near clip of the Spotlight for texture projection.
  61166. */
  61167. set projectionTextureLightNear(value: number);
  61168. protected _projectionTextureLightFar: number;
  61169. /**
  61170. * Gets the far clip of the Spotlight for texture projection.
  61171. */
  61172. get projectionTextureLightFar(): number;
  61173. /**
  61174. * Sets the far clip of the Spotlight for texture projection.
  61175. */
  61176. set projectionTextureLightFar(value: number);
  61177. protected _projectionTextureUpDirection: Vector3;
  61178. /**
  61179. * Gets the Up vector of the Spotlight for texture projection.
  61180. */
  61181. get projectionTextureUpDirection(): Vector3;
  61182. /**
  61183. * Sets the Up vector of the Spotlight for texture projection.
  61184. */
  61185. set projectionTextureUpDirection(value: Vector3);
  61186. private _projectionTexture;
  61187. /**
  61188. * Gets the projection texture of the light.
  61189. */
  61190. get projectionTexture(): Nullable<BaseTexture>;
  61191. /**
  61192. * Sets the projection texture of the light.
  61193. */
  61194. set projectionTexture(value: Nullable<BaseTexture>);
  61195. private static _IsProceduralTexture;
  61196. private static _IsTexture;
  61197. private _projectionTextureViewLightDirty;
  61198. private _projectionTextureProjectionLightDirty;
  61199. private _projectionTextureDirty;
  61200. private _projectionTextureViewTargetVector;
  61201. private _projectionTextureViewLightMatrix;
  61202. private _projectionTextureProjectionLightMatrix;
  61203. private _projectionTextureScalingMatrix;
  61204. /**
  61205. * Creates a SpotLight object in the scene. A spot light is a simply light oriented cone.
  61206. * It can cast shadows.
  61207. * Documentation : https://doc.babylonjs.com/babylon101/lights
  61208. * @param name The light friendly name
  61209. * @param position The position of the spot light in the scene
  61210. * @param direction The direction of the light in the scene
  61211. * @param angle The cone angle of the light in Radians
  61212. * @param exponent The light decay speed with the distance from the emission spot
  61213. * @param scene The scene the lights belongs to
  61214. */
  61215. constructor(name: string, position: Vector3, direction: Vector3, angle: number, exponent: number, scene: Scene);
  61216. /**
  61217. * Returns the string "SpotLight".
  61218. * @returns the class name
  61219. */
  61220. getClassName(): string;
  61221. /**
  61222. * Returns the integer 2.
  61223. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  61224. */
  61225. getTypeID(): number;
  61226. /**
  61227. * Overrides the direction setter to recompute the projection texture view light Matrix.
  61228. */
  61229. protected _setDirection(value: Vector3): void;
  61230. /**
  61231. * Overrides the position setter to recompute the projection texture view light Matrix.
  61232. */
  61233. protected _setPosition(value: Vector3): void;
  61234. /**
  61235. * 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.
  61236. * Returns the SpotLight.
  61237. */
  61238. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  61239. protected _computeProjectionTextureViewLightMatrix(): void;
  61240. protected _computeProjectionTextureProjectionLightMatrix(): void;
  61241. /**
  61242. * Main function for light texture projection matrix computing.
  61243. */
  61244. protected _computeProjectionTextureMatrix(): void;
  61245. protected _buildUniformLayout(): void;
  61246. private _computeAngleValues;
  61247. /**
  61248. * Sets the passed Effect "effect" with the Light textures.
  61249. * @param effect The effect to update
  61250. * @param lightIndex The index of the light in the effect to update
  61251. * @returns The light
  61252. */
  61253. transferTexturesToEffect(effect: Effect, lightIndex: string): Light;
  61254. /**
  61255. * Sets the passed Effect object with the SpotLight transformed position (or position if not parented) and normalized direction.
  61256. * @param effect The effect to update
  61257. * @param lightIndex The index of the light in the effect to update
  61258. * @returns The spot light
  61259. */
  61260. transferToEffect(effect: Effect, lightIndex: string): SpotLight;
  61261. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  61262. /**
  61263. * Disposes the light and the associated resources.
  61264. */
  61265. dispose(): void;
  61266. /**
  61267. * Prepares the list of defines specific to the light type.
  61268. * @param defines the list of defines
  61269. * @param lightIndex defines the index of the light for the effect
  61270. */
  61271. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  61272. }
  61273. }
  61274. declare module BABYLON {
  61275. /**
  61276. * Gizmo that enables viewing a light
  61277. */
  61278. export class LightGizmo extends Gizmo {
  61279. private _lightMesh;
  61280. private _material;
  61281. private _cachedPosition;
  61282. private _cachedForward;
  61283. private _attachedMeshParent;
  61284. private _pointerObserver;
  61285. /**
  61286. * Event that fires each time the gizmo is clicked
  61287. */
  61288. onClickedObservable: Observable<Light>;
  61289. /**
  61290. * Creates a LightGizmo
  61291. * @param gizmoLayer The utility layer the gizmo will be added to
  61292. */
  61293. constructor(gizmoLayer?: UtilityLayerRenderer);
  61294. private _light;
  61295. /**
  61296. * The light that the gizmo is attached to
  61297. */
  61298. set light(light: Nullable<Light>);
  61299. get light(): Nullable<Light>;
  61300. /**
  61301. * Gets the material used to render the light gizmo
  61302. */
  61303. get material(): StandardMaterial;
  61304. /**
  61305. * @hidden
  61306. * Updates the gizmo to match the attached mesh's position/rotation
  61307. */
  61308. protected _update(): void;
  61309. private static _Scale;
  61310. /**
  61311. * Creates the lines for a light mesh
  61312. */
  61313. private static _CreateLightLines;
  61314. /**
  61315. * Disposes of the light gizmo
  61316. */
  61317. dispose(): void;
  61318. private static _CreateHemisphericLightMesh;
  61319. private static _CreatePointLightMesh;
  61320. private static _CreateSpotLightMesh;
  61321. private static _CreateDirectionalLightMesh;
  61322. }
  61323. }
  61324. declare module BABYLON {
  61325. /**
  61326. * Gizmo that enables viewing a camera
  61327. */
  61328. export class CameraGizmo extends Gizmo {
  61329. private _cameraMesh;
  61330. private _cameraLinesMesh;
  61331. private _material;
  61332. private _pointerObserver;
  61333. /**
  61334. * Event that fires each time the gizmo is clicked
  61335. */
  61336. onClickedObservable: Observable<Camera>;
  61337. /**
  61338. * Creates a CameraGizmo
  61339. * @param gizmoLayer The utility layer the gizmo will be added to
  61340. */
  61341. constructor(gizmoLayer?: UtilityLayerRenderer);
  61342. private _camera;
  61343. /** Gets or sets a boolean indicating if frustum lines must be rendered (true by default)) */
  61344. get displayFrustum(): boolean;
  61345. set displayFrustum(value: boolean);
  61346. /**
  61347. * The camera that the gizmo is attached to
  61348. */
  61349. set camera(camera: Nullable<Camera>);
  61350. get camera(): Nullable<Camera>;
  61351. /**
  61352. * Gets the material used to render the camera gizmo
  61353. */
  61354. get material(): StandardMaterial;
  61355. /**
  61356. * @hidden
  61357. * Updates the gizmo to match the attached mesh's position/rotation
  61358. */
  61359. protected _update(): void;
  61360. private static _Scale;
  61361. private _invProjection;
  61362. /**
  61363. * Disposes of the camera gizmo
  61364. */
  61365. dispose(): void;
  61366. private static _CreateCameraMesh;
  61367. private static _CreateCameraFrustum;
  61368. }
  61369. }
  61370. declare module BABYLON {
  61371. /** @hidden */
  61372. export var backgroundFragmentDeclaration: {
  61373. name: string;
  61374. shader: string;
  61375. };
  61376. }
  61377. declare module BABYLON {
  61378. /** @hidden */
  61379. export var backgroundUboDeclaration: {
  61380. name: string;
  61381. shader: string;
  61382. };
  61383. }
  61384. declare module BABYLON {
  61385. /** @hidden */
  61386. export var backgroundPixelShader: {
  61387. name: string;
  61388. shader: string;
  61389. };
  61390. }
  61391. declare module BABYLON {
  61392. /** @hidden */
  61393. export var backgroundVertexDeclaration: {
  61394. name: string;
  61395. shader: string;
  61396. };
  61397. }
  61398. declare module BABYLON {
  61399. /** @hidden */
  61400. export var backgroundVertexShader: {
  61401. name: string;
  61402. shader: string;
  61403. };
  61404. }
  61405. declare module BABYLON {
  61406. /**
  61407. * Background material used to create an efficient environment around your scene.
  61408. */
  61409. export class BackgroundMaterial extends PushMaterial {
  61410. /**
  61411. * Standard reflectance value at parallel view angle.
  61412. */
  61413. static StandardReflectance0: number;
  61414. /**
  61415. * Standard reflectance value at grazing angle.
  61416. */
  61417. static StandardReflectance90: number;
  61418. protected _primaryColor: Color3;
  61419. /**
  61420. * Key light Color (multiply against the environment texture)
  61421. */
  61422. primaryColor: Color3;
  61423. protected __perceptualColor: Nullable<Color3>;
  61424. /**
  61425. * Experimental Internal Use Only.
  61426. *
  61427. * Key light Color in "perceptual value" meaning the color you would like to see on screen.
  61428. * This acts as a helper to set the primary color to a more "human friendly" value.
  61429. * Conversion to linear space as well as exposure and tone mapping correction will be applied to keep the
  61430. * output color as close as possible from the chosen value.
  61431. * (This does not account for contrast color grading and color curves as they are considered post effect and not directly
  61432. * part of lighting setup.)
  61433. */
  61434. get _perceptualColor(): Nullable<Color3>;
  61435. set _perceptualColor(value: Nullable<Color3>);
  61436. protected _primaryColorShadowLevel: float;
  61437. /**
  61438. * Defines the level of the shadows (dark area of the reflection map) in order to help scaling the colors.
  61439. * The color opposite to the primary color is used at the level chosen to define what the black area would look.
  61440. */
  61441. get primaryColorShadowLevel(): float;
  61442. set primaryColorShadowLevel(value: float);
  61443. protected _primaryColorHighlightLevel: float;
  61444. /**
  61445. * Defines the level of the highlights (highlight area of the reflection map) in order to help scaling the colors.
  61446. * The primary color is used at the level chosen to define what the white area would look.
  61447. */
  61448. get primaryColorHighlightLevel(): float;
  61449. set primaryColorHighlightLevel(value: float);
  61450. protected _reflectionTexture: Nullable<BaseTexture>;
  61451. /**
  61452. * Reflection Texture used in the material.
  61453. * Should be author in a specific way for the best result (refer to the documentation).
  61454. */
  61455. reflectionTexture: Nullable<BaseTexture>;
  61456. protected _reflectionBlur: float;
  61457. /**
  61458. * Reflection Texture level of blur.
  61459. *
  61460. * Can be use to reuse an existing HDR Texture and target a specific LOD to prevent authoring the
  61461. * texture twice.
  61462. */
  61463. reflectionBlur: float;
  61464. protected _diffuseTexture: Nullable<BaseTexture>;
  61465. /**
  61466. * Diffuse Texture used in the material.
  61467. * Should be author in a specific way for the best result (refer to the documentation).
  61468. */
  61469. diffuseTexture: Nullable<BaseTexture>;
  61470. protected _shadowLights: Nullable<IShadowLight[]>;
  61471. /**
  61472. * Specify the list of lights casting shadow on the material.
  61473. * All scene shadow lights will be included if null.
  61474. */
  61475. shadowLights: Nullable<IShadowLight[]>;
  61476. protected _shadowLevel: float;
  61477. /**
  61478. * Helps adjusting the shadow to a softer level if required.
  61479. * 0 means black shadows and 1 means no shadows.
  61480. */
  61481. shadowLevel: float;
  61482. protected _sceneCenter: Vector3;
  61483. /**
  61484. * In case of opacity Fresnel or reflection falloff, this is use as a scene center.
  61485. * It is usually zero but might be interesting to modify according to your setup.
  61486. */
  61487. sceneCenter: Vector3;
  61488. protected _opacityFresnel: boolean;
  61489. /**
  61490. * This helps specifying that the material is falling off to the sky box at grazing angle.
  61491. * This helps ensuring a nice transition when the camera goes under the ground.
  61492. */
  61493. opacityFresnel: boolean;
  61494. protected _reflectionFresnel: boolean;
  61495. /**
  61496. * This helps specifying that the material is falling off from diffuse to the reflection texture at grazing angle.
  61497. * This helps adding a mirror texture on the ground.
  61498. */
  61499. reflectionFresnel: boolean;
  61500. protected _reflectionFalloffDistance: number;
  61501. /**
  61502. * This helps specifying the falloff radius off the reflection texture from the sceneCenter.
  61503. * This helps adding a nice falloff effect to the reflection if used as a mirror for instance.
  61504. */
  61505. reflectionFalloffDistance: number;
  61506. protected _reflectionAmount: number;
  61507. /**
  61508. * This specifies the weight of the reflection against the background in case of reflection Fresnel.
  61509. */
  61510. reflectionAmount: number;
  61511. protected _reflectionReflectance0: number;
  61512. /**
  61513. * This specifies the weight of the reflection at grazing angle.
  61514. */
  61515. reflectionReflectance0: number;
  61516. protected _reflectionReflectance90: number;
  61517. /**
  61518. * This specifies the weight of the reflection at a perpendicular point of view.
  61519. */
  61520. reflectionReflectance90: number;
  61521. /**
  61522. * Sets the reflection reflectance fresnel values according to the default standard
  61523. * empirically know to work well :-)
  61524. */
  61525. set reflectionStandardFresnelWeight(value: number);
  61526. protected _useRGBColor: boolean;
  61527. /**
  61528. * Helps to directly use the maps channels instead of their level.
  61529. */
  61530. useRGBColor: boolean;
  61531. protected _enableNoise: boolean;
  61532. /**
  61533. * This helps reducing the banding effect that could occur on the background.
  61534. */
  61535. enableNoise: boolean;
  61536. /**
  61537. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  61538. * Best used when trying to implement visual zoom effects like fish-eye or binoculars while not adjusting camera fov.
  61539. * Recommended to be keep at 1.0 except for special cases.
  61540. */
  61541. get fovMultiplier(): number;
  61542. set fovMultiplier(value: number);
  61543. private _fovMultiplier;
  61544. /**
  61545. * Enable the FOV adjustment feature controlled by fovMultiplier.
  61546. */
  61547. useEquirectangularFOV: boolean;
  61548. private _maxSimultaneousLights;
  61549. /**
  61550. * Number of Simultaneous lights allowed on the material.
  61551. */
  61552. maxSimultaneousLights: int;
  61553. private _shadowOnly;
  61554. /**
  61555. * Make the material only render shadows
  61556. */
  61557. shadowOnly: boolean;
  61558. /**
  61559. * Default configuration related to image processing available in the Background Material.
  61560. */
  61561. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  61562. /**
  61563. * Keep track of the image processing observer to allow dispose and replace.
  61564. */
  61565. private _imageProcessingObserver;
  61566. /**
  61567. * Attaches a new image processing configuration to the PBR Material.
  61568. * @param configuration (if null the scene configuration will be use)
  61569. */
  61570. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  61571. /**
  61572. * Gets the image processing configuration used either in this material.
  61573. */
  61574. get imageProcessingConfiguration(): Nullable<ImageProcessingConfiguration>;
  61575. /**
  61576. * Sets the Default image processing configuration used either in the this material.
  61577. *
  61578. * If sets to null, the scene one is in use.
  61579. */
  61580. set imageProcessingConfiguration(value: Nullable<ImageProcessingConfiguration>);
  61581. /**
  61582. * Gets whether the color curves effect is enabled.
  61583. */
  61584. get cameraColorCurvesEnabled(): boolean;
  61585. /**
  61586. * Sets whether the color curves effect is enabled.
  61587. */
  61588. set cameraColorCurvesEnabled(value: boolean);
  61589. /**
  61590. * Gets whether the color grading effect is enabled.
  61591. */
  61592. get cameraColorGradingEnabled(): boolean;
  61593. /**
  61594. * Gets whether the color grading effect is enabled.
  61595. */
  61596. set cameraColorGradingEnabled(value: boolean);
  61597. /**
  61598. * Gets whether tonemapping is enabled or not.
  61599. */
  61600. get cameraToneMappingEnabled(): boolean;
  61601. /**
  61602. * Sets whether tonemapping is enabled or not
  61603. */
  61604. set cameraToneMappingEnabled(value: boolean);
  61605. /**
  61606. * The camera exposure used on this material.
  61607. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  61608. * This corresponds to a photographic exposure.
  61609. */
  61610. get cameraExposure(): float;
  61611. /**
  61612. * The camera exposure used on this material.
  61613. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  61614. * This corresponds to a photographic exposure.
  61615. */
  61616. set cameraExposure(value: float);
  61617. /**
  61618. * Gets The camera contrast used on this material.
  61619. */
  61620. get cameraContrast(): float;
  61621. /**
  61622. * Sets The camera contrast used on this material.
  61623. */
  61624. set cameraContrast(value: float);
  61625. /**
  61626. * Gets the Color Grading 2D Lookup Texture.
  61627. */
  61628. get cameraColorGradingTexture(): Nullable<BaseTexture>;
  61629. /**
  61630. * Sets the Color Grading 2D Lookup Texture.
  61631. */
  61632. set cameraColorGradingTexture(value: Nullable<BaseTexture>);
  61633. /**
  61634. * The color grading curves provide additional color adjustment that is applied after any color grading transform (3D LUT).
  61635. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  61636. * 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;
  61637. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  61638. */
  61639. get cameraColorCurves(): Nullable<ColorCurves>;
  61640. /**
  61641. * The color grading curves provide additional color adjustment that is applied after any color grading transform (3D LUT).
  61642. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  61643. * 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;
  61644. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  61645. */
  61646. set cameraColorCurves(value: Nullable<ColorCurves>);
  61647. /**
  61648. * Due to a bug in iOS10, video tags (which are using the background material) are in BGR and not RGB.
  61649. * Setting this flag to true (not done automatically!) will convert it back to RGB.
  61650. */
  61651. switchToBGR: boolean;
  61652. private _renderTargets;
  61653. private _reflectionControls;
  61654. private _white;
  61655. private _primaryShadowColor;
  61656. private _primaryHighlightColor;
  61657. /**
  61658. * Instantiates a Background Material in the given scene
  61659. * @param name The friendly name of the material
  61660. * @param scene The scene to add the material to
  61661. */
  61662. constructor(name: string, scene: Scene);
  61663. /**
  61664. * Gets a boolean indicating that current material needs to register RTT
  61665. */
  61666. get hasRenderTargetTextures(): boolean;
  61667. /**
  61668. * The entire material has been created in order to prevent overdraw.
  61669. * @returns false
  61670. */
  61671. needAlphaTesting(): boolean;
  61672. /**
  61673. * The entire material has been created in order to prevent overdraw.
  61674. * @returns true if blending is enable
  61675. */
  61676. needAlphaBlending(): boolean;
  61677. /**
  61678. * Checks whether the material is ready to be rendered for a given mesh.
  61679. * @param mesh The mesh to render
  61680. * @param subMesh The submesh to check against
  61681. * @param useInstances Specify wether or not the material is used with instances
  61682. * @returns true if all the dependencies are ready (Textures, Effects...)
  61683. */
  61684. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  61685. /**
  61686. * Compute the primary color according to the chosen perceptual color.
  61687. */
  61688. private _computePrimaryColorFromPerceptualColor;
  61689. /**
  61690. * Compute the highlights and shadow colors according to their chosen levels.
  61691. */
  61692. private _computePrimaryColors;
  61693. /**
  61694. * Build the uniform buffer used in the material.
  61695. */
  61696. buildUniformLayout(): void;
  61697. /**
  61698. * Unbind the material.
  61699. */
  61700. unbind(): void;
  61701. /**
  61702. * Bind only the world matrix to the material.
  61703. * @param world The world matrix to bind.
  61704. */
  61705. bindOnlyWorldMatrix(world: Matrix): void;
  61706. /**
  61707. * Bind the material for a dedicated submeh (every used meshes will be considered opaque).
  61708. * @param world The world matrix to bind.
  61709. * @param subMesh The submesh to bind for.
  61710. */
  61711. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  61712. /**
  61713. * Checks to see if a texture is used in the material.
  61714. * @param texture - Base texture to use.
  61715. * @returns - Boolean specifying if a texture is used in the material.
  61716. */
  61717. hasTexture(texture: BaseTexture): boolean;
  61718. /**
  61719. * Dispose the material.
  61720. * @param forceDisposeEffect Force disposal of the associated effect.
  61721. * @param forceDisposeTextures Force disposal of the associated textures.
  61722. */
  61723. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  61724. /**
  61725. * Clones the material.
  61726. * @param name The cloned name.
  61727. * @returns The cloned material.
  61728. */
  61729. clone(name: string): BackgroundMaterial;
  61730. /**
  61731. * Serializes the current material to its JSON representation.
  61732. * @returns The JSON representation.
  61733. */
  61734. serialize(): any;
  61735. /**
  61736. * Gets the class name of the material
  61737. * @returns "BackgroundMaterial"
  61738. */
  61739. getClassName(): string;
  61740. /**
  61741. * Parse a JSON input to create back a background material.
  61742. * @param source The JSON data to parse
  61743. * @param scene The scene to create the parsed material in
  61744. * @param rootUrl The root url of the assets the material depends upon
  61745. * @returns the instantiated BackgroundMaterial.
  61746. */
  61747. static Parse(source: any, scene: Scene, rootUrl: string): BackgroundMaterial;
  61748. }
  61749. }
  61750. declare module BABYLON {
  61751. /**
  61752. * Represents the different options available during the creation of
  61753. * a Environment helper.
  61754. *
  61755. * This can control the default ground, skybox and image processing setup of your scene.
  61756. */
  61757. export interface IEnvironmentHelperOptions {
  61758. /**
  61759. * Specifies whether or not to create a ground.
  61760. * True by default.
  61761. */
  61762. createGround: boolean;
  61763. /**
  61764. * Specifies the ground size.
  61765. * 15 by default.
  61766. */
  61767. groundSize: number;
  61768. /**
  61769. * The texture used on the ground for the main color.
  61770. * Comes from the BabylonJS CDN by default.
  61771. *
  61772. * Remarks: Can be either a texture or a url.
  61773. */
  61774. groundTexture: string | BaseTexture;
  61775. /**
  61776. * The color mixed in the ground texture by default.
  61777. * BabylonJS clearColor by default.
  61778. */
  61779. groundColor: Color3;
  61780. /**
  61781. * Specifies the ground opacity.
  61782. * 1 by default.
  61783. */
  61784. groundOpacity: number;
  61785. /**
  61786. * Enables the ground to receive shadows.
  61787. * True by default.
  61788. */
  61789. enableGroundShadow: boolean;
  61790. /**
  61791. * Helps preventing the shadow to be fully black on the ground.
  61792. * 0.5 by default.
  61793. */
  61794. groundShadowLevel: number;
  61795. /**
  61796. * Creates a mirror texture attach to the ground.
  61797. * false by default.
  61798. */
  61799. enableGroundMirror: boolean;
  61800. /**
  61801. * Specifies the ground mirror size ratio.
  61802. * 0.3 by default as the default kernel is 64.
  61803. */
  61804. groundMirrorSizeRatio: number;
  61805. /**
  61806. * Specifies the ground mirror blur kernel size.
  61807. * 64 by default.
  61808. */
  61809. groundMirrorBlurKernel: number;
  61810. /**
  61811. * Specifies the ground mirror visibility amount.
  61812. * 1 by default
  61813. */
  61814. groundMirrorAmount: number;
  61815. /**
  61816. * Specifies the ground mirror reflectance weight.
  61817. * This uses the standard weight of the background material to setup the fresnel effect
  61818. * of the mirror.
  61819. * 1 by default.
  61820. */
  61821. groundMirrorFresnelWeight: number;
  61822. /**
  61823. * Specifies the ground mirror Falloff distance.
  61824. * This can helps reducing the size of the reflection.
  61825. * 0 by Default.
  61826. */
  61827. groundMirrorFallOffDistance: number;
  61828. /**
  61829. * Specifies the ground mirror texture type.
  61830. * Unsigned Int by Default.
  61831. */
  61832. groundMirrorTextureType: number;
  61833. /**
  61834. * Specifies a bias applied to the ground vertical position to prevent z-fighting with
  61835. * the shown objects.
  61836. */
  61837. groundYBias: number;
  61838. /**
  61839. * Specifies whether or not to create a skybox.
  61840. * True by default.
  61841. */
  61842. createSkybox: boolean;
  61843. /**
  61844. * Specifies the skybox size.
  61845. * 20 by default.
  61846. */
  61847. skyboxSize: number;
  61848. /**
  61849. * The texture used on the skybox for the main color.
  61850. * Comes from the BabylonJS CDN by default.
  61851. *
  61852. * Remarks: Can be either a texture or a url.
  61853. */
  61854. skyboxTexture: string | BaseTexture;
  61855. /**
  61856. * The color mixed in the skybox texture by default.
  61857. * BabylonJS clearColor by default.
  61858. */
  61859. skyboxColor: Color3;
  61860. /**
  61861. * The background rotation around the Y axis of the scene.
  61862. * This helps aligning the key lights of your scene with the background.
  61863. * 0 by default.
  61864. */
  61865. backgroundYRotation: number;
  61866. /**
  61867. * Compute automatically the size of the elements to best fit with the scene.
  61868. */
  61869. sizeAuto: boolean;
  61870. /**
  61871. * Default position of the rootMesh if autoSize is not true.
  61872. */
  61873. rootPosition: Vector3;
  61874. /**
  61875. * Sets up the image processing in the scene.
  61876. * true by default.
  61877. */
  61878. setupImageProcessing: boolean;
  61879. /**
  61880. * The texture used as your environment texture in the scene.
  61881. * Comes from the BabylonJS CDN by default and in use if setupImageProcessing is true.
  61882. *
  61883. * Remarks: Can be either a texture or a url.
  61884. */
  61885. environmentTexture: string | BaseTexture;
  61886. /**
  61887. * The value of the exposure to apply to the scene.
  61888. * 0.6 by default if setupImageProcessing is true.
  61889. */
  61890. cameraExposure: number;
  61891. /**
  61892. * The value of the contrast to apply to the scene.
  61893. * 1.6 by default if setupImageProcessing is true.
  61894. */
  61895. cameraContrast: number;
  61896. /**
  61897. * Specifies whether or not tonemapping should be enabled in the scene.
  61898. * true by default if setupImageProcessing is true.
  61899. */
  61900. toneMappingEnabled: boolean;
  61901. }
  61902. /**
  61903. * The Environment helper class can be used to add a fully featured none expensive background to your scene.
  61904. * It includes by default a skybox and a ground relying on the BackgroundMaterial.
  61905. * It also helps with the default setup of your imageProcessing configuration.
  61906. */
  61907. export class EnvironmentHelper {
  61908. /**
  61909. * Default ground texture URL.
  61910. */
  61911. private static _groundTextureCDNUrl;
  61912. /**
  61913. * Default skybox texture URL.
  61914. */
  61915. private static _skyboxTextureCDNUrl;
  61916. /**
  61917. * Default environment texture URL.
  61918. */
  61919. private static _environmentTextureCDNUrl;
  61920. /**
  61921. * Creates the default options for the helper.
  61922. */
  61923. private static _getDefaultOptions;
  61924. private _rootMesh;
  61925. /**
  61926. * Gets the root mesh created by the helper.
  61927. */
  61928. get rootMesh(): Mesh;
  61929. private _skybox;
  61930. /**
  61931. * Gets the skybox created by the helper.
  61932. */
  61933. get skybox(): Nullable<Mesh>;
  61934. private _skyboxTexture;
  61935. /**
  61936. * Gets the skybox texture created by the helper.
  61937. */
  61938. get skyboxTexture(): Nullable<BaseTexture>;
  61939. private _skyboxMaterial;
  61940. /**
  61941. * Gets the skybox material created by the helper.
  61942. */
  61943. get skyboxMaterial(): Nullable<BackgroundMaterial>;
  61944. private _ground;
  61945. /**
  61946. * Gets the ground mesh created by the helper.
  61947. */
  61948. get ground(): Nullable<Mesh>;
  61949. private _groundTexture;
  61950. /**
  61951. * Gets the ground texture created by the helper.
  61952. */
  61953. get groundTexture(): Nullable<BaseTexture>;
  61954. private _groundMirror;
  61955. /**
  61956. * Gets the ground mirror created by the helper.
  61957. */
  61958. get groundMirror(): Nullable<MirrorTexture>;
  61959. /**
  61960. * Gets the ground mirror render list to helps pushing the meshes
  61961. * you wish in the ground reflection.
  61962. */
  61963. get groundMirrorRenderList(): Nullable<AbstractMesh[]>;
  61964. private _groundMaterial;
  61965. /**
  61966. * Gets the ground material created by the helper.
  61967. */
  61968. get groundMaterial(): Nullable<BackgroundMaterial>;
  61969. /**
  61970. * Stores the creation options.
  61971. */
  61972. private readonly _scene;
  61973. private _options;
  61974. /**
  61975. * This observable will be notified with any error during the creation of the environment,
  61976. * mainly texture creation errors.
  61977. */
  61978. onErrorObservable: Observable<{
  61979. message?: string;
  61980. exception?: any;
  61981. }>;
  61982. /**
  61983. * constructor
  61984. * @param options Defines the options we want to customize the helper
  61985. * @param scene The scene to add the material to
  61986. */
  61987. constructor(options: Partial<IEnvironmentHelperOptions>, scene: Scene);
  61988. /**
  61989. * Updates the background according to the new options
  61990. * @param options
  61991. */
  61992. updateOptions(options: Partial<IEnvironmentHelperOptions>): void;
  61993. /**
  61994. * Sets the primary color of all the available elements.
  61995. * @param color the main color to affect to the ground and the background
  61996. */
  61997. setMainColor(color: Color3): void;
  61998. /**
  61999. * Setup the image processing according to the specified options.
  62000. */
  62001. private _setupImageProcessing;
  62002. /**
  62003. * Setup the environment texture according to the specified options.
  62004. */
  62005. private _setupEnvironmentTexture;
  62006. /**
  62007. * Setup the background according to the specified options.
  62008. */
  62009. private _setupBackground;
  62010. /**
  62011. * Get the scene sizes according to the setup.
  62012. */
  62013. private _getSceneSize;
  62014. /**
  62015. * Setup the ground according to the specified options.
  62016. */
  62017. private _setupGround;
  62018. /**
  62019. * Setup the ground material according to the specified options.
  62020. */
  62021. private _setupGroundMaterial;
  62022. /**
  62023. * Setup the ground diffuse texture according to the specified options.
  62024. */
  62025. private _setupGroundDiffuseTexture;
  62026. /**
  62027. * Setup the ground mirror texture according to the specified options.
  62028. */
  62029. private _setupGroundMirrorTexture;
  62030. /**
  62031. * Setup the ground to receive the mirror texture.
  62032. */
  62033. private _setupMirrorInGroundMaterial;
  62034. /**
  62035. * Setup the skybox according to the specified options.
  62036. */
  62037. private _setupSkybox;
  62038. /**
  62039. * Setup the skybox material according to the specified options.
  62040. */
  62041. private _setupSkyboxMaterial;
  62042. /**
  62043. * Setup the skybox reflection texture according to the specified options.
  62044. */
  62045. private _setupSkyboxReflectionTexture;
  62046. private _errorHandler;
  62047. /**
  62048. * Dispose all the elements created by the Helper.
  62049. */
  62050. dispose(): void;
  62051. }
  62052. }
  62053. declare module BABYLON {
  62054. /**
  62055. * Display a 360/180 degree texture on an approximately spherical surface, useful for VR applications or skyboxes.
  62056. * As a subclass of TransformNode, this allow parenting to the camera or multiple textures with different locations in the scene.
  62057. * This class achieves its effect with a Texture and a correctly configured BackgroundMaterial on an inverted sphere.
  62058. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  62059. */
  62060. export abstract class TextureDome<T extends Texture> extends TransformNode {
  62061. protected onError: Nullable<(message?: string, exception?: any) => void>;
  62062. /**
  62063. * Define the source as a Monoscopic panoramic 360/180.
  62064. */
  62065. static readonly MODE_MONOSCOPIC: number;
  62066. /**
  62067. * Define the source as a Stereoscopic TopBottom/OverUnder panoramic 360/180.
  62068. */
  62069. static readonly MODE_TOPBOTTOM: number;
  62070. /**
  62071. * Define the source as a Stereoscopic Side by Side panoramic 360/180.
  62072. */
  62073. static readonly MODE_SIDEBYSIDE: number;
  62074. private _halfDome;
  62075. private _crossEye;
  62076. protected _useDirectMapping: boolean;
  62077. /**
  62078. * The texture being displayed on the sphere
  62079. */
  62080. protected _texture: T;
  62081. /**
  62082. * Gets the texture being displayed on the sphere
  62083. */
  62084. get texture(): T;
  62085. /**
  62086. * Sets the texture being displayed on the sphere
  62087. */
  62088. set texture(newTexture: T);
  62089. /**
  62090. * The skybox material
  62091. */
  62092. protected _material: BackgroundMaterial;
  62093. /**
  62094. * The surface used for the dome
  62095. */
  62096. protected _mesh: Mesh;
  62097. /**
  62098. * Gets the mesh used for the dome.
  62099. */
  62100. get mesh(): Mesh;
  62101. /**
  62102. * A mesh that will be used to mask the back of the dome in case it is a 180 degree movie.
  62103. */
  62104. private _halfDomeMask;
  62105. /**
  62106. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  62107. * Also see the options.resolution property.
  62108. */
  62109. get fovMultiplier(): number;
  62110. set fovMultiplier(value: number);
  62111. protected _textureMode: number;
  62112. /**
  62113. * Gets or set the current texture mode for the texture. It can be:
  62114. * * TextureDome.MODE_MONOSCOPIC : Define the texture source as a Monoscopic panoramic 360.
  62115. * * TextureDome.MODE_TOPBOTTOM : Define the texture source as a Stereoscopic TopBottom/OverUnder panoramic 360.
  62116. * * TextureDome.MODE_SIDEBYSIDE : Define the texture source as a Stereoscopic Side by Side panoramic 360.
  62117. */
  62118. get textureMode(): number;
  62119. /**
  62120. * Sets the current texture mode for the texture. It can be:
  62121. * * TextureDome.MODE_MONOSCOPIC : Define the texture source as a Monoscopic panoramic 360.
  62122. * * TextureDome.MODE_TOPBOTTOM : Define the texture source as a Stereoscopic TopBottom/OverUnder panoramic 360.
  62123. * * TextureDome.MODE_SIDEBYSIDE : Define the texture source as a Stereoscopic Side by Side panoramic 360.
  62124. */
  62125. set textureMode(value: number);
  62126. /**
  62127. * Is it a 180 degrees dome (half dome) or 360 texture (full dome)
  62128. */
  62129. get halfDome(): boolean;
  62130. /**
  62131. * Set the halfDome mode. If set, only the front (180 degrees) will be displayed and the back will be blacked out.
  62132. */
  62133. set halfDome(enabled: boolean);
  62134. /**
  62135. * Set the cross-eye mode. If set, images that can be seen when crossing eyes will render correctly
  62136. */
  62137. set crossEye(enabled: boolean);
  62138. /**
  62139. * Is it a cross-eye texture?
  62140. */
  62141. get crossEye(): boolean;
  62142. /**
  62143. * The background material of this dome.
  62144. */
  62145. get material(): BackgroundMaterial;
  62146. /**
  62147. * Oberserver used in Stereoscopic VR Mode.
  62148. */
  62149. private _onBeforeCameraRenderObserver;
  62150. /**
  62151. * Observable raised when an error occured while loading the 360 image
  62152. */
  62153. onLoadErrorObservable: Observable<string>;
  62154. /**
  62155. * Create an instance of this class and pass through the parameters to the relevant classes- Texture, StandardMaterial, and Mesh.
  62156. * @param name Element's name, child elements will append suffixes for their own names.
  62157. * @param textureUrlOrElement defines the url(s) or the (video) HTML element to use
  62158. * @param options An object containing optional or exposed sub element properties
  62159. */
  62160. constructor(name: string, textureUrlOrElement: string | string[] | HTMLVideoElement, options: {
  62161. resolution?: number;
  62162. clickToPlay?: boolean;
  62163. autoPlay?: boolean;
  62164. loop?: boolean;
  62165. size?: number;
  62166. poster?: string;
  62167. faceForward?: boolean;
  62168. useDirectMapping?: boolean;
  62169. halfDomeMode?: boolean;
  62170. crossEyeMode?: boolean;
  62171. generateMipMaps?: boolean;
  62172. }, scene: Scene, onError?: Nullable<(message?: string, exception?: any) => void>);
  62173. protected abstract _initTexture(urlsOrElement: string | string[] | HTMLElement, scene: Scene, options: any): T;
  62174. protected _changeTextureMode(value: number): void;
  62175. /**
  62176. * Releases resources associated with this node.
  62177. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  62178. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  62179. */
  62180. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  62181. }
  62182. }
  62183. declare module BABYLON {
  62184. /**
  62185. * Display a 360 degree photo on an approximately spherical surface, useful for VR applications or skyboxes.
  62186. * As a subclass of TransformNode, this allow parenting to the camera with different locations in the scene.
  62187. * This class achieves its effect with a Texture and a correctly configured BackgroundMaterial on an inverted sphere.
  62188. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  62189. */
  62190. export class PhotoDome extends TextureDome<Texture> {
  62191. /**
  62192. * Define the image as a Monoscopic panoramic 360 image.
  62193. */
  62194. static readonly MODE_MONOSCOPIC: number;
  62195. /**
  62196. * Define the image as a Stereoscopic TopBottom/OverUnder panoramic 360 image.
  62197. */
  62198. static readonly MODE_TOPBOTTOM: number;
  62199. /**
  62200. * Define the image as a Stereoscopic Side by Side panoramic 360 image.
  62201. */
  62202. static readonly MODE_SIDEBYSIDE: number;
  62203. /**
  62204. * Gets or sets the texture being displayed on the sphere
  62205. */
  62206. get photoTexture(): Texture;
  62207. /**
  62208. * sets the texture being displayed on the sphere
  62209. */
  62210. set photoTexture(value: Texture);
  62211. /**
  62212. * Gets the current video mode for the video. It can be:
  62213. * * TextureDome.MODE_MONOSCOPIC : Define the texture source as a Monoscopic panoramic 360.
  62214. * * TextureDome.MODE_TOPBOTTOM : Define the texture source as a Stereoscopic TopBottom/OverUnder panoramic 360.
  62215. * * TextureDome.MODE_SIDEBYSIDE : Define the texture source as a Stereoscopic Side by Side panoramic 360.
  62216. */
  62217. get imageMode(): number;
  62218. /**
  62219. * Sets the current video mode for the video. It can be:
  62220. * * TextureDome.MODE_MONOSCOPIC : Define the texture source as a Monoscopic panoramic 360.
  62221. * * TextureDome.MODE_TOPBOTTOM : Define the texture source as a Stereoscopic TopBottom/OverUnder panoramic 360.
  62222. * * TextureDome.MODE_SIDEBYSIDE : Define the texture source as a Stereoscopic Side by Side panoramic 360.
  62223. */
  62224. set imageMode(value: number);
  62225. protected _initTexture(urlsOrElement: string, scene: Scene, options: any): Texture;
  62226. }
  62227. }
  62228. declare module BABYLON {
  62229. /**
  62230. * Direct draw surface info
  62231. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dx-graphics-dds-pguide
  62232. */
  62233. export interface DDSInfo {
  62234. /**
  62235. * Width of the texture
  62236. */
  62237. width: number;
  62238. /**
  62239. * Width of the texture
  62240. */
  62241. height: number;
  62242. /**
  62243. * Number of Mipmaps for the texture
  62244. * @see https://en.wikipedia.org/wiki/Mipmap
  62245. */
  62246. mipmapCount: number;
  62247. /**
  62248. * If the textures format is a known fourCC format
  62249. * @see https://www.fourcc.org/
  62250. */
  62251. isFourCC: boolean;
  62252. /**
  62253. * If the texture is an RGB format eg. DXGI_FORMAT_B8G8R8X8_UNORM format
  62254. */
  62255. isRGB: boolean;
  62256. /**
  62257. * If the texture is a lumincance format
  62258. */
  62259. isLuminance: boolean;
  62260. /**
  62261. * If this is a cube texture
  62262. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dds-file-layout-for-cubic-environment-maps
  62263. */
  62264. isCube: boolean;
  62265. /**
  62266. * If the texture is a compressed format eg. FOURCC_DXT1
  62267. */
  62268. isCompressed: boolean;
  62269. /**
  62270. * The dxgiFormat of the texture
  62271. * @see https://docs.microsoft.com/en-us/windows/desktop/api/dxgiformat/ne-dxgiformat-dxgi_format
  62272. */
  62273. dxgiFormat: number;
  62274. /**
  62275. * Texture type eg. Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT
  62276. */
  62277. textureType: number;
  62278. /**
  62279. * Sphericle polynomial created for the dds texture
  62280. */
  62281. sphericalPolynomial?: SphericalPolynomial;
  62282. }
  62283. /**
  62284. * Class used to provide DDS decompression tools
  62285. */
  62286. export class DDSTools {
  62287. /**
  62288. * Gets or sets a boolean indicating that LOD info is stored in alpha channel (false by default)
  62289. */
  62290. static StoreLODInAlphaChannel: boolean;
  62291. /**
  62292. * Gets DDS information from an array buffer
  62293. * @param data defines the array buffer view to read data from
  62294. * @returns the DDS information
  62295. */
  62296. static GetDDSInfo(data: ArrayBufferView): DDSInfo;
  62297. private static _FloatView;
  62298. private static _Int32View;
  62299. private static _ToHalfFloat;
  62300. private static _FromHalfFloat;
  62301. private static _GetHalfFloatAsFloatRGBAArrayBuffer;
  62302. private static _GetHalfFloatRGBAArrayBuffer;
  62303. private static _GetFloatRGBAArrayBuffer;
  62304. private static _GetFloatAsUIntRGBAArrayBuffer;
  62305. private static _GetHalfFloatAsUIntRGBAArrayBuffer;
  62306. private static _GetRGBAArrayBuffer;
  62307. private static _ExtractLongWordOrder;
  62308. private static _GetRGBArrayBuffer;
  62309. private static _GetLuminanceArrayBuffer;
  62310. /**
  62311. * Uploads DDS Levels to a Babylon Texture
  62312. * @hidden
  62313. */
  62314. static UploadDDSLevels(engine: ThinEngine, texture: InternalTexture, data: ArrayBufferView, info: DDSInfo, loadMipmaps: boolean, faces: number, lodIndex?: number, currentFace?: number): void;
  62315. }
  62316. interface ThinEngine {
  62317. /**
  62318. * Create a cube texture from prefiltered data (ie. the mipmaps contain ready to use data for PBR reflection)
  62319. * @param rootUrl defines the url where the file to load is located
  62320. * @param scene defines the current scene
  62321. * @param lodScale defines scale to apply to the mip map selection
  62322. * @param lodOffset defines offset to apply to the mip map selection
  62323. * @param onLoad defines an optional callback raised when the texture is loaded
  62324. * @param onError defines an optional callback raised if there is an issue to load the texture
  62325. * @param format defines the format of the data
  62326. * @param forcedExtension defines the extension to use to pick the right loader
  62327. * @param createPolynomials defines wheter or not to create polynomails harmonics for the texture
  62328. * @returns the cube texture as an InternalTexture
  62329. */
  62330. 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;
  62331. }
  62332. }
  62333. declare module BABYLON {
  62334. /**
  62335. * Implementation of the DDS Texture Loader.
  62336. * @hidden
  62337. */
  62338. export class _DDSTextureLoader implements IInternalTextureLoader {
  62339. /**
  62340. * Defines whether the loader supports cascade loading the different faces.
  62341. */
  62342. readonly supportCascades: boolean;
  62343. /**
  62344. * This returns if the loader support the current file information.
  62345. * @param extension defines the file extension of the file being loaded
  62346. * @returns true if the loader can load the specified file
  62347. */
  62348. canLoad(extension: string): boolean;
  62349. /**
  62350. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  62351. * @param data contains the texture data
  62352. * @param texture defines the BabylonJS internal texture
  62353. * @param createPolynomials will be true if polynomials have been requested
  62354. * @param onLoad defines the callback to trigger once the texture is ready
  62355. * @param onError defines the callback to trigger in case of error
  62356. */
  62357. loadCubeData(imgs: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  62358. /**
  62359. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  62360. * @param data contains the texture data
  62361. * @param texture defines the BabylonJS internal texture
  62362. * @param callback defines the method to call once ready to upload
  62363. */
  62364. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  62365. }
  62366. }
  62367. declare module BABYLON {
  62368. /**
  62369. * Implementation of the ENV Texture Loader.
  62370. * @hidden
  62371. */
  62372. export class _ENVTextureLoader implements IInternalTextureLoader {
  62373. /**
  62374. * Defines whether the loader supports cascade loading the different faces.
  62375. */
  62376. readonly supportCascades: boolean;
  62377. /**
  62378. * This returns if the loader support the current file information.
  62379. * @param extension defines the file extension of the file being loaded
  62380. * @returns true if the loader can load the specified file
  62381. */
  62382. canLoad(extension: string): boolean;
  62383. /**
  62384. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  62385. * @param data contains the texture data
  62386. * @param texture defines the BabylonJS internal texture
  62387. * @param createPolynomials will be true if polynomials have been requested
  62388. * @param onLoad defines the callback to trigger once the texture is ready
  62389. * @param onError defines the callback to trigger in case of error
  62390. */
  62391. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  62392. /**
  62393. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  62394. * @param data contains the texture data
  62395. * @param texture defines the BabylonJS internal texture
  62396. * @param callback defines the method to call once ready to upload
  62397. */
  62398. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  62399. }
  62400. }
  62401. declare module BABYLON {
  62402. /**
  62403. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  62404. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  62405. */
  62406. export class KhronosTextureContainer {
  62407. /** contents of the KTX container file */
  62408. data: ArrayBufferView;
  62409. private static HEADER_LEN;
  62410. private static COMPRESSED_2D;
  62411. private static COMPRESSED_3D;
  62412. private static TEX_2D;
  62413. private static TEX_3D;
  62414. /**
  62415. * Gets the openGL type
  62416. */
  62417. glType: number;
  62418. /**
  62419. * Gets the openGL type size
  62420. */
  62421. glTypeSize: number;
  62422. /**
  62423. * Gets the openGL format
  62424. */
  62425. glFormat: number;
  62426. /**
  62427. * Gets the openGL internal format
  62428. */
  62429. glInternalFormat: number;
  62430. /**
  62431. * Gets the base internal format
  62432. */
  62433. glBaseInternalFormat: number;
  62434. /**
  62435. * Gets image width in pixel
  62436. */
  62437. pixelWidth: number;
  62438. /**
  62439. * Gets image height in pixel
  62440. */
  62441. pixelHeight: number;
  62442. /**
  62443. * Gets image depth in pixels
  62444. */
  62445. pixelDepth: number;
  62446. /**
  62447. * Gets the number of array elements
  62448. */
  62449. numberOfArrayElements: number;
  62450. /**
  62451. * Gets the number of faces
  62452. */
  62453. numberOfFaces: number;
  62454. /**
  62455. * Gets the number of mipmap levels
  62456. */
  62457. numberOfMipmapLevels: number;
  62458. /**
  62459. * Gets the bytes of key value data
  62460. */
  62461. bytesOfKeyValueData: number;
  62462. /**
  62463. * Gets the load type
  62464. */
  62465. loadType: number;
  62466. /**
  62467. * If the container has been made invalid (eg. constructor failed to correctly load array buffer)
  62468. */
  62469. isInvalid: boolean;
  62470. /**
  62471. * Creates a new KhronosTextureContainer
  62472. * @param data contents of the KTX container file
  62473. * @param facesExpected should be either 1 or 6, based whether a cube texture or or
  62474. * @param threeDExpected provision for indicating that data should be a 3D texture, not implemented
  62475. * @param textureArrayExpected provision for indicating that data should be a texture array, not implemented
  62476. */
  62477. constructor(
  62478. /** contents of the KTX container file */
  62479. data: ArrayBufferView, facesExpected: number, threeDExpected?: boolean, textureArrayExpected?: boolean);
  62480. /**
  62481. * Uploads KTX content to a Babylon Texture.
  62482. * It is assumed that the texture has already been created & is currently bound
  62483. * @hidden
  62484. */
  62485. uploadLevels(texture: InternalTexture, loadMipmaps: boolean): void;
  62486. private _upload2DCompressedLevels;
  62487. /**
  62488. * Checks if the given data starts with a KTX file identifier.
  62489. * @param data the data to check
  62490. * @returns true if the data is a KTX file or false otherwise
  62491. */
  62492. static IsValid(data: ArrayBufferView): boolean;
  62493. }
  62494. }
  62495. declare module BABYLON {
  62496. /**
  62497. * Helper class to push actions to a pool of workers.
  62498. */
  62499. export class WorkerPool implements IDisposable {
  62500. private _workerInfos;
  62501. private _pendingActions;
  62502. /**
  62503. * Constructor
  62504. * @param workers Array of workers to use for actions
  62505. */
  62506. constructor(workers: Array<Worker>);
  62507. /**
  62508. * Terminates all workers and clears any pending actions.
  62509. */
  62510. dispose(): void;
  62511. /**
  62512. * Pushes an action to the worker pool. If all the workers are active, the action will be
  62513. * pended until a worker has completed its action.
  62514. * @param action The action to perform. Call onComplete when the action is complete.
  62515. */
  62516. push(action: (worker: Worker, onComplete: () => void) => void): void;
  62517. private _execute;
  62518. }
  62519. }
  62520. declare module BABYLON {
  62521. /**
  62522. * Class for loading KTX2 files
  62523. */
  62524. export class KhronosTextureContainer2 {
  62525. private static _WorkerPoolPromise?;
  62526. private static _Initialized;
  62527. private static _Ktx2Decoder;
  62528. /**
  62529. * URLs to use when loading the KTX2 decoder module as well as its dependencies
  62530. * If a url is null, the default url is used (pointing to https://preview.babylonjs.com)
  62531. * Note that jsDecoderModule can't be null and that the other dependencies will only be loaded if necessary
  62532. * Urls you can change:
  62533. * URLConfig.jsDecoderModule
  62534. * URLConfig.wasmUASTCToASTC
  62535. * URLConfig.wasmUASTCToBC7
  62536. * URLConfig.wasmUASTCToRGBA_UNORM
  62537. * URLConfig.wasmUASTCToRGBA_SRGB
  62538. * URLConfig.jsMSCTranscoder
  62539. * URLConfig.wasmMSCTranscoder
  62540. * You can see their default values in this PG: https://playground.babylonjs.com/#EIJH8L#22
  62541. */
  62542. static URLConfig: {
  62543. jsDecoderModule: string;
  62544. wasmUASTCToASTC: null;
  62545. wasmUASTCToBC7: null;
  62546. wasmUASTCToRGBA_UNORM: null;
  62547. wasmUASTCToRGBA_SRGB: null;
  62548. jsMSCTranscoder: null;
  62549. wasmMSCTranscoder: null;
  62550. };
  62551. /**
  62552. * Default number of workers used to handle data decoding
  62553. */
  62554. static DefaultNumWorkers: number;
  62555. private static GetDefaultNumWorkers;
  62556. private _engine;
  62557. private static _CreateWorkerPool;
  62558. /**
  62559. * Constructor
  62560. * @param engine The engine to use
  62561. * @param numWorkers The number of workers for async operations. Specify `0` to disable web workers and run synchronously in the current context.
  62562. */
  62563. constructor(engine: ThinEngine, numWorkers?: number);
  62564. /** @hidden */
  62565. uploadAsync(data: ArrayBufferView, internalTexture: InternalTexture, options?: any): Promise<void>;
  62566. /**
  62567. * Stop all async operations and release resources.
  62568. */
  62569. dispose(): void;
  62570. protected _createTexture(data: any, internalTexture: InternalTexture, options?: any): void;
  62571. /**
  62572. * Checks if the given data starts with a KTX2 file identifier.
  62573. * @param data the data to check
  62574. * @returns true if the data is a KTX2 file or false otherwise
  62575. */
  62576. static IsValid(data: ArrayBufferView): boolean;
  62577. }
  62578. }
  62579. declare module BABYLON {
  62580. /**
  62581. * Implementation of the KTX Texture Loader.
  62582. * @hidden
  62583. */
  62584. export class _KTXTextureLoader implements IInternalTextureLoader {
  62585. /**
  62586. * Defines whether the loader supports cascade loading the different faces.
  62587. */
  62588. readonly supportCascades: boolean;
  62589. /**
  62590. * This returns if the loader support the current file information.
  62591. * @param extension defines the file extension of the file being loaded
  62592. * @param mimeType defines the optional mime type of the file being loaded
  62593. * @returns true if the loader can load the specified file
  62594. */
  62595. canLoad(extension: string, mimeType?: string): boolean;
  62596. /**
  62597. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  62598. * @param data contains the texture data
  62599. * @param texture defines the BabylonJS internal texture
  62600. * @param createPolynomials will be true if polynomials have been requested
  62601. * @param onLoad defines the callback to trigger once the texture is ready
  62602. * @param onError defines the callback to trigger in case of error
  62603. */
  62604. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  62605. /**
  62606. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  62607. * @param data contains the texture data
  62608. * @param texture defines the BabylonJS internal texture
  62609. * @param callback defines the method to call once ready to upload
  62610. */
  62611. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed: boolean) => void, options?: any): void;
  62612. }
  62613. }
  62614. declare module BABYLON {
  62615. /** @hidden */
  62616. export var _forceSceneHelpersToBundle: boolean;
  62617. interface Scene {
  62618. /**
  62619. * Creates a default light for the scene.
  62620. * @see https://doc.babylonjs.com/How_To/Fast_Build#create-default-light
  62621. * @param replace has the default false, when true replaces the existing lights in the scene with a hemispheric light
  62622. */
  62623. createDefaultLight(replace?: boolean): void;
  62624. /**
  62625. * Creates a default camera for the scene.
  62626. * @see https://doc.babylonjs.com/How_To/Fast_Build#create-default-camera
  62627. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  62628. * @param replace has default false, when true replaces the active camera in the scene
  62629. * @param attachCameraControls has default false, when true attaches camera controls to the canvas.
  62630. */
  62631. createDefaultCamera(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  62632. /**
  62633. * Creates a default camera and a default light.
  62634. * @see https://doc.babylonjs.com/how_to/Fast_Build#create-default-camera-or-light
  62635. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  62636. * @param replace has the default false, when true replaces the active camera/light in the scene
  62637. * @param attachCameraControls has the default false, when true attaches camera controls to the canvas.
  62638. */
  62639. createDefaultCameraOrLight(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  62640. /**
  62641. * Creates a new sky box
  62642. * @see https://doc.babylonjs.com/how_to/Fast_Build#create-default-skybox
  62643. * @param environmentTexture defines the texture to use as environment texture
  62644. * @param pbr has default false which requires the StandardMaterial to be used, when true PBRMaterial must be used
  62645. * @param scale defines the overall scale of the skybox
  62646. * @param blur is only available when pbr is true, default is 0, no blur, maximum value is 1
  62647. * @param setGlobalEnvTexture has default true indicating that scene.environmentTexture must match the current skybox texture
  62648. * @returns a new mesh holding the sky box
  62649. */
  62650. createDefaultSkybox(environmentTexture?: BaseTexture, pbr?: boolean, scale?: number, blur?: number, setGlobalEnvTexture?: boolean): Nullable<Mesh>;
  62651. /**
  62652. * Creates a new environment
  62653. * @see https://doc.babylonjs.com/How_To/Fast_Build#create-default-environment
  62654. * @param options defines the options you can use to configure the environment
  62655. * @returns the new EnvironmentHelper
  62656. */
  62657. createDefaultEnvironment(options?: Partial<IEnvironmentHelperOptions>): Nullable<EnvironmentHelper>;
  62658. /**
  62659. * Creates a new VREXperienceHelper
  62660. * @see https://doc.babylonjs.com/how_to/webvr_helper
  62661. * @param webVROptions defines the options used to create the new VREXperienceHelper
  62662. * @returns a new VREXperienceHelper
  62663. */
  62664. createDefaultVRExperience(webVROptions?: VRExperienceHelperOptions): VRExperienceHelper;
  62665. /**
  62666. * Creates a new WebXRDefaultExperience
  62667. * @see https://doc.babylonjs.com/how_to/introduction_to_webxr
  62668. * @param options experience options
  62669. * @returns a promise for a new WebXRDefaultExperience
  62670. */
  62671. createDefaultXRExperienceAsync(options: WebXRDefaultExperienceOptions): Promise<WebXRDefaultExperience>;
  62672. }
  62673. }
  62674. declare module BABYLON {
  62675. /**
  62676. * Display a 360/180 degree video on an approximately spherical surface, useful for VR applications or skyboxes.
  62677. * As a subclass of TransformNode, this allow parenting to the camera or multiple videos with different locations in the scene.
  62678. * This class achieves its effect with a VideoTexture and a correctly configured BackgroundMaterial on an inverted sphere.
  62679. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  62680. */
  62681. export class VideoDome extends TextureDome<VideoTexture> {
  62682. /**
  62683. * Define the video source as a Monoscopic panoramic 360 video.
  62684. */
  62685. static readonly MODE_MONOSCOPIC: number;
  62686. /**
  62687. * Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  62688. */
  62689. static readonly MODE_TOPBOTTOM: number;
  62690. /**
  62691. * Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  62692. */
  62693. static readonly MODE_SIDEBYSIDE: number;
  62694. /**
  62695. * Get the video texture associated with this video dome
  62696. */
  62697. get videoTexture(): VideoTexture;
  62698. /**
  62699. * Get the video mode of this dome
  62700. */
  62701. get videoMode(): number;
  62702. /**
  62703. * Set the video mode of this dome.
  62704. * @see textureMode
  62705. */
  62706. set videoMode(value: number);
  62707. protected _initTexture(urlsOrElement: string | string[] | HTMLVideoElement, scene: Scene, options: any): VideoTexture;
  62708. }
  62709. }
  62710. declare module BABYLON {
  62711. /**
  62712. * This class can be used to get instrumentation data from a Babylon engine
  62713. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  62714. */
  62715. export class EngineInstrumentation implements IDisposable {
  62716. /**
  62717. * Define the instrumented engine.
  62718. */
  62719. engine: Engine;
  62720. private _captureGPUFrameTime;
  62721. private _gpuFrameTimeToken;
  62722. private _gpuFrameTime;
  62723. private _captureShaderCompilationTime;
  62724. private _shaderCompilationTime;
  62725. private _onBeginFrameObserver;
  62726. private _onEndFrameObserver;
  62727. private _onBeforeShaderCompilationObserver;
  62728. private _onAfterShaderCompilationObserver;
  62729. /**
  62730. * Gets the perf counter used for GPU frame time
  62731. */
  62732. get gpuFrameTimeCounter(): PerfCounter;
  62733. /**
  62734. * Gets the GPU frame time capture status
  62735. */
  62736. get captureGPUFrameTime(): boolean;
  62737. /**
  62738. * Enable or disable the GPU frame time capture
  62739. */
  62740. set captureGPUFrameTime(value: boolean);
  62741. /**
  62742. * Gets the perf counter used for shader compilation time
  62743. */
  62744. get shaderCompilationTimeCounter(): PerfCounter;
  62745. /**
  62746. * Gets the shader compilation time capture status
  62747. */
  62748. get captureShaderCompilationTime(): boolean;
  62749. /**
  62750. * Enable or disable the shader compilation time capture
  62751. */
  62752. set captureShaderCompilationTime(value: boolean);
  62753. /**
  62754. * Instantiates a new engine instrumentation.
  62755. * This class can be used to get instrumentation data from a Babylon engine
  62756. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  62757. * @param engine Defines the engine to instrument
  62758. */
  62759. constructor(
  62760. /**
  62761. * Define the instrumented engine.
  62762. */
  62763. engine: Engine);
  62764. /**
  62765. * Dispose and release associated resources.
  62766. */
  62767. dispose(): void;
  62768. }
  62769. }
  62770. declare module BABYLON {
  62771. /**
  62772. * This class can be used to get instrumentation data from a Babylon engine
  62773. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  62774. */
  62775. export class SceneInstrumentation implements IDisposable {
  62776. /**
  62777. * Defines the scene to instrument
  62778. */
  62779. scene: Scene;
  62780. private _captureActiveMeshesEvaluationTime;
  62781. private _activeMeshesEvaluationTime;
  62782. private _captureRenderTargetsRenderTime;
  62783. private _renderTargetsRenderTime;
  62784. private _captureFrameTime;
  62785. private _frameTime;
  62786. private _captureRenderTime;
  62787. private _renderTime;
  62788. private _captureInterFrameTime;
  62789. private _interFrameTime;
  62790. private _captureParticlesRenderTime;
  62791. private _particlesRenderTime;
  62792. private _captureSpritesRenderTime;
  62793. private _spritesRenderTime;
  62794. private _capturePhysicsTime;
  62795. private _physicsTime;
  62796. private _captureAnimationsTime;
  62797. private _animationsTime;
  62798. private _captureCameraRenderTime;
  62799. private _cameraRenderTime;
  62800. private _onBeforeActiveMeshesEvaluationObserver;
  62801. private _onAfterActiveMeshesEvaluationObserver;
  62802. private _onBeforeRenderTargetsRenderObserver;
  62803. private _onAfterRenderTargetsRenderObserver;
  62804. private _onAfterRenderObserver;
  62805. private _onBeforeDrawPhaseObserver;
  62806. private _onAfterDrawPhaseObserver;
  62807. private _onBeforeAnimationsObserver;
  62808. private _onBeforeParticlesRenderingObserver;
  62809. private _onAfterParticlesRenderingObserver;
  62810. private _onBeforeSpritesRenderingObserver;
  62811. private _onAfterSpritesRenderingObserver;
  62812. private _onBeforePhysicsObserver;
  62813. private _onAfterPhysicsObserver;
  62814. private _onAfterAnimationsObserver;
  62815. private _onBeforeCameraRenderObserver;
  62816. private _onAfterCameraRenderObserver;
  62817. /**
  62818. * Gets the perf counter used for active meshes evaluation time
  62819. */
  62820. get activeMeshesEvaluationTimeCounter(): PerfCounter;
  62821. /**
  62822. * Gets the active meshes evaluation time capture status
  62823. */
  62824. get captureActiveMeshesEvaluationTime(): boolean;
  62825. /**
  62826. * Enable or disable the active meshes evaluation time capture
  62827. */
  62828. set captureActiveMeshesEvaluationTime(value: boolean);
  62829. /**
  62830. * Gets the perf counter used for render targets render time
  62831. */
  62832. get renderTargetsRenderTimeCounter(): PerfCounter;
  62833. /**
  62834. * Gets the render targets render time capture status
  62835. */
  62836. get captureRenderTargetsRenderTime(): boolean;
  62837. /**
  62838. * Enable or disable the render targets render time capture
  62839. */
  62840. set captureRenderTargetsRenderTime(value: boolean);
  62841. /**
  62842. * Gets the perf counter used for particles render time
  62843. */
  62844. get particlesRenderTimeCounter(): PerfCounter;
  62845. /**
  62846. * Gets the particles render time capture status
  62847. */
  62848. get captureParticlesRenderTime(): boolean;
  62849. /**
  62850. * Enable or disable the particles render time capture
  62851. */
  62852. set captureParticlesRenderTime(value: boolean);
  62853. /**
  62854. * Gets the perf counter used for sprites render time
  62855. */
  62856. get spritesRenderTimeCounter(): PerfCounter;
  62857. /**
  62858. * Gets the sprites render time capture status
  62859. */
  62860. get captureSpritesRenderTime(): boolean;
  62861. /**
  62862. * Enable or disable the sprites render time capture
  62863. */
  62864. set captureSpritesRenderTime(value: boolean);
  62865. /**
  62866. * Gets the perf counter used for physics time
  62867. */
  62868. get physicsTimeCounter(): PerfCounter;
  62869. /**
  62870. * Gets the physics time capture status
  62871. */
  62872. get capturePhysicsTime(): boolean;
  62873. /**
  62874. * Enable or disable the physics time capture
  62875. */
  62876. set capturePhysicsTime(value: boolean);
  62877. /**
  62878. * Gets the perf counter used for animations time
  62879. */
  62880. get animationsTimeCounter(): PerfCounter;
  62881. /**
  62882. * Gets the animations time capture status
  62883. */
  62884. get captureAnimationsTime(): boolean;
  62885. /**
  62886. * Enable or disable the animations time capture
  62887. */
  62888. set captureAnimationsTime(value: boolean);
  62889. /**
  62890. * Gets the perf counter used for frame time capture
  62891. */
  62892. get frameTimeCounter(): PerfCounter;
  62893. /**
  62894. * Gets the frame time capture status
  62895. */
  62896. get captureFrameTime(): boolean;
  62897. /**
  62898. * Enable or disable the frame time capture
  62899. */
  62900. set captureFrameTime(value: boolean);
  62901. /**
  62902. * Gets the perf counter used for inter-frames time capture
  62903. */
  62904. get interFrameTimeCounter(): PerfCounter;
  62905. /**
  62906. * Gets the inter-frames time capture status
  62907. */
  62908. get captureInterFrameTime(): boolean;
  62909. /**
  62910. * Enable or disable the inter-frames time capture
  62911. */
  62912. set captureInterFrameTime(value: boolean);
  62913. /**
  62914. * Gets the perf counter used for render time capture
  62915. */
  62916. get renderTimeCounter(): PerfCounter;
  62917. /**
  62918. * Gets the render time capture status
  62919. */
  62920. get captureRenderTime(): boolean;
  62921. /**
  62922. * Enable or disable the render time capture
  62923. */
  62924. set captureRenderTime(value: boolean);
  62925. /**
  62926. * Gets the perf counter used for camera render time capture
  62927. */
  62928. get cameraRenderTimeCounter(): PerfCounter;
  62929. /**
  62930. * Gets the camera render time capture status
  62931. */
  62932. get captureCameraRenderTime(): boolean;
  62933. /**
  62934. * Enable or disable the camera render time capture
  62935. */
  62936. set captureCameraRenderTime(value: boolean);
  62937. /**
  62938. * Gets the perf counter used for draw calls
  62939. */
  62940. get drawCallsCounter(): PerfCounter;
  62941. /**
  62942. * Instantiates a new scene instrumentation.
  62943. * This class can be used to get instrumentation data from a Babylon engine
  62944. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  62945. * @param scene Defines the scene to instrument
  62946. */
  62947. constructor(
  62948. /**
  62949. * Defines the scene to instrument
  62950. */
  62951. scene: Scene);
  62952. /**
  62953. * Dispose and release associated resources.
  62954. */
  62955. dispose(): void;
  62956. }
  62957. }
  62958. declare module BABYLON {
  62959. /** @hidden */
  62960. export var glowMapGenerationPixelShader: {
  62961. name: string;
  62962. shader: string;
  62963. };
  62964. }
  62965. declare module BABYLON {
  62966. /** @hidden */
  62967. export var glowMapGenerationVertexShader: {
  62968. name: string;
  62969. shader: string;
  62970. };
  62971. }
  62972. declare module BABYLON {
  62973. /**
  62974. * Effect layer options. This helps customizing the behaviour
  62975. * of the effect layer.
  62976. */
  62977. export interface IEffectLayerOptions {
  62978. /**
  62979. * Multiplication factor apply to the canvas size to compute the render target size
  62980. * used to generated the objects (the smaller the faster).
  62981. */
  62982. mainTextureRatio: number;
  62983. /**
  62984. * Enforces a fixed size texture to ensure effect stability across devices.
  62985. */
  62986. mainTextureFixedSize?: number;
  62987. /**
  62988. * Alpha blending mode used to apply the blur. Default depends of the implementation.
  62989. */
  62990. alphaBlendingMode: number;
  62991. /**
  62992. * The camera attached to the layer.
  62993. */
  62994. camera: Nullable<Camera>;
  62995. /**
  62996. * The rendering group to draw the layer in.
  62997. */
  62998. renderingGroupId: number;
  62999. }
  63000. /**
  63001. * The effect layer Helps adding post process effect blended with the main pass.
  63002. *
  63003. * This can be for instance use to generate glow or highlight effects on the scene.
  63004. *
  63005. * The effect layer class can not be used directly and is intented to inherited from to be
  63006. * customized per effects.
  63007. */
  63008. export abstract class EffectLayer {
  63009. private _vertexBuffers;
  63010. private _indexBuffer;
  63011. private _cachedDefines;
  63012. private _effectLayerMapGenerationEffect;
  63013. private _effectLayerOptions;
  63014. private _mergeEffect;
  63015. protected _scene: Scene;
  63016. protected _engine: Engine;
  63017. protected _maxSize: number;
  63018. protected _mainTextureDesiredSize: ISize;
  63019. protected _mainTexture: RenderTargetTexture;
  63020. protected _shouldRender: boolean;
  63021. protected _postProcesses: PostProcess[];
  63022. protected _textures: BaseTexture[];
  63023. protected _emissiveTextureAndColor: {
  63024. texture: Nullable<BaseTexture>;
  63025. color: Color4;
  63026. };
  63027. /**
  63028. * The name of the layer
  63029. */
  63030. name: string;
  63031. /**
  63032. * The clear color of the texture used to generate the glow map.
  63033. */
  63034. neutralColor: Color4;
  63035. /**
  63036. * Specifies whether the highlight layer is enabled or not.
  63037. */
  63038. isEnabled: boolean;
  63039. /**
  63040. * Gets the camera attached to the layer.
  63041. */
  63042. get camera(): Nullable<Camera>;
  63043. /**
  63044. * Gets the rendering group id the layer should render in.
  63045. */
  63046. get renderingGroupId(): number;
  63047. set renderingGroupId(renderingGroupId: number);
  63048. /**
  63049. * Specifies if the bounding boxes should be rendered normally or if they should undergo the effect of the layer
  63050. */
  63051. disableBoundingBoxesFromEffectLayer: boolean;
  63052. /**
  63053. * An event triggered when the effect layer has been disposed.
  63054. */
  63055. onDisposeObservable: Observable<EffectLayer>;
  63056. /**
  63057. * An event triggered when the effect layer is about rendering the main texture with the glowy parts.
  63058. */
  63059. onBeforeRenderMainTextureObservable: Observable<EffectLayer>;
  63060. /**
  63061. * An event triggered when the generated texture is being merged in the scene.
  63062. */
  63063. onBeforeComposeObservable: Observable<EffectLayer>;
  63064. /**
  63065. * An event triggered when the mesh is rendered into the effect render target.
  63066. */
  63067. onBeforeRenderMeshToEffect: Observable<AbstractMesh>;
  63068. /**
  63069. * An event triggered after the mesh has been rendered into the effect render target.
  63070. */
  63071. onAfterRenderMeshToEffect: Observable<AbstractMesh>;
  63072. /**
  63073. * An event triggered when the generated texture has been merged in the scene.
  63074. */
  63075. onAfterComposeObservable: Observable<EffectLayer>;
  63076. /**
  63077. * An event triggered when the effect layer changes its size.
  63078. */
  63079. onSizeChangedObservable: Observable<EffectLayer>;
  63080. /** @hidden */
  63081. static _SceneComponentInitialization: (scene: Scene) => void;
  63082. /**
  63083. * Instantiates a new effect Layer and references it in the scene.
  63084. * @param name The name of the layer
  63085. * @param scene The scene to use the layer in
  63086. */
  63087. constructor(
  63088. /** The Friendly of the effect in the scene */
  63089. name: string, scene: Scene);
  63090. /**
  63091. * Get the effect name of the layer.
  63092. * @return The effect name
  63093. */
  63094. abstract getEffectName(): string;
  63095. /**
  63096. * Checks for the readiness of the element composing the layer.
  63097. * @param subMesh the mesh to check for
  63098. * @param useInstances specify whether or not to use instances to render the mesh
  63099. * @return true if ready otherwise, false
  63100. */
  63101. abstract isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  63102. /**
  63103. * Returns whether or not the layer needs stencil enabled during the mesh rendering.
  63104. * @returns true if the effect requires stencil during the main canvas render pass.
  63105. */
  63106. abstract needStencil(): boolean;
  63107. /**
  63108. * Create the merge effect. This is the shader use to blit the information back
  63109. * to the main canvas at the end of the scene rendering.
  63110. * @returns The effect containing the shader used to merge the effect on the main canvas
  63111. */
  63112. protected abstract _createMergeEffect(): Effect;
  63113. /**
  63114. * Creates the render target textures and post processes used in the effect layer.
  63115. */
  63116. protected abstract _createTextureAndPostProcesses(): void;
  63117. /**
  63118. * Implementation specific of rendering the generating effect on the main canvas.
  63119. * @param effect The effect used to render through
  63120. */
  63121. protected abstract _internalRender(effect: Effect): void;
  63122. /**
  63123. * Sets the required values for both the emissive texture and and the main color.
  63124. */
  63125. protected abstract _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  63126. /**
  63127. * Free any resources and references associated to a mesh.
  63128. * Internal use
  63129. * @param mesh The mesh to free.
  63130. */
  63131. abstract _disposeMesh(mesh: Mesh): void;
  63132. /**
  63133. * Serializes this layer (Glow or Highlight for example)
  63134. * @returns a serialized layer object
  63135. */
  63136. abstract serialize?(): any;
  63137. /**
  63138. * Initializes the effect layer with the required options.
  63139. * @param options Sets of none mandatory options to use with the layer (see IEffectLayerOptions for more information)
  63140. */
  63141. protected _init(options: Partial<IEffectLayerOptions>): void;
  63142. /**
  63143. * Generates the index buffer of the full screen quad blending to the main canvas.
  63144. */
  63145. private _generateIndexBuffer;
  63146. /**
  63147. * Generates the vertex buffer of the full screen quad blending to the main canvas.
  63148. */
  63149. private _generateVertexBuffer;
  63150. /**
  63151. * Sets the main texture desired size which is the closest power of two
  63152. * of the engine canvas size.
  63153. */
  63154. private _setMainTextureSize;
  63155. /**
  63156. * Creates the main texture for the effect layer.
  63157. */
  63158. protected _createMainTexture(): void;
  63159. /**
  63160. * Adds specific effects defines.
  63161. * @param defines The defines to add specifics to.
  63162. */
  63163. protected _addCustomEffectDefines(defines: string[]): void;
  63164. /**
  63165. * Checks for the readiness of the element composing the layer.
  63166. * @param subMesh the mesh to check for
  63167. * @param useInstances specify whether or not to use instances to render the mesh
  63168. * @param emissiveTexture the associated emissive texture used to generate the glow
  63169. * @return true if ready otherwise, false
  63170. */
  63171. protected _isReady(subMesh: SubMesh, useInstances: boolean, emissiveTexture: Nullable<BaseTexture>): boolean;
  63172. /**
  63173. * Renders the glowing part of the scene by blending the blurred glowing meshes on top of the rendered scene.
  63174. */
  63175. render(): void;
  63176. /**
  63177. * Determine if a given mesh will be used in the current effect.
  63178. * @param mesh mesh to test
  63179. * @returns true if the mesh will be used
  63180. */
  63181. hasMesh(mesh: AbstractMesh): boolean;
  63182. /**
  63183. * Returns true if the layer contains information to display, otherwise false.
  63184. * @returns true if the glow layer should be rendered
  63185. */
  63186. shouldRender(): boolean;
  63187. /**
  63188. * Returns true if the mesh should render, otherwise false.
  63189. * @param mesh The mesh to render
  63190. * @returns true if it should render otherwise false
  63191. */
  63192. protected _shouldRenderMesh(mesh: AbstractMesh): boolean;
  63193. /**
  63194. * Returns true if the mesh can be rendered, otherwise false.
  63195. * @param mesh The mesh to render
  63196. * @param material The material used on the mesh
  63197. * @returns true if it can be rendered otherwise false
  63198. */
  63199. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  63200. /**
  63201. * Returns true if the mesh should render, otherwise false.
  63202. * @param mesh The mesh to render
  63203. * @returns true if it should render otherwise false
  63204. */
  63205. protected _shouldRenderEmissiveTextureForMesh(): boolean;
  63206. /**
  63207. * Renders the submesh passed in parameter to the generation map.
  63208. */
  63209. protected _renderSubMesh(subMesh: SubMesh, enableAlphaMode?: boolean): void;
  63210. /**
  63211. * Defines whether the current material of the mesh should be use to render the effect.
  63212. * @param mesh defines the current mesh to render
  63213. */
  63214. protected _useMeshMaterial(mesh: AbstractMesh): boolean;
  63215. /**
  63216. * Rebuild the required buffers.
  63217. * @hidden Internal use only.
  63218. */
  63219. _rebuild(): void;
  63220. /**
  63221. * Dispose only the render target textures and post process.
  63222. */
  63223. private _disposeTextureAndPostProcesses;
  63224. /**
  63225. * Dispose the highlight layer and free resources.
  63226. */
  63227. dispose(): void;
  63228. /**
  63229. * Gets the class name of the effect layer
  63230. * @returns the string with the class name of the effect layer
  63231. */
  63232. getClassName(): string;
  63233. /**
  63234. * Creates an effect layer from parsed effect layer data
  63235. * @param parsedEffectLayer defines effect layer data
  63236. * @param scene defines the current scene
  63237. * @param rootUrl defines the root URL containing the effect layer information
  63238. * @returns a parsed effect Layer
  63239. */
  63240. static Parse(parsedEffectLayer: any, scene: Scene, rootUrl: string): EffectLayer;
  63241. }
  63242. }
  63243. declare module BABYLON {
  63244. interface AbstractScene {
  63245. /**
  63246. * The list of effect layers (highlights/glow) added to the scene
  63247. * @see https://doc.babylonjs.com/how_to/highlight_layer
  63248. * @see https://doc.babylonjs.com/how_to/glow_layer
  63249. */
  63250. effectLayers: Array<EffectLayer>;
  63251. /**
  63252. * Removes the given effect layer from this scene.
  63253. * @param toRemove defines the effect layer to remove
  63254. * @returns the index of the removed effect layer
  63255. */
  63256. removeEffectLayer(toRemove: EffectLayer): number;
  63257. /**
  63258. * Adds the given effect layer to this scene
  63259. * @param newEffectLayer defines the effect layer to add
  63260. */
  63261. addEffectLayer(newEffectLayer: EffectLayer): void;
  63262. }
  63263. /**
  63264. * Defines the layer scene component responsible to manage any effect layers
  63265. * in a given scene.
  63266. */
  63267. export class EffectLayerSceneComponent implements ISceneSerializableComponent {
  63268. /**
  63269. * The component name helpful to identify the component in the list of scene components.
  63270. */
  63271. readonly name: string;
  63272. /**
  63273. * The scene the component belongs to.
  63274. */
  63275. scene: Scene;
  63276. private _engine;
  63277. private _renderEffects;
  63278. private _needStencil;
  63279. private _previousStencilState;
  63280. /**
  63281. * Creates a new instance of the component for the given scene
  63282. * @param scene Defines the scene to register the component in
  63283. */
  63284. constructor(scene: Scene);
  63285. /**
  63286. * Registers the component in a given scene
  63287. */
  63288. register(): void;
  63289. /**
  63290. * Rebuilds the elements related to this component in case of
  63291. * context lost for instance.
  63292. */
  63293. rebuild(): void;
  63294. /**
  63295. * Serializes the component data to the specified json object
  63296. * @param serializationObject The object to serialize to
  63297. */
  63298. serialize(serializationObject: any): void;
  63299. /**
  63300. * Adds all the elements from the container to the scene
  63301. * @param container the container holding the elements
  63302. */
  63303. addFromContainer(container: AbstractScene): void;
  63304. /**
  63305. * Removes all the elements in the container from the scene
  63306. * @param container contains the elements to remove
  63307. * @param dispose if the removed element should be disposed (default: false)
  63308. */
  63309. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  63310. /**
  63311. * Disposes the component and the associated resources.
  63312. */
  63313. dispose(): void;
  63314. private _isReadyForMesh;
  63315. private _renderMainTexture;
  63316. private _setStencil;
  63317. private _setStencilBack;
  63318. private _draw;
  63319. private _drawCamera;
  63320. private _drawRenderingGroup;
  63321. }
  63322. }
  63323. declare module BABYLON {
  63324. /** @hidden */
  63325. export var glowMapMergePixelShader: {
  63326. name: string;
  63327. shader: string;
  63328. };
  63329. }
  63330. declare module BABYLON {
  63331. /** @hidden */
  63332. export var glowMapMergeVertexShader: {
  63333. name: string;
  63334. shader: string;
  63335. };
  63336. }
  63337. declare module BABYLON {
  63338. interface AbstractScene {
  63339. /**
  63340. * Return a the first highlight layer of the scene with a given name.
  63341. * @param name The name of the highlight layer to look for.
  63342. * @return The highlight layer if found otherwise null.
  63343. */
  63344. getGlowLayerByName(name: string): Nullable<GlowLayer>;
  63345. }
  63346. /**
  63347. * Glow layer options. This helps customizing the behaviour
  63348. * of the glow layer.
  63349. */
  63350. export interface IGlowLayerOptions {
  63351. /**
  63352. * Multiplication factor apply to the canvas size to compute the render target size
  63353. * used to generated the glowing objects (the smaller the faster).
  63354. */
  63355. mainTextureRatio: number;
  63356. /**
  63357. * Enforces a fixed size texture to ensure resize independent blur.
  63358. */
  63359. mainTextureFixedSize?: number;
  63360. /**
  63361. * How big is the kernel of the blur texture.
  63362. */
  63363. blurKernelSize: number;
  63364. /**
  63365. * The camera attached to the layer.
  63366. */
  63367. camera: Nullable<Camera>;
  63368. /**
  63369. * Enable MSAA by choosing the number of samples.
  63370. */
  63371. mainTextureSamples?: number;
  63372. /**
  63373. * The rendering group to draw the layer in.
  63374. */
  63375. renderingGroupId: number;
  63376. }
  63377. /**
  63378. * The glow layer Helps adding a glow effect around the emissive parts of a mesh.
  63379. *
  63380. * Once instantiated in a scene, by default, all the emissive meshes will glow.
  63381. *
  63382. * Documentation: https://doc.babylonjs.com/how_to/glow_layer
  63383. */
  63384. export class GlowLayer extends EffectLayer {
  63385. /**
  63386. * Effect Name of the layer.
  63387. */
  63388. static readonly EffectName: string;
  63389. /**
  63390. * The default blur kernel size used for the glow.
  63391. */
  63392. static DefaultBlurKernelSize: number;
  63393. /**
  63394. * The default texture size ratio used for the glow.
  63395. */
  63396. static DefaultTextureRatio: number;
  63397. /**
  63398. * Sets the kernel size of the blur.
  63399. */
  63400. set blurKernelSize(value: number);
  63401. /**
  63402. * Gets the kernel size of the blur.
  63403. */
  63404. get blurKernelSize(): number;
  63405. /**
  63406. * Sets the glow intensity.
  63407. */
  63408. set intensity(value: number);
  63409. /**
  63410. * Gets the glow intensity.
  63411. */
  63412. get intensity(): number;
  63413. private _options;
  63414. private _intensity;
  63415. private _horizontalBlurPostprocess1;
  63416. private _verticalBlurPostprocess1;
  63417. private _horizontalBlurPostprocess2;
  63418. private _verticalBlurPostprocess2;
  63419. private _blurTexture1;
  63420. private _blurTexture2;
  63421. private _postProcesses1;
  63422. private _postProcesses2;
  63423. private _includedOnlyMeshes;
  63424. private _excludedMeshes;
  63425. private _meshesUsingTheirOwnMaterials;
  63426. /**
  63427. * Callback used to let the user override the color selection on a per mesh basis
  63428. */
  63429. customEmissiveColorSelector: (mesh: Mesh, subMesh: SubMesh, material: Material, result: Color4) => void;
  63430. /**
  63431. * Callback used to let the user override the texture selection on a per mesh basis
  63432. */
  63433. customEmissiveTextureSelector: (mesh: Mesh, subMesh: SubMesh, material: Material) => Texture;
  63434. /**
  63435. * Instantiates a new glow Layer and references it to the scene.
  63436. * @param name The name of the layer
  63437. * @param scene The scene to use the layer in
  63438. * @param options Sets of none mandatory options to use with the layer (see IGlowLayerOptions for more information)
  63439. */
  63440. constructor(name: string, scene: Scene, options?: Partial<IGlowLayerOptions>);
  63441. /**
  63442. * Get the effect name of the layer.
  63443. * @return The effect name
  63444. */
  63445. getEffectName(): string;
  63446. /**
  63447. * Create the merge effect. This is the shader use to blit the information back
  63448. * to the main canvas at the end of the scene rendering.
  63449. */
  63450. protected _createMergeEffect(): Effect;
  63451. /**
  63452. * Creates the render target textures and post processes used in the glow layer.
  63453. */
  63454. protected _createTextureAndPostProcesses(): void;
  63455. /**
  63456. * Checks for the readiness of the element composing the layer.
  63457. * @param subMesh the mesh to check for
  63458. * @param useInstances specify whether or not to use instances to render the mesh
  63459. * @param emissiveTexture the associated emissive texture used to generate the glow
  63460. * @return true if ready otherwise, false
  63461. */
  63462. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  63463. /**
  63464. * Returns whether or not the layer needs stencil enabled during the mesh rendering.
  63465. */
  63466. needStencil(): boolean;
  63467. /**
  63468. * Returns true if the mesh can be rendered, otherwise false.
  63469. * @param mesh The mesh to render
  63470. * @param material The material used on the mesh
  63471. * @returns true if it can be rendered otherwise false
  63472. */
  63473. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  63474. /**
  63475. * Implementation specific of rendering the generating effect on the main canvas.
  63476. * @param effect The effect used to render through
  63477. */
  63478. protected _internalRender(effect: Effect): void;
  63479. /**
  63480. * Sets the required values for both the emissive texture and and the main color.
  63481. */
  63482. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  63483. /**
  63484. * Returns true if the mesh should render, otherwise false.
  63485. * @param mesh The mesh to render
  63486. * @returns true if it should render otherwise false
  63487. */
  63488. protected _shouldRenderMesh(mesh: Mesh): boolean;
  63489. /**
  63490. * Adds specific effects defines.
  63491. * @param defines The defines to add specifics to.
  63492. */
  63493. protected _addCustomEffectDefines(defines: string[]): void;
  63494. /**
  63495. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the glow layer.
  63496. * @param mesh The mesh to exclude from the glow layer
  63497. */
  63498. addExcludedMesh(mesh: Mesh): void;
  63499. /**
  63500. * Remove a mesh from the exclusion list to let it impact or being impacted by the glow layer.
  63501. * @param mesh The mesh to remove
  63502. */
  63503. removeExcludedMesh(mesh: Mesh): void;
  63504. /**
  63505. * Add a mesh in the inclusion list to impact or being impacted by the glow layer.
  63506. * @param mesh The mesh to include in the glow layer
  63507. */
  63508. addIncludedOnlyMesh(mesh: Mesh): void;
  63509. /**
  63510. * Remove a mesh from the Inclusion list to prevent it to impact or being impacted by the glow layer.
  63511. * @param mesh The mesh to remove
  63512. */
  63513. removeIncludedOnlyMesh(mesh: Mesh): void;
  63514. /**
  63515. * Determine if a given mesh will be used in the glow layer
  63516. * @param mesh The mesh to test
  63517. * @returns true if the mesh will be highlighted by the current glow layer
  63518. */
  63519. hasMesh(mesh: AbstractMesh): boolean;
  63520. /**
  63521. * Defines whether the current material of the mesh should be use to render the effect.
  63522. * @param mesh defines the current mesh to render
  63523. */
  63524. protected _useMeshMaterial(mesh: AbstractMesh): boolean;
  63525. /**
  63526. * Add a mesh to be rendered through its own material and not with emissive only.
  63527. * @param mesh The mesh for which we need to use its material
  63528. */
  63529. referenceMeshToUseItsOwnMaterial(mesh: AbstractMesh): void;
  63530. /**
  63531. * Remove a mesh from being rendered through its own material and not with emissive only.
  63532. * @param mesh The mesh for which we need to not use its material
  63533. */
  63534. unReferenceMeshFromUsingItsOwnMaterial(mesh: AbstractMesh): void;
  63535. /**
  63536. * Free any resources and references associated to a mesh.
  63537. * Internal use
  63538. * @param mesh The mesh to free.
  63539. * @hidden
  63540. */
  63541. _disposeMesh(mesh: Mesh): void;
  63542. /**
  63543. * Gets the class name of the effect layer
  63544. * @returns the string with the class name of the effect layer
  63545. */
  63546. getClassName(): string;
  63547. /**
  63548. * Serializes this glow layer
  63549. * @returns a serialized glow layer object
  63550. */
  63551. serialize(): any;
  63552. /**
  63553. * Creates a Glow Layer from parsed glow layer data
  63554. * @param parsedGlowLayer defines glow layer data
  63555. * @param scene defines the current scene
  63556. * @param rootUrl defines the root URL containing the glow layer information
  63557. * @returns a parsed Glow Layer
  63558. */
  63559. static Parse(parsedGlowLayer: any, scene: Scene, rootUrl: string): GlowLayer;
  63560. }
  63561. }
  63562. declare module BABYLON {
  63563. /** @hidden */
  63564. export var glowBlurPostProcessPixelShader: {
  63565. name: string;
  63566. shader: string;
  63567. };
  63568. }
  63569. declare module BABYLON {
  63570. interface AbstractScene {
  63571. /**
  63572. * Return a the first highlight layer of the scene with a given name.
  63573. * @param name The name of the highlight layer to look for.
  63574. * @return The highlight layer if found otherwise null.
  63575. */
  63576. getHighlightLayerByName(name: string): Nullable<HighlightLayer>;
  63577. }
  63578. /**
  63579. * Highlight layer options. This helps customizing the behaviour
  63580. * of the highlight layer.
  63581. */
  63582. export interface IHighlightLayerOptions {
  63583. /**
  63584. * Multiplication factor apply to the canvas size to compute the render target size
  63585. * used to generated the glowing objects (the smaller the faster).
  63586. */
  63587. mainTextureRatio: number;
  63588. /**
  63589. * Enforces a fixed size texture to ensure resize independent blur.
  63590. */
  63591. mainTextureFixedSize?: number;
  63592. /**
  63593. * Multiplication factor apply to the main texture size in the first step of the blur to reduce the size
  63594. * of the picture to blur (the smaller the faster).
  63595. */
  63596. blurTextureSizeRatio: number;
  63597. /**
  63598. * How big in texel of the blur texture is the vertical blur.
  63599. */
  63600. blurVerticalSize: number;
  63601. /**
  63602. * How big in texel of the blur texture is the horizontal blur.
  63603. */
  63604. blurHorizontalSize: number;
  63605. /**
  63606. * Alpha blending mode used to apply the blur. Default is combine.
  63607. */
  63608. alphaBlendingMode: number;
  63609. /**
  63610. * The camera attached to the layer.
  63611. */
  63612. camera: Nullable<Camera>;
  63613. /**
  63614. * Should we display highlight as a solid stroke?
  63615. */
  63616. isStroke?: boolean;
  63617. /**
  63618. * The rendering group to draw the layer in.
  63619. */
  63620. renderingGroupId: number;
  63621. }
  63622. /**
  63623. * The highlight layer Helps adding a glow effect around a mesh.
  63624. *
  63625. * Once instantiated in a scene, simply use the addMesh or removeMesh method to add or remove
  63626. * glowy meshes to your scene.
  63627. *
  63628. * !!! THIS REQUIRES AN ACTIVE STENCIL BUFFER ON THE CANVAS !!!
  63629. */
  63630. export class HighlightLayer extends EffectLayer {
  63631. name: string;
  63632. /**
  63633. * Effect Name of the highlight layer.
  63634. */
  63635. static readonly EffectName: string;
  63636. /**
  63637. * The neutral color used during the preparation of the glow effect.
  63638. * This is black by default as the blend operation is a blend operation.
  63639. */
  63640. static NeutralColor: Color4;
  63641. /**
  63642. * Stencil value used for glowing meshes.
  63643. */
  63644. static GlowingMeshStencilReference: number;
  63645. /**
  63646. * Stencil value used for the other meshes in the scene.
  63647. */
  63648. static NormalMeshStencilReference: number;
  63649. /**
  63650. * Specifies whether or not the inner glow is ACTIVE in the layer.
  63651. */
  63652. innerGlow: boolean;
  63653. /**
  63654. * Specifies whether or not the outer glow is ACTIVE in the layer.
  63655. */
  63656. outerGlow: boolean;
  63657. /**
  63658. * Specifies the horizontal size of the blur.
  63659. */
  63660. set blurHorizontalSize(value: number);
  63661. /**
  63662. * Specifies the vertical size of the blur.
  63663. */
  63664. set blurVerticalSize(value: number);
  63665. /**
  63666. * Gets the horizontal size of the blur.
  63667. */
  63668. get blurHorizontalSize(): number;
  63669. /**
  63670. * Gets the vertical size of the blur.
  63671. */
  63672. get blurVerticalSize(): number;
  63673. /**
  63674. * An event triggered when the highlight layer is being blurred.
  63675. */
  63676. onBeforeBlurObservable: Observable<HighlightLayer>;
  63677. /**
  63678. * An event triggered when the highlight layer has been blurred.
  63679. */
  63680. onAfterBlurObservable: Observable<HighlightLayer>;
  63681. private _instanceGlowingMeshStencilReference;
  63682. private _options;
  63683. private _downSamplePostprocess;
  63684. private _horizontalBlurPostprocess;
  63685. private _verticalBlurPostprocess;
  63686. private _blurTexture;
  63687. private _meshes;
  63688. private _excludedMeshes;
  63689. /**
  63690. * Instantiates a new highlight Layer and references it to the scene..
  63691. * @param name The name of the layer
  63692. * @param scene The scene to use the layer in
  63693. * @param options Sets of none mandatory options to use with the layer (see IHighlightLayerOptions for more information)
  63694. */
  63695. constructor(name: string, scene: Scene, options?: Partial<IHighlightLayerOptions>);
  63696. /**
  63697. * Get the effect name of the layer.
  63698. * @return The effect name
  63699. */
  63700. getEffectName(): string;
  63701. /**
  63702. * Create the merge effect. This is the shader use to blit the information back
  63703. * to the main canvas at the end of the scene rendering.
  63704. */
  63705. protected _createMergeEffect(): Effect;
  63706. /**
  63707. * Creates the render target textures and post processes used in the highlight layer.
  63708. */
  63709. protected _createTextureAndPostProcesses(): void;
  63710. /**
  63711. * Returns whether or not the layer needs stencil enabled during the mesh rendering.
  63712. */
  63713. needStencil(): boolean;
  63714. /**
  63715. * Checks for the readiness of the element composing the layer.
  63716. * @param subMesh the mesh to check for
  63717. * @param useInstances specify wether or not to use instances to render the mesh
  63718. * @param emissiveTexture the associated emissive texture used to generate the glow
  63719. * @return true if ready otherwise, false
  63720. */
  63721. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  63722. /**
  63723. * Implementation specific of rendering the generating effect on the main canvas.
  63724. * @param effect The effect used to render through
  63725. */
  63726. protected _internalRender(effect: Effect): void;
  63727. /**
  63728. * Returns true if the layer contains information to display, otherwise false.
  63729. */
  63730. shouldRender(): boolean;
  63731. /**
  63732. * Returns true if the mesh should render, otherwise false.
  63733. * @param mesh The mesh to render
  63734. * @returns true if it should render otherwise false
  63735. */
  63736. protected _shouldRenderMesh(mesh: Mesh): boolean;
  63737. /**
  63738. * Returns true if the mesh can be rendered, otherwise false.
  63739. * @param mesh The mesh to render
  63740. * @param material The material used on the mesh
  63741. * @returns true if it can be rendered otherwise false
  63742. */
  63743. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  63744. /**
  63745. * Adds specific effects defines.
  63746. * @param defines The defines to add specifics to.
  63747. */
  63748. protected _addCustomEffectDefines(defines: string[]): void;
  63749. /**
  63750. * Sets the required values for both the emissive texture and and the main color.
  63751. */
  63752. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  63753. /**
  63754. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the highlight layer.
  63755. * @param mesh The mesh to exclude from the highlight layer
  63756. */
  63757. addExcludedMesh(mesh: Mesh): void;
  63758. /**
  63759. * Remove a mesh from the exclusion list to let it impact or being impacted by the highlight layer.
  63760. * @param mesh The mesh to highlight
  63761. */
  63762. removeExcludedMesh(mesh: Mesh): void;
  63763. /**
  63764. * Determine if a given mesh will be highlighted by the current HighlightLayer
  63765. * @param mesh mesh to test
  63766. * @returns true if the mesh will be highlighted by the current HighlightLayer
  63767. */
  63768. hasMesh(mesh: AbstractMesh): boolean;
  63769. /**
  63770. * Add a mesh in the highlight layer in order to make it glow with the chosen color.
  63771. * @param mesh The mesh to highlight
  63772. * @param color The color of the highlight
  63773. * @param glowEmissiveOnly Extract the glow from the emissive texture
  63774. */
  63775. addMesh(mesh: Mesh, color: Color3, glowEmissiveOnly?: boolean): void;
  63776. /**
  63777. * Remove a mesh from the highlight layer in order to make it stop glowing.
  63778. * @param mesh The mesh to highlight
  63779. */
  63780. removeMesh(mesh: Mesh): void;
  63781. /**
  63782. * Remove all the meshes currently referenced in the highlight layer
  63783. */
  63784. removeAllMeshes(): void;
  63785. /**
  63786. * Force the stencil to the normal expected value for none glowing parts
  63787. */
  63788. private _defaultStencilReference;
  63789. /**
  63790. * Free any resources and references associated to a mesh.
  63791. * Internal use
  63792. * @param mesh The mesh to free.
  63793. * @hidden
  63794. */
  63795. _disposeMesh(mesh: Mesh): void;
  63796. /**
  63797. * Dispose the highlight layer and free resources.
  63798. */
  63799. dispose(): void;
  63800. /**
  63801. * Gets the class name of the effect layer
  63802. * @returns the string with the class name of the effect layer
  63803. */
  63804. getClassName(): string;
  63805. /**
  63806. * Serializes this Highlight layer
  63807. * @returns a serialized Highlight layer object
  63808. */
  63809. serialize(): any;
  63810. /**
  63811. * Creates a Highlight layer from parsed Highlight layer data
  63812. * @param parsedHightlightLayer defines the Highlight layer data
  63813. * @param scene defines the current scene
  63814. * @param rootUrl defines the root URL containing the Highlight layer information
  63815. * @returns a parsed Highlight layer
  63816. */
  63817. static Parse(parsedHightlightLayer: any, scene: Scene, rootUrl: string): HighlightLayer;
  63818. }
  63819. }
  63820. declare module BABYLON {
  63821. interface AbstractScene {
  63822. /**
  63823. * The list of layers (background and foreground) of the scene
  63824. */
  63825. layers: Array<Layer>;
  63826. }
  63827. /**
  63828. * Defines the layer scene component responsible to manage any layers
  63829. * in a given scene.
  63830. */
  63831. export class LayerSceneComponent implements ISceneComponent {
  63832. /**
  63833. * The component name helpful to identify the component in the list of scene components.
  63834. */
  63835. readonly name: string;
  63836. /**
  63837. * The scene the component belongs to.
  63838. */
  63839. scene: Scene;
  63840. private _engine;
  63841. /**
  63842. * Creates a new instance of the component for the given scene
  63843. * @param scene Defines the scene to register the component in
  63844. */
  63845. constructor(scene: Scene);
  63846. /**
  63847. * Registers the component in a given scene
  63848. */
  63849. register(): void;
  63850. /**
  63851. * Rebuilds the elements related to this component in case of
  63852. * context lost for instance.
  63853. */
  63854. rebuild(): void;
  63855. /**
  63856. * Disposes the component and the associated resources.
  63857. */
  63858. dispose(): void;
  63859. private _draw;
  63860. private _drawCameraPredicate;
  63861. private _drawCameraBackground;
  63862. private _drawCameraForeground;
  63863. private _drawRenderTargetPredicate;
  63864. private _drawRenderTargetBackground;
  63865. private _drawRenderTargetForeground;
  63866. /**
  63867. * Adds all the elements from the container to the scene
  63868. * @param container the container holding the elements
  63869. */
  63870. addFromContainer(container: AbstractScene): void;
  63871. /**
  63872. * Removes all the elements in the container from the scene
  63873. * @param container contains the elements to remove
  63874. * @param dispose if the removed element should be disposed (default: false)
  63875. */
  63876. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  63877. }
  63878. }
  63879. declare module BABYLON {
  63880. /** @hidden */
  63881. export var layerPixelShader: {
  63882. name: string;
  63883. shader: string;
  63884. };
  63885. }
  63886. declare module BABYLON {
  63887. /** @hidden */
  63888. export var layerVertexShader: {
  63889. name: string;
  63890. shader: string;
  63891. };
  63892. }
  63893. declare module BABYLON {
  63894. /**
  63895. * This represents a full screen 2d layer.
  63896. * This can be useful to display a picture in the background of your scene for instance.
  63897. * @see https://www.babylonjs-playground.com/#08A2BS#1
  63898. */
  63899. export class Layer {
  63900. /**
  63901. * Define the name of the layer.
  63902. */
  63903. name: string;
  63904. /**
  63905. * Define the texture the layer should display.
  63906. */
  63907. texture: Nullable<Texture>;
  63908. /**
  63909. * Is the layer in background or foreground.
  63910. */
  63911. isBackground: boolean;
  63912. /**
  63913. * Define the color of the layer (instead of texture).
  63914. */
  63915. color: Color4;
  63916. /**
  63917. * Define the scale of the layer in order to zoom in out of the texture.
  63918. */
  63919. scale: Vector2;
  63920. /**
  63921. * Define an offset for the layer in order to shift the texture.
  63922. */
  63923. offset: Vector2;
  63924. /**
  63925. * Define the alpha blending mode used in the layer in case the texture or color has an alpha.
  63926. */
  63927. alphaBlendingMode: number;
  63928. /**
  63929. * Define if the layer should alpha test or alpha blend with the rest of the scene.
  63930. * Alpha test will not mix with the background color in case of transparency.
  63931. * It will either use the texture color or the background depending on the alpha value of the current pixel.
  63932. */
  63933. alphaTest: boolean;
  63934. /**
  63935. * Define a mask to restrict the layer to only some of the scene cameras.
  63936. */
  63937. layerMask: number;
  63938. /**
  63939. * Define the list of render target the layer is visible into.
  63940. */
  63941. renderTargetTextures: RenderTargetTexture[];
  63942. /**
  63943. * Define if the layer is only used in renderTarget or if it also
  63944. * renders in the main frame buffer of the canvas.
  63945. */
  63946. renderOnlyInRenderTargetTextures: boolean;
  63947. private _scene;
  63948. private _vertexBuffers;
  63949. private _indexBuffer;
  63950. private _effect;
  63951. private _previousDefines;
  63952. /**
  63953. * An event triggered when the layer is disposed.
  63954. */
  63955. onDisposeObservable: Observable<Layer>;
  63956. private _onDisposeObserver;
  63957. /**
  63958. * Back compatibility with callback before the onDisposeObservable existed.
  63959. * The set callback will be triggered when the layer has been disposed.
  63960. */
  63961. set onDispose(callback: () => void);
  63962. /**
  63963. * An event triggered before rendering the scene
  63964. */
  63965. onBeforeRenderObservable: Observable<Layer>;
  63966. private _onBeforeRenderObserver;
  63967. /**
  63968. * Back compatibility with callback before the onBeforeRenderObservable existed.
  63969. * The set callback will be triggered just before rendering the layer.
  63970. */
  63971. set onBeforeRender(callback: () => void);
  63972. /**
  63973. * An event triggered after rendering the scene
  63974. */
  63975. onAfterRenderObservable: Observable<Layer>;
  63976. private _onAfterRenderObserver;
  63977. /**
  63978. * Back compatibility with callback before the onAfterRenderObservable existed.
  63979. * The set callback will be triggered just after rendering the layer.
  63980. */
  63981. set onAfterRender(callback: () => void);
  63982. /**
  63983. * Instantiates a new layer.
  63984. * This represents a full screen 2d layer.
  63985. * This can be useful to display a picture in the background of your scene for instance.
  63986. * @see https://www.babylonjs-playground.com/#08A2BS#1
  63987. * @param name Define the name of the layer in the scene
  63988. * @param imgUrl Define the url of the texture to display in the layer
  63989. * @param scene Define the scene the layer belongs to
  63990. * @param isBackground Defines whether the layer is displayed in front or behind the scene
  63991. * @param color Defines a color for the layer
  63992. */
  63993. constructor(
  63994. /**
  63995. * Define the name of the layer.
  63996. */
  63997. name: string, imgUrl: Nullable<string>, scene: Nullable<Scene>, isBackground?: boolean, color?: Color4);
  63998. private _createIndexBuffer;
  63999. /** @hidden */
  64000. _rebuild(): void;
  64001. /**
  64002. * Renders the layer in the scene.
  64003. */
  64004. render(): void;
  64005. /**
  64006. * Disposes and releases the associated resources.
  64007. */
  64008. dispose(): void;
  64009. }
  64010. }
  64011. declare module BABYLON {
  64012. /** @hidden */
  64013. export var lensFlarePixelShader: {
  64014. name: string;
  64015. shader: string;
  64016. };
  64017. }
  64018. declare module BABYLON {
  64019. /** @hidden */
  64020. export var lensFlareVertexShader: {
  64021. name: string;
  64022. shader: string;
  64023. };
  64024. }
  64025. declare module BABYLON {
  64026. /**
  64027. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  64028. * It is usually composed of several `lensFlare`.
  64029. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  64030. */
  64031. export class LensFlareSystem {
  64032. /**
  64033. * Define the name of the lens flare system
  64034. */
  64035. name: string;
  64036. /**
  64037. * List of lens flares used in this system.
  64038. */
  64039. lensFlares: LensFlare[];
  64040. /**
  64041. * Define a limit from the border the lens flare can be visible.
  64042. */
  64043. borderLimit: number;
  64044. /**
  64045. * Define a viewport border we do not want to see the lens flare in.
  64046. */
  64047. viewportBorder: number;
  64048. /**
  64049. * Define a predicate which could limit the list of meshes able to occlude the effect.
  64050. */
  64051. meshesSelectionPredicate: (mesh: AbstractMesh) => boolean;
  64052. /**
  64053. * Restricts the rendering of the effect to only the camera rendering this layer mask.
  64054. */
  64055. layerMask: number;
  64056. /**
  64057. * Define the id of the lens flare system in the scene.
  64058. * (equal to name by default)
  64059. */
  64060. id: string;
  64061. private _scene;
  64062. private _emitter;
  64063. private _vertexBuffers;
  64064. private _indexBuffer;
  64065. private _effect;
  64066. private _positionX;
  64067. private _positionY;
  64068. private _isEnabled;
  64069. /** @hidden */
  64070. static _SceneComponentInitialization: (scene: Scene) => void;
  64071. /**
  64072. * Instantiates a lens flare system.
  64073. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  64074. * It is usually composed of several `lensFlare`.
  64075. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  64076. * @param name Define the name of the lens flare system in the scene
  64077. * @param emitter Define the source (the emitter) of the lens flares (it can be a camera, a light or a mesh).
  64078. * @param scene Define the scene the lens flare system belongs to
  64079. */
  64080. constructor(
  64081. /**
  64082. * Define the name of the lens flare system
  64083. */
  64084. name: string, emitter: any, scene: Scene);
  64085. /**
  64086. * Define if the lens flare system is enabled.
  64087. */
  64088. get isEnabled(): boolean;
  64089. set isEnabled(value: boolean);
  64090. /**
  64091. * Get the scene the effects belongs to.
  64092. * @returns the scene holding the lens flare system
  64093. */
  64094. getScene(): Scene;
  64095. /**
  64096. * Get the emitter of the lens flare system.
  64097. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  64098. * @returns the emitter of the lens flare system
  64099. */
  64100. getEmitter(): any;
  64101. /**
  64102. * Set the emitter of the lens flare system.
  64103. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  64104. * @param newEmitter Define the new emitter of the system
  64105. */
  64106. setEmitter(newEmitter: any): void;
  64107. /**
  64108. * Get the lens flare system emitter position.
  64109. * The emitter defines the source of the lens flares (it can be a camera, a light or a mesh).
  64110. * @returns the position
  64111. */
  64112. getEmitterPosition(): Vector3;
  64113. /**
  64114. * @hidden
  64115. */
  64116. computeEffectivePosition(globalViewport: Viewport): boolean;
  64117. /** @hidden */
  64118. _isVisible(): boolean;
  64119. /**
  64120. * @hidden
  64121. */
  64122. render(): boolean;
  64123. /**
  64124. * Dispose and release the lens flare with its associated resources.
  64125. */
  64126. dispose(): void;
  64127. /**
  64128. * Parse a lens flare system from a JSON representation
  64129. * @param parsedLensFlareSystem Define the JSON to parse
  64130. * @param scene Define the scene the parsed system should be instantiated in
  64131. * @param rootUrl Define the rootUrl of the load sequence to easily find a load relative dependencies such as textures
  64132. * @returns the parsed system
  64133. */
  64134. static Parse(parsedLensFlareSystem: any, scene: Scene, rootUrl: string): LensFlareSystem;
  64135. /**
  64136. * Serialize the current Lens Flare System into a JSON representation.
  64137. * @returns the serialized JSON
  64138. */
  64139. serialize(): any;
  64140. }
  64141. }
  64142. declare module BABYLON {
  64143. /**
  64144. * This represents one of the lens effect in a `lensFlareSystem`.
  64145. * It controls one of the individual texture used in the effect.
  64146. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  64147. */
  64148. export class LensFlare {
  64149. /**
  64150. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  64151. */
  64152. size: number;
  64153. /**
  64154. * 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.
  64155. */
  64156. position: number;
  64157. /**
  64158. * Define the lens color.
  64159. */
  64160. color: Color3;
  64161. /**
  64162. * Define the lens texture.
  64163. */
  64164. texture: Nullable<Texture>;
  64165. /**
  64166. * Define the alpha mode to render this particular lens.
  64167. */
  64168. alphaMode: number;
  64169. private _system;
  64170. /**
  64171. * Creates a new Lens Flare.
  64172. * This represents one of the lens effect in a `lensFlareSystem`.
  64173. * It controls one of the individual texture used in the effect.
  64174. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  64175. * @param size Define the size of the lens flare (a floating value between 0 and 1)
  64176. * @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.
  64177. * @param color Define the lens color
  64178. * @param imgUrl Define the lens texture url
  64179. * @param system Define the `lensFlareSystem` this flare is part of
  64180. * @returns The newly created Lens Flare
  64181. */
  64182. static AddFlare(size: number, position: number, color: Color3, imgUrl: string, system: LensFlareSystem): LensFlare;
  64183. /**
  64184. * Instantiates a new Lens Flare.
  64185. * This represents one of the lens effect in a `lensFlareSystem`.
  64186. * It controls one of the individual texture used in the effect.
  64187. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  64188. * @param size Define the size of the lens flare in the system (a floating value between 0 and 1)
  64189. * @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.
  64190. * @param color Define the lens color
  64191. * @param imgUrl Define the lens texture url
  64192. * @param system Define the `lensFlareSystem` this flare is part of
  64193. */
  64194. constructor(
  64195. /**
  64196. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  64197. */
  64198. size: number,
  64199. /**
  64200. * 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.
  64201. */
  64202. position: number, color: Color3, imgUrl: string, system: LensFlareSystem);
  64203. /**
  64204. * Dispose and release the lens flare with its associated resources.
  64205. */
  64206. dispose(): void;
  64207. }
  64208. }
  64209. declare module BABYLON {
  64210. interface AbstractScene {
  64211. /**
  64212. * The list of lens flare system added to the scene
  64213. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  64214. */
  64215. lensFlareSystems: Array<LensFlareSystem>;
  64216. /**
  64217. * Removes the given lens flare system from this scene.
  64218. * @param toRemove The lens flare system to remove
  64219. * @returns The index of the removed lens flare system
  64220. */
  64221. removeLensFlareSystem(toRemove: LensFlareSystem): number;
  64222. /**
  64223. * Adds the given lens flare system to this scene
  64224. * @param newLensFlareSystem The lens flare system to add
  64225. */
  64226. addLensFlareSystem(newLensFlareSystem: LensFlareSystem): void;
  64227. /**
  64228. * Gets a lens flare system using its name
  64229. * @param name defines the name to look for
  64230. * @returns the lens flare system or null if not found
  64231. */
  64232. getLensFlareSystemByName(name: string): Nullable<LensFlareSystem>;
  64233. /**
  64234. * Gets a lens flare system using its id
  64235. * @param id defines the id to look for
  64236. * @returns the lens flare system or null if not found
  64237. */
  64238. getLensFlareSystemByID(id: string): Nullable<LensFlareSystem>;
  64239. }
  64240. /**
  64241. * Defines the lens flare scene component responsible to manage any lens flares
  64242. * in a given scene.
  64243. */
  64244. export class LensFlareSystemSceneComponent implements ISceneSerializableComponent {
  64245. /**
  64246. * The component name helpful to identify the component in the list of scene components.
  64247. */
  64248. readonly name: string;
  64249. /**
  64250. * The scene the component belongs to.
  64251. */
  64252. scene: Scene;
  64253. /**
  64254. * Creates a new instance of the component for the given scene
  64255. * @param scene Defines the scene to register the component in
  64256. */
  64257. constructor(scene: Scene);
  64258. /**
  64259. * Registers the component in a given scene
  64260. */
  64261. register(): void;
  64262. /**
  64263. * Rebuilds the elements related to this component in case of
  64264. * context lost for instance.
  64265. */
  64266. rebuild(): void;
  64267. /**
  64268. * Adds all the elements from the container to the scene
  64269. * @param container the container holding the elements
  64270. */
  64271. addFromContainer(container: AbstractScene): void;
  64272. /**
  64273. * Removes all the elements in the container from the scene
  64274. * @param container contains the elements to remove
  64275. * @param dispose if the removed element should be disposed (default: false)
  64276. */
  64277. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  64278. /**
  64279. * Serializes the component data to the specified json object
  64280. * @param serializationObject The object to serialize to
  64281. */
  64282. serialize(serializationObject: any): void;
  64283. /**
  64284. * Disposes the component and the associated resources.
  64285. */
  64286. dispose(): void;
  64287. private _draw;
  64288. }
  64289. }
  64290. declare module BABYLON {
  64291. /** @hidden */
  64292. export var depthPixelShader: {
  64293. name: string;
  64294. shader: string;
  64295. };
  64296. }
  64297. declare module BABYLON {
  64298. /** @hidden */
  64299. export var depthVertexShader: {
  64300. name: string;
  64301. shader: string;
  64302. };
  64303. }
  64304. declare module BABYLON {
  64305. /**
  64306. * This represents a depth renderer in Babylon.
  64307. * A depth renderer will render to it's depth map every frame which can be displayed or used in post processing
  64308. */
  64309. export class DepthRenderer {
  64310. private _scene;
  64311. private _depthMap;
  64312. private _effect;
  64313. private readonly _storeNonLinearDepth;
  64314. private readonly _clearColor;
  64315. /** Get if the depth renderer is using packed depth or not */
  64316. readonly isPacked: boolean;
  64317. private _cachedDefines;
  64318. private _camera;
  64319. /** Enable or disable the depth renderer. When disabled, the depth texture is not updated */
  64320. enabled: boolean;
  64321. /**
  64322. * Specifiess that the depth renderer will only be used within
  64323. * the camera it is created for.
  64324. * This can help forcing its rendering during the camera processing.
  64325. */
  64326. useOnlyInActiveCamera: boolean;
  64327. /** @hidden */
  64328. static _SceneComponentInitialization: (scene: Scene) => void;
  64329. /**
  64330. * Instantiates a depth renderer
  64331. * @param scene The scene the renderer belongs to
  64332. * @param type The texture type of the depth map (default: Engine.TEXTURETYPE_FLOAT)
  64333. * @param camera The camera to be used to render the depth map (default: scene's active camera)
  64334. * @param storeNonLinearDepth Defines whether the depth is stored linearly like in Babylon Shadows or directly like glFragCoord.z
  64335. */
  64336. constructor(scene: Scene, type?: number, camera?: Nullable<Camera>, storeNonLinearDepth?: boolean);
  64337. /**
  64338. * Creates the depth rendering effect and checks if the effect is ready.
  64339. * @param subMesh The submesh to be used to render the depth map of
  64340. * @param useInstances If multiple world instances should be used
  64341. * @returns if the depth renderer is ready to render the depth map
  64342. */
  64343. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  64344. /**
  64345. * Gets the texture which the depth map will be written to.
  64346. * @returns The depth map texture
  64347. */
  64348. getDepthMap(): RenderTargetTexture;
  64349. /**
  64350. * Disposes of the depth renderer.
  64351. */
  64352. dispose(): void;
  64353. }
  64354. }
  64355. declare module BABYLON {
  64356. /** @hidden */
  64357. export var minmaxReduxPixelShader: {
  64358. name: string;
  64359. shader: string;
  64360. };
  64361. }
  64362. declare module BABYLON {
  64363. /**
  64364. * This class computes a min/max reduction from a texture: it means it computes the minimum
  64365. * and maximum values from all values of the texture.
  64366. * It is performed on the GPU for better performances, thanks to a succession of post processes.
  64367. * The source values are read from the red channel of the texture.
  64368. */
  64369. export class MinMaxReducer {
  64370. /**
  64371. * Observable triggered when the computation has been performed
  64372. */
  64373. onAfterReductionPerformed: Observable<{
  64374. min: number;
  64375. max: number;
  64376. }>;
  64377. protected _camera: Camera;
  64378. protected _sourceTexture: Nullable<RenderTargetTexture>;
  64379. protected _reductionSteps: Nullable<Array<PostProcess>>;
  64380. protected _postProcessManager: PostProcessManager;
  64381. protected _onAfterUnbindObserver: Nullable<Observer<RenderTargetTexture>>;
  64382. protected _forceFullscreenViewport: boolean;
  64383. /**
  64384. * Creates a min/max reducer
  64385. * @param camera The camera to use for the post processes
  64386. */
  64387. constructor(camera: Camera);
  64388. /**
  64389. * Gets the texture used to read the values from.
  64390. */
  64391. get sourceTexture(): Nullable<RenderTargetTexture>;
  64392. /**
  64393. * Sets the source texture to read the values from.
  64394. * One must indicate if the texture is a depth texture or not through the depthRedux parameter
  64395. * because in such textures '1' value must not be taken into account to compute the maximum
  64396. * as this value is used to clear the texture.
  64397. * Note that the computation is not activated by calling this function, you must call activate() for that!
  64398. * @param sourceTexture The texture to read the values from. The values should be in the red channel.
  64399. * @param depthRedux Indicates if the texture is a depth texture or not
  64400. * @param type The type of the textures created for the reduction (defaults to TEXTURETYPE_HALF_FLOAT)
  64401. * @param forceFullscreenViewport Forces the post processes used for the reduction to be applied without taking into account viewport (defaults to true)
  64402. */
  64403. setSourceTexture(sourceTexture: RenderTargetTexture, depthRedux: boolean, type?: number, forceFullscreenViewport?: boolean): void;
  64404. /**
  64405. * Defines the refresh rate of the computation.
  64406. * Use 0 to compute just once, 1 to compute on every frame, 2 to compute every two frames and so on...
  64407. */
  64408. get refreshRate(): number;
  64409. set refreshRate(value: number);
  64410. protected _activated: boolean;
  64411. /**
  64412. * Gets the activation status of the reducer
  64413. */
  64414. get activated(): boolean;
  64415. /**
  64416. * Activates the reduction computation.
  64417. * When activated, the observers registered in onAfterReductionPerformed are
  64418. * called after the computation is performed
  64419. */
  64420. activate(): void;
  64421. /**
  64422. * Deactivates the reduction computation.
  64423. */
  64424. deactivate(): void;
  64425. /**
  64426. * Disposes the min/max reducer
  64427. * @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.
  64428. */
  64429. dispose(disposeAll?: boolean): void;
  64430. }
  64431. }
  64432. declare module BABYLON {
  64433. /**
  64434. * This class is a small wrapper around the MinMaxReducer class to compute the min/max values of a depth texture
  64435. */
  64436. export class DepthReducer extends MinMaxReducer {
  64437. private _depthRenderer;
  64438. private _depthRendererId;
  64439. /**
  64440. * Gets the depth renderer used for the computation.
  64441. * Note that the result is null if you provide your own renderer when calling setDepthRenderer.
  64442. */
  64443. get depthRenderer(): Nullable<DepthRenderer>;
  64444. /**
  64445. * Creates a depth reducer
  64446. * @param camera The camera used to render the depth texture
  64447. */
  64448. constructor(camera: Camera);
  64449. /**
  64450. * Sets the depth renderer to use to generate the depth map
  64451. * @param depthRenderer The depth renderer to use. If not provided, a new one will be created automatically
  64452. * @param type The texture type of the depth map (default: TEXTURETYPE_HALF_FLOAT)
  64453. * @param forceFullscreenViewport Forces the post processes used for the reduction to be applied without taking into account viewport (defaults to true)
  64454. */
  64455. setDepthRenderer(depthRenderer?: Nullable<DepthRenderer>, type?: number, forceFullscreenViewport?: boolean): void;
  64456. /** @hidden */
  64457. setSourceTexture(sourceTexture: RenderTargetTexture, depthRedux: boolean, type?: number, forceFullscreenViewport?: boolean): void;
  64458. /**
  64459. * Activates the reduction computation.
  64460. * When activated, the observers registered in onAfterReductionPerformed are
  64461. * called after the computation is performed
  64462. */
  64463. activate(): void;
  64464. /**
  64465. * Deactivates the reduction computation.
  64466. */
  64467. deactivate(): void;
  64468. /**
  64469. * Disposes the depth reducer
  64470. * @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.
  64471. */
  64472. dispose(disposeAll?: boolean): void;
  64473. }
  64474. }
  64475. declare module BABYLON {
  64476. /**
  64477. * A CSM implementation allowing casting shadows on large scenes.
  64478. * Documentation : https://doc.babylonjs.com/babylon101/cascadedShadows
  64479. * Based on: https://github.com/TheRealMJP/Shadows and https://johanmedestrom.wordpress.com/2016/03/18/opengl-cascaded-shadow-maps/
  64480. */
  64481. export class CascadedShadowGenerator extends ShadowGenerator {
  64482. private static readonly frustumCornersNDCSpace;
  64483. /**
  64484. * Name of the CSM class
  64485. */
  64486. static CLASSNAME: string;
  64487. /**
  64488. * Defines the default number of cascades used by the CSM.
  64489. */
  64490. static readonly DEFAULT_CASCADES_COUNT: number;
  64491. /**
  64492. * Defines the minimum number of cascades used by the CSM.
  64493. */
  64494. static readonly MIN_CASCADES_COUNT: number;
  64495. /**
  64496. * Defines the maximum number of cascades used by the CSM.
  64497. */
  64498. static readonly MAX_CASCADES_COUNT: number;
  64499. protected _validateFilter(filter: number): number;
  64500. /**
  64501. * Gets or sets the actual darkness of the soft shadows while using PCSS filtering (value between 0. and 1.)
  64502. */
  64503. penumbraDarkness: number;
  64504. private _numCascades;
  64505. /**
  64506. * Gets or set the number of cascades used by the CSM.
  64507. */
  64508. get numCascades(): number;
  64509. set numCascades(value: number);
  64510. /**
  64511. * Sets this to true if you want that the edges of the shadows don't "swimm" / "shimmer" when rotating the camera.
  64512. * The trade off is that you lose some precision in the shadow rendering when enabling this setting.
  64513. */
  64514. stabilizeCascades: boolean;
  64515. private _freezeShadowCastersBoundingInfo;
  64516. private _freezeShadowCastersBoundingInfoObservable;
  64517. /**
  64518. * Enables or disables the shadow casters bounding info computation.
  64519. * If your shadow casters don't move, you can disable this feature.
  64520. * If it is enabled, the bounding box computation is done every frame.
  64521. */
  64522. get freezeShadowCastersBoundingInfo(): boolean;
  64523. set freezeShadowCastersBoundingInfo(freeze: boolean);
  64524. private _scbiMin;
  64525. private _scbiMax;
  64526. protected _computeShadowCastersBoundingInfo(): void;
  64527. protected _shadowCastersBoundingInfo: BoundingInfo;
  64528. /**
  64529. * Gets or sets the shadow casters bounding info.
  64530. * If you provide your own shadow casters bounding info, first enable freezeShadowCastersBoundingInfo
  64531. * so that the system won't overwrite the bounds you provide
  64532. */
  64533. get shadowCastersBoundingInfo(): BoundingInfo;
  64534. set shadowCastersBoundingInfo(boundingInfo: BoundingInfo);
  64535. protected _breaksAreDirty: boolean;
  64536. protected _minDistance: number;
  64537. protected _maxDistance: number;
  64538. /**
  64539. * Sets the minimal and maximal distances to use when computing the cascade breaks.
  64540. *
  64541. * The values of min / max are typically the depth zmin and zmax values of your scene, for a given frame.
  64542. * If you don't know these values, simply leave them to their defaults and don't call this function.
  64543. * @param min minimal distance for the breaks (default to 0.)
  64544. * @param max maximal distance for the breaks (default to 1.)
  64545. */
  64546. setMinMaxDistance(min: number, max: number): void;
  64547. /** Gets the minimal distance used in the cascade break computation */
  64548. get minDistance(): number;
  64549. /** Gets the maximal distance used in the cascade break computation */
  64550. get maxDistance(): number;
  64551. /**
  64552. * Gets the class name of that object
  64553. * @returns "CascadedShadowGenerator"
  64554. */
  64555. getClassName(): string;
  64556. private _cascadeMinExtents;
  64557. private _cascadeMaxExtents;
  64558. /**
  64559. * Gets a cascade minimum extents
  64560. * @param cascadeIndex index of the cascade
  64561. * @returns the minimum cascade extents
  64562. */
  64563. getCascadeMinExtents(cascadeIndex: number): Nullable<Vector3>;
  64564. /**
  64565. * Gets a cascade maximum extents
  64566. * @param cascadeIndex index of the cascade
  64567. * @returns the maximum cascade extents
  64568. */
  64569. getCascadeMaxExtents(cascadeIndex: number): Nullable<Vector3>;
  64570. private _cascades;
  64571. private _currentLayer;
  64572. private _viewSpaceFrustumsZ;
  64573. private _viewMatrices;
  64574. private _projectionMatrices;
  64575. private _transformMatrices;
  64576. private _transformMatricesAsArray;
  64577. private _frustumLengths;
  64578. private _lightSizeUVCorrection;
  64579. private _depthCorrection;
  64580. private _frustumCornersWorldSpace;
  64581. private _frustumCenter;
  64582. private _shadowCameraPos;
  64583. private _shadowMaxZ;
  64584. /**
  64585. * Gets the shadow max z distance. It's the limit beyond which shadows are not displayed.
  64586. * It defaults to camera.maxZ
  64587. */
  64588. get shadowMaxZ(): number;
  64589. /**
  64590. * Sets the shadow max z distance.
  64591. */
  64592. set shadowMaxZ(value: number);
  64593. protected _debug: boolean;
  64594. /**
  64595. * Gets or sets the debug flag.
  64596. * When enabled, the cascades are materialized by different colors on the screen.
  64597. */
  64598. get debug(): boolean;
  64599. set debug(dbg: boolean);
  64600. private _depthClamp;
  64601. /**
  64602. * Gets or sets the depth clamping value.
  64603. *
  64604. * When enabled, it improves the shadow quality because the near z plane of the light frustum don't need to be adjusted
  64605. * to account for the shadow casters far away.
  64606. *
  64607. * Note that this property is incompatible with PCSS filtering, so it won't be used in that case.
  64608. */
  64609. get depthClamp(): boolean;
  64610. set depthClamp(value: boolean);
  64611. private _cascadeBlendPercentage;
  64612. /**
  64613. * Gets or sets the percentage of blending between two cascades (value between 0. and 1.).
  64614. * It defaults to 0.1 (10% blending).
  64615. */
  64616. get cascadeBlendPercentage(): number;
  64617. set cascadeBlendPercentage(value: number);
  64618. private _lambda;
  64619. /**
  64620. * Gets or set the lambda parameter.
  64621. * This parameter is used to split the camera frustum and create the cascades.
  64622. * 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.
  64623. * For all values in-between, it's a linear combination of the uniform and logarithm split algorithm.
  64624. */
  64625. get lambda(): number;
  64626. set lambda(value: number);
  64627. /**
  64628. * Gets the view matrix corresponding to a given cascade
  64629. * @param cascadeNum cascade to retrieve the view matrix from
  64630. * @returns the cascade view matrix
  64631. */
  64632. getCascadeViewMatrix(cascadeNum: number): Nullable<Matrix>;
  64633. /**
  64634. * Gets the projection matrix corresponding to a given cascade
  64635. * @param cascadeNum cascade to retrieve the projection matrix from
  64636. * @returns the cascade projection matrix
  64637. */
  64638. getCascadeProjectionMatrix(cascadeNum: number): Nullable<Matrix>;
  64639. /**
  64640. * Gets the transformation matrix corresponding to a given cascade
  64641. * @param cascadeNum cascade to retrieve the transformation matrix from
  64642. * @returns the cascade transformation matrix
  64643. */
  64644. getCascadeTransformMatrix(cascadeNum: number): Nullable<Matrix>;
  64645. private _depthRenderer;
  64646. /**
  64647. * Sets the depth renderer to use when autoCalcDepthBounds is enabled.
  64648. *
  64649. * Note that if no depth renderer is set, a new one will be automatically created internally when necessary.
  64650. *
  64651. * You should call this function if you already have a depth renderer enabled in your scene, to avoid
  64652. * doing multiple depth rendering each frame. If you provide your own depth renderer, make sure it stores linear depth!
  64653. * @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
  64654. */
  64655. setDepthRenderer(depthRenderer: Nullable<DepthRenderer>): void;
  64656. private _depthReducer;
  64657. private _autoCalcDepthBounds;
  64658. /**
  64659. * Gets or sets the autoCalcDepthBounds property.
  64660. *
  64661. * When enabled, a depth rendering pass is first performed (with an internally created depth renderer or with the one
  64662. * you provide by calling setDepthRenderer). Then, a min/max reducing is applied on the depth map to compute the
  64663. * minimal and maximal depth of the map and those values are used as inputs for the setMinMaxDistance() function.
  64664. * It can greatly enhance the shadow quality, at the expense of more GPU works.
  64665. * When using this option, you should increase the value of the lambda parameter, and even set it to 1 for best results.
  64666. */
  64667. get autoCalcDepthBounds(): boolean;
  64668. set autoCalcDepthBounds(value: boolean);
  64669. /**
  64670. * Defines the refresh rate of the min/max computation used when autoCalcDepthBounds is set to true
  64671. * Use 0 to compute just once, 1 to compute on every frame, 2 to compute every two frames and so on...
  64672. * Note that if you provided your own depth renderer through a call to setDepthRenderer, you are responsible
  64673. * for setting the refresh rate on the renderer yourself!
  64674. */
  64675. get autoCalcDepthBoundsRefreshRate(): number;
  64676. set autoCalcDepthBoundsRefreshRate(value: number);
  64677. /**
  64678. * Create the cascade breaks according to the lambda, shadowMaxZ and min/max distance properties, as well as the camera near and far planes.
  64679. * This function is automatically called when updating lambda, shadowMaxZ and min/max distances, however you should call it yourself if
  64680. * you change the camera near/far planes!
  64681. */
  64682. splitFrustum(): void;
  64683. private _splitFrustum;
  64684. private _computeMatrices;
  64685. private _computeFrustumInWorldSpace;
  64686. private _computeCascadeFrustum;
  64687. /**
  64688. * Support test.
  64689. */
  64690. static get IsSupported(): boolean;
  64691. /** @hidden */
  64692. static _SceneComponentInitialization: (scene: Scene) => void;
  64693. /**
  64694. * Creates a Cascaded Shadow Generator object.
  64695. * A ShadowGenerator is the required tool to use the shadows.
  64696. * Each directional light casting shadows needs to use its own ShadowGenerator.
  64697. * Documentation : https://doc.babylonjs.com/babylon101/cascadedShadows
  64698. * @param mapSize The size of the texture what stores the shadows. Example : 1024.
  64699. * @param light The directional light object generating the shadows.
  64700. * @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.
  64701. */
  64702. constructor(mapSize: number, light: DirectionalLight, usefulFloatFirst?: boolean);
  64703. protected _initializeGenerator(): void;
  64704. protected _createTargetRenderTexture(): void;
  64705. protected _initializeShadowMap(): void;
  64706. protected _bindCustomEffectForRenderSubMeshForShadowMap(subMesh: SubMesh, effect: Effect, matriceNames: any, mesh: AbstractMesh): void;
  64707. protected _isReadyCustomDefines(defines: any, subMesh: SubMesh, useInstances: boolean): void;
  64708. /**
  64709. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  64710. * @param defines Defines of the material we want to update
  64711. * @param lightIndex Index of the light in the enabled light list of the material
  64712. */
  64713. prepareDefines(defines: any, lightIndex: number): void;
  64714. /**
  64715. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  64716. * defined in the generator but impacting the effect).
  64717. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  64718. * @param effect The effect we are binfing the information for
  64719. */
  64720. bindShadowLight(lightIndex: string, effect: Effect): void;
  64721. /**
  64722. * Gets the transformation matrix of the first cascade used to project the meshes into the map from the light point of view.
  64723. * (eq to view projection * shadow projection matrices)
  64724. * @returns The transform matrix used to create the shadow map
  64725. */
  64726. getTransformMatrix(): Matrix;
  64727. /**
  64728. * Disposes the ShadowGenerator.
  64729. * Returns nothing.
  64730. */
  64731. dispose(): void;
  64732. /**
  64733. * Serializes the shadow generator setup to a json object.
  64734. * @returns The serialized JSON object
  64735. */
  64736. serialize(): any;
  64737. /**
  64738. * Parses a serialized ShadowGenerator and returns a new ShadowGenerator.
  64739. * @param parsedShadowGenerator The JSON object to parse
  64740. * @param scene The scene to create the shadow map for
  64741. * @returns The parsed shadow generator
  64742. */
  64743. static Parse(parsedShadowGenerator: any, scene: Scene): ShadowGenerator;
  64744. }
  64745. }
  64746. declare module BABYLON {
  64747. /**
  64748. * Defines the shadow generator component responsible to manage any shadow generators
  64749. * in a given scene.
  64750. */
  64751. export class ShadowGeneratorSceneComponent implements ISceneSerializableComponent {
  64752. /**
  64753. * The component name helpful to identify the component in the list of scene components.
  64754. */
  64755. readonly name: string;
  64756. /**
  64757. * The scene the component belongs to.
  64758. */
  64759. scene: Scene;
  64760. /**
  64761. * Creates a new instance of the component for the given scene
  64762. * @param scene Defines the scene to register the component in
  64763. */
  64764. constructor(scene: Scene);
  64765. /**
  64766. * Registers the component in a given scene
  64767. */
  64768. register(): void;
  64769. /**
  64770. * Rebuilds the elements related to this component in case of
  64771. * context lost for instance.
  64772. */
  64773. rebuild(): void;
  64774. /**
  64775. * Serializes the component data to the specified json object
  64776. * @param serializationObject The object to serialize to
  64777. */
  64778. serialize(serializationObject: any): void;
  64779. /**
  64780. * Adds all the elements from the container to the scene
  64781. * @param container the container holding the elements
  64782. */
  64783. addFromContainer(container: AbstractScene): void;
  64784. /**
  64785. * Removes all the elements in the container from the scene
  64786. * @param container contains the elements to remove
  64787. * @param dispose if the removed element should be disposed (default: false)
  64788. */
  64789. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  64790. /**
  64791. * Rebuilds the elements related to this component in case of
  64792. * context lost for instance.
  64793. */
  64794. dispose(): void;
  64795. private _gatherRenderTargets;
  64796. }
  64797. }
  64798. declare module BABYLON {
  64799. /**
  64800. * A point light is a light defined by an unique point in world space.
  64801. * The light is emitted in every direction from this point.
  64802. * A good example of a point light is a standard light bulb.
  64803. * Documentation: https://doc.babylonjs.com/babylon101/lights
  64804. */
  64805. export class PointLight extends ShadowLight {
  64806. private _shadowAngle;
  64807. /**
  64808. * Getter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  64809. * This specifies what angle the shadow will use to be created.
  64810. *
  64811. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  64812. */
  64813. get shadowAngle(): number;
  64814. /**
  64815. * Setter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  64816. * This specifies what angle the shadow will use to be created.
  64817. *
  64818. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  64819. */
  64820. set shadowAngle(value: number);
  64821. /**
  64822. * Gets the direction if it has been set.
  64823. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  64824. */
  64825. get direction(): Vector3;
  64826. /**
  64827. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  64828. */
  64829. set direction(value: Vector3);
  64830. /**
  64831. * Creates a PointLight object from the passed name and position (Vector3) and adds it in the scene.
  64832. * A PointLight emits the light in every direction.
  64833. * It can cast shadows.
  64834. * If the scene camera is already defined and you want to set your PointLight at the camera position, just set it :
  64835. * ```javascript
  64836. * var pointLight = new PointLight("pl", camera.position, scene);
  64837. * ```
  64838. * Documentation : https://doc.babylonjs.com/babylon101/lights
  64839. * @param name The light friendly name
  64840. * @param position The position of the point light in the scene
  64841. * @param scene The scene the lights belongs to
  64842. */
  64843. constructor(name: string, position: Vector3, scene: Scene);
  64844. /**
  64845. * Returns the string "PointLight"
  64846. * @returns the class name
  64847. */
  64848. getClassName(): string;
  64849. /**
  64850. * Returns the integer 0.
  64851. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  64852. */
  64853. getTypeID(): number;
  64854. /**
  64855. * Specifies whether or not the shadowmap should be a cube texture.
  64856. * @returns true if the shadowmap needs to be a cube texture.
  64857. */
  64858. needCube(): boolean;
  64859. /**
  64860. * Returns a new Vector3 aligned with the PointLight cube system according to the passed cube face index (integer).
  64861. * @param faceIndex The index of the face we are computed the direction to generate shadow
  64862. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  64863. */
  64864. getShadowDirection(faceIndex?: number): Vector3;
  64865. /**
  64866. * Sets the passed matrix "matrix" as a left-handed perspective projection matrix with the following settings :
  64867. * - fov = PI / 2
  64868. * - aspect ratio : 1.0
  64869. * - z-near and far equal to the active camera minZ and maxZ.
  64870. * Returns the PointLight.
  64871. */
  64872. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  64873. protected _buildUniformLayout(): void;
  64874. /**
  64875. * Sets the passed Effect "effect" with the PointLight transformed position (or position, if none) and passed name (string).
  64876. * @param effect The effect to update
  64877. * @param lightIndex The index of the light in the effect to update
  64878. * @returns The point light
  64879. */
  64880. transferToEffect(effect: Effect, lightIndex: string): PointLight;
  64881. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  64882. /**
  64883. * Prepares the list of defines specific to the light type.
  64884. * @param defines the list of defines
  64885. * @param lightIndex defines the index of the light for the effect
  64886. */
  64887. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  64888. }
  64889. }
  64890. declare module BABYLON {
  64891. /**
  64892. * Header information of HDR texture files.
  64893. */
  64894. export interface HDRInfo {
  64895. /**
  64896. * The height of the texture in pixels.
  64897. */
  64898. height: number;
  64899. /**
  64900. * The width of the texture in pixels.
  64901. */
  64902. width: number;
  64903. /**
  64904. * The index of the beginning of the data in the binary file.
  64905. */
  64906. dataPosition: number;
  64907. }
  64908. /**
  64909. * This groups tools to convert HDR texture to native colors array.
  64910. */
  64911. export class HDRTools {
  64912. private static Ldexp;
  64913. private static Rgbe2float;
  64914. private static readStringLine;
  64915. /**
  64916. * Reads header information from an RGBE texture stored in a native array.
  64917. * More information on this format are available here:
  64918. * https://en.wikipedia.org/wiki/RGBE_image_format
  64919. *
  64920. * @param uint8array The binary file stored in native array.
  64921. * @return The header information.
  64922. */
  64923. static RGBE_ReadHeader(uint8array: Uint8Array): HDRInfo;
  64924. /**
  64925. * Returns the cubemap information (each faces texture data) extracted from an RGBE texture.
  64926. * This RGBE texture needs to store the information as a panorama.
  64927. *
  64928. * More information on this format are available here:
  64929. * https://en.wikipedia.org/wiki/RGBE_image_format
  64930. *
  64931. * @param buffer The binary file stored in an array buffer.
  64932. * @param size The expected size of the extracted cubemap.
  64933. * @return The Cube Map information.
  64934. */
  64935. static GetCubeMapTextureData(buffer: ArrayBuffer, size: number): CubeMapInfo;
  64936. /**
  64937. * Returns the pixels data extracted from an RGBE texture.
  64938. * This pixels will be stored left to right up to down in the R G B order in one array.
  64939. *
  64940. * More information on this format are available here:
  64941. * https://en.wikipedia.org/wiki/RGBE_image_format
  64942. *
  64943. * @param uint8array The binary file stored in an array buffer.
  64944. * @param hdrInfo The header information of the file.
  64945. * @return The pixels data in RGB right to left up to down order.
  64946. */
  64947. static RGBE_ReadPixels(uint8array: Uint8Array, hdrInfo: HDRInfo): Float32Array;
  64948. private static RGBE_ReadPixels_RLE;
  64949. private static RGBE_ReadPixels_NOT_RLE;
  64950. }
  64951. }
  64952. declare module BABYLON {
  64953. /**
  64954. * Effect Render Options
  64955. */
  64956. export interface IEffectRendererOptions {
  64957. /**
  64958. * Defines the vertices positions.
  64959. */
  64960. positions?: number[];
  64961. /**
  64962. * Defines the indices.
  64963. */
  64964. indices?: number[];
  64965. }
  64966. /**
  64967. * Helper class to render one or more effects.
  64968. * You can access the previous rendering in your shader by declaring a sampler named textureSampler
  64969. */
  64970. export class EffectRenderer {
  64971. private engine;
  64972. private static _DefaultOptions;
  64973. private _vertexBuffers;
  64974. private _indexBuffer;
  64975. private _fullscreenViewport;
  64976. /**
  64977. * Creates an effect renderer
  64978. * @param engine the engine to use for rendering
  64979. * @param options defines the options of the effect renderer
  64980. */
  64981. constructor(engine: ThinEngine, options?: IEffectRendererOptions);
  64982. /**
  64983. * Sets the current viewport in normalized coordinates 0-1
  64984. * @param viewport Defines the viewport to set (defaults to 0 0 1 1)
  64985. */
  64986. setViewport(viewport?: Viewport): void;
  64987. /**
  64988. * Binds the embedded attributes buffer to the effect.
  64989. * @param effect Defines the effect to bind the attributes for
  64990. */
  64991. bindBuffers(effect: Effect): void;
  64992. /**
  64993. * Sets the current effect wrapper to use during draw.
  64994. * The effect needs to be ready before calling this api.
  64995. * This also sets the default full screen position attribute.
  64996. * @param effectWrapper Defines the effect to draw with
  64997. */
  64998. applyEffectWrapper(effectWrapper: EffectWrapper): void;
  64999. /**
  65000. * Restores engine states
  65001. */
  65002. restoreStates(): void;
  65003. /**
  65004. * Draws a full screen quad.
  65005. */
  65006. draw(): void;
  65007. private isRenderTargetTexture;
  65008. /**
  65009. * renders one or more effects to a specified texture
  65010. * @param effectWrapper the effect to renderer
  65011. * @param outputTexture texture to draw to, if null it will render to the screen.
  65012. */
  65013. render(effectWrapper: EffectWrapper, outputTexture?: Nullable<InternalTexture | RenderTargetTexture>): void;
  65014. /**
  65015. * Disposes of the effect renderer
  65016. */
  65017. dispose(): void;
  65018. }
  65019. /**
  65020. * Options to create an EffectWrapper
  65021. */
  65022. interface EffectWrapperCreationOptions {
  65023. /**
  65024. * Engine to use to create the effect
  65025. */
  65026. engine: ThinEngine;
  65027. /**
  65028. * Fragment shader for the effect
  65029. */
  65030. fragmentShader: string;
  65031. /**
  65032. * Use the shader store instead of direct source code
  65033. */
  65034. useShaderStore?: boolean;
  65035. /**
  65036. * Vertex shader for the effect
  65037. */
  65038. vertexShader?: string;
  65039. /**
  65040. * Attributes to use in the shader
  65041. */
  65042. attributeNames?: Array<string>;
  65043. /**
  65044. * Uniforms to use in the shader
  65045. */
  65046. uniformNames?: Array<string>;
  65047. /**
  65048. * Texture sampler names to use in the shader
  65049. */
  65050. samplerNames?: Array<string>;
  65051. /**
  65052. * Defines to use in the shader
  65053. */
  65054. defines?: Array<string>;
  65055. /**
  65056. * Callback when effect is compiled
  65057. */
  65058. onCompiled?: Nullable<(effect: Effect) => void>;
  65059. /**
  65060. * The friendly name of the effect displayed in Spector.
  65061. */
  65062. name?: string;
  65063. }
  65064. /**
  65065. * Wraps an effect to be used for rendering
  65066. */
  65067. export class EffectWrapper {
  65068. /**
  65069. * Event that is fired right before the effect is drawn (should be used to update uniforms)
  65070. */
  65071. onApplyObservable: Observable<{}>;
  65072. /**
  65073. * The underlying effect
  65074. */
  65075. effect: Effect;
  65076. /**
  65077. * Creates an effect to be renderer
  65078. * @param creationOptions options to create the effect
  65079. */
  65080. constructor(creationOptions: EffectWrapperCreationOptions);
  65081. /**
  65082. * Disposes of the effect wrapper
  65083. */
  65084. dispose(): void;
  65085. }
  65086. }
  65087. declare module BABYLON {
  65088. /** @hidden */
  65089. export var hdrFilteringVertexShader: {
  65090. name: string;
  65091. shader: string;
  65092. };
  65093. }
  65094. declare module BABYLON {
  65095. /** @hidden */
  65096. export var hdrFilteringPixelShader: {
  65097. name: string;
  65098. shader: string;
  65099. };
  65100. }
  65101. declare module BABYLON {
  65102. /**
  65103. * Options for texture filtering
  65104. */
  65105. interface IHDRFilteringOptions {
  65106. /**
  65107. * Scales pixel intensity for the input HDR map.
  65108. */
  65109. hdrScale?: number;
  65110. /**
  65111. * Quality of the filter. Should be `Constants.TEXTURE_FILTERING_QUALITY_OFFLINE` for prefiltering
  65112. */
  65113. quality?: number;
  65114. }
  65115. /**
  65116. * Filters HDR maps to get correct renderings of PBR reflections
  65117. */
  65118. export class HDRFiltering {
  65119. private _engine;
  65120. private _effectRenderer;
  65121. private _effectWrapper;
  65122. private _lodGenerationOffset;
  65123. private _lodGenerationScale;
  65124. /**
  65125. * Quality switch for prefiltering. Should be set to `Constants.TEXTURE_FILTERING_QUALITY_OFFLINE` unless
  65126. * you care about baking speed.
  65127. */
  65128. quality: number;
  65129. /**
  65130. * Scales pixel intensity for the input HDR map.
  65131. */
  65132. hdrScale: number;
  65133. /**
  65134. * Instantiates HDR filter for reflection maps
  65135. *
  65136. * @param engine Thin engine
  65137. * @param options Options
  65138. */
  65139. constructor(engine: ThinEngine, options?: IHDRFilteringOptions);
  65140. private _createRenderTarget;
  65141. private _prefilterInternal;
  65142. private _createEffect;
  65143. /**
  65144. * Get a value indicating if the filter is ready to be used
  65145. * @param texture Texture to filter
  65146. * @returns true if the filter is ready
  65147. */
  65148. isReady(texture: BaseTexture): boolean;
  65149. /**
  65150. * Prefilters a cube texture to have mipmap levels representing roughness values.
  65151. * Prefiltering will be invoked at the end of next rendering pass.
  65152. * This has to be done once the map is loaded, and has not been prefiltered by a third party software.
  65153. * See http://blog.selfshadow.com/publications/s2013-shading-course/karis/s2013_pbs_epic_notes_v2.pdf for more information
  65154. * @param texture Texture to filter
  65155. * @param onFinished Callback when filtering is done
  65156. * @return Promise called when prefiltering is done
  65157. */
  65158. prefilter(texture: BaseTexture, onFinished?: Nullable<() => void>): Promise<void>;
  65159. }
  65160. }
  65161. declare module BABYLON {
  65162. /**
  65163. * This represents a texture coming from an HDR input.
  65164. *
  65165. * The only supported format is currently panorama picture stored in RGBE format.
  65166. * Example of such files can be found on HDRLib: http://hdrlib.com/
  65167. */
  65168. export class HDRCubeTexture extends BaseTexture {
  65169. private static _facesMapping;
  65170. private _generateHarmonics;
  65171. private _noMipmap;
  65172. private _prefilterOnLoad;
  65173. private _textureMatrix;
  65174. private _size;
  65175. private _onLoad;
  65176. private _onError;
  65177. /**
  65178. * The texture URL.
  65179. */
  65180. url: string;
  65181. protected _isBlocking: boolean;
  65182. /**
  65183. * Sets whether or not the texture is blocking during loading.
  65184. */
  65185. set isBlocking(value: boolean);
  65186. /**
  65187. * Gets whether or not the texture is blocking during loading.
  65188. */
  65189. get isBlocking(): boolean;
  65190. protected _rotationY: number;
  65191. /**
  65192. * Sets texture matrix rotation angle around Y axis in radians.
  65193. */
  65194. set rotationY(value: number);
  65195. /**
  65196. * Gets texture matrix rotation angle around Y axis radians.
  65197. */
  65198. get rotationY(): number;
  65199. /**
  65200. * Gets or sets the center of the bounding box associated with the cube texture
  65201. * It must define where the camera used to render the texture was set
  65202. */
  65203. boundingBoxPosition: Vector3;
  65204. private _boundingBoxSize;
  65205. /**
  65206. * Gets or sets the size of the bounding box associated with the cube texture
  65207. * When defined, the cubemap will switch to local mode
  65208. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  65209. * @example https://www.babylonjs-playground.com/#RNASML
  65210. */
  65211. set boundingBoxSize(value: Vector3);
  65212. get boundingBoxSize(): Vector3;
  65213. /**
  65214. * Instantiates an HDRTexture from the following parameters.
  65215. *
  65216. * @param url The location of the HDR raw data (Panorama stored in RGBE format)
  65217. * @param sceneOrEngine The scene or engine the texture will be used in
  65218. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  65219. * @param noMipmap Forces to not generate the mipmap if true
  65220. * @param generateHarmonics Specifies whether you want to extract the polynomial harmonics during the generation process
  65221. * @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)
  65222. * @param prefilterOnLoad Prefilters HDR texture to allow use of this texture as a PBR reflection texture.
  65223. */
  65224. 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>);
  65225. /**
  65226. * Get the current class name of the texture useful for serialization or dynamic coding.
  65227. * @returns "HDRCubeTexture"
  65228. */
  65229. getClassName(): string;
  65230. /**
  65231. * Occurs when the file is raw .hdr file.
  65232. */
  65233. private loadTexture;
  65234. clone(): HDRCubeTexture;
  65235. delayLoad(): void;
  65236. /**
  65237. * Get the texture reflection matrix used to rotate/transform the reflection.
  65238. * @returns the reflection matrix
  65239. */
  65240. getReflectionTextureMatrix(): Matrix;
  65241. /**
  65242. * Set the texture reflection matrix used to rotate/transform the reflection.
  65243. * @param value Define the reflection matrix to set
  65244. */
  65245. setReflectionTextureMatrix(value: Matrix): void;
  65246. /**
  65247. * Parses a JSON representation of an HDR Texture in order to create the texture
  65248. * @param parsedTexture Define the JSON representation
  65249. * @param scene Define the scene the texture should be created in
  65250. * @param rootUrl Define the root url in case we need to load relative dependencies
  65251. * @returns the newly created texture after parsing
  65252. */
  65253. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<HDRCubeTexture>;
  65254. serialize(): any;
  65255. }
  65256. }
  65257. declare module BABYLON {
  65258. /**
  65259. * Class used to control physics engine
  65260. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  65261. */
  65262. export class PhysicsEngine implements IPhysicsEngine {
  65263. private _physicsPlugin;
  65264. /**
  65265. * Global value used to control the smallest number supported by the simulation
  65266. */
  65267. static Epsilon: number;
  65268. private _impostors;
  65269. private _joints;
  65270. private _subTimeStep;
  65271. /**
  65272. * Gets the gravity vector used by the simulation
  65273. */
  65274. gravity: Vector3;
  65275. /**
  65276. * Factory used to create the default physics plugin.
  65277. * @returns The default physics plugin
  65278. */
  65279. static DefaultPluginFactory(): IPhysicsEnginePlugin;
  65280. /**
  65281. * Creates a new Physics Engine
  65282. * @param gravity defines the gravity vector used by the simulation
  65283. * @param _physicsPlugin defines the plugin to use (CannonJS by default)
  65284. */
  65285. constructor(gravity: Nullable<Vector3>, _physicsPlugin?: IPhysicsEnginePlugin);
  65286. /**
  65287. * Sets the gravity vector used by the simulation
  65288. * @param gravity defines the gravity vector to use
  65289. */
  65290. setGravity(gravity: Vector3): void;
  65291. /**
  65292. * Set the time step of the physics engine.
  65293. * Default is 1/60.
  65294. * To slow it down, enter 1/600 for example.
  65295. * To speed it up, 1/30
  65296. * @param newTimeStep defines the new timestep to apply to this world.
  65297. */
  65298. setTimeStep(newTimeStep?: number): void;
  65299. /**
  65300. * Get the time step of the physics engine.
  65301. * @returns the current time step
  65302. */
  65303. getTimeStep(): number;
  65304. /**
  65305. * Set the sub time step of the physics engine.
  65306. * Default is 0 meaning there is no sub steps
  65307. * To increase physics resolution precision, set a small value (like 1 ms)
  65308. * @param subTimeStep defines the new sub timestep used for physics resolution.
  65309. */
  65310. setSubTimeStep(subTimeStep?: number): void;
  65311. /**
  65312. * Get the sub time step of the physics engine.
  65313. * @returns the current sub time step
  65314. */
  65315. getSubTimeStep(): number;
  65316. /**
  65317. * Release all resources
  65318. */
  65319. dispose(): void;
  65320. /**
  65321. * Gets the name of the current physics plugin
  65322. * @returns the name of the plugin
  65323. */
  65324. getPhysicsPluginName(): string;
  65325. /**
  65326. * Adding a new impostor for the impostor tracking.
  65327. * This will be done by the impostor itself.
  65328. * @param impostor the impostor to add
  65329. */
  65330. addImpostor(impostor: PhysicsImpostor): void;
  65331. /**
  65332. * Remove an impostor from the engine.
  65333. * This impostor and its mesh will not longer be updated by the physics engine.
  65334. * @param impostor the impostor to remove
  65335. */
  65336. removeImpostor(impostor: PhysicsImpostor): void;
  65337. /**
  65338. * Add a joint to the physics engine
  65339. * @param mainImpostor defines the main impostor to which the joint is added.
  65340. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  65341. * @param joint defines the joint that will connect both impostors.
  65342. */
  65343. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  65344. /**
  65345. * Removes a joint from the simulation
  65346. * @param mainImpostor defines the impostor used with the joint
  65347. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  65348. * @param joint defines the joint to remove
  65349. */
  65350. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  65351. /**
  65352. * Called by the scene. No need to call it.
  65353. * @param delta defines the timespan between frames
  65354. */
  65355. _step(delta: number): void;
  65356. /**
  65357. * Gets the current plugin used to run the simulation
  65358. * @returns current plugin
  65359. */
  65360. getPhysicsPlugin(): IPhysicsEnginePlugin;
  65361. /**
  65362. * Gets the list of physic impostors
  65363. * @returns an array of PhysicsImpostor
  65364. */
  65365. getImpostors(): Array<PhysicsImpostor>;
  65366. /**
  65367. * Gets the impostor for a physics enabled object
  65368. * @param object defines the object impersonated by the impostor
  65369. * @returns the PhysicsImpostor or null if not found
  65370. */
  65371. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  65372. /**
  65373. * Gets the impostor for a physics body object
  65374. * @param body defines physics body used by the impostor
  65375. * @returns the PhysicsImpostor or null if not found
  65376. */
  65377. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  65378. /**
  65379. * Does a raycast in the physics world
  65380. * @param from when should the ray start?
  65381. * @param to when should the ray end?
  65382. * @returns PhysicsRaycastResult
  65383. */
  65384. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  65385. }
  65386. }
  65387. declare module BABYLON {
  65388. /** @hidden */
  65389. export class CannonJSPlugin implements IPhysicsEnginePlugin {
  65390. private _useDeltaForWorldStep;
  65391. world: any;
  65392. name: string;
  65393. private _physicsMaterials;
  65394. private _fixedTimeStep;
  65395. private _cannonRaycastResult;
  65396. private _raycastResult;
  65397. private _physicsBodysToRemoveAfterStep;
  65398. private _firstFrame;
  65399. BJSCANNON: any;
  65400. constructor(_useDeltaForWorldStep?: boolean, iterations?: number, cannonInjection?: any);
  65401. setGravity(gravity: Vector3): void;
  65402. setTimeStep(timeStep: number): void;
  65403. getTimeStep(): number;
  65404. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  65405. private _removeMarkedPhysicsBodiesFromWorld;
  65406. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  65407. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  65408. generatePhysicsBody(impostor: PhysicsImpostor): void;
  65409. private _processChildMeshes;
  65410. removePhysicsBody(impostor: PhysicsImpostor): void;
  65411. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  65412. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  65413. private _addMaterial;
  65414. private _checkWithEpsilon;
  65415. private _createShape;
  65416. private _createHeightmap;
  65417. private _minus90X;
  65418. private _plus90X;
  65419. private _tmpPosition;
  65420. private _tmpDeltaPosition;
  65421. private _tmpUnityRotation;
  65422. private _updatePhysicsBodyTransformation;
  65423. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  65424. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  65425. isSupported(): boolean;
  65426. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  65427. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  65428. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  65429. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  65430. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  65431. getBodyMass(impostor: PhysicsImpostor): number;
  65432. getBodyFriction(impostor: PhysicsImpostor): number;
  65433. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  65434. getBodyRestitution(impostor: PhysicsImpostor): number;
  65435. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  65436. sleepBody(impostor: PhysicsImpostor): void;
  65437. wakeUpBody(impostor: PhysicsImpostor): void;
  65438. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number): void;
  65439. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  65440. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  65441. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  65442. getRadius(impostor: PhysicsImpostor): number;
  65443. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  65444. dispose(): void;
  65445. private _extendNamespace;
  65446. /**
  65447. * Does a raycast in the physics world
  65448. * @param from when should the ray start?
  65449. * @param to when should the ray end?
  65450. * @returns PhysicsRaycastResult
  65451. */
  65452. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  65453. }
  65454. }
  65455. declare module BABYLON {
  65456. /** @hidden */
  65457. export class OimoJSPlugin implements IPhysicsEnginePlugin {
  65458. private _useDeltaForWorldStep;
  65459. world: any;
  65460. name: string;
  65461. BJSOIMO: any;
  65462. private _raycastResult;
  65463. private _fixedTimeStep;
  65464. constructor(_useDeltaForWorldStep?: boolean, iterations?: number, oimoInjection?: any);
  65465. setGravity(gravity: Vector3): void;
  65466. setTimeStep(timeStep: number): void;
  65467. getTimeStep(): number;
  65468. private _tmpImpostorsArray;
  65469. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  65470. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  65471. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  65472. generatePhysicsBody(impostor: PhysicsImpostor): void;
  65473. private _tmpPositionVector;
  65474. removePhysicsBody(impostor: PhysicsImpostor): void;
  65475. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  65476. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  65477. isSupported(): boolean;
  65478. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  65479. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  65480. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  65481. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  65482. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  65483. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  65484. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  65485. getBodyMass(impostor: PhysicsImpostor): number;
  65486. getBodyFriction(impostor: PhysicsImpostor): number;
  65487. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  65488. getBodyRestitution(impostor: PhysicsImpostor): number;
  65489. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  65490. sleepBody(impostor: PhysicsImpostor): void;
  65491. wakeUpBody(impostor: PhysicsImpostor): void;
  65492. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  65493. setMotor(joint: IMotorEnabledJoint, speed: number, force?: number, motorIndex?: number): void;
  65494. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  65495. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  65496. getRadius(impostor: PhysicsImpostor): number;
  65497. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  65498. dispose(): void;
  65499. /**
  65500. * Does a raycast in the physics world
  65501. * @param from when should the ray start?
  65502. * @param to when should the ray end?
  65503. * @returns PhysicsRaycastResult
  65504. */
  65505. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  65506. }
  65507. }
  65508. declare module BABYLON {
  65509. /**
  65510. * AmmoJS Physics plugin
  65511. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  65512. * @see https://github.com/kripken/ammo.js/
  65513. */
  65514. export class AmmoJSPlugin implements IPhysicsEnginePlugin {
  65515. private _useDeltaForWorldStep;
  65516. /**
  65517. * Reference to the Ammo library
  65518. */
  65519. bjsAMMO: any;
  65520. /**
  65521. * Created ammoJS world which physics bodies are added to
  65522. */
  65523. world: any;
  65524. /**
  65525. * Name of the plugin
  65526. */
  65527. name: string;
  65528. private _timeStep;
  65529. private _fixedTimeStep;
  65530. private _maxSteps;
  65531. private _tmpQuaternion;
  65532. private _tmpAmmoTransform;
  65533. private _tmpAmmoQuaternion;
  65534. private _tmpAmmoConcreteContactResultCallback;
  65535. private _collisionConfiguration;
  65536. private _dispatcher;
  65537. private _overlappingPairCache;
  65538. private _solver;
  65539. private _softBodySolver;
  65540. private _tmpAmmoVectorA;
  65541. private _tmpAmmoVectorB;
  65542. private _tmpAmmoVectorC;
  65543. private _tmpAmmoVectorD;
  65544. private _tmpContactCallbackResult;
  65545. private _tmpAmmoVectorRCA;
  65546. private _tmpAmmoVectorRCB;
  65547. private _raycastResult;
  65548. private _tmpContactPoint;
  65549. private static readonly DISABLE_COLLISION_FLAG;
  65550. private static readonly KINEMATIC_FLAG;
  65551. private static readonly DISABLE_DEACTIVATION_FLAG;
  65552. /**
  65553. * Initializes the ammoJS plugin
  65554. * @param _useDeltaForWorldStep if the time between frames should be used when calculating physics steps (Default: true)
  65555. * @param ammoInjection can be used to inject your own ammo reference
  65556. * @param overlappingPairCache can be used to specify your own overlapping pair cache
  65557. */
  65558. constructor(_useDeltaForWorldStep?: boolean, ammoInjection?: any, overlappingPairCache?: any);
  65559. /**
  65560. * Sets the gravity of the physics world (m/(s^2))
  65561. * @param gravity Gravity to set
  65562. */
  65563. setGravity(gravity: Vector3): void;
  65564. /**
  65565. * Amount of time to step forward on each frame (only used if useDeltaForWorldStep is false in the constructor)
  65566. * @param timeStep timestep to use in seconds
  65567. */
  65568. setTimeStep(timeStep: number): void;
  65569. /**
  65570. * 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)
  65571. * @param fixedTimeStep fixedTimeStep to use in seconds
  65572. */
  65573. setFixedTimeStep(fixedTimeStep: number): void;
  65574. /**
  65575. * Sets the maximum number of steps by the physics engine per frame (Default: 5)
  65576. * @param maxSteps the maximum number of steps by the physics engine per frame
  65577. */
  65578. setMaxSteps(maxSteps: number): void;
  65579. /**
  65580. * Gets the current timestep (only used if useDeltaForWorldStep is false in the constructor)
  65581. * @returns the current timestep in seconds
  65582. */
  65583. getTimeStep(): number;
  65584. /**
  65585. * The create custom shape handler function to be called when using BABYLON.PhysicsImposter.CustomImpostor
  65586. */
  65587. onCreateCustomShape: (impostor: PhysicsImpostor) => any;
  65588. private _isImpostorInContact;
  65589. private _isImpostorPairInContact;
  65590. private _stepSimulation;
  65591. /**
  65592. * Moves the physics simulation forward delta seconds and updates the given physics imposters
  65593. * Prior to the step the imposters physics location is set to the position of the babylon meshes
  65594. * After the step the babylon meshes are set to the position of the physics imposters
  65595. * @param delta amount of time to step forward
  65596. * @param impostors array of imposters to update before/after the step
  65597. */
  65598. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  65599. /**
  65600. * Update babylon mesh to match physics world object
  65601. * @param impostor imposter to match
  65602. */
  65603. private _afterSoftStep;
  65604. /**
  65605. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  65606. * @param impostor imposter to match
  65607. */
  65608. private _ropeStep;
  65609. /**
  65610. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  65611. * @param impostor imposter to match
  65612. */
  65613. private _softbodyOrClothStep;
  65614. private _tmpMatrix;
  65615. /**
  65616. * Applies an impulse on the imposter
  65617. * @param impostor imposter to apply impulse to
  65618. * @param force amount of force to be applied to the imposter
  65619. * @param contactPoint the location to apply the impulse on the imposter
  65620. */
  65621. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  65622. /**
  65623. * Applies a force on the imposter
  65624. * @param impostor imposter to apply force
  65625. * @param force amount of force to be applied to the imposter
  65626. * @param contactPoint the location to apply the force on the imposter
  65627. */
  65628. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  65629. /**
  65630. * Creates a physics body using the plugin
  65631. * @param impostor the imposter to create the physics body on
  65632. */
  65633. generatePhysicsBody(impostor: PhysicsImpostor): void;
  65634. /**
  65635. * Removes the physics body from the imposter and disposes of the body's memory
  65636. * @param impostor imposter to remove the physics body from
  65637. */
  65638. removePhysicsBody(impostor: PhysicsImpostor): void;
  65639. /**
  65640. * Generates a joint
  65641. * @param impostorJoint the imposter joint to create the joint with
  65642. */
  65643. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  65644. /**
  65645. * Removes a joint
  65646. * @param impostorJoint the imposter joint to remove the joint from
  65647. */
  65648. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  65649. private _addMeshVerts;
  65650. /**
  65651. * Initialise the soft body vertices to match its object's (mesh) vertices
  65652. * Softbody vertices (nodes) are in world space and to match this
  65653. * The object's position and rotation is set to zero and so its vertices are also then set in world space
  65654. * @param impostor to create the softbody for
  65655. */
  65656. private _softVertexData;
  65657. /**
  65658. * Create an impostor's soft body
  65659. * @param impostor to create the softbody for
  65660. */
  65661. private _createSoftbody;
  65662. /**
  65663. * Create cloth for an impostor
  65664. * @param impostor to create the softbody for
  65665. */
  65666. private _createCloth;
  65667. /**
  65668. * Create rope for an impostor
  65669. * @param impostor to create the softbody for
  65670. */
  65671. private _createRope;
  65672. /**
  65673. * Create a custom physics impostor shape using the plugin's onCreateCustomShape handler
  65674. * @param impostor to create the custom physics shape for
  65675. */
  65676. private _createCustom;
  65677. private _addHullVerts;
  65678. private _createShape;
  65679. /**
  65680. * Sets the physics body position/rotation from the babylon mesh's position/rotation
  65681. * @param impostor imposter containing the physics body and babylon object
  65682. */
  65683. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  65684. /**
  65685. * Sets the babylon object's position/rotation from the physics body's position/rotation
  65686. * @param impostor imposter containing the physics body and babylon object
  65687. * @param newPosition new position
  65688. * @param newRotation new rotation
  65689. */
  65690. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  65691. /**
  65692. * If this plugin is supported
  65693. * @returns true if its supported
  65694. */
  65695. isSupported(): boolean;
  65696. /**
  65697. * Sets the linear velocity of the physics body
  65698. * @param impostor imposter to set the velocity on
  65699. * @param velocity velocity to set
  65700. */
  65701. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  65702. /**
  65703. * Sets the angular velocity of the physics body
  65704. * @param impostor imposter to set the velocity on
  65705. * @param velocity velocity to set
  65706. */
  65707. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  65708. /**
  65709. * gets the linear velocity
  65710. * @param impostor imposter to get linear velocity from
  65711. * @returns linear velocity
  65712. */
  65713. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  65714. /**
  65715. * gets the angular velocity
  65716. * @param impostor imposter to get angular velocity from
  65717. * @returns angular velocity
  65718. */
  65719. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  65720. /**
  65721. * Sets the mass of physics body
  65722. * @param impostor imposter to set the mass on
  65723. * @param mass mass to set
  65724. */
  65725. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  65726. /**
  65727. * Gets the mass of the physics body
  65728. * @param impostor imposter to get the mass from
  65729. * @returns mass
  65730. */
  65731. getBodyMass(impostor: PhysicsImpostor): number;
  65732. /**
  65733. * Gets friction of the impostor
  65734. * @param impostor impostor to get friction from
  65735. * @returns friction value
  65736. */
  65737. getBodyFriction(impostor: PhysicsImpostor): number;
  65738. /**
  65739. * Sets friction of the impostor
  65740. * @param impostor impostor to set friction on
  65741. * @param friction friction value
  65742. */
  65743. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  65744. /**
  65745. * Gets restitution of the impostor
  65746. * @param impostor impostor to get restitution from
  65747. * @returns restitution value
  65748. */
  65749. getBodyRestitution(impostor: PhysicsImpostor): number;
  65750. /**
  65751. * Sets restitution of the impostor
  65752. * @param impostor impostor to set resitution on
  65753. * @param restitution resitution value
  65754. */
  65755. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  65756. /**
  65757. * Gets pressure inside the impostor
  65758. * @param impostor impostor to get pressure from
  65759. * @returns pressure value
  65760. */
  65761. getBodyPressure(impostor: PhysicsImpostor): number;
  65762. /**
  65763. * Sets pressure inside a soft body impostor
  65764. * Cloth and rope must remain 0 pressure
  65765. * @param impostor impostor to set pressure on
  65766. * @param pressure pressure value
  65767. */
  65768. setBodyPressure(impostor: PhysicsImpostor, pressure: number): void;
  65769. /**
  65770. * Gets stiffness of the impostor
  65771. * @param impostor impostor to get stiffness from
  65772. * @returns pressure value
  65773. */
  65774. getBodyStiffness(impostor: PhysicsImpostor): number;
  65775. /**
  65776. * Sets stiffness of the impostor
  65777. * @param impostor impostor to set stiffness on
  65778. * @param stiffness stiffness value from 0 to 1
  65779. */
  65780. setBodyStiffness(impostor: PhysicsImpostor, stiffness: number): void;
  65781. /**
  65782. * Gets velocityIterations of the impostor
  65783. * @param impostor impostor to get velocity iterations from
  65784. * @returns velocityIterations value
  65785. */
  65786. getBodyVelocityIterations(impostor: PhysicsImpostor): number;
  65787. /**
  65788. * Sets velocityIterations of the impostor
  65789. * @param impostor impostor to set velocity iterations on
  65790. * @param velocityIterations velocityIterations value
  65791. */
  65792. setBodyVelocityIterations(impostor: PhysicsImpostor, velocityIterations: number): void;
  65793. /**
  65794. * Gets positionIterations of the impostor
  65795. * @param impostor impostor to get position iterations from
  65796. * @returns positionIterations value
  65797. */
  65798. getBodyPositionIterations(impostor: PhysicsImpostor): number;
  65799. /**
  65800. * Sets positionIterations of the impostor
  65801. * @param impostor impostor to set position on
  65802. * @param positionIterations positionIterations value
  65803. */
  65804. setBodyPositionIterations(impostor: PhysicsImpostor, positionIterations: number): void;
  65805. /**
  65806. * Append an anchor to a cloth object
  65807. * @param impostor is the cloth impostor to add anchor to
  65808. * @param otherImpostor is the rigid impostor to anchor to
  65809. * @param width ratio across width from 0 to 1
  65810. * @param height ratio up height from 0 to 1
  65811. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little stretch
  65812. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  65813. */
  65814. appendAnchor(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  65815. /**
  65816. * Append an hook to a rope object
  65817. * @param impostor is the rope impostor to add hook to
  65818. * @param otherImpostor is the rigid impostor to hook to
  65819. * @param length ratio along the rope from 0 to 1
  65820. * @param influence the elasticity between soft impostor and anchor from 0, very stretchy to 1, little stretch
  65821. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  65822. */
  65823. appendHook(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  65824. /**
  65825. * Sleeps the physics body and stops it from being active
  65826. * @param impostor impostor to sleep
  65827. */
  65828. sleepBody(impostor: PhysicsImpostor): void;
  65829. /**
  65830. * Activates the physics body
  65831. * @param impostor impostor to activate
  65832. */
  65833. wakeUpBody(impostor: PhysicsImpostor): void;
  65834. /**
  65835. * Updates the distance parameters of the joint
  65836. * @param joint joint to update
  65837. * @param maxDistance maximum distance of the joint
  65838. * @param minDistance minimum distance of the joint
  65839. */
  65840. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  65841. /**
  65842. * Sets a motor on the joint
  65843. * @param joint joint to set motor on
  65844. * @param speed speed of the motor
  65845. * @param maxForce maximum force of the motor
  65846. * @param motorIndex index of the motor
  65847. */
  65848. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  65849. /**
  65850. * Sets the motors limit
  65851. * @param joint joint to set limit on
  65852. * @param upperLimit upper limit
  65853. * @param lowerLimit lower limit
  65854. */
  65855. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  65856. /**
  65857. * Syncs the position and rotation of a mesh with the impostor
  65858. * @param mesh mesh to sync
  65859. * @param impostor impostor to update the mesh with
  65860. */
  65861. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  65862. /**
  65863. * Gets the radius of the impostor
  65864. * @param impostor impostor to get radius from
  65865. * @returns the radius
  65866. */
  65867. getRadius(impostor: PhysicsImpostor): number;
  65868. /**
  65869. * Gets the box size of the impostor
  65870. * @param impostor impostor to get box size from
  65871. * @param result the resulting box size
  65872. */
  65873. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  65874. /**
  65875. * Disposes of the impostor
  65876. */
  65877. dispose(): void;
  65878. /**
  65879. * Does a raycast in the physics world
  65880. * @param from when should the ray start?
  65881. * @param to when should the ray end?
  65882. * @returns PhysicsRaycastResult
  65883. */
  65884. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  65885. }
  65886. }
  65887. declare module BABYLON {
  65888. interface AbstractScene {
  65889. /**
  65890. * The list of reflection probes added to the scene
  65891. * @see https://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  65892. */
  65893. reflectionProbes: Array<ReflectionProbe>;
  65894. /**
  65895. * Removes the given reflection probe from this scene.
  65896. * @param toRemove The reflection probe to remove
  65897. * @returns The index of the removed reflection probe
  65898. */
  65899. removeReflectionProbe(toRemove: ReflectionProbe): number;
  65900. /**
  65901. * Adds the given reflection probe to this scene.
  65902. * @param newReflectionProbe The reflection probe to add
  65903. */
  65904. addReflectionProbe(newReflectionProbe: ReflectionProbe): void;
  65905. }
  65906. /**
  65907. * Class used to generate realtime reflection / refraction cube textures
  65908. * @see https://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  65909. */
  65910. export class ReflectionProbe {
  65911. /** defines the name of the probe */
  65912. name: string;
  65913. private _scene;
  65914. private _renderTargetTexture;
  65915. private _projectionMatrix;
  65916. private _viewMatrix;
  65917. private _target;
  65918. private _add;
  65919. private _attachedMesh;
  65920. private _invertYAxis;
  65921. /** Gets or sets probe position (center of the cube map) */
  65922. position: Vector3;
  65923. /**
  65924. * Creates a new reflection probe
  65925. * @param name defines the name of the probe
  65926. * @param size defines the texture resolution (for each face)
  65927. * @param scene defines the hosting scene
  65928. * @param generateMipMaps defines if mip maps should be generated automatically (true by default)
  65929. * @param useFloat defines if HDR data (flaot data) should be used to store colors (false by default)
  65930. */
  65931. constructor(
  65932. /** defines the name of the probe */
  65933. name: string, size: number, scene: Scene, generateMipMaps?: boolean, useFloat?: boolean);
  65934. /** Gets or sets the number of samples to use for multi-sampling (0 by default). Required WebGL2 */
  65935. get samples(): number;
  65936. set samples(value: number);
  65937. /** Gets or sets the refresh rate to use (on every frame by default) */
  65938. get refreshRate(): number;
  65939. set refreshRate(value: number);
  65940. /**
  65941. * Gets the hosting scene
  65942. * @returns a Scene
  65943. */
  65944. getScene(): Scene;
  65945. /** Gets the internal CubeTexture used to render to */
  65946. get cubeTexture(): RenderTargetTexture;
  65947. /** Gets the list of meshes to render */
  65948. get renderList(): Nullable<AbstractMesh[]>;
  65949. /**
  65950. * Attach the probe to a specific mesh (Rendering will be done from attached mesh's position)
  65951. * @param mesh defines the mesh to attach to
  65952. */
  65953. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  65954. /**
  65955. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups
  65956. * @param renderingGroupId The rendering group id corresponding to its index
  65957. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  65958. */
  65959. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  65960. /**
  65961. * Clean all associated resources
  65962. */
  65963. dispose(): void;
  65964. /**
  65965. * Converts the reflection probe information to a readable string for debug purpose.
  65966. * @param fullDetails Supports for multiple levels of logging within scene loading
  65967. * @returns the human readable reflection probe info
  65968. */
  65969. toString(fullDetails?: boolean): string;
  65970. /**
  65971. * Get the class name of the relfection probe.
  65972. * @returns "ReflectionProbe"
  65973. */
  65974. getClassName(): string;
  65975. /**
  65976. * Serialize the reflection probe to a JSON representation we can easily use in the resepective Parse function.
  65977. * @returns The JSON representation of the texture
  65978. */
  65979. serialize(): any;
  65980. /**
  65981. * Parse the JSON representation of a reflection probe in order to recreate the reflection probe in the given scene.
  65982. * @param parsedReflectionProbe Define the JSON representation of the reflection probe
  65983. * @param scene Define the scene the parsed reflection probe should be instantiated in
  65984. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  65985. * @returns The parsed reflection probe if successful
  65986. */
  65987. static Parse(parsedReflectionProbe: any, scene: Scene, rootUrl: string): Nullable<ReflectionProbe>;
  65988. }
  65989. }
  65990. declare module BABYLON {
  65991. /** @hidden */
  65992. export var _BabylonLoaderRegistered: boolean;
  65993. /**
  65994. * Helps setting up some configuration for the babylon file loader.
  65995. */
  65996. export class BabylonFileLoaderConfiguration {
  65997. /**
  65998. * The loader does not allow injecting custom physics engine into the plugins.
  65999. * Unfortunately in ES6, we need to manually inject them into the plugin.
  66000. * So you could set this variable to your engine import to make it work.
  66001. */
  66002. static LoaderInjectedPhysicsEngine: any;
  66003. }
  66004. }
  66005. declare module BABYLON {
  66006. /**
  66007. * A material to use for fast depth-only rendering.
  66008. */
  66009. export class OcclusionMaterial extends ShaderMaterial {
  66010. constructor(name: string, scene: Scene);
  66011. }
  66012. }
  66013. declare module BABYLON {
  66014. /**
  66015. * The Physically based simple base material of BJS.
  66016. *
  66017. * This enables better naming and convention enforcements on top of the pbrMaterial.
  66018. * It is used as the base class for both the specGloss and metalRough conventions.
  66019. */
  66020. export abstract class PBRBaseSimpleMaterial extends PBRBaseMaterial {
  66021. /**
  66022. * Number of Simultaneous lights allowed on the material.
  66023. */
  66024. maxSimultaneousLights: number;
  66025. /**
  66026. * If sets to true, disables all the lights affecting the material.
  66027. */
  66028. disableLighting: boolean;
  66029. /**
  66030. * Environment Texture used in the material (this is use for both reflection and environment lighting).
  66031. */
  66032. environmentTexture: BaseTexture;
  66033. /**
  66034. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  66035. */
  66036. invertNormalMapX: boolean;
  66037. /**
  66038. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  66039. */
  66040. invertNormalMapY: boolean;
  66041. /**
  66042. * Normal map used in the model.
  66043. */
  66044. normalTexture: BaseTexture;
  66045. /**
  66046. * Emissivie color used to self-illuminate the model.
  66047. */
  66048. emissiveColor: Color3;
  66049. /**
  66050. * Emissivie texture used to self-illuminate the model.
  66051. */
  66052. emissiveTexture: BaseTexture;
  66053. /**
  66054. * Occlusion Channel Strength.
  66055. */
  66056. occlusionStrength: number;
  66057. /**
  66058. * Occlusion Texture of the material (adding extra occlusion effects).
  66059. */
  66060. occlusionTexture: BaseTexture;
  66061. /**
  66062. * Defines the alpha limits in alpha test mode.
  66063. */
  66064. alphaCutOff: number;
  66065. /**
  66066. * Gets the current double sided mode.
  66067. */
  66068. get doubleSided(): boolean;
  66069. /**
  66070. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  66071. */
  66072. set doubleSided(value: boolean);
  66073. /**
  66074. * Stores the pre-calculated light information of a mesh in a texture.
  66075. */
  66076. lightmapTexture: BaseTexture;
  66077. /**
  66078. * If true, the light map contains occlusion information instead of lighting info.
  66079. */
  66080. useLightmapAsShadowmap: boolean;
  66081. /**
  66082. * Instantiates a new PBRMaterial instance.
  66083. *
  66084. * @param name The material name
  66085. * @param scene The scene the material will be use in.
  66086. */
  66087. constructor(name: string, scene: Scene);
  66088. getClassName(): string;
  66089. }
  66090. }
  66091. declare module BABYLON {
  66092. /**
  66093. * The PBR material of BJS following the metal roughness convention.
  66094. *
  66095. * This fits to the PBR convention in the GLTF definition:
  66096. * https://github.com/KhronosGroup/glTF/tree/2.0/specification/2.0
  66097. */
  66098. export class PBRMetallicRoughnessMaterial extends PBRBaseSimpleMaterial {
  66099. /**
  66100. * The base color has two different interpretations depending on the value of metalness.
  66101. * When the material is a metal, the base color is the specific measured reflectance value
  66102. * at normal incidence (F0). For a non-metal the base color represents the reflected diffuse color
  66103. * of the material.
  66104. */
  66105. baseColor: Color3;
  66106. /**
  66107. * Base texture of the metallic workflow. It contains both the baseColor information in RGB as
  66108. * well as opacity information in the alpha channel.
  66109. */
  66110. baseTexture: BaseTexture;
  66111. /**
  66112. * Specifies the metallic scalar value of the material.
  66113. * Can also be used to scale the metalness values of the metallic texture.
  66114. */
  66115. metallic: number;
  66116. /**
  66117. * Specifies the roughness scalar value of the material.
  66118. * Can also be used to scale the roughness values of the metallic texture.
  66119. */
  66120. roughness: number;
  66121. /**
  66122. * Texture containing both the metallic value in the B channel and the
  66123. * roughness value in the G channel to keep better precision.
  66124. */
  66125. metallicRoughnessTexture: BaseTexture;
  66126. /**
  66127. * Instantiates a new PBRMetalRoughnessMaterial instance.
  66128. *
  66129. * @param name The material name
  66130. * @param scene The scene the material will be use in.
  66131. */
  66132. constructor(name: string, scene: Scene);
  66133. /**
  66134. * Return the current class name of the material.
  66135. */
  66136. getClassName(): string;
  66137. /**
  66138. * Makes a duplicate of the current material.
  66139. * @param name - name to use for the new material.
  66140. */
  66141. clone(name: string): PBRMetallicRoughnessMaterial;
  66142. /**
  66143. * Serialize the material to a parsable JSON object.
  66144. */
  66145. serialize(): any;
  66146. /**
  66147. * Parses a JSON object corresponding to the serialize function.
  66148. */
  66149. static Parse(source: any, scene: Scene, rootUrl: string): PBRMetallicRoughnessMaterial;
  66150. }
  66151. }
  66152. declare module BABYLON {
  66153. /**
  66154. * The PBR material of BJS following the specular glossiness convention.
  66155. *
  66156. * This fits to the PBR convention in the GLTF definition:
  66157. * https://github.com/KhronosGroup/glTF/tree/2.0/extensions/Khronos/KHR_materials_pbrSpecularGlossiness
  66158. */
  66159. export class PBRSpecularGlossinessMaterial extends PBRBaseSimpleMaterial {
  66160. /**
  66161. * Specifies the diffuse color of the material.
  66162. */
  66163. diffuseColor: Color3;
  66164. /**
  66165. * Specifies the diffuse texture of the material. This can also contains the opacity value in its alpha
  66166. * channel.
  66167. */
  66168. diffuseTexture: BaseTexture;
  66169. /**
  66170. * Specifies the specular color of the material. This indicates how reflective is the material (none to mirror).
  66171. */
  66172. specularColor: Color3;
  66173. /**
  66174. * Specifies the glossiness of the material. This indicates "how sharp is the reflection".
  66175. */
  66176. glossiness: number;
  66177. /**
  66178. * Specifies both the specular color RGB and the glossiness A of the material per pixels.
  66179. */
  66180. specularGlossinessTexture: BaseTexture;
  66181. /**
  66182. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  66183. */
  66184. get useMicroSurfaceFromReflectivityMapAlpha(): boolean;
  66185. /**
  66186. * Instantiates a new PBRSpecularGlossinessMaterial instance.
  66187. *
  66188. * @param name The material name
  66189. * @param scene The scene the material will be use in.
  66190. */
  66191. constructor(name: string, scene: Scene);
  66192. /**
  66193. * Return the current class name of the material.
  66194. */
  66195. getClassName(): string;
  66196. /**
  66197. * Makes a duplicate of the current material.
  66198. * @param name - name to use for the new material.
  66199. */
  66200. clone(name: string): PBRSpecularGlossinessMaterial;
  66201. /**
  66202. * Serialize the material to a parsable JSON object.
  66203. */
  66204. serialize(): any;
  66205. /**
  66206. * Parses a JSON object corresponding to the serialize function.
  66207. */
  66208. static Parse(source: any, scene: Scene, rootUrl: string): PBRSpecularGlossinessMaterial;
  66209. }
  66210. }
  66211. declare module BABYLON {
  66212. /**
  66213. * This represents a color grading texture. This acts as a lookup table LUT, useful during post process
  66214. * It can help converting any input color in a desired output one. This can then be used to create effects
  66215. * from sepia, black and white to sixties or futuristic rendering...
  66216. *
  66217. * The only supported format is currently 3dl.
  66218. * More information on LUT: https://en.wikipedia.org/wiki/3D_lookup_table
  66219. */
  66220. export class ColorGradingTexture extends BaseTexture {
  66221. /**
  66222. * The texture URL.
  66223. */
  66224. url: string;
  66225. /**
  66226. * Empty line regex stored for GC.
  66227. */
  66228. private static _noneEmptyLineRegex;
  66229. private _textureMatrix;
  66230. private _onLoad;
  66231. /**
  66232. * Instantiates a ColorGradingTexture from the following parameters.
  66233. *
  66234. * @param url The location of the color grading data (currently only supporting 3dl)
  66235. * @param sceneOrEngine The scene or engine the texture will be used in
  66236. * @param onLoad defines a callback triggered when the texture has been loaded
  66237. */
  66238. constructor(url: string, sceneOrEngine: Scene | ThinEngine, onLoad?: Nullable<() => void>);
  66239. /**
  66240. * Fires the onload event from the constructor if requested.
  66241. */
  66242. private _triggerOnLoad;
  66243. /**
  66244. * Returns the texture matrix used in most of the material.
  66245. * This is not used in color grading but keep for troubleshooting purpose (easily swap diffuse by colorgrading to look in).
  66246. */
  66247. getTextureMatrix(): Matrix;
  66248. /**
  66249. * Occurs when the file being loaded is a .3dl LUT file.
  66250. */
  66251. private load3dlTexture;
  66252. /**
  66253. * Starts the loading process of the texture.
  66254. */
  66255. private loadTexture;
  66256. /**
  66257. * Clones the color grading texture.
  66258. */
  66259. clone(): ColorGradingTexture;
  66260. /**
  66261. * Called during delayed load for textures.
  66262. */
  66263. delayLoad(): void;
  66264. /**
  66265. * Parses a color grading texture serialized by Babylon.
  66266. * @param parsedTexture The texture information being parsedTexture
  66267. * @param scene The scene to load the texture in
  66268. * @param rootUrl The root url of the data assets to load
  66269. * @return A color grading texture
  66270. */
  66271. static Parse(parsedTexture: any, scene: Scene): Nullable<ColorGradingTexture>;
  66272. /**
  66273. * Serializes the LUT texture to json format.
  66274. */
  66275. serialize(): any;
  66276. }
  66277. }
  66278. declare module BABYLON {
  66279. /**
  66280. * This represents a texture coming from an equirectangular image supported by the web browser canvas.
  66281. */
  66282. export class EquiRectangularCubeTexture extends BaseTexture {
  66283. /** The six faces of the cube. */
  66284. private static _FacesMapping;
  66285. private _noMipmap;
  66286. private _onLoad;
  66287. private _onError;
  66288. /** The size of the cubemap. */
  66289. private _size;
  66290. /** The buffer of the image. */
  66291. private _buffer;
  66292. /** The width of the input image. */
  66293. private _width;
  66294. /** The height of the input image. */
  66295. private _height;
  66296. /** The URL to the image. */
  66297. url: string;
  66298. /**
  66299. * Instantiates an EquiRectangularCubeTexture from the following parameters.
  66300. * @param url The location of the image
  66301. * @param scene The scene the texture will be used in
  66302. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  66303. * @param noMipmap Forces to not generate the mipmap if true
  66304. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  66305. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  66306. * @param onLoad — defines a callback called when texture is loaded
  66307. * @param onError — defines a callback called if there is an error
  66308. */
  66309. constructor(url: string, scene: Scene, size: number, noMipmap?: boolean, gammaSpace?: boolean, onLoad?: Nullable<() => void>, onError?: Nullable<(message?: string, exception?: any) => void>);
  66310. /**
  66311. * Load the image data, by putting the image on a canvas and extracting its buffer.
  66312. */
  66313. private loadImage;
  66314. /**
  66315. * Convert the image buffer into a cubemap and create a CubeTexture.
  66316. */
  66317. private loadTexture;
  66318. /**
  66319. * Convert the ArrayBuffer into a Float32Array and drop the transparency channel.
  66320. * @param buffer The ArrayBuffer that should be converted.
  66321. * @returns The buffer as Float32Array.
  66322. */
  66323. private getFloat32ArrayFromArrayBuffer;
  66324. /**
  66325. * Get the current class name of the texture useful for serialization or dynamic coding.
  66326. * @returns "EquiRectangularCubeTexture"
  66327. */
  66328. getClassName(): string;
  66329. /**
  66330. * Create a clone of the current EquiRectangularCubeTexture and return it.
  66331. * @returns A clone of the current EquiRectangularCubeTexture.
  66332. */
  66333. clone(): EquiRectangularCubeTexture;
  66334. }
  66335. }
  66336. declare module BABYLON {
  66337. /**
  66338. * Defines the options related to the creation of an HtmlElementTexture
  66339. */
  66340. export interface IHtmlElementTextureOptions {
  66341. /**
  66342. * Defines whether mip maps should be created or not.
  66343. */
  66344. generateMipMaps?: boolean;
  66345. /**
  66346. * Defines the sampling mode of the texture.
  66347. */
  66348. samplingMode?: number;
  66349. /**
  66350. * Defines the engine instance to use the texture with. It is not mandatory if you define a scene.
  66351. */
  66352. engine: Nullable<ThinEngine>;
  66353. /**
  66354. * Defines the scene the texture belongs to. It is not mandatory if you define an engine.
  66355. */
  66356. scene: Nullable<Scene>;
  66357. }
  66358. /**
  66359. * This represents the smallest workload to use an already existing element (Canvas or Video) as a texture.
  66360. * To be as efficient as possible depending on your constraints nothing aside the first upload
  66361. * is automatically managed.
  66362. * It is a cheap VideoTexture or DynamicTexture if you prefer to keep full control of the elements
  66363. * in your application.
  66364. *
  66365. * As the update is not automatic, you need to call them manually.
  66366. */
  66367. export class HtmlElementTexture extends BaseTexture {
  66368. /**
  66369. * The texture URL.
  66370. */
  66371. element: HTMLVideoElement | HTMLCanvasElement;
  66372. private static readonly DefaultOptions;
  66373. private _textureMatrix;
  66374. private _isVideo;
  66375. private _generateMipMaps;
  66376. private _samplingMode;
  66377. /**
  66378. * Instantiates a HtmlElementTexture from the following parameters.
  66379. *
  66380. * @param name Defines the name of the texture
  66381. * @param element Defines the video or canvas the texture is filled with
  66382. * @param options Defines the other none mandatory texture creation options
  66383. */
  66384. constructor(name: string, element: HTMLVideoElement | HTMLCanvasElement, options: IHtmlElementTextureOptions);
  66385. private _createInternalTexture;
  66386. /**
  66387. * Returns the texture matrix used in most of the material.
  66388. */
  66389. getTextureMatrix(): Matrix;
  66390. /**
  66391. * Updates the content of the texture.
  66392. * @param invertY Defines whether the texture should be inverted on Y (false by default on video and true on canvas)
  66393. */
  66394. update(invertY?: Nullable<boolean>): void;
  66395. }
  66396. }
  66397. declare module BABYLON {
  66398. /**
  66399. * Based on jsTGALoader - Javascript loader for TGA file
  66400. * By Vincent Thibault
  66401. * @see http://blog.robrowser.com/javascript-tga-loader.html
  66402. */
  66403. export class TGATools {
  66404. private static _TYPE_INDEXED;
  66405. private static _TYPE_RGB;
  66406. private static _TYPE_GREY;
  66407. private static _TYPE_RLE_INDEXED;
  66408. private static _TYPE_RLE_RGB;
  66409. private static _TYPE_RLE_GREY;
  66410. private static _ORIGIN_MASK;
  66411. private static _ORIGIN_SHIFT;
  66412. private static _ORIGIN_BL;
  66413. private static _ORIGIN_BR;
  66414. private static _ORIGIN_UL;
  66415. private static _ORIGIN_UR;
  66416. /**
  66417. * Gets the header of a TGA file
  66418. * @param data defines the TGA data
  66419. * @returns the header
  66420. */
  66421. static GetTGAHeader(data: Uint8Array): any;
  66422. /**
  66423. * Uploads TGA content to a Babylon Texture
  66424. * @hidden
  66425. */
  66426. static UploadContent(texture: InternalTexture, data: Uint8Array): void;
  66427. /** @hidden */
  66428. 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;
  66429. /** @hidden */
  66430. 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;
  66431. /** @hidden */
  66432. 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;
  66433. /** @hidden */
  66434. 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;
  66435. /** @hidden */
  66436. 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;
  66437. /** @hidden */
  66438. 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;
  66439. }
  66440. }
  66441. declare module BABYLON {
  66442. /**
  66443. * Implementation of the TGA Texture Loader.
  66444. * @hidden
  66445. */
  66446. export class _TGATextureLoader implements IInternalTextureLoader {
  66447. /**
  66448. * Defines whether the loader supports cascade loading the different faces.
  66449. */
  66450. readonly supportCascades: boolean;
  66451. /**
  66452. * This returns if the loader support the current file information.
  66453. * @param extension defines the file extension of the file being loaded
  66454. * @returns true if the loader can load the specified file
  66455. */
  66456. canLoad(extension: string): boolean;
  66457. /**
  66458. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  66459. * @param data contains the texture data
  66460. * @param texture defines the BabylonJS internal texture
  66461. * @param createPolynomials will be true if polynomials have been requested
  66462. * @param onLoad defines the callback to trigger once the texture is ready
  66463. * @param onError defines the callback to trigger in case of error
  66464. */
  66465. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  66466. /**
  66467. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  66468. * @param data contains the texture data
  66469. * @param texture defines the BabylonJS internal texture
  66470. * @param callback defines the method to call once ready to upload
  66471. */
  66472. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  66473. }
  66474. }
  66475. declare module BABYLON {
  66476. /**
  66477. * Implementation of the HDR Texture Loader.
  66478. * @hidden
  66479. */
  66480. export class _HDRTextureLoader implements IInternalTextureLoader {
  66481. /**
  66482. * Defines whether the loader supports cascade loading the different faces.
  66483. */
  66484. readonly supportCascades: boolean;
  66485. /**
  66486. * This returns if the loader support the current file information.
  66487. * @param extension defines the file extension of the file being loaded
  66488. * @returns true if the loader can load the specified file
  66489. */
  66490. canLoad(extension: string): boolean;
  66491. /**
  66492. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  66493. * @param data contains the texture data
  66494. * @param texture defines the BabylonJS internal texture
  66495. * @param createPolynomials will be true if polynomials have been requested
  66496. * @param onLoad defines the callback to trigger once the texture is ready
  66497. * @param onError defines the callback to trigger in case of error
  66498. */
  66499. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  66500. /**
  66501. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  66502. * @param data contains the texture data
  66503. * @param texture defines the BabylonJS internal texture
  66504. * @param callback defines the method to call once ready to upload
  66505. */
  66506. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  66507. }
  66508. }
  66509. declare module BABYLON {
  66510. /**
  66511. * Info about the .basis files
  66512. */
  66513. class BasisFileInfo {
  66514. /**
  66515. * If the file has alpha
  66516. */
  66517. hasAlpha: boolean;
  66518. /**
  66519. * Info about each image of the basis file
  66520. */
  66521. images: Array<{
  66522. levels: Array<{
  66523. width: number;
  66524. height: number;
  66525. transcodedPixels: ArrayBufferView;
  66526. }>;
  66527. }>;
  66528. }
  66529. /**
  66530. * Result of transcoding a basis file
  66531. */
  66532. class TranscodeResult {
  66533. /**
  66534. * Info about the .basis file
  66535. */
  66536. fileInfo: BasisFileInfo;
  66537. /**
  66538. * Format to use when loading the file
  66539. */
  66540. format: number;
  66541. }
  66542. /**
  66543. * Configuration options for the Basis transcoder
  66544. */
  66545. export class BasisTranscodeConfiguration {
  66546. /**
  66547. * Supported compression formats used to determine the supported output format of the transcoder
  66548. */
  66549. supportedCompressionFormats?: {
  66550. /**
  66551. * etc1 compression format
  66552. */
  66553. etc1?: boolean;
  66554. /**
  66555. * s3tc compression format
  66556. */
  66557. s3tc?: boolean;
  66558. /**
  66559. * pvrtc compression format
  66560. */
  66561. pvrtc?: boolean;
  66562. /**
  66563. * etc2 compression format
  66564. */
  66565. etc2?: boolean;
  66566. };
  66567. /**
  66568. * If mipmap levels should be loaded for transcoded images (Default: true)
  66569. */
  66570. loadMipmapLevels?: boolean;
  66571. /**
  66572. * Index of a single image to load (Default: all images)
  66573. */
  66574. loadSingleImage?: number;
  66575. }
  66576. /**
  66577. * Used to load .Basis files
  66578. * See https://github.com/BinomialLLC/basis_universal/tree/master/webgl
  66579. */
  66580. export class BasisTools {
  66581. private static _IgnoreSupportedFormats;
  66582. /**
  66583. * URL to use when loading the basis transcoder
  66584. */
  66585. static JSModuleURL: string;
  66586. /**
  66587. * URL to use when loading the wasm module for the transcoder
  66588. */
  66589. static WasmModuleURL: string;
  66590. /**
  66591. * Get the internal format to be passed to texImage2D corresponding to the .basis format value
  66592. * @param basisFormat format chosen from GetSupportedTranscodeFormat
  66593. * @returns internal format corresponding to the Basis format
  66594. */
  66595. static GetInternalFormatFromBasisFormat(basisFormat: number): number;
  66596. private static _WorkerPromise;
  66597. private static _Worker;
  66598. private static _actionId;
  66599. private static _CreateWorkerAsync;
  66600. /**
  66601. * Transcodes a loaded image file to compressed pixel data
  66602. * @param data image data to transcode
  66603. * @param config configuration options for the transcoding
  66604. * @returns a promise resulting in the transcoded image
  66605. */
  66606. static TranscodeAsync(data: ArrayBuffer | ArrayBufferView, config: BasisTranscodeConfiguration): Promise<TranscodeResult>;
  66607. /**
  66608. * Loads a texture from the transcode result
  66609. * @param texture texture load to
  66610. * @param transcodeResult the result of transcoding the basis file to load from
  66611. */
  66612. static LoadTextureFromTranscodeResult(texture: InternalTexture, transcodeResult: TranscodeResult): void;
  66613. }
  66614. }
  66615. declare module BABYLON {
  66616. /**
  66617. * Loader for .basis file format
  66618. */
  66619. export class _BasisTextureLoader implements IInternalTextureLoader {
  66620. /**
  66621. * Defines whether the loader supports cascade loading the different faces.
  66622. */
  66623. readonly supportCascades: boolean;
  66624. /**
  66625. * This returns if the loader support the current file information.
  66626. * @param extension defines the file extension of the file being loaded
  66627. * @returns true if the loader can load the specified file
  66628. */
  66629. canLoad(extension: string): boolean;
  66630. /**
  66631. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  66632. * @param data contains the texture data
  66633. * @param texture defines the BabylonJS internal texture
  66634. * @param createPolynomials will be true if polynomials have been requested
  66635. * @param onLoad defines the callback to trigger once the texture is ready
  66636. * @param onError defines the callback to trigger in case of error
  66637. */
  66638. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  66639. /**
  66640. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  66641. * @param data contains the texture data
  66642. * @param texture defines the BabylonJS internal texture
  66643. * @param callback defines the method to call once ready to upload
  66644. */
  66645. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  66646. }
  66647. }
  66648. declare module BABYLON {
  66649. /**
  66650. * Defines the basic options interface of a TexturePacker Frame
  66651. */
  66652. export interface ITexturePackerFrame {
  66653. /**
  66654. * The frame ID
  66655. */
  66656. id: number;
  66657. /**
  66658. * The frames Scale
  66659. */
  66660. scale: Vector2;
  66661. /**
  66662. * The Frames offset
  66663. */
  66664. offset: Vector2;
  66665. }
  66666. /**
  66667. * This is a support class for frame Data on texture packer sets.
  66668. */
  66669. export class TexturePackerFrame implements ITexturePackerFrame {
  66670. /**
  66671. * The frame ID
  66672. */
  66673. id: number;
  66674. /**
  66675. * The frames Scale
  66676. */
  66677. scale: Vector2;
  66678. /**
  66679. * The Frames offset
  66680. */
  66681. offset: Vector2;
  66682. /**
  66683. * Initializes a texture package frame.
  66684. * @param id The numerical frame identifier
  66685. * @param scale Scalar Vector2 for UV frame
  66686. * @param offset Vector2 for the frame position in UV units.
  66687. * @returns TexturePackerFrame
  66688. */
  66689. constructor(id: number, scale: Vector2, offset: Vector2);
  66690. }
  66691. }
  66692. declare module BABYLON {
  66693. /**
  66694. * Defines the basic options interface of a TexturePacker
  66695. */
  66696. export interface ITexturePackerOptions {
  66697. /**
  66698. * Custom targets for the channels of a texture packer. Default is all the channels of the Standard Material
  66699. */
  66700. map?: string[];
  66701. /**
  66702. * the UV input targets, as a single value for all meshes. Defaults to VertexBuffer.UVKind
  66703. */
  66704. uvsIn?: string;
  66705. /**
  66706. * the UV output targets, as a single value for all meshes. Defaults to VertexBuffer.UVKind
  66707. */
  66708. uvsOut?: string;
  66709. /**
  66710. * number representing the layout style. Defaults to LAYOUT_STRIP
  66711. */
  66712. layout?: number;
  66713. /**
  66714. * number of columns if using custom column count layout(2). This defaults to 4.
  66715. */
  66716. colnum?: number;
  66717. /**
  66718. * flag to update the input meshes to the new packed texture after compilation. Defaults to true.
  66719. */
  66720. updateInputMeshes?: boolean;
  66721. /**
  66722. * boolean flag to dispose all the source textures. Defaults to true.
  66723. */
  66724. disposeSources?: boolean;
  66725. /**
  66726. * Fills the blank cells in a set to the customFillColor. Defaults to true.
  66727. */
  66728. fillBlanks?: boolean;
  66729. /**
  66730. * string value representing the context fill style color. Defaults to 'black'.
  66731. */
  66732. customFillColor?: string;
  66733. /**
  66734. * Width and Height Value of each Frame in the TexturePacker Sets
  66735. */
  66736. frameSize?: number;
  66737. /**
  66738. * Ratio of the value to add padding wise to each cell. Defaults to 0.0115
  66739. */
  66740. paddingRatio?: number;
  66741. /**
  66742. * Number that declares the fill method for the padding gutter.
  66743. */
  66744. paddingMode?: number;
  66745. /**
  66746. * If in SUBUV_COLOR padding mode what color to use.
  66747. */
  66748. paddingColor?: Color3 | Color4;
  66749. }
  66750. /**
  66751. * Defines the basic interface of a TexturePacker JSON File
  66752. */
  66753. export interface ITexturePackerJSON {
  66754. /**
  66755. * The frame ID
  66756. */
  66757. name: string;
  66758. /**
  66759. * The base64 channel data
  66760. */
  66761. sets: any;
  66762. /**
  66763. * The options of the Packer
  66764. */
  66765. options: ITexturePackerOptions;
  66766. /**
  66767. * The frame data of the Packer
  66768. */
  66769. frames: Array<number>;
  66770. }
  66771. /**
  66772. * This is a support class that generates a series of packed texture sets.
  66773. * @see https://doc.babylonjs.com/babylon101/materials
  66774. */
  66775. export class TexturePacker {
  66776. /** Packer Layout Constant 0 */
  66777. static readonly LAYOUT_STRIP: number;
  66778. /** Packer Layout Constant 1 */
  66779. static readonly LAYOUT_POWER2: number;
  66780. /** Packer Layout Constant 2 */
  66781. static readonly LAYOUT_COLNUM: number;
  66782. /** Packer Layout Constant 0 */
  66783. static readonly SUBUV_WRAP: number;
  66784. /** Packer Layout Constant 1 */
  66785. static readonly SUBUV_EXTEND: number;
  66786. /** Packer Layout Constant 2 */
  66787. static readonly SUBUV_COLOR: number;
  66788. /** The Name of the Texture Package */
  66789. name: string;
  66790. /** The scene scope of the TexturePacker */
  66791. scene: Scene;
  66792. /** The Meshes to target */
  66793. meshes: AbstractMesh[];
  66794. /** Arguments passed with the Constructor */
  66795. options: ITexturePackerOptions;
  66796. /** The promise that is started upon initialization */
  66797. promise: Nullable<Promise<TexturePacker | string>>;
  66798. /** The Container object for the channel sets that are generated */
  66799. sets: object;
  66800. /** The Container array for the frames that are generated */
  66801. frames: TexturePackerFrame[];
  66802. /** The expected number of textures the system is parsing. */
  66803. private _expecting;
  66804. /** The padding value from Math.ceil(frameSize * paddingRatio) */
  66805. private _paddingValue;
  66806. /**
  66807. * Initializes a texture package series from an array of meshes or a single mesh.
  66808. * @param name The name of the package
  66809. * @param meshes The target meshes to compose the package from
  66810. * @param options The arguments that texture packer should follow while building.
  66811. * @param scene The scene which the textures are scoped to.
  66812. * @returns TexturePacker
  66813. */
  66814. constructor(name: string, meshes: AbstractMesh[], options: ITexturePackerOptions, scene: Scene);
  66815. /**
  66816. * Starts the package process
  66817. * @param resolve The promises resolution function
  66818. * @returns TexturePacker
  66819. */
  66820. private _createFrames;
  66821. /**
  66822. * Calculates the Size of the Channel Sets
  66823. * @returns Vector2
  66824. */
  66825. private _calculateSize;
  66826. /**
  66827. * Calculates the UV data for the frames.
  66828. * @param baseSize the base frameSize
  66829. * @param padding the base frame padding
  66830. * @param dtSize size of the Dynamic Texture for that channel
  66831. * @param dtUnits is 1/dtSize
  66832. * @param update flag to update the input meshes
  66833. */
  66834. private _calculateMeshUVFrames;
  66835. /**
  66836. * Calculates the frames Offset.
  66837. * @param index of the frame
  66838. * @returns Vector2
  66839. */
  66840. private _getFrameOffset;
  66841. /**
  66842. * Updates a Mesh to the frame data
  66843. * @param mesh that is the target
  66844. * @param frameID or the frame index
  66845. */
  66846. private _updateMeshUV;
  66847. /**
  66848. * Updates a Meshes materials to use the texture packer channels
  66849. * @param m is the mesh to target
  66850. * @param force all channels on the packer to be set.
  66851. */
  66852. private _updateTextureReferences;
  66853. /**
  66854. * Public method to set a Mesh to a frame
  66855. * @param m that is the target
  66856. * @param frameID or the frame index
  66857. * @param updateMaterial trigger for if the Meshes attached Material be updated?
  66858. */
  66859. setMeshToFrame(m: AbstractMesh, frameID: number, updateMaterial?: boolean): void;
  66860. /**
  66861. * Starts the async promise to compile the texture packer.
  66862. * @returns Promise<void>
  66863. */
  66864. processAsync(): Promise<void>;
  66865. /**
  66866. * Disposes all textures associated with this packer
  66867. */
  66868. dispose(): void;
  66869. /**
  66870. * Starts the download process for all the channels converting them to base64 data and embedding it all in a JSON file.
  66871. * @param imageType is the image type to use.
  66872. * @param quality of the image if downloading as jpeg, Ranges from >0 to 1.
  66873. */
  66874. download(imageType?: string, quality?: number): void;
  66875. /**
  66876. * Public method to load a texturePacker JSON file.
  66877. * @param data of the JSON file in string format.
  66878. */
  66879. updateFromJSON(data: string): void;
  66880. }
  66881. }
  66882. declare module BABYLON {
  66883. /**
  66884. * 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.
  66885. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  66886. * @see https://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  66887. */
  66888. export class CustomProceduralTexture extends ProceduralTexture {
  66889. private _animate;
  66890. private _time;
  66891. private _config;
  66892. private _texturePath;
  66893. /**
  66894. * Instantiates a new Custom Procedural Texture.
  66895. * 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.
  66896. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  66897. * @see https://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  66898. * @param name Define the name of the texture
  66899. * @param texturePath Define the folder path containing all the custom texture related files (config, shaders...)
  66900. * @param size Define the size of the texture to create
  66901. * @param scene Define the scene the texture belongs to
  66902. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  66903. * @param generateMipMaps Define if the texture should creates mip maps or not
  66904. */
  66905. constructor(name: string, texturePath: string, size: number, scene: Scene, fallbackTexture?: Texture, generateMipMaps?: boolean);
  66906. private _loadJson;
  66907. /**
  66908. * Is the texture ready to be used ? (rendered at least once)
  66909. * @returns true if ready, otherwise, false.
  66910. */
  66911. isReady(): boolean;
  66912. /**
  66913. * Render the texture to its associated render target.
  66914. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  66915. */
  66916. render(useCameraPostProcess?: boolean): void;
  66917. /**
  66918. * Update the list of dependant textures samplers in the shader.
  66919. */
  66920. updateTextures(): void;
  66921. /**
  66922. * Update the uniform values of the procedural texture in the shader.
  66923. */
  66924. updateShaderUniforms(): void;
  66925. /**
  66926. * Define if the texture animates or not.
  66927. */
  66928. get animate(): boolean;
  66929. set animate(value: boolean);
  66930. }
  66931. }
  66932. declare module BABYLON {
  66933. /** @hidden */
  66934. export var noisePixelShader: {
  66935. name: string;
  66936. shader: string;
  66937. };
  66938. }
  66939. declare module BABYLON {
  66940. /**
  66941. * Class used to generate noise procedural textures
  66942. */
  66943. export class NoiseProceduralTexture extends ProceduralTexture {
  66944. /** Gets or sets the start time (default is 0) */
  66945. time: number;
  66946. /** Gets or sets a value between 0 and 1 indicating the overall brightness of the texture (default is 0.2) */
  66947. brightness: number;
  66948. /** Defines the number of octaves to process */
  66949. octaves: number;
  66950. /** Defines the level of persistence (0.8 by default) */
  66951. persistence: number;
  66952. /** Gets or sets animation speed factor (default is 1) */
  66953. animationSpeedFactor: number;
  66954. /**
  66955. * Creates a new NoiseProceduralTexture
  66956. * @param name defines the name fo the texture
  66957. * @param size defines the size of the texture (default is 256)
  66958. * @param scene defines the hosting scene
  66959. * @param fallbackTexture defines the texture to use if the NoiseProceduralTexture can't be created
  66960. * @param generateMipMaps defines if mipmaps must be generated (true by default)
  66961. */
  66962. constructor(name: string, size?: number, scene?: Nullable<Scene>, fallbackTexture?: Texture, generateMipMaps?: boolean);
  66963. private _updateShaderUniforms;
  66964. protected _getDefines(): string;
  66965. /** Generate the current state of the procedural texture */
  66966. render(useCameraPostProcess?: boolean): void;
  66967. /**
  66968. * Serializes this noise procedural texture
  66969. * @returns a serialized noise procedural texture object
  66970. */
  66971. serialize(): any;
  66972. /**
  66973. * Clone the texture.
  66974. * @returns the cloned texture
  66975. */
  66976. clone(): NoiseProceduralTexture;
  66977. /**
  66978. * Creates a NoiseProceduralTexture from parsed noise procedural texture data
  66979. * @param parsedTexture defines parsed texture data
  66980. * @param scene defines the current scene
  66981. * @param rootUrl defines the root URL containing noise procedural texture information
  66982. * @returns a parsed NoiseProceduralTexture
  66983. */
  66984. static Parse(parsedTexture: any, scene: Scene): NoiseProceduralTexture;
  66985. }
  66986. }
  66987. declare module BABYLON {
  66988. /**
  66989. * Raw cube texture where the raw buffers are passed in
  66990. */
  66991. export class RawCubeTexture extends CubeTexture {
  66992. /**
  66993. * Creates a cube texture where the raw buffers are passed in.
  66994. * @param scene defines the scene the texture is attached to
  66995. * @param data defines the array of data to use to create each face
  66996. * @param size defines the size of the textures
  66997. * @param format defines the format of the data
  66998. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  66999. * @param generateMipMaps defines if the engine should generate the mip levels
  67000. * @param invertY defines if data must be stored with Y axis inverted
  67001. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  67002. * @param compression defines the compression used (null by default)
  67003. */
  67004. constructor(scene: Scene, data: Nullable<ArrayBufferView[]>, size: number, format?: number, type?: number, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, compression?: Nullable<string>);
  67005. /**
  67006. * Updates the raw cube texture.
  67007. * @param data defines the data to store
  67008. * @param format defines the data format
  67009. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  67010. * @param invertY defines if data must be stored with Y axis inverted
  67011. * @param compression defines the compression used (null by default)
  67012. * @param level defines which level of the texture to update
  67013. */
  67014. update(data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression?: Nullable<string>): void;
  67015. /**
  67016. * Updates a raw cube texture with RGBD encoded data.
  67017. * @param data defines the array of data [mipmap][face] to use to create each face
  67018. * @param sphericalPolynomial defines the spherical polynomial for irradiance
  67019. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  67020. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  67021. * @returns a promise that resolves when the operation is complete
  67022. */
  67023. updateRGBDAsync(data: ArrayBufferView[][], sphericalPolynomial?: Nullable<SphericalPolynomial>, lodScale?: number, lodOffset?: number): Promise<void>;
  67024. /**
  67025. * Clones the raw cube texture.
  67026. * @return a new cube texture
  67027. */
  67028. clone(): CubeTexture;
  67029. /** @hidden */
  67030. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  67031. }
  67032. }
  67033. declare module BABYLON {
  67034. /**
  67035. * Class used to store 2D array textures containing user data
  67036. */
  67037. export class RawTexture2DArray extends Texture {
  67038. /** Gets or sets the texture format to use */
  67039. format: number;
  67040. /**
  67041. * Create a new RawTexture2DArray
  67042. * @param data defines the data of the texture
  67043. * @param width defines the width of the texture
  67044. * @param height defines the height of the texture
  67045. * @param depth defines the number of layers of the texture
  67046. * @param format defines the texture format to use
  67047. * @param scene defines the hosting scene
  67048. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  67049. * @param invertY defines if texture must be stored with Y axis inverted
  67050. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  67051. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  67052. */
  67053. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  67054. /** Gets or sets the texture format to use */
  67055. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  67056. /**
  67057. * Update the texture with new data
  67058. * @param data defines the data to store in the texture
  67059. */
  67060. update(data: ArrayBufferView): void;
  67061. }
  67062. }
  67063. declare module BABYLON {
  67064. /**
  67065. * Class used to store 3D textures containing user data
  67066. */
  67067. export class RawTexture3D extends Texture {
  67068. /** Gets or sets the texture format to use */
  67069. format: number;
  67070. /**
  67071. * Create a new RawTexture3D
  67072. * @param data defines the data of the texture
  67073. * @param width defines the width of the texture
  67074. * @param height defines the height of the texture
  67075. * @param depth defines the depth of the texture
  67076. * @param format defines the texture format to use
  67077. * @param scene defines the hosting scene
  67078. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  67079. * @param invertY defines if texture must be stored with Y axis inverted
  67080. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  67081. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  67082. */
  67083. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  67084. /** Gets or sets the texture format to use */
  67085. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  67086. /**
  67087. * Update the texture with new data
  67088. * @param data defines the data to store in the texture
  67089. */
  67090. update(data: ArrayBufferView): void;
  67091. }
  67092. }
  67093. declare module BABYLON {
  67094. /**
  67095. * Creates a refraction texture used by refraction channel of the standard material.
  67096. * It is like a mirror but to see through a material.
  67097. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  67098. */
  67099. export class RefractionTexture extends RenderTargetTexture {
  67100. /**
  67101. * Define the reflection plane we want to use. The refractionPlane is usually set to the constructed refractor.
  67102. * 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.
  67103. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  67104. */
  67105. refractionPlane: Plane;
  67106. /**
  67107. * Define how deep under the surface we should see.
  67108. */
  67109. depth: number;
  67110. /**
  67111. * Creates a refraction texture used by refraction channel of the standard material.
  67112. * It is like a mirror but to see through a material.
  67113. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  67114. * @param name Define the texture name
  67115. * @param size Define the size of the underlying texture
  67116. * @param scene Define the scene the refraction belongs to
  67117. * @param generateMipMaps Define if we need to generate mips level for the refraction
  67118. */
  67119. constructor(name: string, size: number, scene: Scene, generateMipMaps?: boolean);
  67120. /**
  67121. * Clone the refraction texture.
  67122. * @returns the cloned texture
  67123. */
  67124. clone(): RefractionTexture;
  67125. /**
  67126. * Serialize the texture to a JSON representation you could use in Parse later on
  67127. * @returns the serialized JSON representation
  67128. */
  67129. serialize(): any;
  67130. }
  67131. }
  67132. declare module BABYLON {
  67133. /**
  67134. * Block used to add support for vertex skinning (bones)
  67135. */
  67136. export class BonesBlock extends NodeMaterialBlock {
  67137. /**
  67138. * Creates a new BonesBlock
  67139. * @param name defines the block name
  67140. */
  67141. constructor(name: string);
  67142. /**
  67143. * Initialize the block and prepare the context for build
  67144. * @param state defines the state that will be used for the build
  67145. */
  67146. initialize(state: NodeMaterialBuildState): void;
  67147. /**
  67148. * Gets the current class name
  67149. * @returns the class name
  67150. */
  67151. getClassName(): string;
  67152. /**
  67153. * Gets the matrix indices input component
  67154. */
  67155. get matricesIndices(): NodeMaterialConnectionPoint;
  67156. /**
  67157. * Gets the matrix weights input component
  67158. */
  67159. get matricesWeights(): NodeMaterialConnectionPoint;
  67160. /**
  67161. * Gets the extra matrix indices input component
  67162. */
  67163. get matricesIndicesExtra(): NodeMaterialConnectionPoint;
  67164. /**
  67165. * Gets the extra matrix weights input component
  67166. */
  67167. get matricesWeightsExtra(): NodeMaterialConnectionPoint;
  67168. /**
  67169. * Gets the world input component
  67170. */
  67171. get world(): NodeMaterialConnectionPoint;
  67172. /**
  67173. * Gets the output component
  67174. */
  67175. get output(): NodeMaterialConnectionPoint;
  67176. autoConfigure(material: NodeMaterial): void;
  67177. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  67178. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  67179. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  67180. protected _buildBlock(state: NodeMaterialBuildState): this;
  67181. }
  67182. }
  67183. declare module BABYLON {
  67184. /**
  67185. * Block used to add support for instances
  67186. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  67187. */
  67188. export class InstancesBlock extends NodeMaterialBlock {
  67189. /**
  67190. * Creates a new InstancesBlock
  67191. * @param name defines the block name
  67192. */
  67193. constructor(name: string);
  67194. /**
  67195. * Gets the current class name
  67196. * @returns the class name
  67197. */
  67198. getClassName(): string;
  67199. /**
  67200. * Gets the first world row input component
  67201. */
  67202. get world0(): NodeMaterialConnectionPoint;
  67203. /**
  67204. * Gets the second world row input component
  67205. */
  67206. get world1(): NodeMaterialConnectionPoint;
  67207. /**
  67208. * Gets the third world row input component
  67209. */
  67210. get world2(): NodeMaterialConnectionPoint;
  67211. /**
  67212. * Gets the forth world row input component
  67213. */
  67214. get world3(): NodeMaterialConnectionPoint;
  67215. /**
  67216. * Gets the world input component
  67217. */
  67218. get world(): NodeMaterialConnectionPoint;
  67219. /**
  67220. * Gets the output component
  67221. */
  67222. get output(): NodeMaterialConnectionPoint;
  67223. /**
  67224. * Gets the instanceID component
  67225. */
  67226. get instanceID(): NodeMaterialConnectionPoint;
  67227. autoConfigure(material: NodeMaterial): void;
  67228. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean, subMesh?: SubMesh): void;
  67229. protected _buildBlock(state: NodeMaterialBuildState): this;
  67230. }
  67231. }
  67232. declare module BABYLON {
  67233. /**
  67234. * Block used to add morph targets support to vertex shader
  67235. */
  67236. export class MorphTargetsBlock extends NodeMaterialBlock {
  67237. private _repeatableContentAnchor;
  67238. /**
  67239. * Create a new MorphTargetsBlock
  67240. * @param name defines the block name
  67241. */
  67242. constructor(name: string);
  67243. /**
  67244. * Gets the current class name
  67245. * @returns the class name
  67246. */
  67247. getClassName(): string;
  67248. /**
  67249. * Gets the position input component
  67250. */
  67251. get position(): NodeMaterialConnectionPoint;
  67252. /**
  67253. * Gets the normal input component
  67254. */
  67255. get normal(): NodeMaterialConnectionPoint;
  67256. /**
  67257. * Gets the tangent input component
  67258. */
  67259. get tangent(): NodeMaterialConnectionPoint;
  67260. /**
  67261. * Gets the tangent input component
  67262. */
  67263. get uv(): NodeMaterialConnectionPoint;
  67264. /**
  67265. * Gets the position output component
  67266. */
  67267. get positionOutput(): NodeMaterialConnectionPoint;
  67268. /**
  67269. * Gets the normal output component
  67270. */
  67271. get normalOutput(): NodeMaterialConnectionPoint;
  67272. /**
  67273. * Gets the tangent output component
  67274. */
  67275. get tangentOutput(): NodeMaterialConnectionPoint;
  67276. /**
  67277. * Gets the tangent output component
  67278. */
  67279. get uvOutput(): NodeMaterialConnectionPoint;
  67280. initialize(state: NodeMaterialBuildState): void;
  67281. autoConfigure(material: NodeMaterial): void;
  67282. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  67283. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  67284. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  67285. protected _buildBlock(state: NodeMaterialBuildState): this;
  67286. }
  67287. }
  67288. declare module BABYLON {
  67289. /**
  67290. * Block used to get data information from a light
  67291. */
  67292. export class LightInformationBlock extends NodeMaterialBlock {
  67293. private _lightDataUniformName;
  67294. private _lightColorUniformName;
  67295. private _lightTypeDefineName;
  67296. /**
  67297. * Gets or sets the light associated with this block
  67298. */
  67299. light: Nullable<Light>;
  67300. /**
  67301. * Creates a new LightInformationBlock
  67302. * @param name defines the block name
  67303. */
  67304. constructor(name: string);
  67305. /**
  67306. * Gets the current class name
  67307. * @returns the class name
  67308. */
  67309. getClassName(): string;
  67310. /**
  67311. * Gets the world position input component
  67312. */
  67313. get worldPosition(): NodeMaterialConnectionPoint;
  67314. /**
  67315. * Gets the direction output component
  67316. */
  67317. get direction(): NodeMaterialConnectionPoint;
  67318. /**
  67319. * Gets the direction output component
  67320. */
  67321. get color(): NodeMaterialConnectionPoint;
  67322. /**
  67323. * Gets the direction output component
  67324. */
  67325. get intensity(): NodeMaterialConnectionPoint;
  67326. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  67327. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  67328. protected _buildBlock(state: NodeMaterialBuildState): this;
  67329. serialize(): any;
  67330. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  67331. }
  67332. }
  67333. declare module BABYLON {
  67334. /**
  67335. * Block used to add image processing support to fragment shader
  67336. */
  67337. export class ImageProcessingBlock extends NodeMaterialBlock {
  67338. /**
  67339. * Create a new ImageProcessingBlock
  67340. * @param name defines the block name
  67341. */
  67342. constructor(name: string);
  67343. /**
  67344. * Gets the current class name
  67345. * @returns the class name
  67346. */
  67347. getClassName(): string;
  67348. /**
  67349. * Gets the color input component
  67350. */
  67351. get color(): NodeMaterialConnectionPoint;
  67352. /**
  67353. * Gets the output component
  67354. */
  67355. get output(): NodeMaterialConnectionPoint;
  67356. /**
  67357. * Initialize the block and prepare the context for build
  67358. * @param state defines the state that will be used for the build
  67359. */
  67360. initialize(state: NodeMaterialBuildState): void;
  67361. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): boolean;
  67362. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  67363. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  67364. protected _buildBlock(state: NodeMaterialBuildState): this;
  67365. }
  67366. }
  67367. declare module BABYLON {
  67368. /**
  67369. * Block used to perturb normals based on a normal map
  67370. */
  67371. export class PerturbNormalBlock extends NodeMaterialBlock {
  67372. private _tangentSpaceParameterName;
  67373. /** Gets or sets a boolean indicating that normal should be inverted on X axis */
  67374. invertX: boolean;
  67375. /** Gets or sets a boolean indicating that normal should be inverted on Y axis */
  67376. invertY: boolean;
  67377. /**
  67378. * Create a new PerturbNormalBlock
  67379. * @param name defines the block name
  67380. */
  67381. constructor(name: string);
  67382. /**
  67383. * Gets the current class name
  67384. * @returns the class name
  67385. */
  67386. getClassName(): string;
  67387. /**
  67388. * Gets the world position input component
  67389. */
  67390. get worldPosition(): NodeMaterialConnectionPoint;
  67391. /**
  67392. * Gets the world normal input component
  67393. */
  67394. get worldNormal(): NodeMaterialConnectionPoint;
  67395. /**
  67396. * Gets the world tangent input component
  67397. */
  67398. get worldTangent(): NodeMaterialConnectionPoint;
  67399. /**
  67400. * Gets the uv input component
  67401. */
  67402. get uv(): NodeMaterialConnectionPoint;
  67403. /**
  67404. * Gets the normal map color input component
  67405. */
  67406. get normalMapColor(): NodeMaterialConnectionPoint;
  67407. /**
  67408. * Gets the strength input component
  67409. */
  67410. get strength(): NodeMaterialConnectionPoint;
  67411. /**
  67412. * Gets the output component
  67413. */
  67414. get output(): NodeMaterialConnectionPoint;
  67415. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  67416. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  67417. autoConfigure(material: NodeMaterial): void;
  67418. protected _buildBlock(state: NodeMaterialBuildState): this;
  67419. protected _dumpPropertiesCode(): string;
  67420. serialize(): any;
  67421. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  67422. }
  67423. }
  67424. declare module BABYLON {
  67425. /**
  67426. * Block used to discard a pixel if a value is smaller than a cutoff
  67427. */
  67428. export class DiscardBlock extends NodeMaterialBlock {
  67429. /**
  67430. * Create a new DiscardBlock
  67431. * @param name defines the block name
  67432. */
  67433. constructor(name: string);
  67434. /**
  67435. * Gets the current class name
  67436. * @returns the class name
  67437. */
  67438. getClassName(): string;
  67439. /**
  67440. * Gets the color input component
  67441. */
  67442. get value(): NodeMaterialConnectionPoint;
  67443. /**
  67444. * Gets the cutoff input component
  67445. */
  67446. get cutoff(): NodeMaterialConnectionPoint;
  67447. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  67448. }
  67449. }
  67450. declare module BABYLON {
  67451. /**
  67452. * Block used to test if the fragment shader is front facing
  67453. */
  67454. export class FrontFacingBlock extends NodeMaterialBlock {
  67455. /**
  67456. * Creates a new FrontFacingBlock
  67457. * @param name defines the block name
  67458. */
  67459. constructor(name: string);
  67460. /**
  67461. * Gets the current class name
  67462. * @returns the class name
  67463. */
  67464. getClassName(): string;
  67465. /**
  67466. * Gets the output component
  67467. */
  67468. get output(): NodeMaterialConnectionPoint;
  67469. protected _buildBlock(state: NodeMaterialBuildState): this;
  67470. }
  67471. }
  67472. declare module BABYLON {
  67473. /**
  67474. * Block used to get the derivative value on x and y of a given input
  67475. */
  67476. export class DerivativeBlock extends NodeMaterialBlock {
  67477. /**
  67478. * Create a new DerivativeBlock
  67479. * @param name defines the block name
  67480. */
  67481. constructor(name: string);
  67482. /**
  67483. * Gets the current class name
  67484. * @returns the class name
  67485. */
  67486. getClassName(): string;
  67487. /**
  67488. * Gets the input component
  67489. */
  67490. get input(): NodeMaterialConnectionPoint;
  67491. /**
  67492. * Gets the derivative output on x
  67493. */
  67494. get dx(): NodeMaterialConnectionPoint;
  67495. /**
  67496. * Gets the derivative output on y
  67497. */
  67498. get dy(): NodeMaterialConnectionPoint;
  67499. protected _buildBlock(state: NodeMaterialBuildState): this;
  67500. }
  67501. }
  67502. declare module BABYLON {
  67503. /**
  67504. * Block used to make gl_FragCoord available
  67505. */
  67506. export class FragCoordBlock extends NodeMaterialBlock {
  67507. /**
  67508. * Creates a new FragCoordBlock
  67509. * @param name defines the block name
  67510. */
  67511. constructor(name: string);
  67512. /**
  67513. * Gets the current class name
  67514. * @returns the class name
  67515. */
  67516. getClassName(): string;
  67517. /**
  67518. * Gets the xy component
  67519. */
  67520. get xy(): NodeMaterialConnectionPoint;
  67521. /**
  67522. * Gets the xyz component
  67523. */
  67524. get xyz(): NodeMaterialConnectionPoint;
  67525. /**
  67526. * Gets the xyzw component
  67527. */
  67528. get xyzw(): NodeMaterialConnectionPoint;
  67529. /**
  67530. * Gets the x component
  67531. */
  67532. get x(): NodeMaterialConnectionPoint;
  67533. /**
  67534. * Gets the y component
  67535. */
  67536. get y(): NodeMaterialConnectionPoint;
  67537. /**
  67538. * Gets the z component
  67539. */
  67540. get z(): NodeMaterialConnectionPoint;
  67541. /**
  67542. * Gets the w component
  67543. */
  67544. get output(): NodeMaterialConnectionPoint;
  67545. protected writeOutputs(state: NodeMaterialBuildState): string;
  67546. protected _buildBlock(state: NodeMaterialBuildState): this;
  67547. }
  67548. }
  67549. declare module BABYLON {
  67550. /**
  67551. * Block used to get the screen sizes
  67552. */
  67553. export class ScreenSizeBlock extends NodeMaterialBlock {
  67554. private _varName;
  67555. private _scene;
  67556. /**
  67557. * Creates a new ScreenSizeBlock
  67558. * @param name defines the block name
  67559. */
  67560. constructor(name: string);
  67561. /**
  67562. * Gets the current class name
  67563. * @returns the class name
  67564. */
  67565. getClassName(): string;
  67566. /**
  67567. * Gets the xy component
  67568. */
  67569. get xy(): NodeMaterialConnectionPoint;
  67570. /**
  67571. * Gets the x component
  67572. */
  67573. get x(): NodeMaterialConnectionPoint;
  67574. /**
  67575. * Gets the y component
  67576. */
  67577. get y(): NodeMaterialConnectionPoint;
  67578. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  67579. protected writeOutputs(state: NodeMaterialBuildState, varName: string): string;
  67580. protected _buildBlock(state: NodeMaterialBuildState): this;
  67581. }
  67582. }
  67583. declare module BABYLON {
  67584. /**
  67585. * Block used to add support for scene fog
  67586. */
  67587. export class FogBlock extends NodeMaterialBlock {
  67588. private _fogDistanceName;
  67589. private _fogParameters;
  67590. /**
  67591. * Create a new FogBlock
  67592. * @param name defines the block name
  67593. */
  67594. constructor(name: string);
  67595. /**
  67596. * Gets the current class name
  67597. * @returns the class name
  67598. */
  67599. getClassName(): string;
  67600. /**
  67601. * Gets the world position input component
  67602. */
  67603. get worldPosition(): NodeMaterialConnectionPoint;
  67604. /**
  67605. * Gets the view input component
  67606. */
  67607. get view(): NodeMaterialConnectionPoint;
  67608. /**
  67609. * Gets the color input component
  67610. */
  67611. get input(): NodeMaterialConnectionPoint;
  67612. /**
  67613. * Gets the fog color input component
  67614. */
  67615. get fogColor(): NodeMaterialConnectionPoint;
  67616. /**
  67617. * Gets the output component
  67618. */
  67619. get output(): NodeMaterialConnectionPoint;
  67620. autoConfigure(material: NodeMaterial): void;
  67621. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  67622. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  67623. protected _buildBlock(state: NodeMaterialBuildState): this;
  67624. }
  67625. }
  67626. declare module BABYLON {
  67627. /**
  67628. * Block used to add light in the fragment shader
  67629. */
  67630. export class LightBlock extends NodeMaterialBlock {
  67631. private _lightId;
  67632. /**
  67633. * Gets or sets the light associated with this block
  67634. */
  67635. light: Nullable<Light>;
  67636. /**
  67637. * Create a new LightBlock
  67638. * @param name defines the block name
  67639. */
  67640. constructor(name: string);
  67641. /**
  67642. * Gets the current class name
  67643. * @returns the class name
  67644. */
  67645. getClassName(): string;
  67646. /**
  67647. * Gets the world position input component
  67648. */
  67649. get worldPosition(): NodeMaterialConnectionPoint;
  67650. /**
  67651. * Gets the world normal input component
  67652. */
  67653. get worldNormal(): NodeMaterialConnectionPoint;
  67654. /**
  67655. * Gets the camera (or eye) position component
  67656. */
  67657. get cameraPosition(): NodeMaterialConnectionPoint;
  67658. /**
  67659. * Gets the glossiness component
  67660. */
  67661. get glossiness(): NodeMaterialConnectionPoint;
  67662. /**
  67663. * Gets the glossiness power component
  67664. */
  67665. get glossPower(): NodeMaterialConnectionPoint;
  67666. /**
  67667. * Gets the diffuse color component
  67668. */
  67669. get diffuseColor(): NodeMaterialConnectionPoint;
  67670. /**
  67671. * Gets the specular color component
  67672. */
  67673. get specularColor(): NodeMaterialConnectionPoint;
  67674. /**
  67675. * Gets the view matrix component
  67676. */
  67677. get view(): NodeMaterialConnectionPoint;
  67678. /**
  67679. * Gets the diffuse output component
  67680. */
  67681. get diffuseOutput(): NodeMaterialConnectionPoint;
  67682. /**
  67683. * Gets the specular output component
  67684. */
  67685. get specularOutput(): NodeMaterialConnectionPoint;
  67686. /**
  67687. * Gets the shadow output component
  67688. */
  67689. get shadow(): NodeMaterialConnectionPoint;
  67690. autoConfigure(material: NodeMaterial): void;
  67691. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  67692. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, uniformBuffers: string[]): void;
  67693. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  67694. private _injectVertexCode;
  67695. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  67696. serialize(): any;
  67697. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  67698. }
  67699. }
  67700. declare module BABYLON {
  67701. /**
  67702. * Block used to read a reflection texture from a sampler
  67703. */
  67704. export class ReflectionTextureBlock extends ReflectionTextureBaseBlock {
  67705. /**
  67706. * Create a new ReflectionTextureBlock
  67707. * @param name defines the block name
  67708. */
  67709. constructor(name: string);
  67710. /**
  67711. * Gets the current class name
  67712. * @returns the class name
  67713. */
  67714. getClassName(): string;
  67715. /**
  67716. * Gets the world position input component
  67717. */
  67718. get position(): NodeMaterialConnectionPoint;
  67719. /**
  67720. * Gets the world position input component
  67721. */
  67722. get worldPosition(): NodeMaterialConnectionPoint;
  67723. /**
  67724. * Gets the world normal input component
  67725. */
  67726. get worldNormal(): NodeMaterialConnectionPoint;
  67727. /**
  67728. * Gets the world input component
  67729. */
  67730. get world(): NodeMaterialConnectionPoint;
  67731. /**
  67732. * Gets the camera (or eye) position component
  67733. */
  67734. get cameraPosition(): NodeMaterialConnectionPoint;
  67735. /**
  67736. * Gets the view input component
  67737. */
  67738. get view(): NodeMaterialConnectionPoint;
  67739. /**
  67740. * Gets the rgb output component
  67741. */
  67742. get rgb(): NodeMaterialConnectionPoint;
  67743. /**
  67744. * Gets the rgba output component
  67745. */
  67746. get rgba(): NodeMaterialConnectionPoint;
  67747. /**
  67748. * Gets the r output component
  67749. */
  67750. get r(): NodeMaterialConnectionPoint;
  67751. /**
  67752. * Gets the g output component
  67753. */
  67754. get g(): NodeMaterialConnectionPoint;
  67755. /**
  67756. * Gets the b output component
  67757. */
  67758. get b(): NodeMaterialConnectionPoint;
  67759. /**
  67760. * Gets the a output component
  67761. */
  67762. get a(): NodeMaterialConnectionPoint;
  67763. autoConfigure(material: NodeMaterial): void;
  67764. protected _buildBlock(state: NodeMaterialBuildState): this;
  67765. }
  67766. }
  67767. declare module BABYLON {
  67768. /**
  67769. * Block used to add 2 vectors
  67770. */
  67771. export class AddBlock extends NodeMaterialBlock {
  67772. /**
  67773. * Creates a new AddBlock
  67774. * @param name defines the block name
  67775. */
  67776. constructor(name: string);
  67777. /**
  67778. * Gets the current class name
  67779. * @returns the class name
  67780. */
  67781. getClassName(): string;
  67782. /**
  67783. * Gets the left operand input component
  67784. */
  67785. get left(): NodeMaterialConnectionPoint;
  67786. /**
  67787. * Gets the right operand input component
  67788. */
  67789. get right(): NodeMaterialConnectionPoint;
  67790. /**
  67791. * Gets the output component
  67792. */
  67793. get output(): NodeMaterialConnectionPoint;
  67794. protected _buildBlock(state: NodeMaterialBuildState): this;
  67795. }
  67796. }
  67797. declare module BABYLON {
  67798. /**
  67799. * Block used to scale a vector by a float
  67800. */
  67801. export class ScaleBlock extends NodeMaterialBlock {
  67802. /**
  67803. * Creates a new ScaleBlock
  67804. * @param name defines the block name
  67805. */
  67806. constructor(name: string);
  67807. /**
  67808. * Gets the current class name
  67809. * @returns the class name
  67810. */
  67811. getClassName(): string;
  67812. /**
  67813. * Gets the input component
  67814. */
  67815. get input(): NodeMaterialConnectionPoint;
  67816. /**
  67817. * Gets the factor input component
  67818. */
  67819. get factor(): NodeMaterialConnectionPoint;
  67820. /**
  67821. * Gets the output component
  67822. */
  67823. get output(): NodeMaterialConnectionPoint;
  67824. protected _buildBlock(state: NodeMaterialBuildState): this;
  67825. }
  67826. }
  67827. declare module BABYLON {
  67828. /**
  67829. * Block used to clamp a float
  67830. */
  67831. export class ClampBlock extends NodeMaterialBlock {
  67832. /** Gets or sets the minimum range */
  67833. minimum: number;
  67834. /** Gets or sets the maximum range */
  67835. maximum: number;
  67836. /**
  67837. * Creates a new ClampBlock
  67838. * @param name defines the block name
  67839. */
  67840. constructor(name: string);
  67841. /**
  67842. * Gets the current class name
  67843. * @returns the class name
  67844. */
  67845. getClassName(): string;
  67846. /**
  67847. * Gets the value input component
  67848. */
  67849. get value(): NodeMaterialConnectionPoint;
  67850. /**
  67851. * Gets the output component
  67852. */
  67853. get output(): NodeMaterialConnectionPoint;
  67854. protected _buildBlock(state: NodeMaterialBuildState): this;
  67855. protected _dumpPropertiesCode(): string;
  67856. serialize(): any;
  67857. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  67858. }
  67859. }
  67860. declare module BABYLON {
  67861. /**
  67862. * Block used to apply a cross product between 2 vectors
  67863. */
  67864. export class CrossBlock extends NodeMaterialBlock {
  67865. /**
  67866. * Creates a new CrossBlock
  67867. * @param name defines the block name
  67868. */
  67869. constructor(name: string);
  67870. /**
  67871. * Gets the current class name
  67872. * @returns the class name
  67873. */
  67874. getClassName(): string;
  67875. /**
  67876. * Gets the left operand input component
  67877. */
  67878. get left(): NodeMaterialConnectionPoint;
  67879. /**
  67880. * Gets the right operand input component
  67881. */
  67882. get right(): NodeMaterialConnectionPoint;
  67883. /**
  67884. * Gets the output component
  67885. */
  67886. get output(): NodeMaterialConnectionPoint;
  67887. protected _buildBlock(state: NodeMaterialBuildState): this;
  67888. }
  67889. }
  67890. declare module BABYLON {
  67891. /**
  67892. * Block used to apply a dot product between 2 vectors
  67893. */
  67894. export class DotBlock extends NodeMaterialBlock {
  67895. /**
  67896. * Creates a new DotBlock
  67897. * @param name defines the block name
  67898. */
  67899. constructor(name: string);
  67900. /**
  67901. * Gets the current class name
  67902. * @returns the class name
  67903. */
  67904. getClassName(): string;
  67905. /**
  67906. * Gets the left operand input component
  67907. */
  67908. get left(): NodeMaterialConnectionPoint;
  67909. /**
  67910. * Gets the right operand input component
  67911. */
  67912. get right(): NodeMaterialConnectionPoint;
  67913. /**
  67914. * Gets the output component
  67915. */
  67916. get output(): NodeMaterialConnectionPoint;
  67917. protected _buildBlock(state: NodeMaterialBuildState): this;
  67918. }
  67919. }
  67920. declare module BABYLON {
  67921. /**
  67922. * Block used to normalize a vector
  67923. */
  67924. export class NormalizeBlock extends NodeMaterialBlock {
  67925. /**
  67926. * Creates a new NormalizeBlock
  67927. * @param name defines the block name
  67928. */
  67929. constructor(name: string);
  67930. /**
  67931. * Gets the current class name
  67932. * @returns the class name
  67933. */
  67934. getClassName(): string;
  67935. /**
  67936. * Gets the input component
  67937. */
  67938. get input(): NodeMaterialConnectionPoint;
  67939. /**
  67940. * Gets the output component
  67941. */
  67942. get output(): NodeMaterialConnectionPoint;
  67943. protected _buildBlock(state: NodeMaterialBuildState): this;
  67944. }
  67945. }
  67946. declare module BABYLON {
  67947. /**
  67948. * Block used to create a Color3/4 out of individual inputs (one for each component)
  67949. */
  67950. export class ColorMergerBlock extends NodeMaterialBlock {
  67951. /**
  67952. * Create a new ColorMergerBlock
  67953. * @param name defines the block name
  67954. */
  67955. constructor(name: string);
  67956. /**
  67957. * Gets the current class name
  67958. * @returns the class name
  67959. */
  67960. getClassName(): string;
  67961. /**
  67962. * Gets the rgb component (input)
  67963. */
  67964. get rgbIn(): NodeMaterialConnectionPoint;
  67965. /**
  67966. * Gets the r component (input)
  67967. */
  67968. get r(): NodeMaterialConnectionPoint;
  67969. /**
  67970. * Gets the g component (input)
  67971. */
  67972. get g(): NodeMaterialConnectionPoint;
  67973. /**
  67974. * Gets the b component (input)
  67975. */
  67976. get b(): NodeMaterialConnectionPoint;
  67977. /**
  67978. * Gets the a component (input)
  67979. */
  67980. get a(): NodeMaterialConnectionPoint;
  67981. /**
  67982. * Gets the rgba component (output)
  67983. */
  67984. get rgba(): NodeMaterialConnectionPoint;
  67985. /**
  67986. * Gets the rgb component (output)
  67987. */
  67988. get rgbOut(): NodeMaterialConnectionPoint;
  67989. /**
  67990. * Gets the rgb component (output)
  67991. * @deprecated Please use rgbOut instead.
  67992. */
  67993. get rgb(): NodeMaterialConnectionPoint;
  67994. protected _buildBlock(state: NodeMaterialBuildState): this;
  67995. }
  67996. }
  67997. declare module BABYLON {
  67998. /**
  67999. * Block used to expand a Vector3/4 into 4 outputs (one for each component)
  68000. */
  68001. export class VectorSplitterBlock extends NodeMaterialBlock {
  68002. /**
  68003. * Create a new VectorSplitterBlock
  68004. * @param name defines the block name
  68005. */
  68006. constructor(name: string);
  68007. /**
  68008. * Gets the current class name
  68009. * @returns the class name
  68010. */
  68011. getClassName(): string;
  68012. /**
  68013. * Gets the xyzw component (input)
  68014. */
  68015. get xyzw(): NodeMaterialConnectionPoint;
  68016. /**
  68017. * Gets the xyz component (input)
  68018. */
  68019. get xyzIn(): NodeMaterialConnectionPoint;
  68020. /**
  68021. * Gets the xy component (input)
  68022. */
  68023. get xyIn(): NodeMaterialConnectionPoint;
  68024. /**
  68025. * Gets the xyz component (output)
  68026. */
  68027. get xyzOut(): NodeMaterialConnectionPoint;
  68028. /**
  68029. * Gets the xy component (output)
  68030. */
  68031. get xyOut(): NodeMaterialConnectionPoint;
  68032. /**
  68033. * Gets the x component (output)
  68034. */
  68035. get x(): NodeMaterialConnectionPoint;
  68036. /**
  68037. * Gets the y component (output)
  68038. */
  68039. get y(): NodeMaterialConnectionPoint;
  68040. /**
  68041. * Gets the z component (output)
  68042. */
  68043. get z(): NodeMaterialConnectionPoint;
  68044. /**
  68045. * Gets the w component (output)
  68046. */
  68047. get w(): NodeMaterialConnectionPoint;
  68048. protected _inputRename(name: string): string;
  68049. protected _outputRename(name: string): string;
  68050. protected _buildBlock(state: NodeMaterialBuildState): this;
  68051. }
  68052. }
  68053. declare module BABYLON {
  68054. /**
  68055. * Block used to lerp between 2 values
  68056. */
  68057. export class LerpBlock extends NodeMaterialBlock {
  68058. /**
  68059. * Creates a new LerpBlock
  68060. * @param name defines the block name
  68061. */
  68062. constructor(name: string);
  68063. /**
  68064. * Gets the current class name
  68065. * @returns the class name
  68066. */
  68067. getClassName(): string;
  68068. /**
  68069. * Gets the left operand input component
  68070. */
  68071. get left(): NodeMaterialConnectionPoint;
  68072. /**
  68073. * Gets the right operand input component
  68074. */
  68075. get right(): NodeMaterialConnectionPoint;
  68076. /**
  68077. * Gets the gradient operand input component
  68078. */
  68079. get gradient(): NodeMaterialConnectionPoint;
  68080. /**
  68081. * Gets the output component
  68082. */
  68083. get output(): NodeMaterialConnectionPoint;
  68084. protected _buildBlock(state: NodeMaterialBuildState): this;
  68085. }
  68086. }
  68087. declare module BABYLON {
  68088. /**
  68089. * Block used to divide 2 vectors
  68090. */
  68091. export class DivideBlock extends NodeMaterialBlock {
  68092. /**
  68093. * Creates a new DivideBlock
  68094. * @param name defines the block name
  68095. */
  68096. constructor(name: string);
  68097. /**
  68098. * Gets the current class name
  68099. * @returns the class name
  68100. */
  68101. getClassName(): string;
  68102. /**
  68103. * Gets the left operand input component
  68104. */
  68105. get left(): NodeMaterialConnectionPoint;
  68106. /**
  68107. * Gets the right operand input component
  68108. */
  68109. get right(): NodeMaterialConnectionPoint;
  68110. /**
  68111. * Gets the output component
  68112. */
  68113. get output(): NodeMaterialConnectionPoint;
  68114. protected _buildBlock(state: NodeMaterialBuildState): this;
  68115. }
  68116. }
  68117. declare module BABYLON {
  68118. /**
  68119. * Block used to subtract 2 vectors
  68120. */
  68121. export class SubtractBlock extends NodeMaterialBlock {
  68122. /**
  68123. * Creates a new SubtractBlock
  68124. * @param name defines the block name
  68125. */
  68126. constructor(name: string);
  68127. /**
  68128. * Gets the current class name
  68129. * @returns the class name
  68130. */
  68131. getClassName(): string;
  68132. /**
  68133. * Gets the left operand input component
  68134. */
  68135. get left(): NodeMaterialConnectionPoint;
  68136. /**
  68137. * Gets the right operand input component
  68138. */
  68139. get right(): NodeMaterialConnectionPoint;
  68140. /**
  68141. * Gets the output component
  68142. */
  68143. get output(): NodeMaterialConnectionPoint;
  68144. protected _buildBlock(state: NodeMaterialBuildState): this;
  68145. }
  68146. }
  68147. declare module BABYLON {
  68148. /**
  68149. * Block used to step a value
  68150. */
  68151. export class StepBlock extends NodeMaterialBlock {
  68152. /**
  68153. * Creates a new StepBlock
  68154. * @param name defines the block name
  68155. */
  68156. constructor(name: string);
  68157. /**
  68158. * Gets the current class name
  68159. * @returns the class name
  68160. */
  68161. getClassName(): string;
  68162. /**
  68163. * Gets the value operand input component
  68164. */
  68165. get value(): NodeMaterialConnectionPoint;
  68166. /**
  68167. * Gets the edge operand input component
  68168. */
  68169. get edge(): NodeMaterialConnectionPoint;
  68170. /**
  68171. * Gets the output component
  68172. */
  68173. get output(): NodeMaterialConnectionPoint;
  68174. protected _buildBlock(state: NodeMaterialBuildState): this;
  68175. }
  68176. }
  68177. declare module BABYLON {
  68178. /**
  68179. * Block used to get the opposite (1 - x) of a value
  68180. */
  68181. export class OneMinusBlock extends NodeMaterialBlock {
  68182. /**
  68183. * Creates a new OneMinusBlock
  68184. * @param name defines the block name
  68185. */
  68186. constructor(name: string);
  68187. /**
  68188. * Gets the current class name
  68189. * @returns the class name
  68190. */
  68191. getClassName(): string;
  68192. /**
  68193. * Gets the input component
  68194. */
  68195. get input(): NodeMaterialConnectionPoint;
  68196. /**
  68197. * Gets the output component
  68198. */
  68199. get output(): NodeMaterialConnectionPoint;
  68200. protected _buildBlock(state: NodeMaterialBuildState): this;
  68201. }
  68202. }
  68203. declare module BABYLON {
  68204. /**
  68205. * Block used to get the view direction
  68206. */
  68207. export class ViewDirectionBlock extends NodeMaterialBlock {
  68208. /**
  68209. * Creates a new ViewDirectionBlock
  68210. * @param name defines the block name
  68211. */
  68212. constructor(name: string);
  68213. /**
  68214. * Gets the current class name
  68215. * @returns the class name
  68216. */
  68217. getClassName(): string;
  68218. /**
  68219. * Gets the world position component
  68220. */
  68221. get worldPosition(): NodeMaterialConnectionPoint;
  68222. /**
  68223. * Gets the camera position component
  68224. */
  68225. get cameraPosition(): NodeMaterialConnectionPoint;
  68226. /**
  68227. * Gets the output component
  68228. */
  68229. get output(): NodeMaterialConnectionPoint;
  68230. autoConfigure(material: NodeMaterial): void;
  68231. protected _buildBlock(state: NodeMaterialBuildState): this;
  68232. }
  68233. }
  68234. declare module BABYLON {
  68235. /**
  68236. * Block used to compute fresnel value
  68237. */
  68238. export class FresnelBlock extends NodeMaterialBlock {
  68239. /**
  68240. * Create a new FresnelBlock
  68241. * @param name defines the block name
  68242. */
  68243. constructor(name: string);
  68244. /**
  68245. * Gets the current class name
  68246. * @returns the class name
  68247. */
  68248. getClassName(): string;
  68249. /**
  68250. * Gets the world normal input component
  68251. */
  68252. get worldNormal(): NodeMaterialConnectionPoint;
  68253. /**
  68254. * Gets the view direction input component
  68255. */
  68256. get viewDirection(): NodeMaterialConnectionPoint;
  68257. /**
  68258. * Gets the bias input component
  68259. */
  68260. get bias(): NodeMaterialConnectionPoint;
  68261. /**
  68262. * Gets the camera (or eye) position component
  68263. */
  68264. get power(): NodeMaterialConnectionPoint;
  68265. /**
  68266. * Gets the fresnel output component
  68267. */
  68268. get fresnel(): NodeMaterialConnectionPoint;
  68269. autoConfigure(material: NodeMaterial): void;
  68270. protected _buildBlock(state: NodeMaterialBuildState): this;
  68271. }
  68272. }
  68273. declare module BABYLON {
  68274. /**
  68275. * Block used to get the max of 2 values
  68276. */
  68277. export class MaxBlock extends NodeMaterialBlock {
  68278. /**
  68279. * Creates a new MaxBlock
  68280. * @param name defines the block name
  68281. */
  68282. constructor(name: string);
  68283. /**
  68284. * Gets the current class name
  68285. * @returns the class name
  68286. */
  68287. getClassName(): string;
  68288. /**
  68289. * Gets the left operand input component
  68290. */
  68291. get left(): NodeMaterialConnectionPoint;
  68292. /**
  68293. * Gets the right operand input component
  68294. */
  68295. get right(): NodeMaterialConnectionPoint;
  68296. /**
  68297. * Gets the output component
  68298. */
  68299. get output(): NodeMaterialConnectionPoint;
  68300. protected _buildBlock(state: NodeMaterialBuildState): this;
  68301. }
  68302. }
  68303. declare module BABYLON {
  68304. /**
  68305. * Block used to get the min of 2 values
  68306. */
  68307. export class MinBlock extends NodeMaterialBlock {
  68308. /**
  68309. * Creates a new MinBlock
  68310. * @param name defines the block name
  68311. */
  68312. constructor(name: string);
  68313. /**
  68314. * Gets the current class name
  68315. * @returns the class name
  68316. */
  68317. getClassName(): string;
  68318. /**
  68319. * Gets the left operand input component
  68320. */
  68321. get left(): NodeMaterialConnectionPoint;
  68322. /**
  68323. * Gets the right operand input component
  68324. */
  68325. get right(): NodeMaterialConnectionPoint;
  68326. /**
  68327. * Gets the output component
  68328. */
  68329. get output(): NodeMaterialConnectionPoint;
  68330. protected _buildBlock(state: NodeMaterialBuildState): this;
  68331. }
  68332. }
  68333. declare module BABYLON {
  68334. /**
  68335. * Block used to get the distance between 2 values
  68336. */
  68337. export class DistanceBlock extends NodeMaterialBlock {
  68338. /**
  68339. * Creates a new DistanceBlock
  68340. * @param name defines the block name
  68341. */
  68342. constructor(name: string);
  68343. /**
  68344. * Gets the current class name
  68345. * @returns the class name
  68346. */
  68347. getClassName(): string;
  68348. /**
  68349. * Gets the left operand input component
  68350. */
  68351. get left(): NodeMaterialConnectionPoint;
  68352. /**
  68353. * Gets the right operand input component
  68354. */
  68355. get right(): NodeMaterialConnectionPoint;
  68356. /**
  68357. * Gets the output component
  68358. */
  68359. get output(): NodeMaterialConnectionPoint;
  68360. protected _buildBlock(state: NodeMaterialBuildState): this;
  68361. }
  68362. }
  68363. declare module BABYLON {
  68364. /**
  68365. * Block used to get the length of a vector
  68366. */
  68367. export class LengthBlock extends NodeMaterialBlock {
  68368. /**
  68369. * Creates a new LengthBlock
  68370. * @param name defines the block name
  68371. */
  68372. constructor(name: string);
  68373. /**
  68374. * Gets the current class name
  68375. * @returns the class name
  68376. */
  68377. getClassName(): string;
  68378. /**
  68379. * Gets the value input component
  68380. */
  68381. get value(): NodeMaterialConnectionPoint;
  68382. /**
  68383. * Gets the output component
  68384. */
  68385. get output(): NodeMaterialConnectionPoint;
  68386. protected _buildBlock(state: NodeMaterialBuildState): this;
  68387. }
  68388. }
  68389. declare module BABYLON {
  68390. /**
  68391. * Block used to get negative version of a value (i.e. x * -1)
  68392. */
  68393. export class NegateBlock extends NodeMaterialBlock {
  68394. /**
  68395. * Creates a new NegateBlock
  68396. * @param name defines the block name
  68397. */
  68398. constructor(name: string);
  68399. /**
  68400. * Gets the current class name
  68401. * @returns the class name
  68402. */
  68403. getClassName(): string;
  68404. /**
  68405. * Gets the value input component
  68406. */
  68407. get value(): NodeMaterialConnectionPoint;
  68408. /**
  68409. * Gets the output component
  68410. */
  68411. get output(): NodeMaterialConnectionPoint;
  68412. protected _buildBlock(state: NodeMaterialBuildState): this;
  68413. }
  68414. }
  68415. declare module BABYLON {
  68416. /**
  68417. * Block used to get the value of the first parameter raised to the power of the second
  68418. */
  68419. export class PowBlock extends NodeMaterialBlock {
  68420. /**
  68421. * Creates a new PowBlock
  68422. * @param name defines the block name
  68423. */
  68424. constructor(name: string);
  68425. /**
  68426. * Gets the current class name
  68427. * @returns the class name
  68428. */
  68429. getClassName(): string;
  68430. /**
  68431. * Gets the value operand input component
  68432. */
  68433. get value(): NodeMaterialConnectionPoint;
  68434. /**
  68435. * Gets the power operand input component
  68436. */
  68437. get power(): NodeMaterialConnectionPoint;
  68438. /**
  68439. * Gets the output component
  68440. */
  68441. get output(): NodeMaterialConnectionPoint;
  68442. protected _buildBlock(state: NodeMaterialBuildState): this;
  68443. }
  68444. }
  68445. declare module BABYLON {
  68446. /**
  68447. * Block used to get a random number
  68448. */
  68449. export class RandomNumberBlock extends NodeMaterialBlock {
  68450. /**
  68451. * Creates a new RandomNumberBlock
  68452. * @param name defines the block name
  68453. */
  68454. constructor(name: string);
  68455. /**
  68456. * Gets the current class name
  68457. * @returns the class name
  68458. */
  68459. getClassName(): string;
  68460. /**
  68461. * Gets the seed input component
  68462. */
  68463. get seed(): NodeMaterialConnectionPoint;
  68464. /**
  68465. * Gets the output component
  68466. */
  68467. get output(): NodeMaterialConnectionPoint;
  68468. protected _buildBlock(state: NodeMaterialBuildState): this;
  68469. }
  68470. }
  68471. declare module BABYLON {
  68472. /**
  68473. * Block used to compute arc tangent of 2 values
  68474. */
  68475. export class ArcTan2Block extends NodeMaterialBlock {
  68476. /**
  68477. * Creates a new ArcTan2Block
  68478. * @param name defines the block name
  68479. */
  68480. constructor(name: string);
  68481. /**
  68482. * Gets the current class name
  68483. * @returns the class name
  68484. */
  68485. getClassName(): string;
  68486. /**
  68487. * Gets the x operand input component
  68488. */
  68489. get x(): NodeMaterialConnectionPoint;
  68490. /**
  68491. * Gets the y operand input component
  68492. */
  68493. get y(): NodeMaterialConnectionPoint;
  68494. /**
  68495. * Gets the output component
  68496. */
  68497. get output(): NodeMaterialConnectionPoint;
  68498. protected _buildBlock(state: NodeMaterialBuildState): this;
  68499. }
  68500. }
  68501. declare module BABYLON {
  68502. /**
  68503. * Block used to smooth step a value
  68504. */
  68505. export class SmoothStepBlock extends NodeMaterialBlock {
  68506. /**
  68507. * Creates a new SmoothStepBlock
  68508. * @param name defines the block name
  68509. */
  68510. constructor(name: string);
  68511. /**
  68512. * Gets the current class name
  68513. * @returns the class name
  68514. */
  68515. getClassName(): string;
  68516. /**
  68517. * Gets the value operand input component
  68518. */
  68519. get value(): NodeMaterialConnectionPoint;
  68520. /**
  68521. * Gets the first edge operand input component
  68522. */
  68523. get edge0(): NodeMaterialConnectionPoint;
  68524. /**
  68525. * Gets the second edge operand input component
  68526. */
  68527. get edge1(): NodeMaterialConnectionPoint;
  68528. /**
  68529. * Gets the output component
  68530. */
  68531. get output(): NodeMaterialConnectionPoint;
  68532. protected _buildBlock(state: NodeMaterialBuildState): this;
  68533. }
  68534. }
  68535. declare module BABYLON {
  68536. /**
  68537. * Block used to get the reciprocal (1 / x) of a value
  68538. */
  68539. export class ReciprocalBlock extends NodeMaterialBlock {
  68540. /**
  68541. * Creates a new ReciprocalBlock
  68542. * @param name defines the block name
  68543. */
  68544. constructor(name: string);
  68545. /**
  68546. * Gets the current class name
  68547. * @returns the class name
  68548. */
  68549. getClassName(): string;
  68550. /**
  68551. * Gets the input component
  68552. */
  68553. get input(): NodeMaterialConnectionPoint;
  68554. /**
  68555. * Gets the output component
  68556. */
  68557. get output(): NodeMaterialConnectionPoint;
  68558. protected _buildBlock(state: NodeMaterialBuildState): this;
  68559. }
  68560. }
  68561. declare module BABYLON {
  68562. /**
  68563. * Block used to replace a color by another one
  68564. */
  68565. export class ReplaceColorBlock extends NodeMaterialBlock {
  68566. /**
  68567. * Creates a new ReplaceColorBlock
  68568. * @param name defines the block name
  68569. */
  68570. constructor(name: string);
  68571. /**
  68572. * Gets the current class name
  68573. * @returns the class name
  68574. */
  68575. getClassName(): string;
  68576. /**
  68577. * Gets the value input component
  68578. */
  68579. get value(): NodeMaterialConnectionPoint;
  68580. /**
  68581. * Gets the reference input component
  68582. */
  68583. get reference(): NodeMaterialConnectionPoint;
  68584. /**
  68585. * Gets the distance input component
  68586. */
  68587. get distance(): NodeMaterialConnectionPoint;
  68588. /**
  68589. * Gets the replacement input component
  68590. */
  68591. get replacement(): NodeMaterialConnectionPoint;
  68592. /**
  68593. * Gets the output component
  68594. */
  68595. get output(): NodeMaterialConnectionPoint;
  68596. protected _buildBlock(state: NodeMaterialBuildState): this;
  68597. }
  68598. }
  68599. declare module BABYLON {
  68600. /**
  68601. * Block used to posterize a value
  68602. * @see https://en.wikipedia.org/wiki/Posterization
  68603. */
  68604. export class PosterizeBlock extends NodeMaterialBlock {
  68605. /**
  68606. * Creates a new PosterizeBlock
  68607. * @param name defines the block name
  68608. */
  68609. constructor(name: string);
  68610. /**
  68611. * Gets the current class name
  68612. * @returns the class name
  68613. */
  68614. getClassName(): string;
  68615. /**
  68616. * Gets the value input component
  68617. */
  68618. get value(): NodeMaterialConnectionPoint;
  68619. /**
  68620. * Gets the steps input component
  68621. */
  68622. get steps(): NodeMaterialConnectionPoint;
  68623. /**
  68624. * Gets the output component
  68625. */
  68626. get output(): NodeMaterialConnectionPoint;
  68627. protected _buildBlock(state: NodeMaterialBuildState): this;
  68628. }
  68629. }
  68630. declare module BABYLON {
  68631. /**
  68632. * Operations supported by the Wave block
  68633. */
  68634. export enum WaveBlockKind {
  68635. /** SawTooth */
  68636. SawTooth = 0,
  68637. /** Square */
  68638. Square = 1,
  68639. /** Triangle */
  68640. Triangle = 2
  68641. }
  68642. /**
  68643. * Block used to apply wave operation to floats
  68644. */
  68645. export class WaveBlock extends NodeMaterialBlock {
  68646. /**
  68647. * Gets or sets the kibnd of wave to be applied by the block
  68648. */
  68649. kind: WaveBlockKind;
  68650. /**
  68651. * Creates a new WaveBlock
  68652. * @param name defines the block name
  68653. */
  68654. constructor(name: string);
  68655. /**
  68656. * Gets the current class name
  68657. * @returns the class name
  68658. */
  68659. getClassName(): string;
  68660. /**
  68661. * Gets the input component
  68662. */
  68663. get input(): NodeMaterialConnectionPoint;
  68664. /**
  68665. * Gets the output component
  68666. */
  68667. get output(): NodeMaterialConnectionPoint;
  68668. protected _buildBlock(state: NodeMaterialBuildState): this;
  68669. serialize(): any;
  68670. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  68671. }
  68672. }
  68673. declare module BABYLON {
  68674. /**
  68675. * Class used to store a color step for the GradientBlock
  68676. */
  68677. export class GradientBlockColorStep {
  68678. private _step;
  68679. /**
  68680. * Gets value indicating which step this color is associated with (between 0 and 1)
  68681. */
  68682. get step(): number;
  68683. /**
  68684. * Sets a value indicating which step this color is associated with (between 0 and 1)
  68685. */
  68686. set step(val: number);
  68687. private _color;
  68688. /**
  68689. * Gets the color associated with this step
  68690. */
  68691. get color(): Color3;
  68692. /**
  68693. * Sets the color associated with this step
  68694. */
  68695. set color(val: Color3);
  68696. /**
  68697. * Creates a new GradientBlockColorStep
  68698. * @param step defines a value indicating which step this color is associated with (between 0 and 1)
  68699. * @param color defines the color associated with this step
  68700. */
  68701. constructor(step: number, color: Color3);
  68702. }
  68703. /**
  68704. * Block used to return a color from a gradient based on an input value between 0 and 1
  68705. */
  68706. export class GradientBlock extends NodeMaterialBlock {
  68707. /**
  68708. * Gets or sets the list of color steps
  68709. */
  68710. colorSteps: GradientBlockColorStep[];
  68711. /** Gets an observable raised when the value is changed */
  68712. onValueChangedObservable: Observable<GradientBlock>;
  68713. /** calls observable when the value is changed*/
  68714. colorStepsUpdated(): void;
  68715. /**
  68716. * Creates a new GradientBlock
  68717. * @param name defines the block name
  68718. */
  68719. constructor(name: string);
  68720. /**
  68721. * Gets the current class name
  68722. * @returns the class name
  68723. */
  68724. getClassName(): string;
  68725. /**
  68726. * Gets the gradient input component
  68727. */
  68728. get gradient(): NodeMaterialConnectionPoint;
  68729. /**
  68730. * Gets the output component
  68731. */
  68732. get output(): NodeMaterialConnectionPoint;
  68733. private _writeColorConstant;
  68734. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  68735. serialize(): any;
  68736. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  68737. protected _dumpPropertiesCode(): string;
  68738. }
  68739. }
  68740. declare module BABYLON {
  68741. /**
  68742. * Block used to normalize lerp between 2 values
  68743. */
  68744. export class NLerpBlock extends NodeMaterialBlock {
  68745. /**
  68746. * Creates a new NLerpBlock
  68747. * @param name defines the block name
  68748. */
  68749. constructor(name: string);
  68750. /**
  68751. * Gets the current class name
  68752. * @returns the class name
  68753. */
  68754. getClassName(): string;
  68755. /**
  68756. * Gets the left operand input component
  68757. */
  68758. get left(): NodeMaterialConnectionPoint;
  68759. /**
  68760. * Gets the right operand input component
  68761. */
  68762. get right(): NodeMaterialConnectionPoint;
  68763. /**
  68764. * Gets the gradient operand input component
  68765. */
  68766. get gradient(): NodeMaterialConnectionPoint;
  68767. /**
  68768. * Gets the output component
  68769. */
  68770. get output(): NodeMaterialConnectionPoint;
  68771. protected _buildBlock(state: NodeMaterialBuildState): this;
  68772. }
  68773. }
  68774. declare module BABYLON {
  68775. /**
  68776. * block used to Generate a Worley Noise 3D Noise Pattern
  68777. */
  68778. export class WorleyNoise3DBlock extends NodeMaterialBlock {
  68779. /** Gets or sets a boolean indicating that normal should be inverted on X axis */
  68780. manhattanDistance: boolean;
  68781. /**
  68782. * Creates a new WorleyNoise3DBlock
  68783. * @param name defines the block name
  68784. */
  68785. constructor(name: string);
  68786. /**
  68787. * Gets the current class name
  68788. * @returns the class name
  68789. */
  68790. getClassName(): string;
  68791. /**
  68792. * Gets the seed input component
  68793. */
  68794. get seed(): NodeMaterialConnectionPoint;
  68795. /**
  68796. * Gets the jitter input component
  68797. */
  68798. get jitter(): NodeMaterialConnectionPoint;
  68799. /**
  68800. * Gets the output component
  68801. */
  68802. get output(): NodeMaterialConnectionPoint;
  68803. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  68804. /**
  68805. * Exposes the properties to the UI?
  68806. */
  68807. protected _dumpPropertiesCode(): string;
  68808. /**
  68809. * Exposes the properties to the Serialize?
  68810. */
  68811. serialize(): any;
  68812. /**
  68813. * Exposes the properties to the deserialize?
  68814. */
  68815. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  68816. }
  68817. }
  68818. declare module BABYLON {
  68819. /**
  68820. * block used to Generate a Simplex Perlin 3d Noise Pattern
  68821. */
  68822. export class SimplexPerlin3DBlock extends NodeMaterialBlock {
  68823. /**
  68824. * Creates a new SimplexPerlin3DBlock
  68825. * @param name defines the block name
  68826. */
  68827. constructor(name: string);
  68828. /**
  68829. * Gets the current class name
  68830. * @returns the class name
  68831. */
  68832. getClassName(): string;
  68833. /**
  68834. * Gets the seed operand input component
  68835. */
  68836. get seed(): NodeMaterialConnectionPoint;
  68837. /**
  68838. * Gets the output component
  68839. */
  68840. get output(): NodeMaterialConnectionPoint;
  68841. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  68842. }
  68843. }
  68844. declare module BABYLON {
  68845. /**
  68846. * Block used to blend normals
  68847. */
  68848. export class NormalBlendBlock extends NodeMaterialBlock {
  68849. /**
  68850. * Creates a new NormalBlendBlock
  68851. * @param name defines the block name
  68852. */
  68853. constructor(name: string);
  68854. /**
  68855. * Gets the current class name
  68856. * @returns the class name
  68857. */
  68858. getClassName(): string;
  68859. /**
  68860. * Gets the first input component
  68861. */
  68862. get normalMap0(): NodeMaterialConnectionPoint;
  68863. /**
  68864. * Gets the second input component
  68865. */
  68866. get normalMap1(): NodeMaterialConnectionPoint;
  68867. /**
  68868. * Gets the output component
  68869. */
  68870. get output(): NodeMaterialConnectionPoint;
  68871. protected _buildBlock(state: NodeMaterialBuildState): this;
  68872. }
  68873. }
  68874. declare module BABYLON {
  68875. /**
  68876. * Block used to rotate a 2d vector by a given angle
  68877. */
  68878. export class Rotate2dBlock extends NodeMaterialBlock {
  68879. /**
  68880. * Creates a new Rotate2dBlock
  68881. * @param name defines the block name
  68882. */
  68883. constructor(name: string);
  68884. /**
  68885. * Gets the current class name
  68886. * @returns the class name
  68887. */
  68888. getClassName(): string;
  68889. /**
  68890. * Gets the input vector
  68891. */
  68892. get input(): NodeMaterialConnectionPoint;
  68893. /**
  68894. * Gets the input angle
  68895. */
  68896. get angle(): NodeMaterialConnectionPoint;
  68897. /**
  68898. * Gets the output component
  68899. */
  68900. get output(): NodeMaterialConnectionPoint;
  68901. autoConfigure(material: NodeMaterial): void;
  68902. protected _buildBlock(state: NodeMaterialBuildState): this;
  68903. }
  68904. }
  68905. declare module BABYLON {
  68906. /**
  68907. * Block used to get the reflected vector from a direction and a normal
  68908. */
  68909. export class ReflectBlock extends NodeMaterialBlock {
  68910. /**
  68911. * Creates a new ReflectBlock
  68912. * @param name defines the block name
  68913. */
  68914. constructor(name: string);
  68915. /**
  68916. * Gets the current class name
  68917. * @returns the class name
  68918. */
  68919. getClassName(): string;
  68920. /**
  68921. * Gets the incident component
  68922. */
  68923. get incident(): NodeMaterialConnectionPoint;
  68924. /**
  68925. * Gets the normal component
  68926. */
  68927. get normal(): NodeMaterialConnectionPoint;
  68928. /**
  68929. * Gets the output component
  68930. */
  68931. get output(): NodeMaterialConnectionPoint;
  68932. protected _buildBlock(state: NodeMaterialBuildState): this;
  68933. }
  68934. }
  68935. declare module BABYLON {
  68936. /**
  68937. * Block used to get the refracted vector from a direction and a normal
  68938. */
  68939. export class RefractBlock extends NodeMaterialBlock {
  68940. /**
  68941. * Creates a new RefractBlock
  68942. * @param name defines the block name
  68943. */
  68944. constructor(name: string);
  68945. /**
  68946. * Gets the current class name
  68947. * @returns the class name
  68948. */
  68949. getClassName(): string;
  68950. /**
  68951. * Gets the incident component
  68952. */
  68953. get incident(): NodeMaterialConnectionPoint;
  68954. /**
  68955. * Gets the normal component
  68956. */
  68957. get normal(): NodeMaterialConnectionPoint;
  68958. /**
  68959. * Gets the index of refraction component
  68960. */
  68961. get ior(): NodeMaterialConnectionPoint;
  68962. /**
  68963. * Gets the output component
  68964. */
  68965. get output(): NodeMaterialConnectionPoint;
  68966. protected _buildBlock(state: NodeMaterialBuildState): this;
  68967. }
  68968. }
  68969. declare module BABYLON {
  68970. /**
  68971. * Block used to desaturate a color
  68972. */
  68973. export class DesaturateBlock extends NodeMaterialBlock {
  68974. /**
  68975. * Creates a new DesaturateBlock
  68976. * @param name defines the block name
  68977. */
  68978. constructor(name: string);
  68979. /**
  68980. * Gets the current class name
  68981. * @returns the class name
  68982. */
  68983. getClassName(): string;
  68984. /**
  68985. * Gets the color operand input component
  68986. */
  68987. get color(): NodeMaterialConnectionPoint;
  68988. /**
  68989. * Gets the level operand input component
  68990. */
  68991. get level(): NodeMaterialConnectionPoint;
  68992. /**
  68993. * Gets the output component
  68994. */
  68995. get output(): NodeMaterialConnectionPoint;
  68996. protected _buildBlock(state: NodeMaterialBuildState): this;
  68997. }
  68998. }
  68999. declare module BABYLON {
  69000. /**
  69001. * Block used to implement the reflection module of the PBR material
  69002. */
  69003. export class ReflectionBlock extends ReflectionTextureBaseBlock {
  69004. /** @hidden */
  69005. _defineLODReflectionAlpha: string;
  69006. /** @hidden */
  69007. _defineLinearSpecularReflection: string;
  69008. private _vEnvironmentIrradianceName;
  69009. /** @hidden */
  69010. _vReflectionMicrosurfaceInfosName: string;
  69011. /** @hidden */
  69012. _vReflectionInfosName: string;
  69013. /** @hidden */
  69014. _vReflectionFilteringInfoName: string;
  69015. private _scene;
  69016. /**
  69017. * The properties below are set by the main PBR block prior to calling methods of this class.
  69018. * This is to avoid having to add them as inputs here whereas they are already inputs of the main block, so already known.
  69019. * It's less burden on the user side in the editor part.
  69020. */
  69021. /** @hidden */
  69022. worldPositionConnectionPoint: NodeMaterialConnectionPoint;
  69023. /** @hidden */
  69024. worldNormalConnectionPoint: NodeMaterialConnectionPoint;
  69025. /** @hidden */
  69026. cameraPositionConnectionPoint: NodeMaterialConnectionPoint;
  69027. /** @hidden */
  69028. viewConnectionPoint: NodeMaterialConnectionPoint;
  69029. /**
  69030. * Defines if the material uses spherical harmonics vs spherical polynomials for the
  69031. * diffuse part of the IBL.
  69032. */
  69033. useSphericalHarmonics: boolean;
  69034. /**
  69035. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  69036. */
  69037. forceIrradianceInFragment: boolean;
  69038. /**
  69039. * Create a new ReflectionBlock
  69040. * @param name defines the block name
  69041. */
  69042. constructor(name: string);
  69043. /**
  69044. * Gets the current class name
  69045. * @returns the class name
  69046. */
  69047. getClassName(): string;
  69048. /**
  69049. * Gets the position input component
  69050. */
  69051. get position(): NodeMaterialConnectionPoint;
  69052. /**
  69053. * Gets the world position input component
  69054. */
  69055. get worldPosition(): NodeMaterialConnectionPoint;
  69056. /**
  69057. * Gets the world normal input component
  69058. */
  69059. get worldNormal(): NodeMaterialConnectionPoint;
  69060. /**
  69061. * Gets the world input component
  69062. */
  69063. get world(): NodeMaterialConnectionPoint;
  69064. /**
  69065. * Gets the camera (or eye) position component
  69066. */
  69067. get cameraPosition(): NodeMaterialConnectionPoint;
  69068. /**
  69069. * Gets the view input component
  69070. */
  69071. get view(): NodeMaterialConnectionPoint;
  69072. /**
  69073. * Gets the color input component
  69074. */
  69075. get color(): NodeMaterialConnectionPoint;
  69076. /**
  69077. * Gets the reflection object output component
  69078. */
  69079. get reflection(): NodeMaterialConnectionPoint;
  69080. /**
  69081. * Returns true if the block has a texture (either its own texture or the environment texture from the scene, if set)
  69082. */
  69083. get hasTexture(): boolean;
  69084. /**
  69085. * Gets the reflection color (either the name of the variable if the color input is connected, else a default value)
  69086. */
  69087. get reflectionColor(): string;
  69088. protected _getTexture(): Nullable<BaseTexture>;
  69089. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  69090. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh, subMesh?: SubMesh): void;
  69091. /**
  69092. * Gets the code to inject in the vertex shader
  69093. * @param state current state of the node material building
  69094. * @returns the shader code
  69095. */
  69096. handleVertexSide(state: NodeMaterialBuildState): string;
  69097. /**
  69098. * Gets the main code of the block (fragment side)
  69099. * @param state current state of the node material building
  69100. * @param normalVarName name of the existing variable corresponding to the normal
  69101. * @returns the shader code
  69102. */
  69103. getCode(state: NodeMaterialBuildState, normalVarName: string): string;
  69104. protected _buildBlock(state: NodeMaterialBuildState): this;
  69105. protected _dumpPropertiesCode(): string;
  69106. serialize(): any;
  69107. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  69108. }
  69109. }
  69110. declare module BABYLON {
  69111. /**
  69112. * Block used to implement the sheen module of the PBR material
  69113. */
  69114. export class SheenBlock extends NodeMaterialBlock {
  69115. /**
  69116. * Create a new SheenBlock
  69117. * @param name defines the block name
  69118. */
  69119. constructor(name: string);
  69120. /**
  69121. * If true, the sheen effect is layered above the base BRDF with the albedo-scaling technique.
  69122. * It allows the strength of the sheen effect to not depend on the base color of the material,
  69123. * making it easier to setup and tweak the effect
  69124. */
  69125. albedoScaling: boolean;
  69126. /**
  69127. * Defines if the sheen is linked to the sheen color.
  69128. */
  69129. linkSheenWithAlbedo: boolean;
  69130. /**
  69131. * Initialize the block and prepare the context for build
  69132. * @param state defines the state that will be used for the build
  69133. */
  69134. initialize(state: NodeMaterialBuildState): void;
  69135. /**
  69136. * Gets the current class name
  69137. * @returns the class name
  69138. */
  69139. getClassName(): string;
  69140. /**
  69141. * Gets the intensity input component
  69142. */
  69143. get intensity(): NodeMaterialConnectionPoint;
  69144. /**
  69145. * Gets the color input component
  69146. */
  69147. get color(): NodeMaterialConnectionPoint;
  69148. /**
  69149. * Gets the roughness input component
  69150. */
  69151. get roughness(): NodeMaterialConnectionPoint;
  69152. /**
  69153. * Gets the sheen object output component
  69154. */
  69155. get sheen(): NodeMaterialConnectionPoint;
  69156. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  69157. /**
  69158. * Gets the main code of the block (fragment side)
  69159. * @param reflectionBlock instance of a ReflectionBlock null if the code must be generated without an active reflection module
  69160. * @returns the shader code
  69161. */
  69162. getCode(reflectionBlock: Nullable<ReflectionBlock>): string;
  69163. protected _buildBlock(state: NodeMaterialBuildState): this;
  69164. protected _dumpPropertiesCode(): string;
  69165. serialize(): any;
  69166. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  69167. }
  69168. }
  69169. declare module BABYLON {
  69170. /**
  69171. * Block used to implement the anisotropy module of the PBR material
  69172. */
  69173. export class AnisotropyBlock extends NodeMaterialBlock {
  69174. /**
  69175. * The two properties below are set by the main PBR block prior to calling methods of this class.
  69176. * This is to avoid having to add them as inputs here whereas they are already inputs of the main block, so already known.
  69177. * It's less burden on the user side in the editor part.
  69178. */
  69179. /** @hidden */
  69180. worldPositionConnectionPoint: NodeMaterialConnectionPoint;
  69181. /** @hidden */
  69182. worldNormalConnectionPoint: NodeMaterialConnectionPoint;
  69183. /**
  69184. * Create a new AnisotropyBlock
  69185. * @param name defines the block name
  69186. */
  69187. constructor(name: string);
  69188. /**
  69189. * Initialize the block and prepare the context for build
  69190. * @param state defines the state that will be used for the build
  69191. */
  69192. initialize(state: NodeMaterialBuildState): void;
  69193. /**
  69194. * Gets the current class name
  69195. * @returns the class name
  69196. */
  69197. getClassName(): string;
  69198. /**
  69199. * Gets the intensity input component
  69200. */
  69201. get intensity(): NodeMaterialConnectionPoint;
  69202. /**
  69203. * Gets the direction input component
  69204. */
  69205. get direction(): NodeMaterialConnectionPoint;
  69206. /**
  69207. * Gets the uv input component
  69208. */
  69209. get uv(): NodeMaterialConnectionPoint;
  69210. /**
  69211. * Gets the worldTangent input component
  69212. */
  69213. get worldTangent(): NodeMaterialConnectionPoint;
  69214. /**
  69215. * Gets the anisotropy object output component
  69216. */
  69217. get anisotropy(): NodeMaterialConnectionPoint;
  69218. private _generateTBNSpace;
  69219. /**
  69220. * Gets the main code of the block (fragment side)
  69221. * @param state current state of the node material building
  69222. * @param generateTBNSpace if true, the code needed to create the TBN coordinate space is generated
  69223. * @returns the shader code
  69224. */
  69225. getCode(state: NodeMaterialBuildState, generateTBNSpace?: boolean): string;
  69226. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  69227. protected _buildBlock(state: NodeMaterialBuildState): this;
  69228. }
  69229. }
  69230. declare module BABYLON {
  69231. /**
  69232. * Block used to implement the clear coat module of the PBR material
  69233. */
  69234. export class ClearCoatBlock extends NodeMaterialBlock {
  69235. private _scene;
  69236. /**
  69237. * Create a new ClearCoatBlock
  69238. * @param name defines the block name
  69239. */
  69240. constructor(name: string);
  69241. /**
  69242. * Defines if the F0 value should be remapped to account for the interface change in the material.
  69243. */
  69244. remapF0OnInterfaceChange: boolean;
  69245. /**
  69246. * Initialize the block and prepare the context for build
  69247. * @param state defines the state that will be used for the build
  69248. */
  69249. initialize(state: NodeMaterialBuildState): void;
  69250. /**
  69251. * Gets the current class name
  69252. * @returns the class name
  69253. */
  69254. getClassName(): string;
  69255. /**
  69256. * Gets the intensity input component
  69257. */
  69258. get intensity(): NodeMaterialConnectionPoint;
  69259. /**
  69260. * Gets the roughness input component
  69261. */
  69262. get roughness(): NodeMaterialConnectionPoint;
  69263. /**
  69264. * Gets the ior input component
  69265. */
  69266. get indexOfRefraction(): NodeMaterialConnectionPoint;
  69267. /**
  69268. * Gets the bump texture input component
  69269. */
  69270. get normalMapColor(): NodeMaterialConnectionPoint;
  69271. /**
  69272. * Gets the uv input component
  69273. */
  69274. get uv(): NodeMaterialConnectionPoint;
  69275. /**
  69276. * Gets the tint color input component
  69277. */
  69278. get tintColor(): NodeMaterialConnectionPoint;
  69279. /**
  69280. * Gets the tint "at distance" input component
  69281. */
  69282. get tintAtDistance(): NodeMaterialConnectionPoint;
  69283. /**
  69284. * Gets the tint thickness input component
  69285. */
  69286. get tintThickness(): NodeMaterialConnectionPoint;
  69287. /**
  69288. * Gets the world tangent input component
  69289. */
  69290. get worldTangent(): NodeMaterialConnectionPoint;
  69291. /**
  69292. * Gets the clear coat object output component
  69293. */
  69294. get clearcoat(): NodeMaterialConnectionPoint;
  69295. autoConfigure(material: NodeMaterial): void;
  69296. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  69297. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh, subMesh?: SubMesh): void;
  69298. private _generateTBNSpace;
  69299. /**
  69300. * Gets the main code of the block (fragment side)
  69301. * @param state current state of the node material building
  69302. * @param ccBlock instance of a ClearCoatBlock or null if the code must be generated without an active clear coat module
  69303. * @param reflectionBlock instance of a ReflectionBlock null if the code must be generated without an active reflection module
  69304. * @param worldPosVarName name of the variable holding the world position
  69305. * @param generateTBNSpace if true, the code needed to create the TBN coordinate space is generated
  69306. * @param vTBNAvailable indicate that the vTBN variable is already existing because it has already been generated by another block (PerturbNormal or Anisotropy)
  69307. * @param worldNormalVarName name of the variable holding the world normal
  69308. * @returns the shader code
  69309. */
  69310. static GetCode(state: NodeMaterialBuildState, ccBlock: Nullable<ClearCoatBlock>, reflectionBlock: Nullable<ReflectionBlock>, worldPosVarName: string, generateTBNSpace: boolean, vTBNAvailable: boolean, worldNormalVarName: string): string;
  69311. protected _buildBlock(state: NodeMaterialBuildState): this;
  69312. protected _dumpPropertiesCode(): string;
  69313. serialize(): any;
  69314. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  69315. }
  69316. }
  69317. declare module BABYLON {
  69318. /**
  69319. * Block used to implement the sub surface module of the PBR material
  69320. */
  69321. export class SubSurfaceBlock extends NodeMaterialBlock {
  69322. /**
  69323. * Create a new SubSurfaceBlock
  69324. * @param name defines the block name
  69325. */
  69326. constructor(name: string);
  69327. /**
  69328. * Initialize the block and prepare the context for build
  69329. * @param state defines the state that will be used for the build
  69330. */
  69331. initialize(state: NodeMaterialBuildState): void;
  69332. /**
  69333. * Gets the current class name
  69334. * @returns the class name
  69335. */
  69336. getClassName(): string;
  69337. /**
  69338. * Gets the thickness component
  69339. */
  69340. get thickness(): NodeMaterialConnectionPoint;
  69341. /**
  69342. * Gets the tint color input component
  69343. */
  69344. get tintColor(): NodeMaterialConnectionPoint;
  69345. /**
  69346. * Gets the translucency intensity input component
  69347. */
  69348. get translucencyIntensity(): NodeMaterialConnectionPoint;
  69349. /**
  69350. * Gets the translucency diffusion distance input component
  69351. */
  69352. get translucencyDiffusionDist(): NodeMaterialConnectionPoint;
  69353. /**
  69354. * Gets the refraction object parameters
  69355. */
  69356. get refraction(): NodeMaterialConnectionPoint;
  69357. /**
  69358. * Gets the sub surface object output component
  69359. */
  69360. get subsurface(): NodeMaterialConnectionPoint;
  69361. autoConfigure(material: NodeMaterial): void;
  69362. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  69363. /**
  69364. * Gets the main code of the block (fragment side)
  69365. * @param state current state of the node material building
  69366. * @param ssBlock instance of a SubSurfaceBlock or null if the code must be generated without an active sub surface module
  69367. * @param reflectionBlock instance of a ReflectionBlock null if the code must be generated without an active reflection module
  69368. * @param worldPosVarName name of the variable holding the world position
  69369. * @returns the shader code
  69370. */
  69371. static GetCode(state: NodeMaterialBuildState, ssBlock: Nullable<SubSurfaceBlock>, reflectionBlock: Nullable<ReflectionBlock>, worldPosVarName: string): string;
  69372. protected _buildBlock(state: NodeMaterialBuildState): this;
  69373. }
  69374. }
  69375. declare module BABYLON {
  69376. /**
  69377. * Block used to implement the PBR metallic/roughness model
  69378. */
  69379. export class PBRMetallicRoughnessBlock extends NodeMaterialBlock {
  69380. /**
  69381. * Gets or sets the light associated with this block
  69382. */
  69383. light: Nullable<Light>;
  69384. private _lightId;
  69385. private _scene;
  69386. private _environmentBRDFTexture;
  69387. private _environmentBrdfSamplerName;
  69388. private _vNormalWName;
  69389. private _invertNormalName;
  69390. private _metallicReflectanceColor;
  69391. private _metallicF0Factor;
  69392. private _vMetallicReflectanceFactorsName;
  69393. /**
  69394. * Create a new ReflectionBlock
  69395. * @param name defines the block name
  69396. */
  69397. constructor(name: string);
  69398. /**
  69399. * Intensity of the direct lights e.g. the four lights available in your scene.
  69400. * This impacts both the direct diffuse and specular highlights.
  69401. */
  69402. directIntensity: number;
  69403. /**
  69404. * Intensity of the environment e.g. how much the environment will light the object
  69405. * either through harmonics for rough material or through the reflection for shiny ones.
  69406. */
  69407. environmentIntensity: number;
  69408. /**
  69409. * This is a special control allowing the reduction of the specular highlights coming from the
  69410. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  69411. */
  69412. specularIntensity: number;
  69413. /**
  69414. * Defines the falloff type used in this material.
  69415. * It by default is Physical.
  69416. */
  69417. lightFalloff: number;
  69418. /**
  69419. * Specifies that alpha test should be used
  69420. */
  69421. useAlphaTest: boolean;
  69422. /**
  69423. * Defines the alpha limits in alpha test mode.
  69424. */
  69425. alphaTestCutoff: number;
  69426. /**
  69427. * Specifies that alpha blending should be used
  69428. */
  69429. useAlphaBlending: boolean;
  69430. /**
  69431. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most luminous ones).
  69432. * A car glass is a good example of that. When the street lights reflects on it you can not see what is behind.
  69433. */
  69434. useRadianceOverAlpha: boolean;
  69435. /**
  69436. * Specifies that the material will keeps the specular highlights over a transparent surface (only the most luminous ones).
  69437. * A car glass is a good example of that. When sun reflects on it you can not see what is behind.
  69438. */
  69439. useSpecularOverAlpha: boolean;
  69440. /**
  69441. * Enables specular anti aliasing in the PBR shader.
  69442. * It will both interacts on the Geometry for analytical and IBL lighting.
  69443. * It also prefilter the roughness map based on the bump values.
  69444. */
  69445. enableSpecularAntiAliasing: boolean;
  69446. /**
  69447. * Enables realtime filtering on the texture.
  69448. */
  69449. realTimeFiltering: boolean;
  69450. /**
  69451. * Quality switch for realtime filtering
  69452. */
  69453. realTimeFilteringQuality: number;
  69454. /**
  69455. * Defines if the material uses energy conservation.
  69456. */
  69457. useEnergyConservation: boolean;
  69458. /**
  69459. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  69460. * too much the area relying on ambient texture to define their ambient occlusion.
  69461. */
  69462. useRadianceOcclusion: boolean;
  69463. /**
  69464. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  69465. * makes the reflect vector face the model (under horizon).
  69466. */
  69467. useHorizonOcclusion: boolean;
  69468. /**
  69469. * If set to true, no lighting calculations will be applied.
  69470. */
  69471. unlit: boolean;
  69472. /**
  69473. * Force normal to face away from face.
  69474. */
  69475. forceNormalForward: boolean;
  69476. /**
  69477. * Defines the material debug mode.
  69478. * It helps seeing only some components of the material while troubleshooting.
  69479. */
  69480. debugMode: number;
  69481. /**
  69482. * Specify from where on screen the debug mode should start.
  69483. * The value goes from -1 (full screen) to 1 (not visible)
  69484. * It helps with side by side comparison against the final render
  69485. * This defaults to 0
  69486. */
  69487. debugLimit: number;
  69488. /**
  69489. * As the default viewing range might not be enough (if the ambient is really small for instance)
  69490. * You can use the factor to better multiply the final value.
  69491. */
  69492. debugFactor: number;
  69493. /**
  69494. * Initialize the block and prepare the context for build
  69495. * @param state defines the state that will be used for the build
  69496. */
  69497. initialize(state: NodeMaterialBuildState): void;
  69498. /**
  69499. * Gets the current class name
  69500. * @returns the class name
  69501. */
  69502. getClassName(): string;
  69503. /**
  69504. * Gets the world position input component
  69505. */
  69506. get worldPosition(): NodeMaterialConnectionPoint;
  69507. /**
  69508. * Gets the world normal input component
  69509. */
  69510. get worldNormal(): NodeMaterialConnectionPoint;
  69511. /**
  69512. * Gets the view matrix parameter
  69513. */
  69514. get view(): NodeMaterialConnectionPoint;
  69515. /**
  69516. * Gets the camera position input component
  69517. */
  69518. get cameraPosition(): NodeMaterialConnectionPoint;
  69519. /**
  69520. * Gets the perturbed normal input component
  69521. */
  69522. get perturbedNormal(): NodeMaterialConnectionPoint;
  69523. /**
  69524. * Gets the base color input component
  69525. */
  69526. get baseColor(): NodeMaterialConnectionPoint;
  69527. /**
  69528. * Gets the metallic input component
  69529. */
  69530. get metallic(): NodeMaterialConnectionPoint;
  69531. /**
  69532. * Gets the roughness input component
  69533. */
  69534. get roughness(): NodeMaterialConnectionPoint;
  69535. /**
  69536. * Gets the ambient occlusion input component
  69537. */
  69538. get ambientOcc(): NodeMaterialConnectionPoint;
  69539. /**
  69540. * Gets the opacity input component
  69541. */
  69542. get opacity(): NodeMaterialConnectionPoint;
  69543. /**
  69544. * Gets the index of refraction input component
  69545. */
  69546. get indexOfRefraction(): NodeMaterialConnectionPoint;
  69547. /**
  69548. * Gets the ambient color input component
  69549. */
  69550. get ambientColor(): NodeMaterialConnectionPoint;
  69551. /**
  69552. * Gets the reflection object parameters
  69553. */
  69554. get reflection(): NodeMaterialConnectionPoint;
  69555. /**
  69556. * Gets the clear coat object parameters
  69557. */
  69558. get clearcoat(): NodeMaterialConnectionPoint;
  69559. /**
  69560. * Gets the sheen object parameters
  69561. */
  69562. get sheen(): NodeMaterialConnectionPoint;
  69563. /**
  69564. * Gets the sub surface object parameters
  69565. */
  69566. get subsurface(): NodeMaterialConnectionPoint;
  69567. /**
  69568. * Gets the anisotropy object parameters
  69569. */
  69570. get anisotropy(): NodeMaterialConnectionPoint;
  69571. /**
  69572. * Gets the ambient output component
  69573. */
  69574. get ambientClr(): NodeMaterialConnectionPoint;
  69575. /**
  69576. * Gets the diffuse output component
  69577. */
  69578. get diffuseDir(): NodeMaterialConnectionPoint;
  69579. /**
  69580. * Gets the specular output component
  69581. */
  69582. get specularDir(): NodeMaterialConnectionPoint;
  69583. /**
  69584. * Gets the clear coat output component
  69585. */
  69586. get clearcoatDir(): NodeMaterialConnectionPoint;
  69587. /**
  69588. * Gets the sheen output component
  69589. */
  69590. get sheenDir(): NodeMaterialConnectionPoint;
  69591. /**
  69592. * Gets the indirect diffuse output component
  69593. */
  69594. get diffuseIndirect(): NodeMaterialConnectionPoint;
  69595. /**
  69596. * Gets the indirect specular output component
  69597. */
  69598. get specularIndirect(): NodeMaterialConnectionPoint;
  69599. /**
  69600. * Gets the indirect clear coat output component
  69601. */
  69602. get clearcoatIndirect(): NodeMaterialConnectionPoint;
  69603. /**
  69604. * Gets the indirect sheen output component
  69605. */
  69606. get sheenIndirect(): NodeMaterialConnectionPoint;
  69607. /**
  69608. * Gets the refraction output component
  69609. */
  69610. get refraction(): NodeMaterialConnectionPoint;
  69611. /**
  69612. * Gets the global lighting output component
  69613. */
  69614. get lighting(): NodeMaterialConnectionPoint;
  69615. /**
  69616. * Gets the shadow output component
  69617. */
  69618. get shadow(): NodeMaterialConnectionPoint;
  69619. /**
  69620. * Gets the alpha output component
  69621. */
  69622. get alpha(): NodeMaterialConnectionPoint;
  69623. autoConfigure(material: NodeMaterial): void;
  69624. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  69625. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, uniformBuffers: string[]): void;
  69626. isReady(): boolean;
  69627. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  69628. private _injectVertexCode;
  69629. private _getAlbedoOpacityCode;
  69630. private _getAmbientOcclusionCode;
  69631. private _getReflectivityCode;
  69632. protected _buildBlock(state: NodeMaterialBuildState): this;
  69633. protected _dumpPropertiesCode(): string;
  69634. serialize(): any;
  69635. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  69636. }
  69637. }
  69638. declare module BABYLON {
  69639. /**
  69640. * Block used to compute value of one parameter modulo another
  69641. */
  69642. export class ModBlock extends NodeMaterialBlock {
  69643. /**
  69644. * Creates a new ModBlock
  69645. * @param name defines the block name
  69646. */
  69647. constructor(name: string);
  69648. /**
  69649. * Gets the current class name
  69650. * @returns the class name
  69651. */
  69652. getClassName(): string;
  69653. /**
  69654. * Gets the left operand input component
  69655. */
  69656. get left(): NodeMaterialConnectionPoint;
  69657. /**
  69658. * Gets the right operand input component
  69659. */
  69660. get right(): NodeMaterialConnectionPoint;
  69661. /**
  69662. * Gets the output component
  69663. */
  69664. get output(): NodeMaterialConnectionPoint;
  69665. protected _buildBlock(state: NodeMaterialBuildState): this;
  69666. }
  69667. }
  69668. declare module BABYLON {
  69669. /**
  69670. * Configuration for Draco compression
  69671. */
  69672. export interface IDracoCompressionConfiguration {
  69673. /**
  69674. * Configuration for the decoder.
  69675. */
  69676. decoder: {
  69677. /**
  69678. * The url to the WebAssembly module.
  69679. */
  69680. wasmUrl?: string;
  69681. /**
  69682. * The url to the WebAssembly binary.
  69683. */
  69684. wasmBinaryUrl?: string;
  69685. /**
  69686. * The url to the fallback JavaScript module.
  69687. */
  69688. fallbackUrl?: string;
  69689. };
  69690. }
  69691. /**
  69692. * Draco compression (https://google.github.io/draco/)
  69693. *
  69694. * This class wraps the Draco module.
  69695. *
  69696. * **Encoder**
  69697. *
  69698. * The encoder is not currently implemented.
  69699. *
  69700. * **Decoder**
  69701. *
  69702. * 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.
  69703. *
  69704. * To update the configuration, use the following code:
  69705. * ```javascript
  69706. * DracoCompression.Configuration = {
  69707. * decoder: {
  69708. * wasmUrl: "<url to the WebAssembly library>",
  69709. * wasmBinaryUrl: "<url to the WebAssembly binary>",
  69710. * fallbackUrl: "<url to the fallback JavaScript library>",
  69711. * }
  69712. * };
  69713. * ```
  69714. *
  69715. * Draco has two versions, one for WebAssembly and one for JavaScript. The decoder configuration can be set to only support WebAssembly or only support the JavaScript version.
  69716. * Decoding will automatically fallback to the JavaScript version if WebAssembly version is not configured or if WebAssembly is not supported by the browser.
  69717. * Use `DracoCompression.DecoderAvailable` to determine if the decoder configuration is available for the current context.
  69718. *
  69719. * To decode Draco compressed data, get the default DracoCompression object and call decodeMeshAsync:
  69720. * ```javascript
  69721. * var vertexData = await DracoCompression.Default.decodeMeshAsync(data);
  69722. * ```
  69723. *
  69724. * @see https://www.babylonjs-playground.com/#N3EK4B#0
  69725. */
  69726. export class DracoCompression implements IDisposable {
  69727. private _workerPoolPromise?;
  69728. private _decoderModulePromise?;
  69729. /**
  69730. * The configuration. Defaults to the following urls:
  69731. * - wasmUrl: "https://preview.babylonjs.com/draco_wasm_wrapper_gltf.js"
  69732. * - wasmBinaryUrl: "https://preview.babylonjs.com/draco_decoder_gltf.wasm"
  69733. * - fallbackUrl: "https://preview.babylonjs.com/draco_decoder_gltf.js"
  69734. */
  69735. static Configuration: IDracoCompressionConfiguration;
  69736. /**
  69737. * Returns true if the decoder configuration is available.
  69738. */
  69739. static get DecoderAvailable(): boolean;
  69740. /**
  69741. * Default number of workers to create when creating the draco compression object.
  69742. */
  69743. static DefaultNumWorkers: number;
  69744. private static GetDefaultNumWorkers;
  69745. private static _Default;
  69746. /**
  69747. * Default instance for the draco compression object.
  69748. */
  69749. static get Default(): DracoCompression;
  69750. /**
  69751. * Constructor
  69752. * @param numWorkers The number of workers for async operations. Specify `0` to disable web workers and run synchronously in the current context.
  69753. */
  69754. constructor(numWorkers?: number);
  69755. /**
  69756. * Stop all async operations and release resources.
  69757. */
  69758. dispose(): void;
  69759. /**
  69760. * Returns a promise that resolves when ready. Call this manually to ensure draco compression is ready before use.
  69761. * @returns a promise that resolves when ready
  69762. */
  69763. whenReadyAsync(): Promise<void>;
  69764. /**
  69765. * Decode Draco compressed mesh data to vertex data.
  69766. * @param data The ArrayBuffer or ArrayBufferView for the Draco compression data
  69767. * @param attributes A map of attributes from vertex buffer kinds to Draco unique ids
  69768. * @returns A promise that resolves with the decoded vertex data
  69769. */
  69770. decodeMeshAsync(data: ArrayBuffer | ArrayBufferView, attributes?: {
  69771. [kind: string]: number;
  69772. }): Promise<VertexData>;
  69773. }
  69774. }
  69775. declare module BABYLON {
  69776. /**
  69777. * Class for building Constructive Solid Geometry
  69778. */
  69779. export class CSG {
  69780. private polygons;
  69781. /**
  69782. * The world matrix
  69783. */
  69784. matrix: Matrix;
  69785. /**
  69786. * Stores the position
  69787. */
  69788. position: Vector3;
  69789. /**
  69790. * Stores the rotation
  69791. */
  69792. rotation: Vector3;
  69793. /**
  69794. * Stores the rotation quaternion
  69795. */
  69796. rotationQuaternion: Nullable<Quaternion>;
  69797. /**
  69798. * Stores the scaling vector
  69799. */
  69800. scaling: Vector3;
  69801. /**
  69802. * Convert the Mesh to CSG
  69803. * @param mesh The Mesh to convert to CSG
  69804. * @returns A new CSG from the Mesh
  69805. */
  69806. static FromMesh(mesh: Mesh): CSG;
  69807. /**
  69808. * Construct a CSG solid from a list of `CSG.Polygon` instances.
  69809. * @param polygons Polygons used to construct a CSG solid
  69810. */
  69811. private static FromPolygons;
  69812. /**
  69813. * Clones, or makes a deep copy, of the CSG
  69814. * @returns A new CSG
  69815. */
  69816. clone(): CSG;
  69817. /**
  69818. * Unions this CSG with another CSG
  69819. * @param csg The CSG to union against this CSG
  69820. * @returns The unioned CSG
  69821. */
  69822. union(csg: CSG): CSG;
  69823. /**
  69824. * Unions this CSG with another CSG in place
  69825. * @param csg The CSG to union against this CSG
  69826. */
  69827. unionInPlace(csg: CSG): void;
  69828. /**
  69829. * Subtracts this CSG with another CSG
  69830. * @param csg The CSG to subtract against this CSG
  69831. * @returns A new CSG
  69832. */
  69833. subtract(csg: CSG): CSG;
  69834. /**
  69835. * Subtracts this CSG with another CSG in place
  69836. * @param csg The CSG to subtract against this CSG
  69837. */
  69838. subtractInPlace(csg: CSG): void;
  69839. /**
  69840. * Intersect this CSG with another CSG
  69841. * @param csg The CSG to intersect against this CSG
  69842. * @returns A new CSG
  69843. */
  69844. intersect(csg: CSG): CSG;
  69845. /**
  69846. * Intersects this CSG with another CSG in place
  69847. * @param csg The CSG to intersect against this CSG
  69848. */
  69849. intersectInPlace(csg: CSG): void;
  69850. /**
  69851. * Return a new CSG solid with solid and empty space switched. This solid is
  69852. * not modified.
  69853. * @returns A new CSG solid with solid and empty space switched
  69854. */
  69855. inverse(): CSG;
  69856. /**
  69857. * Inverses the CSG in place
  69858. */
  69859. inverseInPlace(): void;
  69860. /**
  69861. * This is used to keep meshes transformations so they can be restored
  69862. * when we build back a Babylon Mesh
  69863. * NB : All CSG operations are performed in world coordinates
  69864. * @param csg The CSG to copy the transform attributes from
  69865. * @returns This CSG
  69866. */
  69867. copyTransformAttributes(csg: CSG): CSG;
  69868. /**
  69869. * Build Raw mesh from CSG
  69870. * Coordinates here are in world space
  69871. * @param name The name of the mesh geometry
  69872. * @param scene The Scene
  69873. * @param keepSubMeshes Specifies if the submeshes should be kept
  69874. * @returns A new Mesh
  69875. */
  69876. buildMeshGeometry(name: string, scene?: Scene, keepSubMeshes?: boolean): Mesh;
  69877. /**
  69878. * Build Mesh from CSG taking material and transforms into account
  69879. * @param name The name of the Mesh
  69880. * @param material The material of the Mesh
  69881. * @param scene The Scene
  69882. * @param keepSubMeshes Specifies if submeshes should be kept
  69883. * @returns The new Mesh
  69884. */
  69885. toMesh(name: string, material?: Nullable<Material>, scene?: Scene, keepSubMeshes?: boolean): Mesh;
  69886. }
  69887. }
  69888. declare module BABYLON {
  69889. /**
  69890. * Class used to create a trail following a mesh
  69891. */
  69892. export class TrailMesh extends Mesh {
  69893. private _generator;
  69894. private _autoStart;
  69895. private _running;
  69896. private _diameter;
  69897. private _length;
  69898. private _sectionPolygonPointsCount;
  69899. private _sectionVectors;
  69900. private _sectionNormalVectors;
  69901. private _beforeRenderObserver;
  69902. /**
  69903. * @constructor
  69904. * @param name The value used by scene.getMeshByName() to do a lookup.
  69905. * @param generator The mesh or transform node to generate a trail.
  69906. * @param scene The scene to add this mesh to.
  69907. * @param diameter Diameter of trailing mesh. Default is 1.
  69908. * @param length Length of trailing mesh. Default is 60.
  69909. * @param autoStart Automatically start trailing mesh. Default true.
  69910. */
  69911. constructor(name: string, generator: TransformNode, scene: Scene, diameter?: number, length?: number, autoStart?: boolean);
  69912. /**
  69913. * "TrailMesh"
  69914. * @returns "TrailMesh"
  69915. */
  69916. getClassName(): string;
  69917. private _createMesh;
  69918. /**
  69919. * Start trailing mesh.
  69920. */
  69921. start(): void;
  69922. /**
  69923. * Stop trailing mesh.
  69924. */
  69925. stop(): void;
  69926. /**
  69927. * Update trailing mesh geometry.
  69928. */
  69929. update(): void;
  69930. /**
  69931. * Returns a new TrailMesh object.
  69932. * @param name is a string, the name given to the new mesh
  69933. * @param newGenerator use new generator object for cloned trail mesh
  69934. * @returns a new mesh
  69935. */
  69936. clone(name: string | undefined, newGenerator: TransformNode): TrailMesh;
  69937. /**
  69938. * Serializes this trail mesh
  69939. * @param serializationObject object to write serialization to
  69940. */
  69941. serialize(serializationObject: any): void;
  69942. /**
  69943. * Parses a serialized trail mesh
  69944. * @param parsedMesh the serialized mesh
  69945. * @param scene the scene to create the trail mesh in
  69946. * @returns the created trail mesh
  69947. */
  69948. static Parse(parsedMesh: any, scene: Scene): TrailMesh;
  69949. }
  69950. }
  69951. declare module BABYLON {
  69952. /**
  69953. * Class containing static functions to help procedurally build meshes
  69954. */
  69955. export class TiledBoxBuilder {
  69956. /**
  69957. * Creates a box mesh
  69958. * 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)
  69959. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  69960. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  69961. * * 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
  69962. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  69963. * @param name defines the name of the mesh
  69964. * @param options defines the options used to create the mesh
  69965. * @param scene defines the hosting scene
  69966. * @returns the box mesh
  69967. */
  69968. static CreateTiledBox(name: string, options: {
  69969. pattern?: number;
  69970. width?: number;
  69971. height?: number;
  69972. depth?: number;
  69973. tileSize?: number;
  69974. tileWidth?: number;
  69975. tileHeight?: number;
  69976. alignHorizontal?: number;
  69977. alignVertical?: number;
  69978. faceUV?: Vector4[];
  69979. faceColors?: Color4[];
  69980. sideOrientation?: number;
  69981. updatable?: boolean;
  69982. }, scene?: Nullable<Scene>): Mesh;
  69983. }
  69984. }
  69985. declare module BABYLON {
  69986. /**
  69987. * Class containing static functions to help procedurally build meshes
  69988. */
  69989. export class TorusKnotBuilder {
  69990. /**
  69991. * Creates a torus knot mesh
  69992. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  69993. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  69994. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  69995. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  69996. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  69997. * * 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
  69998. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  69999. * @param name defines the name of the mesh
  70000. * @param options defines the options used to create the mesh
  70001. * @param scene defines the hosting scene
  70002. * @returns the torus knot mesh
  70003. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  70004. */
  70005. static CreateTorusKnot(name: string, options: {
  70006. radius?: number;
  70007. tube?: number;
  70008. radialSegments?: number;
  70009. tubularSegments?: number;
  70010. p?: number;
  70011. q?: number;
  70012. updatable?: boolean;
  70013. sideOrientation?: number;
  70014. frontUVs?: Vector4;
  70015. backUVs?: Vector4;
  70016. }, scene: any): Mesh;
  70017. }
  70018. }
  70019. declare module BABYLON {
  70020. /**
  70021. * Polygon
  70022. * @see https://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  70023. */
  70024. export class Polygon {
  70025. /**
  70026. * Creates a rectangle
  70027. * @param xmin bottom X coord
  70028. * @param ymin bottom Y coord
  70029. * @param xmax top X coord
  70030. * @param ymax top Y coord
  70031. * @returns points that make the resulting rectangle
  70032. */
  70033. static Rectangle(xmin: number, ymin: number, xmax: number, ymax: number): Vector2[];
  70034. /**
  70035. * Creates a circle
  70036. * @param radius radius of circle
  70037. * @param cx scale in x
  70038. * @param cy scale in y
  70039. * @param numberOfSides number of sides that make up the circle
  70040. * @returns points that make the resulting circle
  70041. */
  70042. static Circle(radius: number, cx?: number, cy?: number, numberOfSides?: number): Vector2[];
  70043. /**
  70044. * Creates a polygon from input string
  70045. * @param input Input polygon data
  70046. * @returns the parsed points
  70047. */
  70048. static Parse(input: string): Vector2[];
  70049. /**
  70050. * Starts building a polygon from x and y coordinates
  70051. * @param x x coordinate
  70052. * @param y y coordinate
  70053. * @returns the started path2
  70054. */
  70055. static StartingAt(x: number, y: number): Path2;
  70056. }
  70057. /**
  70058. * Builds a polygon
  70059. * @see https://doc.babylonjs.com/how_to/polygonmeshbuilder
  70060. */
  70061. export class PolygonMeshBuilder {
  70062. private _points;
  70063. private _outlinepoints;
  70064. private _holes;
  70065. private _name;
  70066. private _scene;
  70067. private _epoints;
  70068. private _eholes;
  70069. private _addToepoint;
  70070. /**
  70071. * Babylon reference to the earcut plugin.
  70072. */
  70073. bjsEarcut: any;
  70074. /**
  70075. * Creates a PolygonMeshBuilder
  70076. * @param name name of the builder
  70077. * @param contours Path of the polygon
  70078. * @param scene scene to add to when creating the mesh
  70079. * @param earcutInjection can be used to inject your own earcut reference
  70080. */
  70081. constructor(name: string, contours: Path2 | Vector2[] | any, scene?: Scene, earcutInjection?: any);
  70082. /**
  70083. * Adds a hole within the polygon
  70084. * @param hole Array of points defining the hole
  70085. * @returns this
  70086. */
  70087. addHole(hole: Vector2[]): PolygonMeshBuilder;
  70088. /**
  70089. * Creates the polygon
  70090. * @param updatable If the mesh should be updatable
  70091. * @param depth The depth of the mesh created
  70092. * @param smoothingThreshold Dot product threshold for smoothed normals
  70093. * @returns the created mesh
  70094. */
  70095. build(updatable?: boolean, depth?: number, smoothingThreshold?: number): Mesh;
  70096. /**
  70097. * Creates the polygon
  70098. * @param depth The depth of the mesh created
  70099. * @param smoothingThreshold Dot product threshold for smoothed normals
  70100. * @returns the created VertexData
  70101. */
  70102. buildVertexData(depth?: number, smoothingThreshold?: number): VertexData;
  70103. /**
  70104. * Adds a side to the polygon
  70105. * @param positions points that make the polygon
  70106. * @param normals normals of the polygon
  70107. * @param uvs uvs of the polygon
  70108. * @param indices indices of the polygon
  70109. * @param bounds bounds of the polygon
  70110. * @param points points of the polygon
  70111. * @param depth depth of the polygon
  70112. * @param flip flip of the polygon
  70113. */
  70114. private addSide;
  70115. }
  70116. }
  70117. declare module BABYLON {
  70118. /**
  70119. * Class containing static functions to help procedurally build meshes
  70120. */
  70121. export class PolygonBuilder {
  70122. /**
  70123. * Creates a polygon mesh
  70124. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  70125. * * 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
  70126. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  70127. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  70128. * * 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)
  70129. * * Remember you can only change the shape positions, not their number when updating a polygon
  70130. * @param name defines the name of the mesh
  70131. * @param options defines the options used to create the mesh
  70132. * @param scene defines the hosting scene
  70133. * @param earcutInjection can be used to inject your own earcut reference
  70134. * @returns the polygon mesh
  70135. */
  70136. static CreatePolygon(name: string, options: {
  70137. shape: Vector3[];
  70138. holes?: Vector3[][];
  70139. depth?: number;
  70140. smoothingThreshold?: number;
  70141. faceUV?: Vector4[];
  70142. faceColors?: Color4[];
  70143. updatable?: boolean;
  70144. sideOrientation?: number;
  70145. frontUVs?: Vector4;
  70146. backUVs?: Vector4;
  70147. wrap?: boolean;
  70148. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  70149. /**
  70150. * Creates an extruded polygon mesh, with depth in the Y direction.
  70151. * * 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)
  70152. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  70153. * @param name defines the name of the mesh
  70154. * @param options defines the options used to create the mesh
  70155. * @param scene defines the hosting scene
  70156. * @param earcutInjection can be used to inject your own earcut reference
  70157. * @returns the polygon mesh
  70158. */
  70159. static ExtrudePolygon(name: string, options: {
  70160. shape: Vector3[];
  70161. holes?: Vector3[][];
  70162. depth?: number;
  70163. faceUV?: Vector4[];
  70164. faceColors?: Color4[];
  70165. updatable?: boolean;
  70166. sideOrientation?: number;
  70167. frontUVs?: Vector4;
  70168. backUVs?: Vector4;
  70169. wrap?: boolean;
  70170. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  70171. }
  70172. }
  70173. declare module BABYLON {
  70174. /**
  70175. * Class containing static functions to help procedurally build meshes
  70176. */
  70177. export class LatheBuilder {
  70178. /**
  70179. * Creates lathe mesh.
  70180. * The lathe is a shape with a symmetry axis : a 2D model shape is rotated around this axis to design the lathe
  70181. * * 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
  70182. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  70183. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  70184. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  70185. * * 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
  70186. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  70187. * * 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
  70188. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  70189. * * 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
  70190. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  70191. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  70192. * @param name defines the name of the mesh
  70193. * @param options defines the options used to create the mesh
  70194. * @param scene defines the hosting scene
  70195. * @returns the lathe mesh
  70196. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  70197. */
  70198. static CreateLathe(name: string, options: {
  70199. shape: Vector3[];
  70200. radius?: number;
  70201. tessellation?: number;
  70202. clip?: number;
  70203. arc?: number;
  70204. closed?: boolean;
  70205. updatable?: boolean;
  70206. sideOrientation?: number;
  70207. frontUVs?: Vector4;
  70208. backUVs?: Vector4;
  70209. cap?: number;
  70210. invertUV?: boolean;
  70211. }, scene?: Nullable<Scene>): Mesh;
  70212. }
  70213. }
  70214. declare module BABYLON {
  70215. /**
  70216. * Class containing static functions to help procedurally build meshes
  70217. */
  70218. export class TiledPlaneBuilder {
  70219. /**
  70220. * Creates a tiled plane mesh
  70221. * * The parameter `pattern` will, depending on value, do nothing or
  70222. * * * flip (reflect about central vertical) alternate tiles across and up
  70223. * * * flip every tile on alternate rows
  70224. * * * rotate (180 degs) alternate tiles across and up
  70225. * * * rotate every tile on alternate rows
  70226. * * * flip and rotate alternate tiles across and up
  70227. * * * flip and rotate every tile on alternate rows
  70228. * * The parameter `tileSize` sets the size (float) of each tile side (default 1)
  70229. * * You can set some different tile dimensions by using the parameters `tileWidth` and `tileHeight` (both by default have the same value of `tileSize`)
  70230. * * 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
  70231. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  70232. * * 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)
  70233. * * 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)
  70234. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  70235. * @param name defines the name of the mesh
  70236. * @param options defines the options used to create the mesh
  70237. * @param scene defines the hosting scene
  70238. * @returns the box mesh
  70239. */
  70240. static CreateTiledPlane(name: string, options: {
  70241. pattern?: number;
  70242. tileSize?: number;
  70243. tileWidth?: number;
  70244. tileHeight?: number;
  70245. size?: number;
  70246. width?: number;
  70247. height?: number;
  70248. alignHorizontal?: number;
  70249. alignVertical?: number;
  70250. sideOrientation?: number;
  70251. frontUVs?: Vector4;
  70252. backUVs?: Vector4;
  70253. updatable?: boolean;
  70254. }, scene?: Nullable<Scene>): Mesh;
  70255. }
  70256. }
  70257. declare module BABYLON {
  70258. /**
  70259. * Class containing static functions to help procedurally build meshes
  70260. */
  70261. export class TubeBuilder {
  70262. /**
  70263. * Creates a tube mesh.
  70264. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  70265. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  70266. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  70267. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  70268. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overrides the parameter `radius`
  70269. * * 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)
  70270. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  70271. * * 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
  70272. * * 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
  70273. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  70274. * * 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
  70275. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  70276. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  70277. * @param name defines the name of the mesh
  70278. * @param options defines the options used to create the mesh
  70279. * @param scene defines the hosting scene
  70280. * @returns the tube mesh
  70281. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  70282. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  70283. */
  70284. static CreateTube(name: string, options: {
  70285. path: Vector3[];
  70286. radius?: number;
  70287. tessellation?: number;
  70288. radiusFunction?: {
  70289. (i: number, distance: number): number;
  70290. };
  70291. cap?: number;
  70292. arc?: number;
  70293. updatable?: boolean;
  70294. sideOrientation?: number;
  70295. frontUVs?: Vector4;
  70296. backUVs?: Vector4;
  70297. instance?: Mesh;
  70298. invertUV?: boolean;
  70299. }, scene?: Nullable<Scene>): Mesh;
  70300. }
  70301. }
  70302. declare module BABYLON {
  70303. /**
  70304. * Class containing static functions to help procedurally build meshes
  70305. */
  70306. export class IcoSphereBuilder {
  70307. /**
  70308. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  70309. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  70310. * * 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`)
  70311. * * The parameter `subdivisions` sets the number of subdivisions (positive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  70312. * * 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
  70313. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  70314. * * 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
  70315. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  70316. * @param name defines the name of the mesh
  70317. * @param options defines the options used to create the mesh
  70318. * @param scene defines the hosting scene
  70319. * @returns the icosahedron mesh
  70320. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  70321. */
  70322. static CreateIcoSphere(name: string, options: {
  70323. radius?: number;
  70324. radiusX?: number;
  70325. radiusY?: number;
  70326. radiusZ?: number;
  70327. flat?: boolean;
  70328. subdivisions?: number;
  70329. sideOrientation?: number;
  70330. frontUVs?: Vector4;
  70331. backUVs?: Vector4;
  70332. updatable?: boolean;
  70333. }, scene?: Nullable<Scene>): Mesh;
  70334. }
  70335. }
  70336. declare module BABYLON {
  70337. /**
  70338. * Class containing static functions to help procedurally build meshes
  70339. */
  70340. export class DecalBuilder {
  70341. /**
  70342. * Creates a decal mesh.
  70343. * 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
  70344. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  70345. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  70346. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  70347. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  70348. * @param name defines the name of the mesh
  70349. * @param sourceMesh defines the mesh where the decal must be applied
  70350. * @param options defines the options used to create the mesh
  70351. * @param scene defines the hosting scene
  70352. * @returns the decal mesh
  70353. * @see https://doc.babylonjs.com/how_to/decals
  70354. */
  70355. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  70356. position?: Vector3;
  70357. normal?: Vector3;
  70358. size?: Vector3;
  70359. angle?: number;
  70360. }): Mesh;
  70361. }
  70362. }
  70363. declare module BABYLON {
  70364. /**
  70365. * Class containing static functions to help procedurally build meshes
  70366. */
  70367. export class MeshBuilder {
  70368. /**
  70369. * Creates a box mesh
  70370. * * The parameter `size` sets the size (float) of each box side (default 1)
  70371. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  70372. * * 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)
  70373. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  70374. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  70375. * * 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
  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. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  70378. * @param name defines the name of the mesh
  70379. * @param options defines the options used to create the mesh
  70380. * @param scene defines the hosting scene
  70381. * @returns the box mesh
  70382. */
  70383. static CreateBox(name: string, options: {
  70384. size?: number;
  70385. width?: number;
  70386. height?: number;
  70387. depth?: number;
  70388. faceUV?: Vector4[];
  70389. faceColors?: Color4[];
  70390. sideOrientation?: number;
  70391. frontUVs?: Vector4;
  70392. backUVs?: Vector4;
  70393. wrap?: boolean;
  70394. topBaseAt?: number;
  70395. bottomBaseAt?: number;
  70396. updatable?: boolean;
  70397. }, scene?: Nullable<Scene>): Mesh;
  70398. /**
  70399. * Creates a tiled box mesh
  70400. * * faceTiles sets the pattern, tile size and number of tiles for a face
  70401. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  70402. * @param name defines the name of the mesh
  70403. * @param options defines the options used to create the mesh
  70404. * @param scene defines the hosting scene
  70405. * @returns the tiled box mesh
  70406. */
  70407. static CreateTiledBox(name: string, options: {
  70408. pattern?: number;
  70409. size?: number;
  70410. width?: number;
  70411. height?: number;
  70412. depth: number;
  70413. tileSize?: number;
  70414. tileWidth?: number;
  70415. tileHeight?: number;
  70416. faceUV?: Vector4[];
  70417. faceColors?: Color4[];
  70418. alignHorizontal?: number;
  70419. alignVertical?: number;
  70420. sideOrientation?: number;
  70421. updatable?: boolean;
  70422. }, scene?: Nullable<Scene>): Mesh;
  70423. /**
  70424. * Creates a sphere mesh
  70425. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  70426. * * 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`)
  70427. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  70428. * * 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
  70429. * * 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)
  70430. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  70431. * * 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
  70432. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  70433. * @param name defines the name of the mesh
  70434. * @param options defines the options used to create the mesh
  70435. * @param scene defines the hosting scene
  70436. * @returns the sphere mesh
  70437. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  70438. */
  70439. static CreateSphere(name: string, options: {
  70440. segments?: number;
  70441. diameter?: number;
  70442. diameterX?: number;
  70443. diameterY?: number;
  70444. diameterZ?: number;
  70445. arc?: number;
  70446. slice?: number;
  70447. sideOrientation?: number;
  70448. frontUVs?: Vector4;
  70449. backUVs?: Vector4;
  70450. updatable?: boolean;
  70451. }, scene?: Nullable<Scene>): Mesh;
  70452. /**
  70453. * Creates a plane polygonal mesh. By default, this is a disc
  70454. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  70455. * * 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
  70456. * * 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
  70457. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  70458. * * 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
  70459. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  70460. * @param name defines the name of the mesh
  70461. * @param options defines the options used to create the mesh
  70462. * @param scene defines the hosting scene
  70463. * @returns the plane polygonal mesh
  70464. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  70465. */
  70466. static CreateDisc(name: string, options: {
  70467. radius?: number;
  70468. tessellation?: number;
  70469. arc?: number;
  70470. updatable?: boolean;
  70471. sideOrientation?: number;
  70472. frontUVs?: Vector4;
  70473. backUVs?: Vector4;
  70474. }, scene?: Nullable<Scene>): Mesh;
  70475. /**
  70476. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  70477. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  70478. * * 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`)
  70479. * * The parameter `subdivisions` sets the number of subdivisions (positive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  70480. * * 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
  70481. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  70482. * * 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
  70483. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  70484. * @param name defines the name of the mesh
  70485. * @param options defines the options used to create the mesh
  70486. * @param scene defines the hosting scene
  70487. * @returns the icosahedron mesh
  70488. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  70489. */
  70490. static CreateIcoSphere(name: string, options: {
  70491. radius?: number;
  70492. radiusX?: number;
  70493. radiusY?: number;
  70494. radiusZ?: number;
  70495. flat?: boolean;
  70496. subdivisions?: number;
  70497. sideOrientation?: number;
  70498. frontUVs?: Vector4;
  70499. backUVs?: Vector4;
  70500. updatable?: boolean;
  70501. }, scene?: Nullable<Scene>): Mesh;
  70502. /**
  70503. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  70504. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  70505. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  70506. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  70507. * * 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
  70508. * * 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
  70509. * * 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
  70510. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  70511. * * 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
  70512. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  70513. * * 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
  70514. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  70515. * * 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
  70516. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  70517. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  70518. * @param name defines the name of the mesh
  70519. * @param options defines the options used to create the mesh
  70520. * @param scene defines the hosting scene
  70521. * @returns the ribbon mesh
  70522. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  70523. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  70524. */
  70525. static CreateRibbon(name: string, options: {
  70526. pathArray: Vector3[][];
  70527. closeArray?: boolean;
  70528. closePath?: boolean;
  70529. offset?: number;
  70530. updatable?: boolean;
  70531. sideOrientation?: number;
  70532. frontUVs?: Vector4;
  70533. backUVs?: Vector4;
  70534. instance?: Mesh;
  70535. invertUV?: boolean;
  70536. uvs?: Vector2[];
  70537. colors?: Color4[];
  70538. }, scene?: Nullable<Scene>): Mesh;
  70539. /**
  70540. * Creates a cylinder or a cone mesh
  70541. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  70542. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  70543. * * 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.
  70544. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  70545. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  70546. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  70547. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  70548. * * 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).
  70549. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  70550. * * 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).
  70551. * * 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
  70552. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  70553. * * 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
  70554. * * 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.
  70555. * * If `enclose` is false, a ring surface is one element.
  70556. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  70557. * * 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
  70558. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  70559. * * 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
  70560. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  70561. * @param name defines the name of the mesh
  70562. * @param options defines the options used to create the mesh
  70563. * @param scene defines the hosting scene
  70564. * @returns the cylinder mesh
  70565. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  70566. */
  70567. static CreateCylinder(name: string, options: {
  70568. height?: number;
  70569. diameterTop?: number;
  70570. diameterBottom?: number;
  70571. diameter?: number;
  70572. tessellation?: number;
  70573. subdivisions?: number;
  70574. arc?: number;
  70575. faceColors?: Color4[];
  70576. faceUV?: Vector4[];
  70577. updatable?: boolean;
  70578. hasRings?: boolean;
  70579. enclose?: boolean;
  70580. cap?: number;
  70581. sideOrientation?: number;
  70582. frontUVs?: Vector4;
  70583. backUVs?: Vector4;
  70584. }, scene?: Nullable<Scene>): Mesh;
  70585. /**
  70586. * Creates a torus mesh
  70587. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  70588. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  70589. * * The parameter `tessellation` sets the number of torus sides (positive integer, default 16)
  70590. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  70591. * * 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
  70592. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  70593. * @param name defines the name of the mesh
  70594. * @param options defines the options used to create the mesh
  70595. * @param scene defines the hosting scene
  70596. * @returns the torus mesh
  70597. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  70598. */
  70599. static CreateTorus(name: string, options: {
  70600. diameter?: number;
  70601. thickness?: number;
  70602. tessellation?: number;
  70603. updatable?: boolean;
  70604. sideOrientation?: number;
  70605. frontUVs?: Vector4;
  70606. backUVs?: Vector4;
  70607. }, scene?: Nullable<Scene>): Mesh;
  70608. /**
  70609. * Creates a torus knot mesh
  70610. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  70611. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  70612. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  70613. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  70614. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  70615. * * 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
  70616. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  70617. * @param name defines the name of the mesh
  70618. * @param options defines the options used to create the mesh
  70619. * @param scene defines the hosting scene
  70620. * @returns the torus knot mesh
  70621. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  70622. */
  70623. static CreateTorusKnot(name: string, options: {
  70624. radius?: number;
  70625. tube?: number;
  70626. radialSegments?: number;
  70627. tubularSegments?: number;
  70628. p?: number;
  70629. q?: number;
  70630. updatable?: boolean;
  70631. sideOrientation?: number;
  70632. frontUVs?: Vector4;
  70633. backUVs?: Vector4;
  70634. }, scene?: Nullable<Scene>): Mesh;
  70635. /**
  70636. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  70637. * * 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
  70638. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  70639. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  70640. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  70641. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  70642. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  70643. * * 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
  70644. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  70645. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  70646. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  70647. * @param name defines the name of the new line system
  70648. * @param options defines the options used to create the line system
  70649. * @param scene defines the hosting scene
  70650. * @returns a new line system mesh
  70651. */
  70652. static CreateLineSystem(name: string, options: {
  70653. lines: Vector3[][];
  70654. updatable?: boolean;
  70655. instance?: Nullable<LinesMesh>;
  70656. colors?: Nullable<Color4[][]>;
  70657. useVertexAlpha?: boolean;
  70658. }, scene: Nullable<Scene>): LinesMesh;
  70659. /**
  70660. * Creates a line mesh
  70661. * 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
  70662. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  70663. * * The parameter `points` is an array successive Vector3
  70664. * * 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
  70665. * * The optional parameter `colors` is an array of successive Color4, one per line point
  70666. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  70667. * * When updating an instance, remember that only point positions can change, not the number of points
  70668. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  70669. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  70670. * @param name defines the name of the new line system
  70671. * @param options defines the options used to create the line system
  70672. * @param scene defines the hosting scene
  70673. * @returns a new line mesh
  70674. */
  70675. static CreateLines(name: string, options: {
  70676. points: Vector3[];
  70677. updatable?: boolean;
  70678. instance?: Nullable<LinesMesh>;
  70679. colors?: Color4[];
  70680. useVertexAlpha?: boolean;
  70681. }, scene?: Nullable<Scene>): LinesMesh;
  70682. /**
  70683. * Creates a dashed line mesh
  70684. * * 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
  70685. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  70686. * * The parameter `points` is an array successive Vector3
  70687. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  70688. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  70689. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  70690. * * 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
  70691. * * When updating an instance, remember that only point positions can change, not the number of points
  70692. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  70693. * @param name defines the name of the mesh
  70694. * @param options defines the options used to create the mesh
  70695. * @param scene defines the hosting scene
  70696. * @returns the dashed line mesh
  70697. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  70698. */
  70699. static CreateDashedLines(name: string, options: {
  70700. points: Vector3[];
  70701. dashSize?: number;
  70702. gapSize?: number;
  70703. dashNb?: number;
  70704. updatable?: boolean;
  70705. instance?: LinesMesh;
  70706. }, scene?: Nullable<Scene>): LinesMesh;
  70707. /**
  70708. * 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.
  70709. * * 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.
  70710. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  70711. * * 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.
  70712. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  70713. * * 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
  70714. * * 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
  70715. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  70716. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  70717. * * 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
  70718. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  70719. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  70720. * @param name defines the name of the mesh
  70721. * @param options defines the options used to create the mesh
  70722. * @param scene defines the hosting scene
  70723. * @returns the extruded shape mesh
  70724. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  70725. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  70726. */
  70727. static ExtrudeShape(name: string, options: {
  70728. shape: Vector3[];
  70729. path: Vector3[];
  70730. scale?: number;
  70731. rotation?: number;
  70732. cap?: number;
  70733. updatable?: boolean;
  70734. sideOrientation?: number;
  70735. frontUVs?: Vector4;
  70736. backUVs?: Vector4;
  70737. instance?: Mesh;
  70738. invertUV?: boolean;
  70739. }, scene?: Nullable<Scene>): Mesh;
  70740. /**
  70741. * Creates an custom extruded shape mesh.
  70742. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  70743. * * 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.
  70744. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  70745. * * The parameter `rotationFunction` (JS function) is a custom Javascript function called on each path point. This function is passed the position i of the point in the path and the distance of this point from the beginning of the path
  70746. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  70747. * * 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
  70748. * * It must returns a float value that will be the scale value applied to the shape on each path point
  70749. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  70750. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  70751. * * 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
  70752. * * 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
  70753. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  70754. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  70755. * * 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
  70756. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  70757. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  70758. * @param name defines the name of the mesh
  70759. * @param options defines the options used to create the mesh
  70760. * @param scene defines the hosting scene
  70761. * @returns the custom extruded shape mesh
  70762. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  70763. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  70764. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  70765. */
  70766. static ExtrudeShapeCustom(name: string, options: {
  70767. shape: Vector3[];
  70768. path: Vector3[];
  70769. scaleFunction?: any;
  70770. rotationFunction?: any;
  70771. ribbonCloseArray?: boolean;
  70772. ribbonClosePath?: boolean;
  70773. cap?: number;
  70774. updatable?: boolean;
  70775. sideOrientation?: number;
  70776. frontUVs?: Vector4;
  70777. backUVs?: Vector4;
  70778. instance?: Mesh;
  70779. invertUV?: boolean;
  70780. }, scene?: Nullable<Scene>): Mesh;
  70781. /**
  70782. * Creates lathe mesh.
  70783. * The lathe is a shape with a symmetry axis : a 2D model shape is rotated around this axis to design the lathe
  70784. * * 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
  70785. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  70786. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  70787. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  70788. * * 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
  70789. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  70790. * * 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
  70791. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  70792. * * 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
  70793. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  70794. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  70795. * @param name defines the name of the mesh
  70796. * @param options defines the options used to create the mesh
  70797. * @param scene defines the hosting scene
  70798. * @returns the lathe mesh
  70799. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  70800. */
  70801. static CreateLathe(name: string, options: {
  70802. shape: Vector3[];
  70803. radius?: number;
  70804. tessellation?: number;
  70805. clip?: number;
  70806. arc?: number;
  70807. closed?: boolean;
  70808. updatable?: boolean;
  70809. sideOrientation?: number;
  70810. frontUVs?: Vector4;
  70811. backUVs?: Vector4;
  70812. cap?: number;
  70813. invertUV?: boolean;
  70814. }, scene?: Nullable<Scene>): Mesh;
  70815. /**
  70816. * Creates a tiled plane mesh
  70817. * * You can set a limited pattern arrangement with the tiles
  70818. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  70819. * * 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
  70820. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  70821. * @param name defines the name of the mesh
  70822. * @param options defines the options used to create the mesh
  70823. * @param scene defines the hosting scene
  70824. * @returns the plane mesh
  70825. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  70826. */
  70827. static CreateTiledPlane(name: string, options: {
  70828. pattern?: number;
  70829. tileSize?: number;
  70830. tileWidth?: number;
  70831. tileHeight?: number;
  70832. size?: number;
  70833. width?: number;
  70834. height?: number;
  70835. alignHorizontal?: number;
  70836. alignVertical?: number;
  70837. sideOrientation?: number;
  70838. frontUVs?: Vector4;
  70839. backUVs?: Vector4;
  70840. updatable?: boolean;
  70841. }, scene?: Nullable<Scene>): Mesh;
  70842. /**
  70843. * Creates a plane mesh
  70844. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  70845. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  70846. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  70847. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  70848. * * 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
  70849. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  70850. * @param name defines the name of the mesh
  70851. * @param options defines the options used to create the mesh
  70852. * @param scene defines the hosting scene
  70853. * @returns the plane mesh
  70854. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  70855. */
  70856. static CreatePlane(name: string, options: {
  70857. size?: number;
  70858. width?: number;
  70859. height?: number;
  70860. sideOrientation?: number;
  70861. frontUVs?: Vector4;
  70862. backUVs?: Vector4;
  70863. updatable?: boolean;
  70864. sourcePlane?: Plane;
  70865. }, scene?: Nullable<Scene>): Mesh;
  70866. /**
  70867. * Creates a ground mesh
  70868. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  70869. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  70870. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  70871. * @param name defines the name of the mesh
  70872. * @param options defines the options used to create the mesh
  70873. * @param scene defines the hosting scene
  70874. * @returns the ground mesh
  70875. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  70876. */
  70877. static CreateGround(name: string, options: {
  70878. width?: number;
  70879. height?: number;
  70880. subdivisions?: number;
  70881. subdivisionsX?: number;
  70882. subdivisionsY?: number;
  70883. updatable?: boolean;
  70884. }, scene?: Nullable<Scene>): Mesh;
  70885. /**
  70886. * Creates a tiled ground mesh
  70887. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  70888. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  70889. * * 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
  70890. * * 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
  70891. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  70892. * @param name defines the name of the mesh
  70893. * @param options defines the options used to create the mesh
  70894. * @param scene defines the hosting scene
  70895. * @returns the tiled ground mesh
  70896. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  70897. */
  70898. static CreateTiledGround(name: string, options: {
  70899. xmin: number;
  70900. zmin: number;
  70901. xmax: number;
  70902. zmax: number;
  70903. subdivisions?: {
  70904. w: number;
  70905. h: number;
  70906. };
  70907. precision?: {
  70908. w: number;
  70909. h: number;
  70910. };
  70911. updatable?: boolean;
  70912. }, scene?: Nullable<Scene>): Mesh;
  70913. /**
  70914. * Creates a ground mesh from a height map
  70915. * * The parameter `url` sets the URL of the height map image resource.
  70916. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  70917. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  70918. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  70919. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  70920. * * 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.
  70921. * * 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).
  70922. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  70923. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  70924. * @param name defines the name of the mesh
  70925. * @param url defines the url to the height map
  70926. * @param options defines the options used to create the mesh
  70927. * @param scene defines the hosting scene
  70928. * @returns the ground mesh
  70929. * @see https://doc.babylonjs.com/babylon101/height_map
  70930. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  70931. */
  70932. static CreateGroundFromHeightMap(name: string, url: string, options: {
  70933. width?: number;
  70934. height?: number;
  70935. subdivisions?: number;
  70936. minHeight?: number;
  70937. maxHeight?: number;
  70938. colorFilter?: Color3;
  70939. alphaFilter?: number;
  70940. updatable?: boolean;
  70941. onReady?: (mesh: GroundMesh) => void;
  70942. }, scene?: Nullable<Scene>): GroundMesh;
  70943. /**
  70944. * Creates a polygon mesh
  70945. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  70946. * * 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
  70947. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  70948. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  70949. * * 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)
  70950. * * Remember you can only change the shape positions, not their number when updating a polygon
  70951. * @param name defines the name of the mesh
  70952. * @param options defines the options used to create the mesh
  70953. * @param scene defines the hosting scene
  70954. * @param earcutInjection can be used to inject your own earcut reference
  70955. * @returns the polygon mesh
  70956. */
  70957. static CreatePolygon(name: string, options: {
  70958. shape: Vector3[];
  70959. holes?: Vector3[][];
  70960. depth?: number;
  70961. faceUV?: Vector4[];
  70962. faceColors?: Color4[];
  70963. updatable?: boolean;
  70964. sideOrientation?: number;
  70965. frontUVs?: Vector4;
  70966. backUVs?: Vector4;
  70967. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  70968. /**
  70969. * Creates an extruded polygon mesh, with depth in the Y direction.
  70970. * * 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)
  70971. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  70972. * @param name defines the name of the mesh
  70973. * @param options defines the options used to create the mesh
  70974. * @param scene defines the hosting scene
  70975. * @param earcutInjection can be used to inject your own earcut reference
  70976. * @returns the polygon mesh
  70977. */
  70978. static ExtrudePolygon(name: string, options: {
  70979. shape: Vector3[];
  70980. holes?: Vector3[][];
  70981. depth?: number;
  70982. faceUV?: Vector4[];
  70983. faceColors?: Color4[];
  70984. updatable?: boolean;
  70985. sideOrientation?: number;
  70986. frontUVs?: Vector4;
  70987. backUVs?: Vector4;
  70988. wrap?: boolean;
  70989. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  70990. /**
  70991. * Creates a tube mesh.
  70992. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  70993. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  70994. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  70995. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  70996. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overrides the parameter `radius`
  70997. * * 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)
  70998. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  70999. * * 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
  71000. * * 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
  71001. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  71002. * * 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
  71003. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  71004. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  71005. * @param name defines the name of the mesh
  71006. * @param options defines the options used to create the mesh
  71007. * @param scene defines the hosting scene
  71008. * @returns the tube mesh
  71009. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  71010. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  71011. */
  71012. static CreateTube(name: string, options: {
  71013. path: Vector3[];
  71014. radius?: number;
  71015. tessellation?: number;
  71016. radiusFunction?: {
  71017. (i: number, distance: number): number;
  71018. };
  71019. cap?: number;
  71020. arc?: number;
  71021. updatable?: boolean;
  71022. sideOrientation?: number;
  71023. frontUVs?: Vector4;
  71024. backUVs?: Vector4;
  71025. instance?: Mesh;
  71026. invertUV?: boolean;
  71027. }, scene?: Nullable<Scene>): Mesh;
  71028. /**
  71029. * Creates a polyhedron mesh
  71030. * * 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
  71031. * * The parameter `size` (positive float, default 1) sets the polygon size
  71032. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  71033. * * 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`
  71034. * * 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
  71035. * * 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)`)
  71036. * * 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
  71037. * * 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
  71038. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  71039. * * 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
  71040. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  71041. * @param name defines the name of the mesh
  71042. * @param options defines the options used to create the mesh
  71043. * @param scene defines the hosting scene
  71044. * @returns the polyhedron mesh
  71045. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  71046. */
  71047. static CreatePolyhedron(name: string, options: {
  71048. type?: number;
  71049. size?: number;
  71050. sizeX?: number;
  71051. sizeY?: number;
  71052. sizeZ?: number;
  71053. custom?: any;
  71054. faceUV?: Vector4[];
  71055. faceColors?: Color4[];
  71056. flat?: boolean;
  71057. updatable?: boolean;
  71058. sideOrientation?: number;
  71059. frontUVs?: Vector4;
  71060. backUVs?: Vector4;
  71061. }, scene?: Nullable<Scene>): Mesh;
  71062. /**
  71063. * Creates a decal mesh.
  71064. * 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
  71065. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  71066. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  71067. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  71068. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  71069. * @param name defines the name of the mesh
  71070. * @param sourceMesh defines the mesh where the decal must be applied
  71071. * @param options defines the options used to create the mesh
  71072. * @param scene defines the hosting scene
  71073. * @returns the decal mesh
  71074. * @see https://doc.babylonjs.com/how_to/decals
  71075. */
  71076. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  71077. position?: Vector3;
  71078. normal?: Vector3;
  71079. size?: Vector3;
  71080. angle?: number;
  71081. }): Mesh;
  71082. /**
  71083. * Creates a Capsule Mesh
  71084. * @param name defines the name of the mesh.
  71085. * @param options the constructors options used to shape the mesh.
  71086. * @param scene defines the scene the mesh is scoped to.
  71087. * @returns the capsule mesh
  71088. * @see https://doc.babylonjs.com/how_to/capsule_shape
  71089. */
  71090. static CreateCapsule(name: string, options?: ICreateCapsuleOptions, scene?: Nullable<Scene>): Mesh;
  71091. }
  71092. }
  71093. declare module BABYLON {
  71094. /**
  71095. * A simplifier interface for future simplification implementations
  71096. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  71097. */
  71098. export interface ISimplifier {
  71099. /**
  71100. * Simplification of a given mesh according to the given settings.
  71101. * Since this requires computation, it is assumed that the function runs async.
  71102. * @param settings The settings of the simplification, including quality and distance
  71103. * @param successCallback A callback that will be called after the mesh was simplified.
  71104. * @param errorCallback in case of an error, this callback will be called. optional.
  71105. */
  71106. simplify(settings: ISimplificationSettings, successCallback: (simplifiedMeshes: Mesh) => void, errorCallback?: () => void): void;
  71107. }
  71108. /**
  71109. * Expected simplification settings.
  71110. * Quality should be between 0 and 1 (1 being 100%, 0 being 0%)
  71111. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  71112. */
  71113. export interface ISimplificationSettings {
  71114. /**
  71115. * Gets or sets the expected quality
  71116. */
  71117. quality: number;
  71118. /**
  71119. * Gets or sets the distance when this optimized version should be used
  71120. */
  71121. distance: number;
  71122. /**
  71123. * Gets an already optimized mesh
  71124. */
  71125. optimizeMesh?: boolean;
  71126. }
  71127. /**
  71128. * Class used to specify simplification options
  71129. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  71130. */
  71131. export class SimplificationSettings implements ISimplificationSettings {
  71132. /** expected quality */
  71133. quality: number;
  71134. /** distance when this optimized version should be used */
  71135. distance: number;
  71136. /** already optimized mesh */
  71137. optimizeMesh?: boolean | undefined;
  71138. /**
  71139. * Creates a SimplificationSettings
  71140. * @param quality expected quality
  71141. * @param distance distance when this optimized version should be used
  71142. * @param optimizeMesh already optimized mesh
  71143. */
  71144. constructor(
  71145. /** expected quality */
  71146. quality: number,
  71147. /** distance when this optimized version should be used */
  71148. distance: number,
  71149. /** already optimized mesh */
  71150. optimizeMesh?: boolean | undefined);
  71151. }
  71152. /**
  71153. * Interface used to define a simplification task
  71154. */
  71155. export interface ISimplificationTask {
  71156. /**
  71157. * Array of settings
  71158. */
  71159. settings: Array<ISimplificationSettings>;
  71160. /**
  71161. * Simplification type
  71162. */
  71163. simplificationType: SimplificationType;
  71164. /**
  71165. * Mesh to simplify
  71166. */
  71167. mesh: Mesh;
  71168. /**
  71169. * Callback called on success
  71170. */
  71171. successCallback?: () => void;
  71172. /**
  71173. * Defines if parallel processing can be used
  71174. */
  71175. parallelProcessing: boolean;
  71176. }
  71177. /**
  71178. * Queue used to order the simplification tasks
  71179. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  71180. */
  71181. export class SimplificationQueue {
  71182. private _simplificationArray;
  71183. /**
  71184. * Gets a boolean indicating that the process is still running
  71185. */
  71186. running: boolean;
  71187. /**
  71188. * Creates a new queue
  71189. */
  71190. constructor();
  71191. /**
  71192. * Adds a new simplification task
  71193. * @param task defines a task to add
  71194. */
  71195. addTask(task: ISimplificationTask): void;
  71196. /**
  71197. * Execute next task
  71198. */
  71199. executeNext(): void;
  71200. /**
  71201. * Execute a simplification task
  71202. * @param task defines the task to run
  71203. */
  71204. runSimplification(task: ISimplificationTask): void;
  71205. private getSimplifier;
  71206. }
  71207. /**
  71208. * The implemented types of simplification
  71209. * At the moment only Quadratic Error Decimation is implemented
  71210. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  71211. */
  71212. export enum SimplificationType {
  71213. /** Quadratic error decimation */
  71214. QUADRATIC = 0
  71215. }
  71216. /**
  71217. * An implementation of the Quadratic Error simplification algorithm.
  71218. * Original paper : http://www1.cs.columbia.edu/~cs4162/html05s/garland97.pdf
  71219. * Ported mostly from QSlim and http://voxels.blogspot.de/2014/05/quadric-mesh-simplification-with-source.html to babylon JS
  71220. * @author RaananW
  71221. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  71222. */
  71223. export class QuadraticErrorSimplification implements ISimplifier {
  71224. private _mesh;
  71225. private triangles;
  71226. private vertices;
  71227. private references;
  71228. private _reconstructedMesh;
  71229. /** Gets or sets the number pf sync iterations */
  71230. syncIterations: number;
  71231. /** Gets or sets the aggressiveness of the simplifier */
  71232. aggressiveness: number;
  71233. /** Gets or sets the number of allowed iterations for decimation */
  71234. decimationIterations: number;
  71235. /** Gets or sets the espilon to use for bounding box computation */
  71236. boundingBoxEpsilon: number;
  71237. /**
  71238. * Creates a new QuadraticErrorSimplification
  71239. * @param _mesh defines the target mesh
  71240. */
  71241. constructor(_mesh: Mesh);
  71242. /**
  71243. * Simplification of a given mesh according to the given settings.
  71244. * Since this requires computation, it is assumed that the function runs async.
  71245. * @param settings The settings of the simplification, including quality and distance
  71246. * @param successCallback A callback that will be called after the mesh was simplified.
  71247. */
  71248. simplify(settings: ISimplificationSettings, successCallback: (simplifiedMesh: Mesh) => void): void;
  71249. private runDecimation;
  71250. private initWithMesh;
  71251. private init;
  71252. private reconstructMesh;
  71253. private initDecimatedMesh;
  71254. private isFlipped;
  71255. private updateTriangles;
  71256. private identifyBorder;
  71257. private updateMesh;
  71258. private vertexError;
  71259. private calculateError;
  71260. }
  71261. }
  71262. declare module BABYLON {
  71263. interface Scene {
  71264. /** @hidden (Backing field) */
  71265. _simplificationQueue: SimplificationQueue;
  71266. /**
  71267. * Gets or sets the simplification queue attached to the scene
  71268. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  71269. */
  71270. simplificationQueue: SimplificationQueue;
  71271. }
  71272. interface Mesh {
  71273. /**
  71274. * Simplify the mesh according to the given array of settings.
  71275. * Function will return immediately and will simplify async
  71276. * @param settings a collection of simplification settings
  71277. * @param parallelProcessing should all levels calculate parallel or one after the other
  71278. * @param simplificationType the type of simplification to run
  71279. * @param successCallback optional success callback to be called after the simplification finished processing all settings
  71280. * @returns the current mesh
  71281. */
  71282. simplify(settings: Array<ISimplificationSettings>, parallelProcessing?: boolean, simplificationType?: SimplificationType, successCallback?: (mesh?: Mesh, submeshIndex?: number) => void): Mesh;
  71283. }
  71284. /**
  71285. * Defines the simplification queue scene component responsible to help scheduling the various simplification task
  71286. * created in a scene
  71287. */
  71288. export class SimplicationQueueSceneComponent implements ISceneComponent {
  71289. /**
  71290. * The component name helpfull to identify the component in the list of scene components.
  71291. */
  71292. readonly name: string;
  71293. /**
  71294. * The scene the component belongs to.
  71295. */
  71296. scene: Scene;
  71297. /**
  71298. * Creates a new instance of the component for the given scene
  71299. * @param scene Defines the scene to register the component in
  71300. */
  71301. constructor(scene: Scene);
  71302. /**
  71303. * Registers the component in a given scene
  71304. */
  71305. register(): void;
  71306. /**
  71307. * Rebuilds the elements related to this component in case of
  71308. * context lost for instance.
  71309. */
  71310. rebuild(): void;
  71311. /**
  71312. * Disposes the component and the associated resources
  71313. */
  71314. dispose(): void;
  71315. private _beforeCameraUpdate;
  71316. }
  71317. }
  71318. declare module BABYLON {
  71319. interface Mesh {
  71320. /**
  71321. * Gets or sets a boolean defining if we want picking to pick thin instances as well
  71322. */
  71323. thinInstanceEnablePicking: boolean;
  71324. /**
  71325. * Creates a new thin instance
  71326. * @param matrix the matrix or array of matrices (position, rotation, scale) of the thin instance(s) to create
  71327. * @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
  71328. * @returns the thin instance index number. If you pass an array of matrices, other instance indexes are index+1, index+2, etc
  71329. */
  71330. thinInstanceAdd(matrix: DeepImmutableObject<Matrix> | Array<DeepImmutableObject<Matrix>>, refresh: boolean): number;
  71331. /**
  71332. * Adds the transformation (matrix) of the current mesh as a thin instance
  71333. * @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
  71334. * @returns the thin instance index number
  71335. */
  71336. thinInstanceAddSelf(refresh: boolean): number;
  71337. /**
  71338. * Registers a custom attribute to be used with thin instances
  71339. * @param kind name of the attribute
  71340. * @param stride size in floats of the attribute
  71341. */
  71342. thinInstanceRegisterAttribute(kind: string, stride: number): void;
  71343. /**
  71344. * Sets the matrix of a thin instance
  71345. * @param index index of the thin instance
  71346. * @param matrix matrix to set
  71347. * @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
  71348. */
  71349. thinInstanceSetMatrixAt(index: number, matrix: DeepImmutableObject<Matrix>, refresh: boolean): void;
  71350. /**
  71351. * Sets the value of a custom attribute for a thin instance
  71352. * @param kind name of the attribute
  71353. * @param index index of the thin instance
  71354. * @param value value to set
  71355. * @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
  71356. */
  71357. thinInstanceSetAttributeAt(kind: string, index: number, value: Array<number>, refresh: boolean): void;
  71358. /**
  71359. * 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.
  71360. */
  71361. thinInstanceCount: number;
  71362. /**
  71363. * Sets a buffer to be used with thin instances. This method is a faster way to setup multiple instances than calling thinInstanceAdd repeatedly
  71364. * @param kind name of the attribute. Use "matrix" to setup the buffer of matrices
  71365. * @param buffer buffer to set
  71366. * @param stride size in floats of each value of the buffer
  71367. * @param staticBuffer indicates that the buffer is static, so that you won't change it after it is set (better performances - false by default)
  71368. */
  71369. thinInstanceSetBuffer(kind: string, buffer: Nullable<Float32Array>, stride: number, staticBuffer: boolean): void;
  71370. /**
  71371. * Gets the list of world matrices
  71372. * @return an array containing all the world matrices from the thin instances
  71373. */
  71374. thinInstanceGetWorldMatrices(): Matrix[];
  71375. /**
  71376. * Synchronize the gpu buffers with a thin instance buffer. Call this method if you update later on the buffers passed to thinInstanceSetBuffer
  71377. * @param kind name of the attribute to update. Use "matrix" to update the buffer of matrices
  71378. */
  71379. thinInstanceBufferUpdated(kind: string): void;
  71380. /**
  71381. * Applies a partial update to a buffer directly on the GPU
  71382. * 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
  71383. * @param kind name of the attribute to update. Use "matrix" to update the buffer of matrices
  71384. * @param data the data to set in the GPU buffer
  71385. * @param offset the offset in the GPU buffer where to update the data
  71386. */
  71387. thinInstancePartialBufferUpdate(kind: string, data: Float32Array, offset: number): void;
  71388. /**
  71389. * Refreshes the bounding info, taking into account all the thin instances defined
  71390. * @param forceRefreshParentInfo true to force recomputing the mesh bounding info and use it to compute the aggregated bounding info
  71391. */
  71392. thinInstanceRefreshBoundingInfo(forceRefreshParentInfo: boolean): void;
  71393. /** @hidden */
  71394. _thinInstanceInitializeUserStorage(): void;
  71395. /** @hidden */
  71396. _thinInstanceUpdateBufferSize(kind: string, numInstances: number): void;
  71397. /** @hidden */
  71398. _userThinInstanceBuffersStorage: {
  71399. data: {
  71400. [key: string]: Float32Array;
  71401. };
  71402. sizes: {
  71403. [key: string]: number;
  71404. };
  71405. vertexBuffers: {
  71406. [key: string]: Nullable<VertexBuffer>;
  71407. };
  71408. strides: {
  71409. [key: string]: number;
  71410. };
  71411. };
  71412. }
  71413. }
  71414. declare module BABYLON {
  71415. /**
  71416. * Navigation plugin interface to add navigation constrained by a navigation mesh
  71417. */
  71418. export interface INavigationEnginePlugin {
  71419. /**
  71420. * plugin name
  71421. */
  71422. name: string;
  71423. /**
  71424. * Creates a navigation mesh
  71425. * @param meshes array of all the geometry used to compute the navigation mesh
  71426. * @param parameters bunch of parameters used to filter geometry
  71427. */
  71428. createNavMesh(meshes: Array<Mesh>, parameters: INavMeshParameters): void;
  71429. /**
  71430. * Create a navigation mesh debug mesh
  71431. * @param scene is where the mesh will be added
  71432. * @returns debug display mesh
  71433. */
  71434. createDebugNavMesh(scene: Scene): Mesh;
  71435. /**
  71436. * Get a navigation mesh constrained position, closest to the parameter position
  71437. * @param position world position
  71438. * @returns the closest point to position constrained by the navigation mesh
  71439. */
  71440. getClosestPoint(position: Vector3): Vector3;
  71441. /**
  71442. * Get a navigation mesh constrained position, closest to the parameter position
  71443. * @param position world position
  71444. * @param result output the closest point to position constrained by the navigation mesh
  71445. */
  71446. getClosestPointToRef(position: Vector3, result: Vector3): void;
  71447. /**
  71448. * Get a navigation mesh constrained position, within a particular radius
  71449. * @param position world position
  71450. * @param maxRadius the maximum distance to the constrained world position
  71451. * @returns the closest point to position constrained by the navigation mesh
  71452. */
  71453. getRandomPointAround(position: Vector3, maxRadius: number): Vector3;
  71454. /**
  71455. * Get a navigation mesh constrained position, within a particular radius
  71456. * @param position world position
  71457. * @param maxRadius the maximum distance to the constrained world position
  71458. * @param result output the closest point to position constrained by the navigation mesh
  71459. */
  71460. getRandomPointAroundToRef(position: Vector3, maxRadius: number, result: Vector3): void;
  71461. /**
  71462. * Compute the final position from a segment made of destination-position
  71463. * @param position world position
  71464. * @param destination world position
  71465. * @returns the resulting point along the navmesh
  71466. */
  71467. moveAlong(position: Vector3, destination: Vector3): Vector3;
  71468. /**
  71469. * Compute the final position from a segment made of destination-position
  71470. * @param position world position
  71471. * @param destination world position
  71472. * @param result output the resulting point along the navmesh
  71473. */
  71474. moveAlongToRef(position: Vector3, destination: Vector3, result: Vector3): void;
  71475. /**
  71476. * Compute a navigation path from start to end. Returns an empty array if no path can be computed
  71477. * @param start world position
  71478. * @param end world position
  71479. * @returns array containing world position composing the path
  71480. */
  71481. computePath(start: Vector3, end: Vector3): Vector3[];
  71482. /**
  71483. * If this plugin is supported
  71484. * @returns true if plugin is supported
  71485. */
  71486. isSupported(): boolean;
  71487. /**
  71488. * Create a new Crowd so you can add agents
  71489. * @param maxAgents the maximum agent count in the crowd
  71490. * @param maxAgentRadius the maximum radius an agent can have
  71491. * @param scene to attach the crowd to
  71492. * @returns the crowd you can add agents to
  71493. */
  71494. createCrowd(maxAgents: number, maxAgentRadius: number, scene: Scene): ICrowd;
  71495. /**
  71496. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  71497. * The queries will try to find a solution within those bounds
  71498. * default is (1,1,1)
  71499. * @param extent x,y,z value that define the extent around the queries point of reference
  71500. */
  71501. setDefaultQueryExtent(extent: Vector3): void;
  71502. /**
  71503. * Get the Bounding box extent specified by setDefaultQueryExtent
  71504. * @returns the box extent values
  71505. */
  71506. getDefaultQueryExtent(): Vector3;
  71507. /**
  71508. * build the navmesh from a previously saved state using getNavmeshData
  71509. * @param data the Uint8Array returned by getNavmeshData
  71510. */
  71511. buildFromNavmeshData(data: Uint8Array): void;
  71512. /**
  71513. * returns the navmesh data that can be used later. The navmesh must be built before retrieving the data
  71514. * @returns data the Uint8Array that can be saved and reused
  71515. */
  71516. getNavmeshData(): Uint8Array;
  71517. /**
  71518. * Get the Bounding box extent result specified by setDefaultQueryExtent
  71519. * @param result output the box extent values
  71520. */
  71521. getDefaultQueryExtentToRef(result: Vector3): void;
  71522. /**
  71523. * Set the time step of the navigation tick update.
  71524. * Default is 1/60.
  71525. * A value of 0 will disable fixed time update
  71526. * @param newTimeStep the new timestep to apply to this world.
  71527. */
  71528. setTimeStep(newTimeStep: number): void;
  71529. /**
  71530. * Get the time step of the navigation tick update.
  71531. * @returns the current time step
  71532. */
  71533. getTimeStep(): number;
  71534. /**
  71535. * If delta time in navigation tick update is greater than the time step
  71536. * a number of sub iterations are done. If more iterations are need to reach deltatime
  71537. * they will be discarded.
  71538. * A value of 0 will set to no maximum and update will use as many substeps as needed
  71539. * @param newStepCount the maximum number of iterations
  71540. */
  71541. setMaximumSubStepCount(newStepCount: number): void;
  71542. /**
  71543. * Get the maximum number of iterations per navigation tick update
  71544. * @returns the maximum number of iterations
  71545. */
  71546. getMaximumSubStepCount(): number;
  71547. /**
  71548. * Release all resources
  71549. */
  71550. dispose(): void;
  71551. }
  71552. /**
  71553. * Crowd Interface. A Crowd is a collection of moving agents constrained by a navigation mesh
  71554. */
  71555. export interface ICrowd {
  71556. /**
  71557. * Add a new agent to the crowd with the specified parameter a corresponding transformNode.
  71558. * You can attach anything to that node. The node position is updated in the scene update tick.
  71559. * @param pos world position that will be constrained by the navigation mesh
  71560. * @param parameters agent parameters
  71561. * @param transform hooked to the agent that will be update by the scene
  71562. * @returns agent index
  71563. */
  71564. addAgent(pos: Vector3, parameters: IAgentParameters, transform: TransformNode): number;
  71565. /**
  71566. * Returns the agent position in world space
  71567. * @param index agent index returned by addAgent
  71568. * @returns world space position
  71569. */
  71570. getAgentPosition(index: number): Vector3;
  71571. /**
  71572. * Gets the agent position result in world space
  71573. * @param index agent index returned by addAgent
  71574. * @param result output world space position
  71575. */
  71576. getAgentPositionToRef(index: number, result: Vector3): void;
  71577. /**
  71578. * Gets the agent velocity in world space
  71579. * @param index agent index returned by addAgent
  71580. * @returns world space velocity
  71581. */
  71582. getAgentVelocity(index: number): Vector3;
  71583. /**
  71584. * Gets the agent velocity result in world space
  71585. * @param index agent index returned by addAgent
  71586. * @param result output world space velocity
  71587. */
  71588. getAgentVelocityToRef(index: number, result: Vector3): void;
  71589. /**
  71590. * Gets the agent next target point on the path
  71591. * @param index agent index returned by addAgent
  71592. * @returns world space position
  71593. */
  71594. getAgentNextTargetPath(index: number): Vector3;
  71595. /**
  71596. * Gets the agent state
  71597. * @param index agent index returned by addAgent
  71598. * @returns agent state
  71599. */
  71600. getAgentState(index: number): number;
  71601. /**
  71602. * returns true if the agent in over an off mesh link connection
  71603. * @param index agent index returned by addAgent
  71604. * @returns true if over an off mesh link connection
  71605. */
  71606. overOffmeshConnection(index: number): boolean;
  71607. /**
  71608. * Gets the agent next target point on the path
  71609. * @param index agent index returned by addAgent
  71610. * @param result output world space position
  71611. */
  71612. getAgentNextTargetPathToRef(index: number, result: Vector3): void;
  71613. /**
  71614. * remove a particular agent previously created
  71615. * @param index agent index returned by addAgent
  71616. */
  71617. removeAgent(index: number): void;
  71618. /**
  71619. * get the list of all agents attached to this crowd
  71620. * @returns list of agent indices
  71621. */
  71622. getAgents(): number[];
  71623. /**
  71624. * Tick update done by the Scene. Agent position/velocity/acceleration is updated by this function
  71625. * @param deltaTime in seconds
  71626. */
  71627. update(deltaTime: number): void;
  71628. /**
  71629. * Asks a particular agent to go to a destination. That destination is constrained by the navigation mesh
  71630. * @param index agent index returned by addAgent
  71631. * @param destination targeted world position
  71632. */
  71633. agentGoto(index: number, destination: Vector3): void;
  71634. /**
  71635. * Teleport the agent to a new position
  71636. * @param index agent index returned by addAgent
  71637. * @param destination targeted world position
  71638. */
  71639. agentTeleport(index: number, destination: Vector3): void;
  71640. /**
  71641. * Update agent parameters
  71642. * @param index agent index returned by addAgent
  71643. * @param parameters agent parameters
  71644. */
  71645. updateAgentParameters(index: number, parameters: IAgentParameters): void;
  71646. /**
  71647. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  71648. * The queries will try to find a solution within those bounds
  71649. * default is (1,1,1)
  71650. * @param extent x,y,z value that define the extent around the queries point of reference
  71651. */
  71652. setDefaultQueryExtent(extent: Vector3): void;
  71653. /**
  71654. * Get the Bounding box extent specified by setDefaultQueryExtent
  71655. * @returns the box extent values
  71656. */
  71657. getDefaultQueryExtent(): Vector3;
  71658. /**
  71659. * Get the Bounding box extent result specified by setDefaultQueryExtent
  71660. * @param result output the box extent values
  71661. */
  71662. getDefaultQueryExtentToRef(result: Vector3): void;
  71663. /**
  71664. * Release all resources
  71665. */
  71666. dispose(): void;
  71667. }
  71668. /**
  71669. * Configures an agent
  71670. */
  71671. export interface IAgentParameters {
  71672. /**
  71673. * Agent radius. [Limit: >= 0]
  71674. */
  71675. radius: number;
  71676. /**
  71677. * Agent height. [Limit: > 0]
  71678. */
  71679. height: number;
  71680. /**
  71681. * Maximum allowed acceleration. [Limit: >= 0]
  71682. */
  71683. maxAcceleration: number;
  71684. /**
  71685. * Maximum allowed speed. [Limit: >= 0]
  71686. */
  71687. maxSpeed: number;
  71688. /**
  71689. * Defines how close a collision element must be before it is considered for steering behaviors. [Limits: > 0]
  71690. */
  71691. collisionQueryRange: number;
  71692. /**
  71693. * The path visibility optimization range. [Limit: > 0]
  71694. */
  71695. pathOptimizationRange: number;
  71696. /**
  71697. * How aggressive the agent manager should be at avoiding collisions with this agent. [Limit: >= 0]
  71698. */
  71699. separationWeight: number;
  71700. }
  71701. /**
  71702. * Configures the navigation mesh creation
  71703. */
  71704. export interface INavMeshParameters {
  71705. /**
  71706. * The xz-plane cell size to use for fields. [Limit: > 0] [Units: wu]
  71707. */
  71708. cs: number;
  71709. /**
  71710. * The y-axis cell size to use for fields. [Limit: > 0] [Units: wu]
  71711. */
  71712. ch: number;
  71713. /**
  71714. * The maximum slope that is considered walkable. [Limits: 0 <= value < 90] [Units: Degrees]
  71715. */
  71716. walkableSlopeAngle: number;
  71717. /**
  71718. * Minimum floor to 'ceiling' height that will still allow the floor area to
  71719. * be considered walkable. [Limit: >= 3] [Units: vx]
  71720. */
  71721. walkableHeight: number;
  71722. /**
  71723. * Maximum ledge height that is considered to still be traversable. [Limit: >=0] [Units: vx]
  71724. */
  71725. walkableClimb: number;
  71726. /**
  71727. * The distance to erode/shrink the walkable area of the heightfield away from
  71728. * obstructions. [Limit: >=0] [Units: vx]
  71729. */
  71730. walkableRadius: number;
  71731. /**
  71732. * The maximum allowed length for contour edges along the border of the mesh. [Limit: >=0] [Units: vx]
  71733. */
  71734. maxEdgeLen: number;
  71735. /**
  71736. * The maximum distance a simplified contour's border edges should deviate
  71737. * the original raw contour. [Limit: >=0] [Units: vx]
  71738. */
  71739. maxSimplificationError: number;
  71740. /**
  71741. * The minimum number of cells allowed to form isolated island areas. [Limit: >=0] [Units: vx]
  71742. */
  71743. minRegionArea: number;
  71744. /**
  71745. * Any regions with a span count smaller than this value will, if possible,
  71746. * be merged with larger regions. [Limit: >=0] [Units: vx]
  71747. */
  71748. mergeRegionArea: number;
  71749. /**
  71750. * The maximum number of vertices allowed for polygons generated during the
  71751. * contour to polygon conversion process. [Limit: >= 3]
  71752. */
  71753. maxVertsPerPoly: number;
  71754. /**
  71755. * Sets the sampling distance to use when generating the detail mesh.
  71756. * (For height detail only.) [Limits: 0 or >= 0.9] [Units: wu]
  71757. */
  71758. detailSampleDist: number;
  71759. /**
  71760. * The maximum distance the detail mesh surface should deviate from heightfield
  71761. * data. (For height detail only.) [Limit: >=0] [Units: wu]
  71762. */
  71763. detailSampleMaxError: number;
  71764. }
  71765. }
  71766. declare module BABYLON {
  71767. /**
  71768. * RecastJS navigation plugin
  71769. */
  71770. export class RecastJSPlugin implements INavigationEnginePlugin {
  71771. /**
  71772. * Reference to the Recast library
  71773. */
  71774. bjsRECAST: any;
  71775. /**
  71776. * plugin name
  71777. */
  71778. name: string;
  71779. /**
  71780. * the first navmesh created. We might extend this to support multiple navmeshes
  71781. */
  71782. navMesh: any;
  71783. private _maximumSubStepCount;
  71784. private _timeStep;
  71785. /**
  71786. * Initializes the recastJS plugin
  71787. * @param recastInjection can be used to inject your own recast reference
  71788. */
  71789. constructor(recastInjection?: any);
  71790. /**
  71791. * Set the time step of the navigation tick update.
  71792. * Default is 1/60.
  71793. * A value of 0 will disable fixed time update
  71794. * @param newTimeStep the new timestep to apply to this world.
  71795. */
  71796. setTimeStep(newTimeStep?: number): void;
  71797. /**
  71798. * Get the time step of the navigation tick update.
  71799. * @returns the current time step
  71800. */
  71801. getTimeStep(): number;
  71802. /**
  71803. * If delta time in navigation tick update is greater than the time step
  71804. * a number of sub iterations are done. If more iterations are need to reach deltatime
  71805. * they will be discarded.
  71806. * A value of 0 will set to no maximum and update will use as many substeps as needed
  71807. * @param newStepCount the maximum number of iterations
  71808. */
  71809. setMaximumSubStepCount(newStepCount?: number): void;
  71810. /**
  71811. * Get the maximum number of iterations per navigation tick update
  71812. * @returns the maximum number of iterations
  71813. */
  71814. getMaximumSubStepCount(): number;
  71815. /**
  71816. * Creates a navigation mesh
  71817. * @param meshes array of all the geometry used to compute the navigation mesh
  71818. * @param parameters bunch of parameters used to filter geometry
  71819. */
  71820. createNavMesh(meshes: Array<Mesh>, parameters: INavMeshParameters): void;
  71821. /**
  71822. * Create a navigation mesh debug mesh
  71823. * @param scene is where the mesh will be added
  71824. * @returns debug display mesh
  71825. */
  71826. createDebugNavMesh(scene: Scene): Mesh;
  71827. /**
  71828. * Get a navigation mesh constrained position, closest to the parameter position
  71829. * @param position world position
  71830. * @returns the closest point to position constrained by the navigation mesh
  71831. */
  71832. getClosestPoint(position: Vector3): Vector3;
  71833. /**
  71834. * Get a navigation mesh constrained position, closest to the parameter position
  71835. * @param position world position
  71836. * @param result output the closest point to position constrained by the navigation mesh
  71837. */
  71838. getClosestPointToRef(position: Vector3, result: Vector3): void;
  71839. /**
  71840. * Get a navigation mesh constrained position, within a particular radius
  71841. * @param position world position
  71842. * @param maxRadius the maximum distance to the constrained world position
  71843. * @returns the closest point to position constrained by the navigation mesh
  71844. */
  71845. getRandomPointAround(position: Vector3, maxRadius: number): Vector3;
  71846. /**
  71847. * Get a navigation mesh constrained position, within a particular radius
  71848. * @param position world position
  71849. * @param maxRadius the maximum distance to the constrained world position
  71850. * @param result output the closest point to position constrained by the navigation mesh
  71851. */
  71852. getRandomPointAroundToRef(position: Vector3, maxRadius: number, result: Vector3): void;
  71853. /**
  71854. * Compute the final position from a segment made of destination-position
  71855. * @param position world position
  71856. * @param destination world position
  71857. * @returns the resulting point along the navmesh
  71858. */
  71859. moveAlong(position: Vector3, destination: Vector3): Vector3;
  71860. /**
  71861. * Compute the final position from a segment made of destination-position
  71862. * @param position world position
  71863. * @param destination world position
  71864. * @param result output the resulting point along the navmesh
  71865. */
  71866. moveAlongToRef(position: Vector3, destination: Vector3, result: Vector3): void;
  71867. /**
  71868. * Compute a navigation path from start to end. Returns an empty array if no path can be computed
  71869. * @param start world position
  71870. * @param end world position
  71871. * @returns array containing world position composing the path
  71872. */
  71873. computePath(start: Vector3, end: Vector3): Vector3[];
  71874. /**
  71875. * Create a new Crowd so you can add agents
  71876. * @param maxAgents the maximum agent count in the crowd
  71877. * @param maxAgentRadius the maximum radius an agent can have
  71878. * @param scene to attach the crowd to
  71879. * @returns the crowd you can add agents to
  71880. */
  71881. createCrowd(maxAgents: number, maxAgentRadius: number, scene: Scene): ICrowd;
  71882. /**
  71883. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  71884. * The queries will try to find a solution within those bounds
  71885. * default is (1,1,1)
  71886. * @param extent x,y,z value that define the extent around the queries point of reference
  71887. */
  71888. setDefaultQueryExtent(extent: Vector3): void;
  71889. /**
  71890. * Get the Bounding box extent specified by setDefaultQueryExtent
  71891. * @returns the box extent values
  71892. */
  71893. getDefaultQueryExtent(): Vector3;
  71894. /**
  71895. * build the navmesh from a previously saved state using getNavmeshData
  71896. * @param data the Uint8Array returned by getNavmeshData
  71897. */
  71898. buildFromNavmeshData(data: Uint8Array): void;
  71899. /**
  71900. * returns the navmesh data that can be used later. The navmesh must be built before retrieving the data
  71901. * @returns data the Uint8Array that can be saved and reused
  71902. */
  71903. getNavmeshData(): Uint8Array;
  71904. /**
  71905. * Get the Bounding box extent result specified by setDefaultQueryExtent
  71906. * @param result output the box extent values
  71907. */
  71908. getDefaultQueryExtentToRef(result: Vector3): void;
  71909. /**
  71910. * Disposes
  71911. */
  71912. dispose(): void;
  71913. /**
  71914. * If this plugin is supported
  71915. * @returns true if plugin is supported
  71916. */
  71917. isSupported(): boolean;
  71918. }
  71919. /**
  71920. * Recast detour crowd implementation
  71921. */
  71922. export class RecastJSCrowd implements ICrowd {
  71923. /**
  71924. * Recast/detour plugin
  71925. */
  71926. bjsRECASTPlugin: RecastJSPlugin;
  71927. /**
  71928. * Link to the detour crowd
  71929. */
  71930. recastCrowd: any;
  71931. /**
  71932. * One transform per agent
  71933. */
  71934. transforms: TransformNode[];
  71935. /**
  71936. * All agents created
  71937. */
  71938. agents: number[];
  71939. /**
  71940. * Link to the scene is kept to unregister the crowd from the scene
  71941. */
  71942. private _scene;
  71943. /**
  71944. * Observer for crowd updates
  71945. */
  71946. private _onBeforeAnimationsObserver;
  71947. /**
  71948. * Constructor
  71949. * @param plugin recastJS plugin
  71950. * @param maxAgents the maximum agent count in the crowd
  71951. * @param maxAgentRadius the maximum radius an agent can have
  71952. * @param scene to attach the crowd to
  71953. * @returns the crowd you can add agents to
  71954. */
  71955. constructor(plugin: RecastJSPlugin, maxAgents: number, maxAgentRadius: number, scene: Scene);
  71956. /**
  71957. * Add a new agent to the crowd with the specified parameter a corresponding transformNode.
  71958. * You can attach anything to that node. The node position is updated in the scene update tick.
  71959. * @param pos world position that will be constrained by the navigation mesh
  71960. * @param parameters agent parameters
  71961. * @param transform hooked to the agent that will be update by the scene
  71962. * @returns agent index
  71963. */
  71964. addAgent(pos: Vector3, parameters: IAgentParameters, transform: TransformNode): number;
  71965. /**
  71966. * Returns the agent position in world space
  71967. * @param index agent index returned by addAgent
  71968. * @returns world space position
  71969. */
  71970. getAgentPosition(index: number): Vector3;
  71971. /**
  71972. * Returns the agent position result in world space
  71973. * @param index agent index returned by addAgent
  71974. * @param result output world space position
  71975. */
  71976. getAgentPositionToRef(index: number, result: Vector3): void;
  71977. /**
  71978. * Returns the agent velocity in world space
  71979. * @param index agent index returned by addAgent
  71980. * @returns world space velocity
  71981. */
  71982. getAgentVelocity(index: number): Vector3;
  71983. /**
  71984. * Returns the agent velocity result in world space
  71985. * @param index agent index returned by addAgent
  71986. * @param result output world space velocity
  71987. */
  71988. getAgentVelocityToRef(index: number, result: Vector3): void;
  71989. /**
  71990. * Returns the agent next target point on the path
  71991. * @param index agent index returned by addAgent
  71992. * @returns world space position
  71993. */
  71994. getAgentNextTargetPath(index: number): Vector3;
  71995. /**
  71996. * Returns the agent next target point on the path
  71997. * @param index agent index returned by addAgent
  71998. * @param result output world space position
  71999. */
  72000. getAgentNextTargetPathToRef(index: number, result: Vector3): void;
  72001. /**
  72002. * Gets the agent state
  72003. * @param index agent index returned by addAgent
  72004. * @returns agent state
  72005. */
  72006. getAgentState(index: number): number;
  72007. /**
  72008. * returns true if the agent in over an off mesh link connection
  72009. * @param index agent index returned by addAgent
  72010. * @returns true if over an off mesh link connection
  72011. */
  72012. overOffmeshConnection(index: number): boolean;
  72013. /**
  72014. * Asks a particular agent to go to a destination. That destination is constrained by the navigation mesh
  72015. * @param index agent index returned by addAgent
  72016. * @param destination targeted world position
  72017. */
  72018. agentGoto(index: number, destination: Vector3): void;
  72019. /**
  72020. * Teleport the agent to a new position
  72021. * @param index agent index returned by addAgent
  72022. * @param destination targeted world position
  72023. */
  72024. agentTeleport(index: number, destination: Vector3): void;
  72025. /**
  72026. * Update agent parameters
  72027. * @param index agent index returned by addAgent
  72028. * @param parameters agent parameters
  72029. */
  72030. updateAgentParameters(index: number, parameters: IAgentParameters): void;
  72031. /**
  72032. * remove a particular agent previously created
  72033. * @param index agent index returned by addAgent
  72034. */
  72035. removeAgent(index: number): void;
  72036. /**
  72037. * get the list of all agents attached to this crowd
  72038. * @returns list of agent indices
  72039. */
  72040. getAgents(): number[];
  72041. /**
  72042. * Tick update done by the Scene. Agent position/velocity/acceleration is updated by this function
  72043. * @param deltaTime in seconds
  72044. */
  72045. update(deltaTime: number): void;
  72046. /**
  72047. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  72048. * The queries will try to find a solution within those bounds
  72049. * default is (1,1,1)
  72050. * @param extent x,y,z value that define the extent around the queries point of reference
  72051. */
  72052. setDefaultQueryExtent(extent: Vector3): void;
  72053. /**
  72054. * Get the Bounding box extent specified by setDefaultQueryExtent
  72055. * @returns the box extent values
  72056. */
  72057. getDefaultQueryExtent(): Vector3;
  72058. /**
  72059. * Get the Bounding box extent result specified by setDefaultQueryExtent
  72060. * @param result output the box extent values
  72061. */
  72062. getDefaultQueryExtentToRef(result: Vector3): void;
  72063. /**
  72064. * Release all resources
  72065. */
  72066. dispose(): void;
  72067. }
  72068. }
  72069. declare module BABYLON {
  72070. /**
  72071. * Class used to enable access to IndexedDB
  72072. * @see https://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  72073. */
  72074. export class Database implements IOfflineProvider {
  72075. private _callbackManifestChecked;
  72076. private _currentSceneUrl;
  72077. private _db;
  72078. private _enableSceneOffline;
  72079. private _enableTexturesOffline;
  72080. private _manifestVersionFound;
  72081. private _mustUpdateRessources;
  72082. private _hasReachedQuota;
  72083. private _isSupported;
  72084. private _idbFactory;
  72085. /** Gets a boolean indicating if the user agent supports blob storage (this value will be updated after creating the first Database object) */
  72086. private static IsUASupportingBlobStorage;
  72087. /**
  72088. * Gets a boolean indicating if Database storage is enabled (off by default)
  72089. */
  72090. static IDBStorageEnabled: boolean;
  72091. /**
  72092. * Gets a boolean indicating if scene must be saved in the database
  72093. */
  72094. get enableSceneOffline(): boolean;
  72095. /**
  72096. * Gets a boolean indicating if textures must be saved in the database
  72097. */
  72098. get enableTexturesOffline(): boolean;
  72099. /**
  72100. * Creates a new Database
  72101. * @param urlToScene defines the url to load the scene
  72102. * @param callbackManifestChecked defines the callback to use when manifest is checked
  72103. * @param disableManifestCheck defines a boolean indicating that we want to skip the manifest validation (it will be considered validated and up to date)
  72104. */
  72105. constructor(urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck?: boolean);
  72106. private static _ParseURL;
  72107. private static _ReturnFullUrlLocation;
  72108. private _checkManifestFile;
  72109. /**
  72110. * Open the database and make it available
  72111. * @param successCallback defines the callback to call on success
  72112. * @param errorCallback defines the callback to call on error
  72113. */
  72114. open(successCallback: () => void, errorCallback: () => void): void;
  72115. /**
  72116. * Loads an image from the database
  72117. * @param url defines the url to load from
  72118. * @param image defines the target DOM image
  72119. */
  72120. loadImage(url: string, image: HTMLImageElement): void;
  72121. private _loadImageFromDBAsync;
  72122. private _saveImageIntoDBAsync;
  72123. private _checkVersionFromDB;
  72124. private _loadVersionFromDBAsync;
  72125. private _saveVersionIntoDBAsync;
  72126. /**
  72127. * Loads a file from database
  72128. * @param url defines the URL to load from
  72129. * @param sceneLoaded defines a callback to call on success
  72130. * @param progressCallBack defines a callback to call when progress changed
  72131. * @param errorCallback defines a callback to call on error
  72132. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  72133. */
  72134. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  72135. private _loadFileAsync;
  72136. private _saveFileAsync;
  72137. /**
  72138. * Validates if xhr data is correct
  72139. * @param xhr defines the request to validate
  72140. * @param dataType defines the expected data type
  72141. * @returns true if data is correct
  72142. */
  72143. private static _ValidateXHRData;
  72144. }
  72145. }
  72146. declare module BABYLON {
  72147. /** @hidden */
  72148. export var gpuUpdateParticlesPixelShader: {
  72149. name: string;
  72150. shader: string;
  72151. };
  72152. }
  72153. declare module BABYLON {
  72154. /** @hidden */
  72155. export var gpuUpdateParticlesVertexShader: {
  72156. name: string;
  72157. shader: string;
  72158. };
  72159. }
  72160. declare module BABYLON {
  72161. /** @hidden */
  72162. export var clipPlaneFragmentDeclaration2: {
  72163. name: string;
  72164. shader: string;
  72165. };
  72166. }
  72167. declare module BABYLON {
  72168. /** @hidden */
  72169. export var gpuRenderParticlesPixelShader: {
  72170. name: string;
  72171. shader: string;
  72172. };
  72173. }
  72174. declare module BABYLON {
  72175. /** @hidden */
  72176. export var clipPlaneVertexDeclaration2: {
  72177. name: string;
  72178. shader: string;
  72179. };
  72180. }
  72181. declare module BABYLON {
  72182. /** @hidden */
  72183. export var gpuRenderParticlesVertexShader: {
  72184. name: string;
  72185. shader: string;
  72186. };
  72187. }
  72188. declare module BABYLON {
  72189. /**
  72190. * This represents a GPU particle system in Babylon
  72191. * This is the fastest particle system in Babylon as it uses the GPU to update the individual particle data
  72192. * @see https://www.babylonjs-playground.com/#PU4WYI#4
  72193. */
  72194. export class GPUParticleSystem extends BaseParticleSystem implements IDisposable, IParticleSystem, IAnimatable {
  72195. /**
  72196. * The layer mask we are rendering the particles through.
  72197. */
  72198. layerMask: number;
  72199. private _capacity;
  72200. private _activeCount;
  72201. private _currentActiveCount;
  72202. private _accumulatedCount;
  72203. private _renderEffect;
  72204. private _updateEffect;
  72205. private _buffer0;
  72206. private _buffer1;
  72207. private _spriteBuffer;
  72208. private _updateVAO;
  72209. private _renderVAO;
  72210. private _targetIndex;
  72211. private _sourceBuffer;
  72212. private _targetBuffer;
  72213. private _currentRenderId;
  72214. private _started;
  72215. private _stopped;
  72216. private _timeDelta;
  72217. private _randomTexture;
  72218. private _randomTexture2;
  72219. private _attributesStrideSize;
  72220. private _updateEffectOptions;
  72221. private _randomTextureSize;
  72222. private _actualFrame;
  72223. private _customEffect;
  72224. private readonly _rawTextureWidth;
  72225. /**
  72226. * Gets a boolean indicating if the GPU particles can be rendered on current browser
  72227. */
  72228. static get IsSupported(): boolean;
  72229. /**
  72230. * An event triggered when the system is disposed.
  72231. */
  72232. onDisposeObservable: Observable<IParticleSystem>;
  72233. /**
  72234. * An event triggered when the system is stopped
  72235. */
  72236. onStoppedObservable: Observable<IParticleSystem>;
  72237. /**
  72238. * Gets the maximum number of particles active at the same time.
  72239. * @returns The max number of active particles.
  72240. */
  72241. getCapacity(): number;
  72242. /**
  72243. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  72244. * to override the particles.
  72245. */
  72246. forceDepthWrite: boolean;
  72247. /**
  72248. * Gets or set the number of active particles
  72249. */
  72250. get activeParticleCount(): number;
  72251. set activeParticleCount(value: number);
  72252. private _preWarmDone;
  72253. /**
  72254. * Specifies if the particles are updated in emitter local space or world space.
  72255. */
  72256. isLocal: boolean;
  72257. /** Gets or sets a matrix to use to compute projection */
  72258. defaultProjectionMatrix: Matrix;
  72259. /**
  72260. * Is this system ready to be used/rendered
  72261. * @return true if the system is ready
  72262. */
  72263. isReady(): boolean;
  72264. /**
  72265. * Gets if the system has been started. (Note: this will still be true after stop is called)
  72266. * @returns True if it has been started, otherwise false.
  72267. */
  72268. isStarted(): boolean;
  72269. /**
  72270. * Gets if the system has been stopped. (Note: rendering is still happening but the system is frozen)
  72271. * @returns True if it has been stopped, otherwise false.
  72272. */
  72273. isStopped(): boolean;
  72274. /**
  72275. * Gets a boolean indicating that the system is stopping
  72276. * @returns true if the system is currently stopping
  72277. */
  72278. isStopping(): boolean;
  72279. /**
  72280. * Gets the number of particles active at the same time.
  72281. * @returns The number of active particles.
  72282. */
  72283. getActiveCount(): number;
  72284. /**
  72285. * Starts the particle system and begins to emit
  72286. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  72287. */
  72288. start(delay?: number): void;
  72289. /**
  72290. * Stops the particle system.
  72291. */
  72292. stop(): void;
  72293. /**
  72294. * Remove all active particles
  72295. */
  72296. reset(): void;
  72297. /**
  72298. * Returns the string "GPUParticleSystem"
  72299. * @returns a string containing the class name
  72300. */
  72301. getClassName(): string;
  72302. /**
  72303. * Gets the custom effect used to render the particles
  72304. * @param blendMode Blend mode for which the effect should be retrieved
  72305. * @returns The effect
  72306. */
  72307. getCustomEffect(blendMode?: number): Nullable<Effect>;
  72308. /**
  72309. * Sets the custom effect used to render the particles
  72310. * @param effect The effect to set
  72311. * @param blendMode Blend mode for which the effect should be set
  72312. */
  72313. setCustomEffect(effect: Nullable<Effect>, blendMode?: number): void;
  72314. /** @hidden */
  72315. protected _onBeforeDrawParticlesObservable: Nullable<Observable<Nullable<Effect>>>;
  72316. /**
  72317. * Observable that will be called just before the particles are drawn
  72318. */
  72319. get onBeforeDrawParticlesObservable(): Observable<Nullable<Effect>>;
  72320. /**
  72321. * Gets the name of the particle vertex shader
  72322. */
  72323. get vertexShaderName(): string;
  72324. private _colorGradientsTexture;
  72325. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: RawTexture): BaseParticleSystem;
  72326. /**
  72327. * Adds a new color gradient
  72328. * @param gradient defines the gradient to use (between 0 and 1)
  72329. * @param color1 defines the color to affect to the specified gradient
  72330. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  72331. * @returns the current particle system
  72332. */
  72333. addColorGradient(gradient: number, color1: Color4, color2?: Color4): GPUParticleSystem;
  72334. private _refreshColorGradient;
  72335. /** Force the system to rebuild all gradients that need to be resync */
  72336. forceRefreshGradients(): void;
  72337. /**
  72338. * Remove a specific color gradient
  72339. * @param gradient defines the gradient to remove
  72340. * @returns the current particle system
  72341. */
  72342. removeColorGradient(gradient: number): GPUParticleSystem;
  72343. private _angularSpeedGradientsTexture;
  72344. private _sizeGradientsTexture;
  72345. private _velocityGradientsTexture;
  72346. private _limitVelocityGradientsTexture;
  72347. private _dragGradientsTexture;
  72348. private _addFactorGradient;
  72349. /**
  72350. * Adds a new size gradient
  72351. * @param gradient defines the gradient to use (between 0 and 1)
  72352. * @param factor defines the size factor to affect to the specified gradient
  72353. * @returns the current particle system
  72354. */
  72355. addSizeGradient(gradient: number, factor: number): GPUParticleSystem;
  72356. /**
  72357. * Remove a specific size gradient
  72358. * @param gradient defines the gradient to remove
  72359. * @returns the current particle system
  72360. */
  72361. removeSizeGradient(gradient: number): GPUParticleSystem;
  72362. private _refreshFactorGradient;
  72363. /**
  72364. * Adds a new angular speed gradient
  72365. * @param gradient defines the gradient to use (between 0 and 1)
  72366. * @param factor defines the angular speed to affect to the specified gradient
  72367. * @returns the current particle system
  72368. */
  72369. addAngularSpeedGradient(gradient: number, factor: number): GPUParticleSystem;
  72370. /**
  72371. * Remove a specific angular speed gradient
  72372. * @param gradient defines the gradient to remove
  72373. * @returns the current particle system
  72374. */
  72375. removeAngularSpeedGradient(gradient: number): GPUParticleSystem;
  72376. /**
  72377. * Adds a new velocity gradient
  72378. * @param gradient defines the gradient to use (between 0 and 1)
  72379. * @param factor defines the velocity to affect to the specified gradient
  72380. * @returns the current particle system
  72381. */
  72382. addVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  72383. /**
  72384. * Remove a specific velocity gradient
  72385. * @param gradient defines the gradient to remove
  72386. * @returns the current particle system
  72387. */
  72388. removeVelocityGradient(gradient: number): GPUParticleSystem;
  72389. /**
  72390. * Adds a new limit velocity gradient
  72391. * @param gradient defines the gradient to use (between 0 and 1)
  72392. * @param factor defines the limit velocity value to affect to the specified gradient
  72393. * @returns the current particle system
  72394. */
  72395. addLimitVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  72396. /**
  72397. * Remove a specific limit velocity gradient
  72398. * @param gradient defines the gradient to remove
  72399. * @returns the current particle system
  72400. */
  72401. removeLimitVelocityGradient(gradient: number): GPUParticleSystem;
  72402. /**
  72403. * Adds a new drag gradient
  72404. * @param gradient defines the gradient to use (between 0 and 1)
  72405. * @param factor defines the drag value to affect to the specified gradient
  72406. * @returns the current particle system
  72407. */
  72408. addDragGradient(gradient: number, factor: number): GPUParticleSystem;
  72409. /**
  72410. * Remove a specific drag gradient
  72411. * @param gradient defines the gradient to remove
  72412. * @returns the current particle system
  72413. */
  72414. removeDragGradient(gradient: number): GPUParticleSystem;
  72415. /**
  72416. * Not supported by GPUParticleSystem
  72417. * @param gradient defines the gradient to use (between 0 and 1)
  72418. * @param factor defines the emit rate value to affect to the specified gradient
  72419. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  72420. * @returns the current particle system
  72421. */
  72422. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  72423. /**
  72424. * Not supported by GPUParticleSystem
  72425. * @param gradient defines the gradient to remove
  72426. * @returns the current particle system
  72427. */
  72428. removeEmitRateGradient(gradient: number): IParticleSystem;
  72429. /**
  72430. * Not supported by GPUParticleSystem
  72431. * @param gradient defines the gradient to use (between 0 and 1)
  72432. * @param factor defines the start size value to affect to the specified gradient
  72433. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  72434. * @returns the current particle system
  72435. */
  72436. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  72437. /**
  72438. * Not supported by GPUParticleSystem
  72439. * @param gradient defines the gradient to remove
  72440. * @returns the current particle system
  72441. */
  72442. removeStartSizeGradient(gradient: number): IParticleSystem;
  72443. /**
  72444. * Not supported by GPUParticleSystem
  72445. * @param gradient defines the gradient to use (between 0 and 1)
  72446. * @param min defines the color remap minimal range
  72447. * @param max defines the color remap maximal range
  72448. * @returns the current particle system
  72449. */
  72450. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  72451. /**
  72452. * Not supported by GPUParticleSystem
  72453. * @param gradient defines the gradient to remove
  72454. * @returns the current particle system
  72455. */
  72456. removeColorRemapGradient(): IParticleSystem;
  72457. /**
  72458. * Not supported by GPUParticleSystem
  72459. * @param gradient defines the gradient to use (between 0 and 1)
  72460. * @param min defines the alpha remap minimal range
  72461. * @param max defines the alpha remap maximal range
  72462. * @returns the current particle system
  72463. */
  72464. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  72465. /**
  72466. * Not supported by GPUParticleSystem
  72467. * @param gradient defines the gradient to remove
  72468. * @returns the current particle system
  72469. */
  72470. removeAlphaRemapGradient(): IParticleSystem;
  72471. /**
  72472. * Not supported by GPUParticleSystem
  72473. * @param gradient defines the gradient to use (between 0 and 1)
  72474. * @param color defines the color to affect to the specified gradient
  72475. * @returns the current particle system
  72476. */
  72477. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  72478. /**
  72479. * Not supported by GPUParticleSystem
  72480. * @param gradient defines the gradient to remove
  72481. * @returns the current particle system
  72482. */
  72483. removeRampGradient(): IParticleSystem;
  72484. /**
  72485. * Not supported by GPUParticleSystem
  72486. * @returns the list of ramp gradients
  72487. */
  72488. getRampGradients(): Nullable<Array<Color3Gradient>>;
  72489. /**
  72490. * Not supported by GPUParticleSystem
  72491. * Gets or sets a boolean indicating that ramp gradients must be used
  72492. * @see https://doc.babylonjs.com/babylon101/particles#ramp-gradients
  72493. */
  72494. get useRampGradients(): boolean;
  72495. set useRampGradients(value: boolean);
  72496. /**
  72497. * Not supported by GPUParticleSystem
  72498. * @param gradient defines the gradient to use (between 0 and 1)
  72499. * @param factor defines the life time factor to affect to the specified gradient
  72500. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  72501. * @returns the current particle system
  72502. */
  72503. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  72504. /**
  72505. * Not supported by GPUParticleSystem
  72506. * @param gradient defines the gradient to remove
  72507. * @returns the current particle system
  72508. */
  72509. removeLifeTimeGradient(gradient: number): IParticleSystem;
  72510. /**
  72511. * Instantiates a GPU particle system.
  72512. * 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.
  72513. * @param name The name of the particle system
  72514. * @param options The options used to create the system
  72515. * @param sceneOrEngine The scene the particle system belongs to or the engine to use if no scene
  72516. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  72517. * @param customEffect a custom effect used to change the way particles are rendered by default
  72518. */
  72519. constructor(name: string, options: Partial<{
  72520. capacity: number;
  72521. randomTextureSize: number;
  72522. }>, sceneOrEngine: Scene | ThinEngine, isAnimationSheetEnabled?: boolean, customEffect?: Nullable<Effect>);
  72523. protected _reset(): void;
  72524. private _createUpdateVAO;
  72525. private _createRenderVAO;
  72526. private _initialize;
  72527. /** @hidden */
  72528. _recreateUpdateEffect(): void;
  72529. private _getEffect;
  72530. /**
  72531. * Fill the defines array according to the current settings of the particle system
  72532. * @param defines Array to be updated
  72533. * @param blendMode blend mode to take into account when updating the array
  72534. */
  72535. fillDefines(defines: Array<string>, blendMode?: number): void;
  72536. /**
  72537. * Fill the uniforms, attributes and samplers arrays according to the current settings of the particle system
  72538. * @param uniforms Uniforms array to fill
  72539. * @param attributes Attributes array to fill
  72540. * @param samplers Samplers array to fill
  72541. */
  72542. fillUniformsAttributesAndSamplerNames(uniforms: Array<string>, attributes: Array<string>, samplers: Array<string>): void;
  72543. /** @hidden */
  72544. _recreateRenderEffect(): Effect;
  72545. /**
  72546. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  72547. * @param preWarm defines if we are in the pre-warmimg phase
  72548. */
  72549. animate(preWarm?: boolean): void;
  72550. private _createFactorGradientTexture;
  72551. private _createSizeGradientTexture;
  72552. private _createAngularSpeedGradientTexture;
  72553. private _createVelocityGradientTexture;
  72554. private _createLimitVelocityGradientTexture;
  72555. private _createDragGradientTexture;
  72556. private _createColorGradientTexture;
  72557. /**
  72558. * Renders the particle system in its current state
  72559. * @param preWarm defines if the system should only update the particles but not render them
  72560. * @returns the current number of particles
  72561. */
  72562. render(preWarm?: boolean): number;
  72563. /**
  72564. * Rebuilds the particle system
  72565. */
  72566. rebuild(): void;
  72567. private _releaseBuffers;
  72568. private _releaseVAOs;
  72569. /**
  72570. * Disposes the particle system and free the associated resources
  72571. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  72572. */
  72573. dispose(disposeTexture?: boolean): void;
  72574. /**
  72575. * Clones the particle system.
  72576. * @param name The name of the cloned object
  72577. * @param newEmitter The new emitter to use
  72578. * @returns the cloned particle system
  72579. */
  72580. clone(name: string, newEmitter: any): GPUParticleSystem;
  72581. /**
  72582. * Serializes the particle system to a JSON object
  72583. * @param serializeTexture defines if the texture must be serialized as well
  72584. * @returns the JSON object
  72585. */
  72586. serialize(serializeTexture?: boolean): any;
  72587. /**
  72588. * Parses a JSON object to create a GPU particle system.
  72589. * @param parsedParticleSystem The JSON object to parse
  72590. * @param sceneOrEngine The scene or the engine to create the particle system in
  72591. * @param rootUrl The root url to use to load external dependencies like texture
  72592. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  72593. * @returns the parsed GPU particle system
  72594. */
  72595. static Parse(parsedParticleSystem: any, sceneOrEngine: Scene | ThinEngine, rootUrl: string, doNotStart?: boolean): GPUParticleSystem;
  72596. }
  72597. }
  72598. declare module BABYLON {
  72599. /**
  72600. * Represents a set of particle systems working together to create a specific effect
  72601. */
  72602. export class ParticleSystemSet implements IDisposable {
  72603. /**
  72604. * Gets or sets base Assets URL
  72605. */
  72606. static BaseAssetsUrl: string;
  72607. private _emitterCreationOptions;
  72608. private _emitterNode;
  72609. /**
  72610. * Gets the particle system list
  72611. */
  72612. systems: IParticleSystem[];
  72613. /**
  72614. * Gets the emitter node used with this set
  72615. */
  72616. get emitterNode(): Nullable<TransformNode>;
  72617. /**
  72618. * Creates a new emitter mesh as a sphere
  72619. * @param options defines the options used to create the sphere
  72620. * @param renderingGroupId defines the renderingGroupId to use for the sphere
  72621. * @param scene defines the hosting scene
  72622. */
  72623. setEmitterAsSphere(options: {
  72624. diameter: number;
  72625. segments: number;
  72626. color: Color3;
  72627. }, renderingGroupId: number, scene: Scene): void;
  72628. /**
  72629. * Starts all particle systems of the set
  72630. * @param emitter defines an optional mesh to use as emitter for the particle systems
  72631. */
  72632. start(emitter?: AbstractMesh): void;
  72633. /**
  72634. * Release all associated resources
  72635. */
  72636. dispose(): void;
  72637. /**
  72638. * Serialize the set into a JSON compatible object
  72639. * @param serializeTexture defines if the texture must be serialized as well
  72640. * @returns a JSON compatible representation of the set
  72641. */
  72642. serialize(serializeTexture?: boolean): any;
  72643. /**
  72644. * Parse a new ParticleSystemSet from a serialized source
  72645. * @param data defines a JSON compatible representation of the set
  72646. * @param scene defines the hosting scene
  72647. * @param gpu defines if we want GPU particles or CPU particles
  72648. * @returns a new ParticleSystemSet
  72649. */
  72650. static Parse(data: any, scene: Scene, gpu?: boolean): ParticleSystemSet;
  72651. }
  72652. }
  72653. declare module BABYLON {
  72654. /**
  72655. * This class is made for on one-liner static method to help creating particle system set.
  72656. */
  72657. export class ParticleHelper {
  72658. /**
  72659. * Gets or sets base Assets URL
  72660. */
  72661. static BaseAssetsUrl: string;
  72662. /** Define the Url to load snippets */
  72663. static SnippetUrl: string;
  72664. /**
  72665. * Create a default particle system that you can tweak
  72666. * @param emitter defines the emitter to use
  72667. * @param capacity defines the system capacity (default is 500 particles)
  72668. * @param scene defines the hosting scene
  72669. * @param useGPU defines if a GPUParticleSystem must be created (default is false)
  72670. * @returns the new Particle system
  72671. */
  72672. static CreateDefault(emitter: Nullable<AbstractMesh | Vector3>, capacity?: number, scene?: Scene, useGPU?: boolean): IParticleSystem;
  72673. /**
  72674. * This is the main static method (one-liner) of this helper to create different particle systems
  72675. * @param type This string represents the type to the particle system to create
  72676. * @param scene The scene where the particle system should live
  72677. * @param gpu If the system will use gpu
  72678. * @returns the ParticleSystemSet created
  72679. */
  72680. static CreateAsync(type: string, scene: Nullable<Scene>, gpu?: boolean): Promise<ParticleSystemSet>;
  72681. /**
  72682. * Static function used to export a particle system to a ParticleSystemSet variable.
  72683. * Please note that the emitter shape is not exported
  72684. * @param systems defines the particle systems to export
  72685. * @returns the created particle system set
  72686. */
  72687. static ExportSet(systems: IParticleSystem[]): ParticleSystemSet;
  72688. /**
  72689. * Creates a particle system from a snippet saved in a remote file
  72690. * @param name defines the name of the particle system to create (can be null or empty to use the one from the json data)
  72691. * @param url defines the url to load from
  72692. * @param scene defines the hosting scene
  72693. * @param gpu If the system will use gpu
  72694. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  72695. * @returns a promise that will resolve to the new particle system
  72696. */
  72697. static ParseFromFileAsync(name: Nullable<string>, url: string, scene: Scene, gpu?: boolean, rootUrl?: string): Promise<IParticleSystem>;
  72698. /**
  72699. * Creates a particle system from a snippet saved by the particle system editor
  72700. * @param snippetId defines the snippet to load (can be set to _BLANK to create a default one)
  72701. * @param scene defines the hosting scene
  72702. * @param gpu If the system will use gpu
  72703. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  72704. * @returns a promise that will resolve to the new particle system
  72705. */
  72706. static CreateFromSnippetAsync(snippetId: string, scene: Scene, gpu?: boolean, rootUrl?: string): Promise<IParticleSystem>;
  72707. }
  72708. }
  72709. declare module BABYLON {
  72710. interface Engine {
  72711. /**
  72712. * Create an effect to use with particle systems.
  72713. * Please note that some parameters like animation sheets or not being billboard are not supported in this configuration, except if you pass
  72714. * the particle system for which you want to create a custom effect in the last parameter
  72715. * @param fragmentName defines the base name of the effect (The name of file without .fragment.fx)
  72716. * @param uniformsNames defines a list of attribute names
  72717. * @param samplers defines an array of string used to represent textures
  72718. * @param defines defines the string containing the defines to use to compile the shaders
  72719. * @param fallbacks defines the list of potential fallbacks to use if shader compilation fails
  72720. * @param onCompiled defines a function to call when the effect creation is successful
  72721. * @param onError defines a function to call when the effect creation has failed
  72722. * @param particleSystem the particle system you want to create the effect for
  72723. * @returns the new Effect
  72724. */
  72725. createEffectForParticles(fragmentName: string, uniformsNames: string[], samplers: string[], defines: string, fallbacks?: EffectFallbacks, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void, particleSystem?: IParticleSystem): Effect;
  72726. }
  72727. interface Mesh {
  72728. /**
  72729. * Returns an array populated with IParticleSystem objects whose the mesh is the emitter
  72730. * @returns an array of IParticleSystem
  72731. */
  72732. getEmittedParticleSystems(): IParticleSystem[];
  72733. /**
  72734. * Returns an array populated with IParticleSystem objects whose the mesh or its children are the emitter
  72735. * @returns an array of IParticleSystem
  72736. */
  72737. getHierarchyEmittedParticleSystems(): IParticleSystem[];
  72738. }
  72739. }
  72740. declare module BABYLON {
  72741. /** Defines the 4 color options */
  72742. export enum PointColor {
  72743. /** color value */
  72744. Color = 2,
  72745. /** uv value */
  72746. UV = 1,
  72747. /** random value */
  72748. Random = 0,
  72749. /** stated value */
  72750. Stated = 3
  72751. }
  72752. /**
  72753. * The PointCloudSystem (PCS) is a single updatable mesh. The points corresponding to the vertices of this big mesh.
  72754. * 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.
  72755. * The PointCloudSystem is also a particle system, with each point being a particle. It provides some methods to manage the particles.
  72756. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  72757. *
  72758. * Full documentation here : TO BE ENTERED
  72759. */
  72760. export class PointsCloudSystem implements IDisposable {
  72761. /**
  72762. * The PCS array of cloud point objects. Just access each particle as with any classic array.
  72763. * Example : var p = SPS.particles[i];
  72764. */
  72765. particles: CloudPoint[];
  72766. /**
  72767. * The PCS total number of particles. Read only. Use PCS.counter instead if you need to set your own value.
  72768. */
  72769. nbParticles: number;
  72770. /**
  72771. * This a counter for your own usage. It's not set by any SPS functions.
  72772. */
  72773. counter: number;
  72774. /**
  72775. * The PCS name. This name is also given to the underlying mesh.
  72776. */
  72777. name: string;
  72778. /**
  72779. * The PCS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are available.
  72780. */
  72781. mesh: Mesh;
  72782. /**
  72783. * This empty object is intended to store some PCS specific or temporary values in order to lower the Garbage Collector activity.
  72784. * Please read :
  72785. */
  72786. vars: any;
  72787. /**
  72788. * @hidden
  72789. */
  72790. _size: number;
  72791. private _scene;
  72792. private _promises;
  72793. private _positions;
  72794. private _indices;
  72795. private _normals;
  72796. private _colors;
  72797. private _uvs;
  72798. private _indices32;
  72799. private _positions32;
  72800. private _colors32;
  72801. private _uvs32;
  72802. private _updatable;
  72803. private _isVisibilityBoxLocked;
  72804. private _alwaysVisible;
  72805. private _groups;
  72806. private _groupCounter;
  72807. private _computeParticleColor;
  72808. private _computeParticleTexture;
  72809. private _computeParticleRotation;
  72810. private _computeBoundingBox;
  72811. private _isReady;
  72812. /**
  72813. * Creates a PCS (Points Cloud System) object
  72814. * @param name (String) is the PCS name, this will be the underlying mesh name
  72815. * @param pointSize (number) is the size for each point
  72816. * @param scene (Scene) is the scene in which the PCS is added
  72817. * @param options defines the options of the PCS e.g.
  72818. * * updatable (optional boolean, default true) : if the PCS must be updatable or immutable
  72819. */
  72820. constructor(name: string, pointSize: number, scene: Scene, options?: {
  72821. updatable?: boolean;
  72822. });
  72823. /**
  72824. * Builds the PCS underlying mesh. Returns a standard Mesh.
  72825. * If no points were added to the PCS, the returned mesh is just a single point.
  72826. * @returns a promise for the created mesh
  72827. */
  72828. buildMeshAsync(): Promise<Mesh>;
  72829. /**
  72830. * @hidden
  72831. */
  72832. private _buildMesh;
  72833. private _addParticle;
  72834. private _randomUnitVector;
  72835. private _getColorIndicesForCoord;
  72836. private _setPointsColorOrUV;
  72837. private _colorFromTexture;
  72838. private _calculateDensity;
  72839. /**
  72840. * Adds points to the PCS in random positions within a unit sphere
  72841. * @param nb (positive integer) the number of particles to be created from this model
  72842. * @param pointFunction is an optional javascript function to be called for each particle on PCS creation
  72843. * @returns the number of groups in the system
  72844. */
  72845. addPoints(nb: number, pointFunction?: any): number;
  72846. /**
  72847. * Adds points to the PCS from the surface of the model shape
  72848. * @param mesh is any Mesh object that will be used as a surface model for the points
  72849. * @param nb (positive integer) the number of particles to be created from this model
  72850. * @param colorWith determines whether a point is colored using color (default), uv, random, stated or none (invisible)
  72851. * @param color (color4) to be used when colorWith is stated or color (number) when used to specify texture position
  72852. * @param range (number from 0 to 1) to determine the variation in shape and tone for a stated color
  72853. * @returns the number of groups in the system
  72854. */
  72855. addSurfacePoints(mesh: Mesh, nb: number, colorWith?: number, color?: Color4 | number, range?: number): number;
  72856. /**
  72857. * Adds points to the PCS inside the model shape
  72858. * @param mesh is any Mesh object that will be used as a surface model for the points
  72859. * @param nb (positive integer) the number of particles to be created from this model
  72860. * @param colorWith determines whether a point is colored using color (default), uv, random, stated or none (invisible)
  72861. * @param color (color4) to be used when colorWith is stated or color (number) when used to specify texture position
  72862. * @param range (number from 0 to 1) to determine the variation in shape and tone for a stated color
  72863. * @returns the number of groups in the system
  72864. */
  72865. addVolumePoints(mesh: Mesh, nb: number, colorWith?: number, color?: Color4 | number, range?: number): number;
  72866. /**
  72867. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  72868. * This method calls `updateParticle()` for each particle of the SPS.
  72869. * For an animated SPS, it is usually called within the render loop.
  72870. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  72871. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  72872. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  72873. * @returns the PCS.
  72874. */
  72875. setParticles(start?: number, end?: number, update?: boolean): PointsCloudSystem;
  72876. /**
  72877. * Disposes the PCS.
  72878. */
  72879. dispose(): void;
  72880. /**
  72881. * Visibility helper : Recomputes the visible size according to the mesh bounding box
  72882. * doc :
  72883. * @returns the PCS.
  72884. */
  72885. refreshVisibleSize(): PointsCloudSystem;
  72886. /**
  72887. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  72888. * @param size the size (float) of the visibility box
  72889. * note : this doesn't lock the PCS mesh bounding box.
  72890. * doc :
  72891. */
  72892. setVisibilityBox(size: number): void;
  72893. /**
  72894. * Gets whether the PCS is always visible or not
  72895. * doc :
  72896. */
  72897. get isAlwaysVisible(): boolean;
  72898. /**
  72899. * Sets the PCS as always visible or not
  72900. * doc :
  72901. */
  72902. set isAlwaysVisible(val: boolean);
  72903. /**
  72904. * Tells to `setParticles()` to compute the particle rotations or not
  72905. * Default value : false. The PCS is faster when it's set to false
  72906. * Note : particle rotations are only applied to parent particles
  72907. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate
  72908. */
  72909. set computeParticleRotation(val: boolean);
  72910. /**
  72911. * Tells to `setParticles()` to compute the particle colors or not.
  72912. * Default value : true. The PCS is faster when it's set to false.
  72913. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  72914. */
  72915. set computeParticleColor(val: boolean);
  72916. set computeParticleTexture(val: boolean);
  72917. /**
  72918. * Gets if `setParticles()` computes the particle colors or not.
  72919. * Default value : false. The PCS is faster when it's set to false.
  72920. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  72921. */
  72922. get computeParticleColor(): boolean;
  72923. /**
  72924. * Gets if `setParticles()` computes the particle textures or not.
  72925. * Default value : false. The PCS is faster when it's set to false.
  72926. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  72927. */
  72928. get computeParticleTexture(): boolean;
  72929. /**
  72930. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  72931. */
  72932. set computeBoundingBox(val: boolean);
  72933. /**
  72934. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  72935. */
  72936. get computeBoundingBox(): boolean;
  72937. /**
  72938. * This function does nothing. It may be overwritten to set all the particle first values.
  72939. * The PCS doesn't call this function, you may have to call it by your own.
  72940. * doc :
  72941. */
  72942. initParticles(): void;
  72943. /**
  72944. * This function does nothing. It may be overwritten to recycle a particle
  72945. * The PCS doesn't call this function, you can to call it
  72946. * doc :
  72947. * @param particle The particle to recycle
  72948. * @returns the recycled particle
  72949. */
  72950. recycleParticle(particle: CloudPoint): CloudPoint;
  72951. /**
  72952. * Updates a particle : this function should be overwritten by the user.
  72953. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  72954. * doc :
  72955. * @example : just set a particle position or velocity and recycle conditions
  72956. * @param particle The particle to update
  72957. * @returns the updated particle
  72958. */
  72959. updateParticle(particle: CloudPoint): CloudPoint;
  72960. /**
  72961. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  72962. * This does nothing and may be overwritten by the user.
  72963. * @param start the particle index in the particle array where to start to iterate, same than the value passed to setParticle()
  72964. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  72965. * @param update the boolean update value actually passed to setParticles()
  72966. */
  72967. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  72968. /**
  72969. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  72970. * This will be passed three parameters.
  72971. * This does nothing and may be overwritten by the user.
  72972. * @param start the particle index in the particle array where to start to iterate, same than the value passed to setParticle()
  72973. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  72974. * @param update the boolean update value actually passed to setParticles()
  72975. */
  72976. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  72977. }
  72978. }
  72979. declare module BABYLON {
  72980. /**
  72981. * Represents one particle of a points cloud system.
  72982. */
  72983. export class CloudPoint {
  72984. /**
  72985. * particle global index
  72986. */
  72987. idx: number;
  72988. /**
  72989. * The color of the particle
  72990. */
  72991. color: Nullable<Color4>;
  72992. /**
  72993. * The world space position of the particle.
  72994. */
  72995. position: Vector3;
  72996. /**
  72997. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  72998. */
  72999. rotation: Vector3;
  73000. /**
  73001. * The world space rotation quaternion of the particle.
  73002. */
  73003. rotationQuaternion: Nullable<Quaternion>;
  73004. /**
  73005. * The uv of the particle.
  73006. */
  73007. uv: Nullable<Vector2>;
  73008. /**
  73009. * The current speed of the particle.
  73010. */
  73011. velocity: Vector3;
  73012. /**
  73013. * The pivot point in the particle local space.
  73014. */
  73015. pivot: Vector3;
  73016. /**
  73017. * Must the particle be translated from its pivot point in its local space ?
  73018. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  73019. * Default : false
  73020. */
  73021. translateFromPivot: boolean;
  73022. /**
  73023. * Index of this particle in the global "positions" array (Internal use)
  73024. * @hidden
  73025. */
  73026. _pos: number;
  73027. /**
  73028. * @hidden Index of this particle in the global "indices" array (Internal use)
  73029. */
  73030. _ind: number;
  73031. /**
  73032. * Group this particle belongs to
  73033. */
  73034. _group: PointsGroup;
  73035. /**
  73036. * Group id of this particle
  73037. */
  73038. groupId: number;
  73039. /**
  73040. * Index of the particle in its group id (Internal use)
  73041. */
  73042. idxInGroup: number;
  73043. /**
  73044. * @hidden Particle BoundingInfo object (Internal use)
  73045. */
  73046. _boundingInfo: BoundingInfo;
  73047. /**
  73048. * @hidden Reference to the PCS that the particle belongs to (Internal use)
  73049. */
  73050. _pcs: PointsCloudSystem;
  73051. /**
  73052. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  73053. */
  73054. _stillInvisible: boolean;
  73055. /**
  73056. * @hidden Last computed particle rotation matrix
  73057. */
  73058. _rotationMatrix: number[];
  73059. /**
  73060. * Parent particle Id, if any.
  73061. * Default null.
  73062. */
  73063. parentId: Nullable<number>;
  73064. /**
  73065. * @hidden Internal global position in the PCS.
  73066. */
  73067. _globalPosition: Vector3;
  73068. /**
  73069. * Creates a Point Cloud object.
  73070. * Don't create particles manually, use instead the PCS internal tools like _addParticle()
  73071. * @param particleIndex (integer) is the particle index in the PCS pool. It's also the particle identifier.
  73072. * @param group (PointsGroup) is the group the particle belongs to
  73073. * @param groupId (integer) is the group identifier in the PCS.
  73074. * @param idxInGroup (integer) is the index of the particle in the current point group (ex: the 10th point of addPoints(30))
  73075. * @param pcs defines the PCS it is associated to
  73076. */
  73077. constructor(particleIndex: number, group: PointsGroup, groupId: number, idxInGroup: number, pcs: PointsCloudSystem);
  73078. /**
  73079. * get point size
  73080. */
  73081. get size(): Vector3;
  73082. /**
  73083. * Set point size
  73084. */
  73085. set size(scale: Vector3);
  73086. /**
  73087. * Legacy support, changed quaternion to rotationQuaternion
  73088. */
  73089. get quaternion(): Nullable<Quaternion>;
  73090. /**
  73091. * Legacy support, changed quaternion to rotationQuaternion
  73092. */
  73093. set quaternion(q: Nullable<Quaternion>);
  73094. /**
  73095. * Returns a boolean. True if the particle intersects a mesh, else false
  73096. * The intersection is computed on the particle position and Axis Aligned Bounding Box (AABB) or Sphere
  73097. * @param target is the object (point or mesh) what the intersection is computed against
  73098. * @param isSphere is boolean flag when false (default) bounding box of mesh is used, when true the bounding sphere is used
  73099. * @returns true if it intersects
  73100. */
  73101. intersectsMesh(target: Mesh, isSphere: boolean): boolean;
  73102. /**
  73103. * get the rotation matrix of the particle
  73104. * @hidden
  73105. */
  73106. getRotationMatrix(m: Matrix): void;
  73107. }
  73108. /**
  73109. * Represents a group of points in a points cloud system
  73110. * * PCS internal tool, don't use it manually.
  73111. */
  73112. export class PointsGroup {
  73113. /**
  73114. * The group id
  73115. * @hidden
  73116. */
  73117. groupID: number;
  73118. /**
  73119. * image data for group (internal use)
  73120. * @hidden
  73121. */
  73122. _groupImageData: Nullable<ArrayBufferView>;
  73123. /**
  73124. * Image Width (internal use)
  73125. * @hidden
  73126. */
  73127. _groupImgWidth: number;
  73128. /**
  73129. * Image Height (internal use)
  73130. * @hidden
  73131. */
  73132. _groupImgHeight: number;
  73133. /**
  73134. * Custom position function (internal use)
  73135. * @hidden
  73136. */
  73137. _positionFunction: Nullable<(particle: CloudPoint, i?: number, s?: number) => void>;
  73138. /**
  73139. * density per facet for surface points
  73140. * @hidden
  73141. */
  73142. _groupDensity: number[];
  73143. /**
  73144. * Only when points are colored by texture carries pointer to texture list array
  73145. * @hidden
  73146. */
  73147. _textureNb: number;
  73148. /**
  73149. * Creates a points group object. This is an internal reference to produce particles for the PCS.
  73150. * PCS internal tool, don't use it manually.
  73151. * @hidden
  73152. */
  73153. constructor(id: number, posFunction: Nullable<(particle: CloudPoint, i?: number, s?: number) => void>);
  73154. }
  73155. }
  73156. declare module BABYLON {
  73157. interface Scene {
  73158. /** @hidden (Backing field) */
  73159. _physicsEngine: Nullable<IPhysicsEngine>;
  73160. /** @hidden */
  73161. _physicsTimeAccumulator: number;
  73162. /**
  73163. * Gets the current physics engine
  73164. * @returns a IPhysicsEngine or null if none attached
  73165. */
  73166. getPhysicsEngine(): Nullable<IPhysicsEngine>;
  73167. /**
  73168. * Enables physics to the current scene
  73169. * @param gravity defines the scene's gravity for the physics engine
  73170. * @param plugin defines the physics engine to be used. defaults to OimoJS.
  73171. * @return a boolean indicating if the physics engine was initialized
  73172. */
  73173. enablePhysics(gravity: Nullable<Vector3>, plugin?: IPhysicsEnginePlugin): boolean;
  73174. /**
  73175. * Disables and disposes the physics engine associated with the scene
  73176. */
  73177. disablePhysicsEngine(): void;
  73178. /**
  73179. * Gets a boolean indicating if there is an active physics engine
  73180. * @returns a boolean indicating if there is an active physics engine
  73181. */
  73182. isPhysicsEnabled(): boolean;
  73183. /**
  73184. * Deletes a physics compound impostor
  73185. * @param compound defines the compound to delete
  73186. */
  73187. deleteCompoundImpostor(compound: any): void;
  73188. /**
  73189. * An event triggered when physic simulation is about to be run
  73190. */
  73191. onBeforePhysicsObservable: Observable<Scene>;
  73192. /**
  73193. * An event triggered when physic simulation has been done
  73194. */
  73195. onAfterPhysicsObservable: Observable<Scene>;
  73196. }
  73197. interface AbstractMesh {
  73198. /** @hidden */
  73199. _physicsImpostor: Nullable<PhysicsImpostor>;
  73200. /**
  73201. * Gets or sets impostor used for physic simulation
  73202. * @see https://doc.babylonjs.com/features/physics_engine
  73203. */
  73204. physicsImpostor: Nullable<PhysicsImpostor>;
  73205. /**
  73206. * Gets the current physics impostor
  73207. * @see https://doc.babylonjs.com/features/physics_engine
  73208. * @returns a physics impostor or null
  73209. */
  73210. getPhysicsImpostor(): Nullable<PhysicsImpostor>;
  73211. /** Apply a physic impulse to the mesh
  73212. * @param force defines the force to apply
  73213. * @param contactPoint defines where to apply the force
  73214. * @returns the current mesh
  73215. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  73216. */
  73217. applyImpulse(force: Vector3, contactPoint: Vector3): AbstractMesh;
  73218. /**
  73219. * Creates a physic joint between two meshes
  73220. * @param otherMesh defines the other mesh to use
  73221. * @param pivot1 defines the pivot to use on this mesh
  73222. * @param pivot2 defines the pivot to use on the other mesh
  73223. * @param options defines additional options (can be plugin dependent)
  73224. * @returns the current mesh
  73225. * @see https://www.babylonjs-playground.com/#0BS5U0#0
  73226. */
  73227. setPhysicsLinkWith(otherMesh: Mesh, pivot1: Vector3, pivot2: Vector3, options?: any): AbstractMesh;
  73228. /** @hidden */
  73229. _disposePhysicsObserver: Nullable<Observer<Node>>;
  73230. }
  73231. /**
  73232. * Defines the physics engine scene component responsible to manage a physics engine
  73233. */
  73234. export class PhysicsEngineSceneComponent implements ISceneComponent {
  73235. /**
  73236. * The component name helpful to identify the component in the list of scene components.
  73237. */
  73238. readonly name: string;
  73239. /**
  73240. * The scene the component belongs to.
  73241. */
  73242. scene: Scene;
  73243. /**
  73244. * Creates a new instance of the component for the given scene
  73245. * @param scene Defines the scene to register the component in
  73246. */
  73247. constructor(scene: Scene);
  73248. /**
  73249. * Registers the component in a given scene
  73250. */
  73251. register(): void;
  73252. /**
  73253. * Rebuilds the elements related to this component in case of
  73254. * context lost for instance.
  73255. */
  73256. rebuild(): void;
  73257. /**
  73258. * Disposes the component and the associated resources
  73259. */
  73260. dispose(): void;
  73261. }
  73262. }
  73263. declare module BABYLON {
  73264. /**
  73265. * A helper for physics simulations
  73266. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  73267. */
  73268. export class PhysicsHelper {
  73269. private _scene;
  73270. private _physicsEngine;
  73271. /**
  73272. * Initializes the Physics helper
  73273. * @param scene Babylon.js scene
  73274. */
  73275. constructor(scene: Scene);
  73276. /**
  73277. * Applies a radial explosion impulse
  73278. * @param origin the origin of the explosion
  73279. * @param radiusOrEventOptions the radius or the options of radial explosion
  73280. * @param strength the explosion strength
  73281. * @param falloff possible options: Constant & Linear. Defaults to Constant
  73282. * @returns A physics radial explosion event, or null
  73283. */
  73284. applyRadialExplosionImpulse(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  73285. /**
  73286. * Applies a radial explosion force
  73287. * @param origin the origin of the explosion
  73288. * @param radiusOrEventOptions the radius or the options of radial explosion
  73289. * @param strength the explosion strength
  73290. * @param falloff possible options: Constant & Linear. Defaults to Constant
  73291. * @returns A physics radial explosion event, or null
  73292. */
  73293. applyRadialExplosionForce(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  73294. /**
  73295. * Creates a gravitational field
  73296. * @param origin the origin of the explosion
  73297. * @param radiusOrEventOptions the radius or the options of radial explosion
  73298. * @param strength the explosion strength
  73299. * @param falloff possible options: Constant & Linear. Defaults to Constant
  73300. * @returns A physics gravitational field event, or null
  73301. */
  73302. gravitationalField(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsGravitationalFieldEvent>;
  73303. /**
  73304. * Creates a physics updraft event
  73305. * @param origin the origin of the updraft
  73306. * @param radiusOrEventOptions the radius or the options of the updraft
  73307. * @param strength the strength of the updraft
  73308. * @param height the height of the updraft
  73309. * @param updraftMode possible options: Center & Perpendicular. Defaults to Center
  73310. * @returns A physics updraft event, or null
  73311. */
  73312. updraft(origin: Vector3, radiusOrEventOptions: number | PhysicsUpdraftEventOptions, strength?: number, height?: number, updraftMode?: PhysicsUpdraftMode): Nullable<PhysicsUpdraftEvent>;
  73313. /**
  73314. * Creates a physics vortex event
  73315. * @param origin the of the vortex
  73316. * @param radiusOrEventOptions the radius or the options of the vortex
  73317. * @param strength the strength of the vortex
  73318. * @param height the height of the vortex
  73319. * @returns a Physics vortex event, or null
  73320. * A physics vortex event or null
  73321. */
  73322. vortex(origin: Vector3, radiusOrEventOptions: number | PhysicsVortexEventOptions, strength?: number, height?: number): Nullable<PhysicsVortexEvent>;
  73323. }
  73324. /**
  73325. * Represents a physics radial explosion event
  73326. */
  73327. class PhysicsRadialExplosionEvent {
  73328. private _scene;
  73329. private _options;
  73330. private _sphere;
  73331. private _dataFetched;
  73332. /**
  73333. * Initializes a radial explosion event
  73334. * @param _scene BabylonJS scene
  73335. * @param _options The options for the vortex event
  73336. */
  73337. constructor(_scene: Scene, _options: PhysicsRadialExplosionEventOptions);
  73338. /**
  73339. * Returns the data related to the radial explosion event (sphere).
  73340. * @returns The radial explosion event data
  73341. */
  73342. getData(): PhysicsRadialExplosionEventData;
  73343. /**
  73344. * Returns the force and contact point of the impostor or false, if the impostor is not affected by the force/impulse.
  73345. * @param impostor A physics imposter
  73346. * @param origin the origin of the explosion
  73347. * @returns {Nullable<PhysicsHitData>} A physics force and contact point, or null
  73348. */
  73349. getImpostorHitData(impostor: PhysicsImpostor, origin: Vector3): Nullable<PhysicsHitData>;
  73350. /**
  73351. * Triggers affected impostors callbacks
  73352. * @param affectedImpostorsWithData defines the list of affected impostors (including associated data)
  73353. */
  73354. triggerAffectedImpostorsCallback(affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>): void;
  73355. /**
  73356. * Disposes the sphere.
  73357. * @param force Specifies if the sphere should be disposed by force
  73358. */
  73359. dispose(force?: boolean): void;
  73360. /*** Helpers ***/
  73361. private _prepareSphere;
  73362. private _intersectsWithSphere;
  73363. }
  73364. /**
  73365. * Represents a gravitational field event
  73366. */
  73367. class PhysicsGravitationalFieldEvent {
  73368. private _physicsHelper;
  73369. private _scene;
  73370. private _origin;
  73371. private _options;
  73372. private _tickCallback;
  73373. private _sphere;
  73374. private _dataFetched;
  73375. /**
  73376. * Initializes the physics gravitational field event
  73377. * @param _physicsHelper A physics helper
  73378. * @param _scene BabylonJS scene
  73379. * @param _origin The origin position of the gravitational field event
  73380. * @param _options The options for the vortex event
  73381. */
  73382. constructor(_physicsHelper: PhysicsHelper, _scene: Scene, _origin: Vector3, _options: PhysicsRadialExplosionEventOptions);
  73383. /**
  73384. * Returns the data related to the gravitational field event (sphere).
  73385. * @returns A gravitational field event
  73386. */
  73387. getData(): PhysicsGravitationalFieldEventData;
  73388. /**
  73389. * Enables the gravitational field.
  73390. */
  73391. enable(): void;
  73392. /**
  73393. * Disables the gravitational field.
  73394. */
  73395. disable(): void;
  73396. /**
  73397. * Disposes the sphere.
  73398. * @param force The force to dispose from the gravitational field event
  73399. */
  73400. dispose(force?: boolean): void;
  73401. private _tick;
  73402. }
  73403. /**
  73404. * Represents a physics updraft event
  73405. */
  73406. class PhysicsUpdraftEvent {
  73407. private _scene;
  73408. private _origin;
  73409. private _options;
  73410. private _physicsEngine;
  73411. private _originTop;
  73412. private _originDirection;
  73413. private _tickCallback;
  73414. private _cylinder;
  73415. private _cylinderPosition;
  73416. private _dataFetched;
  73417. /**
  73418. * Initializes the physics updraft event
  73419. * @param _scene BabylonJS scene
  73420. * @param _origin The origin position of the updraft
  73421. * @param _options The options for the updraft event
  73422. */
  73423. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsUpdraftEventOptions);
  73424. /**
  73425. * Returns the data related to the updraft event (cylinder).
  73426. * @returns A physics updraft event
  73427. */
  73428. getData(): PhysicsUpdraftEventData;
  73429. /**
  73430. * Enables the updraft.
  73431. */
  73432. enable(): void;
  73433. /**
  73434. * Disables the updraft.
  73435. */
  73436. disable(): void;
  73437. /**
  73438. * Disposes the cylinder.
  73439. * @param force Specifies if the updraft should be disposed by force
  73440. */
  73441. dispose(force?: boolean): void;
  73442. private getImpostorHitData;
  73443. private _tick;
  73444. /*** Helpers ***/
  73445. private _prepareCylinder;
  73446. private _intersectsWithCylinder;
  73447. }
  73448. /**
  73449. * Represents a physics vortex event
  73450. */
  73451. class PhysicsVortexEvent {
  73452. private _scene;
  73453. private _origin;
  73454. private _options;
  73455. private _physicsEngine;
  73456. private _originTop;
  73457. private _tickCallback;
  73458. private _cylinder;
  73459. private _cylinderPosition;
  73460. private _dataFetched;
  73461. /**
  73462. * Initializes the physics vortex event
  73463. * @param _scene The BabylonJS scene
  73464. * @param _origin The origin position of the vortex
  73465. * @param _options The options for the vortex event
  73466. */
  73467. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsVortexEventOptions);
  73468. /**
  73469. * Returns the data related to the vortex event (cylinder).
  73470. * @returns The physics vortex event data
  73471. */
  73472. getData(): PhysicsVortexEventData;
  73473. /**
  73474. * Enables the vortex.
  73475. */
  73476. enable(): void;
  73477. /**
  73478. * Disables the cortex.
  73479. */
  73480. disable(): void;
  73481. /**
  73482. * Disposes the sphere.
  73483. * @param force
  73484. */
  73485. dispose(force?: boolean): void;
  73486. private getImpostorHitData;
  73487. private _tick;
  73488. /*** Helpers ***/
  73489. private _prepareCylinder;
  73490. private _intersectsWithCylinder;
  73491. }
  73492. /**
  73493. * Options fot the radial explosion event
  73494. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  73495. */
  73496. export class PhysicsRadialExplosionEventOptions {
  73497. /**
  73498. * The radius of the sphere for the radial explosion.
  73499. */
  73500. radius: number;
  73501. /**
  73502. * The strength of the explosion.
  73503. */
  73504. strength: number;
  73505. /**
  73506. * The strength of the force in correspondence to the distance of the affected object
  73507. */
  73508. falloff: PhysicsRadialImpulseFalloff;
  73509. /**
  73510. * Sphere options for the radial explosion.
  73511. */
  73512. sphere: {
  73513. segments: number;
  73514. diameter: number;
  73515. };
  73516. /**
  73517. * Sphere options for the radial explosion.
  73518. */
  73519. affectedImpostorsCallback: (affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>) => void;
  73520. }
  73521. /**
  73522. * Options fot the updraft event
  73523. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  73524. */
  73525. export class PhysicsUpdraftEventOptions {
  73526. /**
  73527. * The radius of the cylinder for the vortex
  73528. */
  73529. radius: number;
  73530. /**
  73531. * The strength of the updraft.
  73532. */
  73533. strength: number;
  73534. /**
  73535. * The height of the cylinder for the updraft.
  73536. */
  73537. height: number;
  73538. /**
  73539. * The mode for the the updraft.
  73540. */
  73541. updraftMode: PhysicsUpdraftMode;
  73542. }
  73543. /**
  73544. * Options fot the vortex event
  73545. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  73546. */
  73547. export class PhysicsVortexEventOptions {
  73548. /**
  73549. * The radius of the cylinder for the vortex
  73550. */
  73551. radius: number;
  73552. /**
  73553. * The strength of the vortex.
  73554. */
  73555. strength: number;
  73556. /**
  73557. * The height of the cylinder for the vortex.
  73558. */
  73559. height: number;
  73560. /**
  73561. * At which distance, relative to the radius the centripetal forces should kick in? Range: 0-1
  73562. */
  73563. centripetalForceThreshold: number;
  73564. /**
  73565. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when below the threshold.
  73566. */
  73567. centripetalForceMultiplier: number;
  73568. /**
  73569. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when above the threshold.
  73570. */
  73571. centrifugalForceMultiplier: number;
  73572. /**
  73573. * This multiplier determines with how much force the objects will be pushed upwards, when in the vortex.
  73574. */
  73575. updraftForceMultiplier: number;
  73576. }
  73577. /**
  73578. * The strength of the force in correspondence to the distance of the affected object
  73579. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  73580. */
  73581. export enum PhysicsRadialImpulseFalloff {
  73582. /** Defines that impulse is constant in strength across it's whole radius */
  73583. Constant = 0,
  73584. /** Defines that impulse gets weaker if it's further from the origin */
  73585. Linear = 1
  73586. }
  73587. /**
  73588. * The strength of the force in correspondence to the distance of the affected object
  73589. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  73590. */
  73591. export enum PhysicsUpdraftMode {
  73592. /** Defines that the upstream forces will pull towards the top center of the cylinder */
  73593. Center = 0,
  73594. /** Defines that once a impostor is inside the cylinder, it will shoot out perpendicular from the ground of the cylinder */
  73595. Perpendicular = 1
  73596. }
  73597. /**
  73598. * Interface for a physics hit data
  73599. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  73600. */
  73601. export interface PhysicsHitData {
  73602. /**
  73603. * The force applied at the contact point
  73604. */
  73605. force: Vector3;
  73606. /**
  73607. * The contact point
  73608. */
  73609. contactPoint: Vector3;
  73610. /**
  73611. * The distance from the origin to the contact point
  73612. */
  73613. distanceFromOrigin: number;
  73614. }
  73615. /**
  73616. * Interface for radial explosion event data
  73617. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  73618. */
  73619. export interface PhysicsRadialExplosionEventData {
  73620. /**
  73621. * A sphere used for the radial explosion event
  73622. */
  73623. sphere: Mesh;
  73624. }
  73625. /**
  73626. * Interface for gravitational field event data
  73627. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  73628. */
  73629. export interface PhysicsGravitationalFieldEventData {
  73630. /**
  73631. * A sphere mesh used for the gravitational field event
  73632. */
  73633. sphere: Mesh;
  73634. }
  73635. /**
  73636. * Interface for updraft event data
  73637. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  73638. */
  73639. export interface PhysicsUpdraftEventData {
  73640. /**
  73641. * A cylinder used for the updraft event
  73642. */
  73643. cylinder: Mesh;
  73644. }
  73645. /**
  73646. * Interface for vortex event data
  73647. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  73648. */
  73649. export interface PhysicsVortexEventData {
  73650. /**
  73651. * A cylinder used for the vortex event
  73652. */
  73653. cylinder: Mesh;
  73654. }
  73655. /**
  73656. * Interface for an affected physics impostor
  73657. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  73658. */
  73659. export interface PhysicsAffectedImpostorWithData {
  73660. /**
  73661. * The impostor affected by the effect
  73662. */
  73663. impostor: PhysicsImpostor;
  73664. /**
  73665. * The data about the hit/force from the explosion
  73666. */
  73667. hitData: PhysicsHitData;
  73668. }
  73669. }
  73670. declare module BABYLON {
  73671. /** @hidden */
  73672. export var blackAndWhitePixelShader: {
  73673. name: string;
  73674. shader: string;
  73675. };
  73676. }
  73677. declare module BABYLON {
  73678. /**
  73679. * Post process used to render in black and white
  73680. */
  73681. export class BlackAndWhitePostProcess extends PostProcess {
  73682. /**
  73683. * Linear about to convert he result to black and white (default: 1)
  73684. */
  73685. degree: number;
  73686. /**
  73687. * Gets a string identifying the name of the class
  73688. * @returns "BlackAndWhitePostProcess" string
  73689. */
  73690. getClassName(): string;
  73691. /**
  73692. * Creates a black and white post process
  73693. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#black-and-white
  73694. * @param name The name of the effect.
  73695. * @param options The required width/height ratio to downsize to before computing the render pass.
  73696. * @param camera The camera to apply the render pass to.
  73697. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  73698. * @param engine The engine which the post process will be applied. (default: current engine)
  73699. * @param reusable If the post process can be reused on the same frame. (default: false)
  73700. */
  73701. constructor(name: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  73702. /** @hidden */
  73703. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): Nullable<BlackAndWhitePostProcess>;
  73704. }
  73705. }
  73706. declare module BABYLON {
  73707. /**
  73708. * This represents a set of one or more post processes in Babylon.
  73709. * A post process can be used to apply a shader to a texture after it is rendered.
  73710. * @example https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  73711. */
  73712. export class PostProcessRenderEffect {
  73713. private _postProcesses;
  73714. private _getPostProcesses;
  73715. private _singleInstance;
  73716. private _cameras;
  73717. private _indicesForCamera;
  73718. /**
  73719. * Name of the effect
  73720. * @hidden
  73721. */
  73722. _name: string;
  73723. /**
  73724. * Instantiates a post process render effect.
  73725. * A post process can be used to apply a shader to a texture after it is rendered.
  73726. * @param engine The engine the effect is tied to
  73727. * @param name The name of the effect
  73728. * @param getPostProcesses A function that returns a set of post processes which the effect will run in order to be run.
  73729. * @param singleInstance False if this post process can be run on multiple cameras. (default: true)
  73730. */
  73731. constructor(engine: Engine, name: string, getPostProcesses: () => Nullable<PostProcess | Array<PostProcess>>, singleInstance?: boolean);
  73732. /**
  73733. * Checks if all the post processes in the effect are supported.
  73734. */
  73735. get isSupported(): boolean;
  73736. /**
  73737. * Updates the current state of the effect
  73738. * @hidden
  73739. */
  73740. _update(): void;
  73741. /**
  73742. * Attaches the effect on cameras
  73743. * @param cameras The camera to attach to.
  73744. * @hidden
  73745. */
  73746. _attachCameras(cameras: Camera): void;
  73747. /**
  73748. * Attaches the effect on cameras
  73749. * @param cameras The camera to attach to.
  73750. * @hidden
  73751. */
  73752. _attachCameras(cameras: Camera[]): void;
  73753. /**
  73754. * Detaches the effect on cameras
  73755. * @param cameras The camera to detatch from.
  73756. * @hidden
  73757. */
  73758. _detachCameras(cameras: Camera): void;
  73759. /**
  73760. * Detatches the effect on cameras
  73761. * @param cameras The camera to detatch from.
  73762. * @hidden
  73763. */
  73764. _detachCameras(cameras: Camera[]): void;
  73765. /**
  73766. * Enables the effect on given cameras
  73767. * @param cameras The camera to enable.
  73768. * @hidden
  73769. */
  73770. _enable(cameras: Camera): void;
  73771. /**
  73772. * Enables the effect on given cameras
  73773. * @param cameras The camera to enable.
  73774. * @hidden
  73775. */
  73776. _enable(cameras: Nullable<Camera[]>): void;
  73777. /**
  73778. * Disables the effect on the given cameras
  73779. * @param cameras The camera to disable.
  73780. * @hidden
  73781. */
  73782. _disable(cameras: Camera): void;
  73783. /**
  73784. * Disables the effect on the given cameras
  73785. * @param cameras The camera to disable.
  73786. * @hidden
  73787. */
  73788. _disable(cameras: Nullable<Camera[]>): void;
  73789. /**
  73790. * Gets a list of the post processes contained in the effect.
  73791. * @param camera The camera to get the post processes on.
  73792. * @returns The list of the post processes in the effect.
  73793. */
  73794. getPostProcesses(camera?: Camera): Nullable<Array<PostProcess>>;
  73795. }
  73796. }
  73797. declare module BABYLON {
  73798. /** @hidden */
  73799. export var extractHighlightsPixelShader: {
  73800. name: string;
  73801. shader: string;
  73802. };
  73803. }
  73804. declare module BABYLON {
  73805. /**
  73806. * 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.
  73807. */
  73808. export class ExtractHighlightsPostProcess extends PostProcess {
  73809. /**
  73810. * The luminance threshold, pixels below this value will be set to black.
  73811. */
  73812. threshold: number;
  73813. /** @hidden */
  73814. _exposure: number;
  73815. /**
  73816. * Post process which has the input texture to be used when performing highlight extraction
  73817. * @hidden
  73818. */
  73819. _inputPostProcess: Nullable<PostProcess>;
  73820. /**
  73821. * Gets a string identifying the name of the class
  73822. * @returns "ExtractHighlightsPostProcess" string
  73823. */
  73824. getClassName(): string;
  73825. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  73826. }
  73827. }
  73828. declare module BABYLON {
  73829. /** @hidden */
  73830. export var bloomMergePixelShader: {
  73831. name: string;
  73832. shader: string;
  73833. };
  73834. }
  73835. declare module BABYLON {
  73836. /**
  73837. * The BloomMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  73838. */
  73839. export class BloomMergePostProcess extends PostProcess {
  73840. /** Weight of the bloom to be added to the original input. */
  73841. weight: number;
  73842. /**
  73843. * Gets a string identifying the name of the class
  73844. * @returns "BloomMergePostProcess" string
  73845. */
  73846. getClassName(): string;
  73847. /**
  73848. * Creates a new instance of @see BloomMergePostProcess
  73849. * @param name The name of the effect.
  73850. * @param originalFromInput Post process which's input will be used for the merge.
  73851. * @param blurred Blurred highlights post process which's output will be used.
  73852. * @param weight Weight of the bloom to be added to the original input.
  73853. * @param options The required width/height ratio to downsize to before computing the render pass.
  73854. * @param camera The camera to apply the render pass to.
  73855. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  73856. * @param engine The engine which the post process will be applied. (default: current engine)
  73857. * @param reusable If the post process can be reused on the same frame. (default: false)
  73858. * @param textureType Type of textures used when performing the post process. (default: 0)
  73859. * @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)
  73860. */
  73861. constructor(name: string, originalFromInput: PostProcess, blurred: PostProcess,
  73862. /** Weight of the bloom to be added to the original input. */
  73863. weight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  73864. }
  73865. }
  73866. declare module BABYLON {
  73867. /**
  73868. * The bloom effect spreads bright areas of an image to simulate artifacts seen in cameras
  73869. */
  73870. export class BloomEffect extends PostProcessRenderEffect {
  73871. private bloomScale;
  73872. /**
  73873. * @hidden Internal
  73874. */
  73875. _effects: Array<PostProcess>;
  73876. /**
  73877. * @hidden Internal
  73878. */
  73879. _downscale: ExtractHighlightsPostProcess;
  73880. private _blurX;
  73881. private _blurY;
  73882. private _merge;
  73883. /**
  73884. * The luminance threshold to find bright areas of the image to bloom.
  73885. */
  73886. get threshold(): number;
  73887. set threshold(value: number);
  73888. /**
  73889. * The strength of the bloom.
  73890. */
  73891. get weight(): number;
  73892. set weight(value: number);
  73893. /**
  73894. * Specifies the size of the bloom blur kernel, relative to the final output size
  73895. */
  73896. get kernel(): number;
  73897. set kernel(value: number);
  73898. /**
  73899. * Creates a new instance of @see BloomEffect
  73900. * @param scene The scene the effect belongs to.
  73901. * @param bloomScale The ratio of the blur texture to the input texture that should be used to compute the bloom.
  73902. * @param bloomKernel The size of the kernel to be used when applying the blur.
  73903. * @param bloomWeight The the strength of bloom.
  73904. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  73905. * @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)
  73906. */
  73907. constructor(scene: Scene, bloomScale: number, bloomWeight: number, bloomKernel: number, pipelineTextureType?: number, blockCompilation?: boolean);
  73908. /**
  73909. * Disposes each of the internal effects for a given camera.
  73910. * @param camera The camera to dispose the effect on.
  73911. */
  73912. disposeEffects(camera: Camera): void;
  73913. /**
  73914. * @hidden Internal
  73915. */
  73916. _updateEffects(): void;
  73917. /**
  73918. * Internal
  73919. * @returns if all the contained post processes are ready.
  73920. * @hidden
  73921. */
  73922. _isReady(): boolean;
  73923. }
  73924. }
  73925. declare module BABYLON {
  73926. /** @hidden */
  73927. export var chromaticAberrationPixelShader: {
  73928. name: string;
  73929. shader: string;
  73930. };
  73931. }
  73932. declare module BABYLON {
  73933. /**
  73934. * The ChromaticAberrationPostProcess separates the rgb channels in an image to produce chromatic distortion around the edges of the screen
  73935. */
  73936. export class ChromaticAberrationPostProcess extends PostProcess {
  73937. /**
  73938. * The amount of seperation of rgb channels (default: 30)
  73939. */
  73940. aberrationAmount: number;
  73941. /**
  73942. * The amount the effect will increase for pixels closer to the edge of the screen. (default: 0)
  73943. */
  73944. radialIntensity: number;
  73945. /**
  73946. * 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))
  73947. */
  73948. direction: Vector2;
  73949. /**
  73950. * 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))
  73951. */
  73952. centerPosition: Vector2;
  73953. /** The width of the screen to apply the effect on */
  73954. screenWidth: number;
  73955. /** The height of the screen to apply the effect on */
  73956. screenHeight: number;
  73957. /**
  73958. * Gets a string identifying the name of the class
  73959. * @returns "ChromaticAberrationPostProcess" string
  73960. */
  73961. getClassName(): string;
  73962. /**
  73963. * Creates a new instance ChromaticAberrationPostProcess
  73964. * @param name The name of the effect.
  73965. * @param screenWidth The width of the screen to apply the effect on.
  73966. * @param screenHeight The height of the screen to apply the effect on.
  73967. * @param options The required width/height ratio to downsize to before computing the render pass.
  73968. * @param camera The camera to apply the render pass to.
  73969. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  73970. * @param engine The engine which the post process will be applied. (default: current engine)
  73971. * @param reusable If the post process can be reused on the same frame. (default: false)
  73972. * @param textureType Type of textures used when performing the post process. (default: 0)
  73973. * @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)
  73974. */
  73975. constructor(name: string, screenWidth: number, screenHeight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  73976. /** @hidden */
  73977. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): Nullable<ChromaticAberrationPostProcess>;
  73978. }
  73979. }
  73980. declare module BABYLON {
  73981. /** @hidden */
  73982. export var circleOfConfusionPixelShader: {
  73983. name: string;
  73984. shader: string;
  73985. };
  73986. }
  73987. declare module BABYLON {
  73988. /**
  73989. * The CircleOfConfusionPostProcess computes the circle of confusion value for each pixel given required lens parameters. See https://en.wikipedia.org/wiki/Circle_of_confusion
  73990. */
  73991. export class CircleOfConfusionPostProcess extends PostProcess {
  73992. /**
  73993. * 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.
  73994. */
  73995. lensSize: number;
  73996. /**
  73997. * F-Stop of the effect's camera. The diamater of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  73998. */
  73999. fStop: number;
  74000. /**
  74001. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  74002. */
  74003. focusDistance: number;
  74004. /**
  74005. * Focal length of the effect's camera in scene units/1000 (eg. millimeter). (default: 50)
  74006. */
  74007. focalLength: number;
  74008. /**
  74009. * Gets a string identifying the name of the class
  74010. * @returns "CircleOfConfusionPostProcess" string
  74011. */
  74012. getClassName(): string;
  74013. private _depthTexture;
  74014. /**
  74015. * Creates a new instance CircleOfConfusionPostProcess
  74016. * @param name The name of the effect.
  74017. * @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.
  74018. * @param options The required width/height ratio to downsize to before computing the render pass.
  74019. * @param camera The camera to apply the render pass to.
  74020. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  74021. * @param engine The engine which the post process will be applied. (default: current engine)
  74022. * @param reusable If the post process can be reused on the same frame. (default: false)
  74023. * @param textureType Type of textures used when performing the post process. (default: 0)
  74024. * @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)
  74025. */
  74026. constructor(name: string, depthTexture: Nullable<RenderTargetTexture>, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  74027. /**
  74028. * 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.
  74029. */
  74030. set depthTexture(value: RenderTargetTexture);
  74031. }
  74032. }
  74033. declare module BABYLON {
  74034. /** @hidden */
  74035. export var colorCorrectionPixelShader: {
  74036. name: string;
  74037. shader: string;
  74038. };
  74039. }
  74040. declare module BABYLON {
  74041. /**
  74042. *
  74043. * This post-process allows the modification of rendered colors by using
  74044. * a 'look-up table' (LUT). This effect is also called Color Grading.
  74045. *
  74046. * The object needs to be provided an url to a texture containing the color
  74047. * look-up table: the texture must be 256 pixels wide and 16 pixels high.
  74048. * Use an image editing software to tweak the LUT to match your needs.
  74049. *
  74050. * For an example of a color LUT, see here:
  74051. * @see http://udn.epicgames.com/Three/rsrc/Three/ColorGrading/RGBTable16x1.png
  74052. * For explanations on color grading, see here:
  74053. * @see http://udn.epicgames.com/Three/ColorGrading.html
  74054. *
  74055. */
  74056. export class ColorCorrectionPostProcess extends PostProcess {
  74057. private _colorTableTexture;
  74058. /**
  74059. * Gets the color table url used to create the LUT texture
  74060. */
  74061. colorTableUrl: string;
  74062. /**
  74063. * Gets a string identifying the name of the class
  74064. * @returns "ColorCorrectionPostProcess" string
  74065. */
  74066. getClassName(): string;
  74067. constructor(name: string, colorTableUrl: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  74068. /** @hidden */
  74069. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): Nullable<ColorCorrectionPostProcess>;
  74070. }
  74071. }
  74072. declare module BABYLON {
  74073. /** @hidden */
  74074. export var convolutionPixelShader: {
  74075. name: string;
  74076. shader: string;
  74077. };
  74078. }
  74079. declare module BABYLON {
  74080. /**
  74081. * The ConvolutionPostProcess applies a 3x3 kernel to every pixel of the
  74082. * input texture to perform effects such as edge detection or sharpening
  74083. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  74084. */
  74085. export class ConvolutionPostProcess extends PostProcess {
  74086. /** Array of 9 values corresponding to the 3x3 kernel to be applied */
  74087. kernel: number[];
  74088. /**
  74089. * Gets a string identifying the name of the class
  74090. * @returns "ConvolutionPostProcess" string
  74091. */
  74092. getClassName(): string;
  74093. /**
  74094. * Creates a new instance ConvolutionPostProcess
  74095. * @param name The name of the effect.
  74096. * @param kernel Array of 9 values corresponding to the 3x3 kernel to be applied
  74097. * @param options The required width/height ratio to downsize to before computing the render pass.
  74098. * @param camera The camera to apply the render pass to.
  74099. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  74100. * @param engine The engine which the post process will be applied. (default: current engine)
  74101. * @param reusable If the post process can be reused on the same frame. (default: false)
  74102. * @param textureType Type of textures used when performing the post process. (default: 0)
  74103. */
  74104. constructor(name: string, kernel: number[], options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  74105. /** @hidden */
  74106. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): Nullable<ConvolutionPostProcess>;
  74107. /**
  74108. * Edge detection 0 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  74109. */
  74110. static EdgeDetect0Kernel: number[];
  74111. /**
  74112. * Edge detection 1 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  74113. */
  74114. static EdgeDetect1Kernel: number[];
  74115. /**
  74116. * Edge detection 2 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  74117. */
  74118. static EdgeDetect2Kernel: number[];
  74119. /**
  74120. * Kernel to sharpen an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  74121. */
  74122. static SharpenKernel: number[];
  74123. /**
  74124. * Kernel to emboss an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  74125. */
  74126. static EmbossKernel: number[];
  74127. /**
  74128. * Kernel to blur an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  74129. */
  74130. static GaussianKernel: number[];
  74131. }
  74132. }
  74133. declare module BABYLON {
  74134. /**
  74135. * The DepthOfFieldBlurPostProcess applied a blur in a give direction.
  74136. * This blur differs from the standard BlurPostProcess as it attempts to avoid blurring pixels
  74137. * based on samples that have a large difference in distance than the center pixel.
  74138. * See section 2.6.2 http://fileadmin.cs.lth.se/cs/education/edan35/lectures/12dof.pdf
  74139. */
  74140. export class DepthOfFieldBlurPostProcess extends BlurPostProcess {
  74141. /**
  74142. * The direction the blur should be applied
  74143. */
  74144. direction: Vector2;
  74145. /**
  74146. * Gets a string identifying the name of the class
  74147. * @returns "DepthOfFieldBlurPostProcess" string
  74148. */
  74149. getClassName(): string;
  74150. /**
  74151. * Creates a new instance CircleOfConfusionPostProcess
  74152. * @param name The name of the effect.
  74153. * @param scene The scene the effect belongs to.
  74154. * @param direction The direction the blur should be applied.
  74155. * @param kernel The size of the kernel used to blur.
  74156. * @param options The required width/height ratio to downsize to before computing the render pass.
  74157. * @param camera The camera to apply the render pass to.
  74158. * @param circleOfConfusion The circle of confusion + depth map to be used to avoid blurring accross edges
  74159. * @param imageToBlur The image to apply the blur to (default: Current rendered frame)
  74160. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  74161. * @param engine The engine which the post process will be applied. (default: current engine)
  74162. * @param reusable If the post process can be reused on the same frame. (default: false)
  74163. * @param textureType Type of textures used when performing the post process. (default: 0)
  74164. * @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)
  74165. */
  74166. 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);
  74167. }
  74168. }
  74169. declare module BABYLON {
  74170. /** @hidden */
  74171. export var depthOfFieldMergePixelShader: {
  74172. name: string;
  74173. shader: string;
  74174. };
  74175. }
  74176. declare module BABYLON {
  74177. /**
  74178. * Options to be set when merging outputs from the default pipeline.
  74179. */
  74180. export class DepthOfFieldMergePostProcessOptions {
  74181. /**
  74182. * The original image to merge on top of
  74183. */
  74184. originalFromInput: PostProcess;
  74185. /**
  74186. * Parameters to perform the merge of the depth of field effect
  74187. */
  74188. depthOfField?: {
  74189. circleOfConfusion: PostProcess;
  74190. blurSteps: Array<PostProcess>;
  74191. };
  74192. /**
  74193. * Parameters to perform the merge of bloom effect
  74194. */
  74195. bloom?: {
  74196. blurred: PostProcess;
  74197. weight: number;
  74198. };
  74199. }
  74200. /**
  74201. * The DepthOfFieldMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  74202. */
  74203. export class DepthOfFieldMergePostProcess extends PostProcess {
  74204. private blurSteps;
  74205. /**
  74206. * Gets a string identifying the name of the class
  74207. * @returns "DepthOfFieldMergePostProcess" string
  74208. */
  74209. getClassName(): string;
  74210. /**
  74211. * Creates a new instance of DepthOfFieldMergePostProcess
  74212. * @param name The name of the effect.
  74213. * @param originalFromInput Post process which's input will be used for the merge.
  74214. * @param circleOfConfusion Circle of confusion post process which's output will be used to blur each pixel.
  74215. * @param blurSteps Blur post processes from low to high which will be mixed with the original image.
  74216. * @param options The required width/height ratio to downsize to before computing the render pass.
  74217. * @param camera The camera to apply the render pass to.
  74218. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  74219. * @param engine The engine which the post process will be applied. (default: current engine)
  74220. * @param reusable If the post process can be reused on the same frame. (default: false)
  74221. * @param textureType Type of textures used when performing the post process. (default: 0)
  74222. * @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)
  74223. */
  74224. 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);
  74225. /**
  74226. * Updates the effect with the current post process compile time values and recompiles the shader.
  74227. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  74228. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  74229. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  74230. * @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
  74231. * @param onCompiled Called when the shader has been compiled.
  74232. * @param onError Called if there is an error when compiling a shader.
  74233. */
  74234. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  74235. }
  74236. }
  74237. declare module BABYLON {
  74238. /**
  74239. * Specifies the level of max blur that should be applied when using the depth of field effect
  74240. */
  74241. export enum DepthOfFieldEffectBlurLevel {
  74242. /**
  74243. * Subtle blur
  74244. */
  74245. Low = 0,
  74246. /**
  74247. * Medium blur
  74248. */
  74249. Medium = 1,
  74250. /**
  74251. * Large blur
  74252. */
  74253. High = 2
  74254. }
  74255. /**
  74256. * The depth of field effect applies a blur to objects that are closer or further from where the camera is focusing.
  74257. */
  74258. export class DepthOfFieldEffect extends PostProcessRenderEffect {
  74259. private _circleOfConfusion;
  74260. /**
  74261. * @hidden Internal, blurs from high to low
  74262. */
  74263. _depthOfFieldBlurX: Array<DepthOfFieldBlurPostProcess>;
  74264. private _depthOfFieldBlurY;
  74265. private _dofMerge;
  74266. /**
  74267. * @hidden Internal post processes in depth of field effect
  74268. */
  74269. _effects: Array<PostProcess>;
  74270. /**
  74271. * The focal the length of the camera used in the effect in scene units/1000 (eg. millimeter)
  74272. */
  74273. set focalLength(value: number);
  74274. get focalLength(): number;
  74275. /**
  74276. * F-Stop of the effect's camera. The diameter of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  74277. */
  74278. set fStop(value: number);
  74279. get fStop(): number;
  74280. /**
  74281. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  74282. */
  74283. set focusDistance(value: number);
  74284. get focusDistance(): number;
  74285. /**
  74286. * 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.
  74287. */
  74288. set lensSize(value: number);
  74289. get lensSize(): number;
  74290. /**
  74291. * Creates a new instance DepthOfFieldEffect
  74292. * @param scene The scene the effect belongs to.
  74293. * @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.
  74294. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  74295. * @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)
  74296. */
  74297. constructor(scene: Scene, depthTexture: Nullable<RenderTargetTexture>, blurLevel?: DepthOfFieldEffectBlurLevel, pipelineTextureType?: number, blockCompilation?: boolean);
  74298. /**
  74299. * Get the current class name of the current effet
  74300. * @returns "DepthOfFieldEffect"
  74301. */
  74302. getClassName(): string;
  74303. /**
  74304. * 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.
  74305. */
  74306. set depthTexture(value: RenderTargetTexture);
  74307. /**
  74308. * Disposes each of the internal effects for a given camera.
  74309. * @param camera The camera to dispose the effect on.
  74310. */
  74311. disposeEffects(camera: Camera): void;
  74312. /**
  74313. * @hidden Internal
  74314. */
  74315. _updateEffects(): void;
  74316. /**
  74317. * Internal
  74318. * @returns if all the contained post processes are ready.
  74319. * @hidden
  74320. */
  74321. _isReady(): boolean;
  74322. }
  74323. }
  74324. declare module BABYLON {
  74325. /** @hidden */
  74326. export var displayPassPixelShader: {
  74327. name: string;
  74328. shader: string;
  74329. };
  74330. }
  74331. declare module BABYLON {
  74332. /**
  74333. * DisplayPassPostProcess which produces an output the same as it's input
  74334. */
  74335. export class DisplayPassPostProcess extends PostProcess {
  74336. /**
  74337. * Gets a string identifying the name of the class
  74338. * @returns "DisplayPassPostProcess" string
  74339. */
  74340. getClassName(): string;
  74341. /**
  74342. * Creates the DisplayPassPostProcess
  74343. * @param name The name of the effect.
  74344. * @param options The required width/height ratio to downsize to before computing the render pass.
  74345. * @param camera The camera to apply the render pass to.
  74346. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  74347. * @param engine The engine which the post process will be applied. (default: current engine)
  74348. * @param reusable If the post process can be reused on the same frame. (default: false)
  74349. */
  74350. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  74351. /** @hidden */
  74352. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): Nullable<DisplayPassPostProcess>;
  74353. }
  74354. }
  74355. declare module BABYLON {
  74356. /** @hidden */
  74357. export var filterPixelShader: {
  74358. name: string;
  74359. shader: string;
  74360. };
  74361. }
  74362. declare module BABYLON {
  74363. /**
  74364. * Applies a kernel filter to the image
  74365. */
  74366. export class FilterPostProcess extends PostProcess {
  74367. /** The matrix to be applied to the image */
  74368. kernelMatrix: Matrix;
  74369. /**
  74370. * Gets a string identifying the name of the class
  74371. * @returns "FilterPostProcess" string
  74372. */
  74373. getClassName(): string;
  74374. /**
  74375. *
  74376. * @param name The name of the effect.
  74377. * @param kernelMatrix The matrix to be applied to the image
  74378. * @param options The required width/height ratio to downsize to before computing the render pass.
  74379. * @param camera The camera to apply the render pass to.
  74380. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  74381. * @param engine The engine which the post process will be applied. (default: current engine)
  74382. * @param reusable If the post process can be reused on the same frame. (default: false)
  74383. */
  74384. constructor(name: string, kernelMatrix: Matrix, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  74385. /** @hidden */
  74386. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): Nullable<FilterPostProcess>;
  74387. }
  74388. }
  74389. declare module BABYLON {
  74390. /** @hidden */
  74391. export var fxaaPixelShader: {
  74392. name: string;
  74393. shader: string;
  74394. };
  74395. }
  74396. declare module BABYLON {
  74397. /** @hidden */
  74398. export var fxaaVertexShader: {
  74399. name: string;
  74400. shader: string;
  74401. };
  74402. }
  74403. declare module BABYLON {
  74404. /**
  74405. * Fxaa post process
  74406. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#fxaa
  74407. */
  74408. export class FxaaPostProcess extends PostProcess {
  74409. /**
  74410. * Gets a string identifying the name of the class
  74411. * @returns "FxaaPostProcess" string
  74412. */
  74413. getClassName(): string;
  74414. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  74415. private _getDefines;
  74416. /** @hidden */
  74417. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): FxaaPostProcess;
  74418. }
  74419. }
  74420. declare module BABYLON {
  74421. /** @hidden */
  74422. export var grainPixelShader: {
  74423. name: string;
  74424. shader: string;
  74425. };
  74426. }
  74427. declare module BABYLON {
  74428. /**
  74429. * The GrainPostProcess adds noise to the image at mid luminance levels
  74430. */
  74431. export class GrainPostProcess extends PostProcess {
  74432. /**
  74433. * The intensity of the grain added (default: 30)
  74434. */
  74435. intensity: number;
  74436. /**
  74437. * If the grain should be randomized on every frame
  74438. */
  74439. animated: boolean;
  74440. /**
  74441. * Gets a string identifying the name of the class
  74442. * @returns "GrainPostProcess" string
  74443. */
  74444. getClassName(): string;
  74445. /**
  74446. * Creates a new instance of @see GrainPostProcess
  74447. * @param name The name of the effect.
  74448. * @param options The required width/height ratio to downsize to before computing the render pass.
  74449. * @param camera The camera to apply the render pass to.
  74450. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  74451. * @param engine The engine which the post process will be applied. (default: current engine)
  74452. * @param reusable If the post process can be reused on the same frame. (default: false)
  74453. * @param textureType Type of textures used when performing the post process. (default: 0)
  74454. * @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)
  74455. */
  74456. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  74457. /** @hidden */
  74458. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): GrainPostProcess;
  74459. }
  74460. }
  74461. declare module BABYLON {
  74462. /** @hidden */
  74463. export var highlightsPixelShader: {
  74464. name: string;
  74465. shader: string;
  74466. };
  74467. }
  74468. declare module BABYLON {
  74469. /**
  74470. * Extracts highlights from the image
  74471. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  74472. */
  74473. export class HighlightsPostProcess extends PostProcess {
  74474. /**
  74475. * Gets a string identifying the name of the class
  74476. * @returns "HighlightsPostProcess" string
  74477. */
  74478. getClassName(): string;
  74479. /**
  74480. * Extracts highlights from the image
  74481. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  74482. * @param name The name of the effect.
  74483. * @param options The required width/height ratio to downsize to before computing the render pass.
  74484. * @param camera The camera to apply the render pass to.
  74485. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  74486. * @param engine The engine which the post process will be applied. (default: current engine)
  74487. * @param reusable If the post process can be reused on the same frame. (default: false)
  74488. * @param textureType Type of texture for the post process (default: Engine.TEXTURETYPE_UNSIGNED_INT)
  74489. */
  74490. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  74491. }
  74492. }
  74493. declare module BABYLON {
  74494. /**
  74495. * Contains all parameters needed for the prepass to perform
  74496. * motion blur
  74497. */
  74498. export class MotionBlurConfiguration implements PrePassEffectConfiguration {
  74499. /**
  74500. * Is motion blur enabled
  74501. */
  74502. enabled: boolean;
  74503. /**
  74504. * Name of the configuration
  74505. */
  74506. name: string;
  74507. /**
  74508. * Textures that should be present in the MRT for this effect to work
  74509. */
  74510. readonly texturesRequired: number[];
  74511. }
  74512. }
  74513. declare module BABYLON {
  74514. interface Scene {
  74515. /** @hidden (Backing field) */
  74516. _geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  74517. /**
  74518. * Gets or Sets the current geometry buffer associated to the scene.
  74519. */
  74520. geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  74521. /**
  74522. * Enables a GeometryBufferRender and associates it with the scene
  74523. * @param ratio defines the scaling ratio to apply to the renderer (1 by default which means same resolution)
  74524. * @returns the GeometryBufferRenderer
  74525. */
  74526. enableGeometryBufferRenderer(ratio?: number): Nullable<GeometryBufferRenderer>;
  74527. /**
  74528. * Disables the GeometryBufferRender associated with the scene
  74529. */
  74530. disableGeometryBufferRenderer(): void;
  74531. }
  74532. /**
  74533. * Defines the Geometry Buffer scene component responsible to manage a G-Buffer useful
  74534. * in several rendering techniques.
  74535. */
  74536. export class GeometryBufferRendererSceneComponent implements ISceneComponent {
  74537. /**
  74538. * The component name helpful to identify the component in the list of scene components.
  74539. */
  74540. readonly name: string;
  74541. /**
  74542. * The scene the component belongs to.
  74543. */
  74544. scene: Scene;
  74545. /**
  74546. * Creates a new instance of the component for the given scene
  74547. * @param scene Defines the scene to register the component in
  74548. */
  74549. constructor(scene: Scene);
  74550. /**
  74551. * Registers the component in a given scene
  74552. */
  74553. register(): void;
  74554. /**
  74555. * Rebuilds the elements related to this component in case of
  74556. * context lost for instance.
  74557. */
  74558. rebuild(): void;
  74559. /**
  74560. * Disposes the component and the associated ressources
  74561. */
  74562. dispose(): void;
  74563. private _gatherRenderTargets;
  74564. }
  74565. }
  74566. declare module BABYLON {
  74567. /** @hidden */
  74568. export var motionBlurPixelShader: {
  74569. name: string;
  74570. shader: string;
  74571. };
  74572. }
  74573. declare module BABYLON {
  74574. /**
  74575. * The Motion Blur Post Process which blurs an image based on the objects velocity in scene.
  74576. * Velocity can be affected by each object's rotation, position and scale depending on the transformation speed.
  74577. * As an example, all you have to do is to create the post-process:
  74578. * var mb = new BABYLON.MotionBlurPostProcess(
  74579. * 'mb', // The name of the effect.
  74580. * scene, // The scene containing the objects to blur according to their velocity.
  74581. * 1.0, // The required width/height ratio to downsize to before computing the render pass.
  74582. * camera // The camera to apply the render pass to.
  74583. * );
  74584. * Then, all objects moving, rotating and/or scaling will be blurred depending on the transformation speed.
  74585. */
  74586. export class MotionBlurPostProcess extends PostProcess {
  74587. /**
  74588. * Defines how much the image is blurred by the movement. Default value is equal to 1
  74589. */
  74590. motionStrength: number;
  74591. /**
  74592. * Gets the number of iterations are used for motion blur quality. Default value is equal to 32
  74593. */
  74594. get motionBlurSamples(): number;
  74595. /**
  74596. * Sets the number of iterations to be used for motion blur quality
  74597. */
  74598. set motionBlurSamples(samples: number);
  74599. private _motionBlurSamples;
  74600. /**
  74601. * Gets wether or not the motion blur post-process is in object based mode.
  74602. */
  74603. get isObjectBased(): boolean;
  74604. /**
  74605. * Sets wether or not the motion blur post-process is in object based mode.
  74606. */
  74607. set isObjectBased(value: boolean);
  74608. private _isObjectBased;
  74609. private _forceGeometryBuffer;
  74610. private _geometryBufferRenderer;
  74611. private _prePassRenderer;
  74612. private _invViewProjection;
  74613. private _previousViewProjection;
  74614. /**
  74615. * Gets a string identifying the name of the class
  74616. * @returns "MotionBlurPostProcess" string
  74617. */
  74618. getClassName(): string;
  74619. /**
  74620. * Creates a new instance MotionBlurPostProcess
  74621. * @param name The name of the effect.
  74622. * @param scene The scene containing the objects to blur according to their velocity.
  74623. * @param options The required width/height ratio to downsize to before computing the render pass.
  74624. * @param camera The camera to apply the render pass to.
  74625. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  74626. * @param engine The engine which the post process will be applied. (default: current engine)
  74627. * @param reusable If the post process can be reused on the same frame. (default: false)
  74628. * @param textureType Type of textures used when performing the post process. (default: 0)
  74629. * @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)
  74630. * @param forceGeometryBuffer If this post process should use geometry buffer instead of prepass (default: false)
  74631. */
  74632. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean, forceGeometryBuffer?: boolean);
  74633. /**
  74634. * Excludes the given skinned mesh from computing bones velocities.
  74635. * 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.
  74636. * @param skinnedMesh The mesh containing the skeleton to ignore when computing the velocity map.
  74637. */
  74638. excludeSkinnedMesh(skinnedMesh: AbstractMesh): void;
  74639. /**
  74640. * Removes the given skinned mesh from the excluded meshes to integrate bones velocities while rendering the velocity map.
  74641. * @param skinnedMesh The mesh containing the skeleton that has been ignored previously.
  74642. * @see excludeSkinnedMesh to exclude a skinned mesh from bones velocity computation.
  74643. */
  74644. removeExcludedSkinnedMesh(skinnedMesh: AbstractMesh): void;
  74645. /**
  74646. * Disposes the post process.
  74647. * @param camera The camera to dispose the post process on.
  74648. */
  74649. dispose(camera?: Camera): void;
  74650. /**
  74651. * Called on the mode changed (object based or screen based).
  74652. */
  74653. private _applyMode;
  74654. /**
  74655. * Called on the effect is applied when the motion blur post-process is in object based mode.
  74656. */
  74657. private _onApplyObjectBased;
  74658. /**
  74659. * Called on the effect is applied when the motion blur post-process is in screen based mode.
  74660. */
  74661. private _onApplyScreenBased;
  74662. /**
  74663. * Called on the effect must be updated (changed mode, samples count, etc.).
  74664. */
  74665. private _updateEffect;
  74666. /** @hidden */
  74667. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): Nullable<MotionBlurPostProcess>;
  74668. }
  74669. }
  74670. declare module BABYLON {
  74671. /** @hidden */
  74672. export var refractionPixelShader: {
  74673. name: string;
  74674. shader: string;
  74675. };
  74676. }
  74677. declare module BABYLON {
  74678. /**
  74679. * Post process which applies a refractin texture
  74680. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  74681. */
  74682. export class RefractionPostProcess extends PostProcess {
  74683. private _refTexture;
  74684. private _ownRefractionTexture;
  74685. /** the base color of the refraction (used to taint the rendering) */
  74686. color: Color3;
  74687. /** simulated refraction depth */
  74688. depth: number;
  74689. /** the coefficient of the base color (0 to remove base color tainting) */
  74690. colorLevel: number;
  74691. /** Gets the url used to load the refraction texture */
  74692. refractionTextureUrl: string;
  74693. /**
  74694. * Gets or sets the refraction texture
  74695. * Please note that you are responsible for disposing the texture if you set it manually
  74696. */
  74697. get refractionTexture(): Texture;
  74698. set refractionTexture(value: Texture);
  74699. /**
  74700. * Gets a string identifying the name of the class
  74701. * @returns "RefractionPostProcess" string
  74702. */
  74703. getClassName(): string;
  74704. /**
  74705. * Initializes the RefractionPostProcess
  74706. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  74707. * @param name The name of the effect.
  74708. * @param refractionTextureUrl Url of the refraction texture to use
  74709. * @param color the base color of the refraction (used to taint the rendering)
  74710. * @param depth simulated refraction depth
  74711. * @param colorLevel the coefficient of the base color (0 to remove base color tainting)
  74712. * @param camera The camera to apply the render pass to.
  74713. * @param options The required width/height ratio to downsize to before computing the render pass.
  74714. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  74715. * @param engine The engine which the post process will be applied. (default: current engine)
  74716. * @param reusable If the post process can be reused on the same frame. (default: false)
  74717. */
  74718. constructor(name: string, refractionTextureUrl: string, color: Color3, depth: number, colorLevel: number, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  74719. /**
  74720. * Disposes of the post process
  74721. * @param camera Camera to dispose post process on
  74722. */
  74723. dispose(camera: Camera): void;
  74724. /** @hidden */
  74725. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): RefractionPostProcess;
  74726. }
  74727. }
  74728. declare module BABYLON {
  74729. /** @hidden */
  74730. export var sharpenPixelShader: {
  74731. name: string;
  74732. shader: string;
  74733. };
  74734. }
  74735. declare module BABYLON {
  74736. /**
  74737. * The SharpenPostProcess applies a sharpen kernel to every pixel
  74738. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  74739. */
  74740. export class SharpenPostProcess extends PostProcess {
  74741. /**
  74742. * How much of the original color should be applied. Setting this to 0 will display edge detection. (default: 1)
  74743. */
  74744. colorAmount: number;
  74745. /**
  74746. * How much sharpness should be applied (default: 0.3)
  74747. */
  74748. edgeAmount: number;
  74749. /**
  74750. * Gets a string identifying the name of the class
  74751. * @returns "SharpenPostProcess" string
  74752. */
  74753. getClassName(): string;
  74754. /**
  74755. * Creates a new instance ConvolutionPostProcess
  74756. * @param name The name of the effect.
  74757. * @param options The required width/height ratio to downsize to before computing the render pass.
  74758. * @param camera The camera to apply the render pass to.
  74759. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  74760. * @param engine The engine which the post process will be applied. (default: current engine)
  74761. * @param reusable If the post process can be reused on the same frame. (default: false)
  74762. * @param textureType Type of textures used when performing the post process. (default: 0)
  74763. * @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)
  74764. */
  74765. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  74766. /** @hidden */
  74767. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): SharpenPostProcess;
  74768. }
  74769. }
  74770. declare module BABYLON {
  74771. /**
  74772. * PostProcessRenderPipeline
  74773. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  74774. */
  74775. export class PostProcessRenderPipeline {
  74776. private engine;
  74777. private _renderEffects;
  74778. private _renderEffectsForIsolatedPass;
  74779. /**
  74780. * List of inspectable custom properties (used by the Inspector)
  74781. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  74782. */
  74783. inspectableCustomProperties: IInspectable[];
  74784. /**
  74785. * @hidden
  74786. */
  74787. protected _cameras: Camera[];
  74788. /** @hidden */
  74789. _name: string;
  74790. /**
  74791. * Gets pipeline name
  74792. */
  74793. get name(): string;
  74794. /** Gets the list of attached cameras */
  74795. get cameras(): Camera[];
  74796. /**
  74797. * Initializes a PostProcessRenderPipeline
  74798. * @param engine engine to add the pipeline to
  74799. * @param name name of the pipeline
  74800. */
  74801. constructor(engine: Engine, name: string);
  74802. /**
  74803. * Gets the class name
  74804. * @returns "PostProcessRenderPipeline"
  74805. */
  74806. getClassName(): string;
  74807. /**
  74808. * If all the render effects in the pipeline are supported
  74809. */
  74810. get isSupported(): boolean;
  74811. /**
  74812. * Adds an effect to the pipeline
  74813. * @param renderEffect the effect to add
  74814. */
  74815. addEffect(renderEffect: PostProcessRenderEffect): void;
  74816. /** @hidden */
  74817. _rebuild(): void;
  74818. /** @hidden */
  74819. _enableEffect(renderEffectName: string, cameras: Camera): void;
  74820. /** @hidden */
  74821. _enableEffect(renderEffectName: string, cameras: Camera[]): void;
  74822. /** @hidden */
  74823. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  74824. /** @hidden */
  74825. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  74826. /** @hidden */
  74827. _attachCameras(cameras: Camera, unique: boolean): void;
  74828. /** @hidden */
  74829. _attachCameras(cameras: Camera[], unique: boolean): void;
  74830. /** @hidden */
  74831. _detachCameras(cameras: Camera): void;
  74832. /** @hidden */
  74833. _detachCameras(cameras: Nullable<Camera[]>): void;
  74834. /** @hidden */
  74835. _update(): void;
  74836. /** @hidden */
  74837. _reset(): void;
  74838. protected _enableMSAAOnFirstPostProcess(sampleCount: number): boolean;
  74839. /**
  74840. * Sets the required values to the prepass renderer.
  74841. * @param prePassRenderer defines the prepass renderer to setup.
  74842. * @returns true if the pre pass is needed.
  74843. */
  74844. setPrePassRenderer(prePassRenderer: PrePassRenderer): boolean;
  74845. /**
  74846. * Disposes of the pipeline
  74847. */
  74848. dispose(): void;
  74849. }
  74850. }
  74851. declare module BABYLON {
  74852. /**
  74853. * PostProcessRenderPipelineManager class
  74854. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  74855. */
  74856. export class PostProcessRenderPipelineManager {
  74857. private _renderPipelines;
  74858. /**
  74859. * Initializes a PostProcessRenderPipelineManager
  74860. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  74861. */
  74862. constructor();
  74863. /**
  74864. * Gets the list of supported render pipelines
  74865. */
  74866. get supportedPipelines(): PostProcessRenderPipeline[];
  74867. /**
  74868. * Adds a pipeline to the manager
  74869. * @param renderPipeline The pipeline to add
  74870. */
  74871. addPipeline(renderPipeline: PostProcessRenderPipeline): void;
  74872. /**
  74873. * Attaches a camera to the pipeline
  74874. * @param renderPipelineName The name of the pipeline to attach to
  74875. * @param cameras the camera to attach
  74876. * @param unique if the camera can be attached multiple times to the pipeline
  74877. */
  74878. attachCamerasToRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera, unique?: boolean): void;
  74879. /**
  74880. * Detaches a camera from the pipeline
  74881. * @param renderPipelineName The name of the pipeline to detach from
  74882. * @param cameras the camera to detach
  74883. */
  74884. detachCamerasFromRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera): void;
  74885. /**
  74886. * Enables an effect by name on a pipeline
  74887. * @param renderPipelineName the name of the pipeline to enable the effect in
  74888. * @param renderEffectName the name of the effect to enable
  74889. * @param cameras the cameras that the effect should be enabled on
  74890. */
  74891. enableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  74892. /**
  74893. * Disables an effect by name on a pipeline
  74894. * @param renderPipelineName the name of the pipeline to disable the effect in
  74895. * @param renderEffectName the name of the effect to disable
  74896. * @param cameras the cameras that the effect should be disabled on
  74897. */
  74898. disableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  74899. /**
  74900. * Updates the state of all contained render pipelines and disposes of any non supported pipelines
  74901. */
  74902. update(): void;
  74903. /** @hidden */
  74904. _rebuild(): void;
  74905. /**
  74906. * Disposes of the manager and pipelines
  74907. */
  74908. dispose(): void;
  74909. }
  74910. }
  74911. declare module BABYLON {
  74912. interface Scene {
  74913. /** @hidden (Backing field) */
  74914. _postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  74915. /**
  74916. * Gets the postprocess render pipeline manager
  74917. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  74918. * @see https://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  74919. */
  74920. readonly postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  74921. }
  74922. /**
  74923. * Defines the Render Pipeline scene component responsible to rendering pipelines
  74924. */
  74925. export class PostProcessRenderPipelineManagerSceneComponent implements ISceneComponent {
  74926. /**
  74927. * The component name helpfull to identify the component in the list of scene components.
  74928. */
  74929. readonly name: string;
  74930. /**
  74931. * The scene the component belongs to.
  74932. */
  74933. scene: Scene;
  74934. /**
  74935. * Creates a new instance of the component for the given scene
  74936. * @param scene Defines the scene to register the component in
  74937. */
  74938. constructor(scene: Scene);
  74939. /**
  74940. * Registers the component in a given scene
  74941. */
  74942. register(): void;
  74943. /**
  74944. * Rebuilds the elements related to this component in case of
  74945. * context lost for instance.
  74946. */
  74947. rebuild(): void;
  74948. /**
  74949. * Disposes the component and the associated ressources
  74950. */
  74951. dispose(): void;
  74952. private _gatherRenderTargets;
  74953. }
  74954. }
  74955. declare module BABYLON {
  74956. /**
  74957. * The default rendering pipeline can be added to a scene to apply common post processing effects such as anti-aliasing or depth of field.
  74958. * See https://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  74959. */
  74960. export class DefaultRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  74961. private _scene;
  74962. private _camerasToBeAttached;
  74963. /**
  74964. * ID of the sharpen post process,
  74965. */
  74966. private readonly SharpenPostProcessId;
  74967. /**
  74968. * @ignore
  74969. * ID of the image processing post process;
  74970. */
  74971. readonly ImageProcessingPostProcessId: string;
  74972. /**
  74973. * @ignore
  74974. * ID of the Fast Approximate Anti-Aliasing post process;
  74975. */
  74976. readonly FxaaPostProcessId: string;
  74977. /**
  74978. * ID of the chromatic aberration post process,
  74979. */
  74980. private readonly ChromaticAberrationPostProcessId;
  74981. /**
  74982. * ID of the grain post process
  74983. */
  74984. private readonly GrainPostProcessId;
  74985. /**
  74986. * Sharpen post process which will apply a sharpen convolution to enhance edges
  74987. */
  74988. sharpen: SharpenPostProcess;
  74989. private _sharpenEffect;
  74990. private bloom;
  74991. /**
  74992. * Depth of field effect, applies a blur based on how far away objects are from the focus distance.
  74993. */
  74994. depthOfField: DepthOfFieldEffect;
  74995. /**
  74996. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  74997. */
  74998. fxaa: FxaaPostProcess;
  74999. /**
  75000. * Image post processing pass used to perform operations such as tone mapping or color grading.
  75001. */
  75002. imageProcessing: ImageProcessingPostProcess;
  75003. /**
  75004. * Chromatic aberration post process which will shift rgb colors in the image
  75005. */
  75006. chromaticAberration: ChromaticAberrationPostProcess;
  75007. private _chromaticAberrationEffect;
  75008. /**
  75009. * Grain post process which add noise to the image
  75010. */
  75011. grain: GrainPostProcess;
  75012. private _grainEffect;
  75013. /**
  75014. * Glow post process which adds a glow to emissive areas of the image
  75015. */
  75016. private _glowLayer;
  75017. /**
  75018. * Animations which can be used to tweak settings over a period of time
  75019. */
  75020. animations: Animation[];
  75021. private _imageProcessingConfigurationObserver;
  75022. private _sharpenEnabled;
  75023. private _bloomEnabled;
  75024. private _depthOfFieldEnabled;
  75025. private _depthOfFieldBlurLevel;
  75026. private _fxaaEnabled;
  75027. private _imageProcessingEnabled;
  75028. private _defaultPipelineTextureType;
  75029. private _bloomScale;
  75030. private _chromaticAberrationEnabled;
  75031. private _grainEnabled;
  75032. private _buildAllowed;
  75033. /**
  75034. * This is triggered each time the pipeline has been built.
  75035. */
  75036. onBuildObservable: Observable<DefaultRenderingPipeline>;
  75037. /**
  75038. * Gets active scene
  75039. */
  75040. get scene(): Scene;
  75041. /**
  75042. * Enable or disable the sharpen process from the pipeline
  75043. */
  75044. set sharpenEnabled(enabled: boolean);
  75045. get sharpenEnabled(): boolean;
  75046. private _resizeObserver;
  75047. private _hardwareScaleLevel;
  75048. private _bloomKernel;
  75049. /**
  75050. * Specifies the size of the bloom blur kernel, relative to the final output size
  75051. */
  75052. get bloomKernel(): number;
  75053. set bloomKernel(value: number);
  75054. /**
  75055. * Specifies the weight of the bloom in the final rendering
  75056. */
  75057. private _bloomWeight;
  75058. /**
  75059. * Specifies the luma threshold for the area that will be blurred by the bloom
  75060. */
  75061. private _bloomThreshold;
  75062. private _hdr;
  75063. /**
  75064. * The strength of the bloom.
  75065. */
  75066. set bloomWeight(value: number);
  75067. get bloomWeight(): number;
  75068. /**
  75069. * The strength of the bloom.
  75070. */
  75071. set bloomThreshold(value: number);
  75072. get bloomThreshold(): number;
  75073. /**
  75074. * The scale of the bloom, lower value will provide better performance.
  75075. */
  75076. set bloomScale(value: number);
  75077. get bloomScale(): number;
  75078. /**
  75079. * Enable or disable the bloom from the pipeline
  75080. */
  75081. set bloomEnabled(enabled: boolean);
  75082. get bloomEnabled(): boolean;
  75083. private _rebuildBloom;
  75084. /**
  75085. * If the depth of field is enabled.
  75086. */
  75087. get depthOfFieldEnabled(): boolean;
  75088. set depthOfFieldEnabled(enabled: boolean);
  75089. /**
  75090. * Blur level of the depth of field effect. (Higher blur will effect performance)
  75091. */
  75092. get depthOfFieldBlurLevel(): DepthOfFieldEffectBlurLevel;
  75093. set depthOfFieldBlurLevel(value: DepthOfFieldEffectBlurLevel);
  75094. /**
  75095. * If the anti aliasing is enabled.
  75096. */
  75097. set fxaaEnabled(enabled: boolean);
  75098. get fxaaEnabled(): boolean;
  75099. private _samples;
  75100. /**
  75101. * MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  75102. */
  75103. set samples(sampleCount: number);
  75104. get samples(): number;
  75105. /**
  75106. * If image processing is enabled.
  75107. */
  75108. set imageProcessingEnabled(enabled: boolean);
  75109. get imageProcessingEnabled(): boolean;
  75110. /**
  75111. * If glow layer is enabled. (Adds a glow effect to emmissive materials)
  75112. */
  75113. set glowLayerEnabled(enabled: boolean);
  75114. get glowLayerEnabled(): boolean;
  75115. /**
  75116. * Gets the glow layer (or null if not defined)
  75117. */
  75118. get glowLayer(): Nullable<GlowLayer>;
  75119. /**
  75120. * Enable or disable the chromaticAberration process from the pipeline
  75121. */
  75122. set chromaticAberrationEnabled(enabled: boolean);
  75123. get chromaticAberrationEnabled(): boolean;
  75124. /**
  75125. * Enable or disable the grain process from the pipeline
  75126. */
  75127. set grainEnabled(enabled: boolean);
  75128. get grainEnabled(): boolean;
  75129. /**
  75130. * @constructor
  75131. * @param name - The rendering pipeline name (default: "")
  75132. * @param hdr - If high dynamic range textures should be used (default: true)
  75133. * @param scene - The scene linked to this pipeline (default: the last created scene)
  75134. * @param cameras - The array of cameras that the rendering pipeline will be attached to (default: scene.cameras)
  75135. * @param automaticBuild - if false, you will have to manually call prepare() to update the pipeline (default: true)
  75136. */
  75137. constructor(name?: string, hdr?: boolean, scene?: Scene, cameras?: Camera[], automaticBuild?: boolean);
  75138. /**
  75139. * Get the class name
  75140. * @returns "DefaultRenderingPipeline"
  75141. */
  75142. getClassName(): string;
  75143. /**
  75144. * Force the compilation of the entire pipeline.
  75145. */
  75146. prepare(): void;
  75147. private _hasCleared;
  75148. private _prevPostProcess;
  75149. private _prevPrevPostProcess;
  75150. private _setAutoClearAndTextureSharing;
  75151. private _depthOfFieldSceneObserver;
  75152. private _buildPipeline;
  75153. private _disposePostProcesses;
  75154. /**
  75155. * Adds a camera to the pipeline
  75156. * @param camera the camera to be added
  75157. */
  75158. addCamera(camera: Camera): void;
  75159. /**
  75160. * Removes a camera from the pipeline
  75161. * @param camera the camera to remove
  75162. */
  75163. removeCamera(camera: Camera): void;
  75164. /**
  75165. * Dispose of the pipeline and stop all post processes
  75166. */
  75167. dispose(): void;
  75168. /**
  75169. * Serialize the rendering pipeline (Used when exporting)
  75170. * @returns the serialized object
  75171. */
  75172. serialize(): any;
  75173. /**
  75174. * Parse the serialized pipeline
  75175. * @param source Source pipeline.
  75176. * @param scene The scene to load the pipeline to.
  75177. * @param rootUrl The URL of the serialized pipeline.
  75178. * @returns An instantiated pipeline from the serialized object.
  75179. */
  75180. static Parse(source: any, scene: Scene, rootUrl: string): DefaultRenderingPipeline;
  75181. }
  75182. }
  75183. declare module BABYLON {
  75184. /** @hidden */
  75185. export var lensHighlightsPixelShader: {
  75186. name: string;
  75187. shader: string;
  75188. };
  75189. }
  75190. declare module BABYLON {
  75191. /** @hidden */
  75192. export var depthOfFieldPixelShader: {
  75193. name: string;
  75194. shader: string;
  75195. };
  75196. }
  75197. declare module BABYLON {
  75198. /**
  75199. * BABYLON.JS Chromatic Aberration GLSL Shader
  75200. * Author: Olivier Guyot
  75201. * Separates very slightly R, G and B colors on the edges of the screen
  75202. * Inspired by Francois Tarlier & Martins Upitis
  75203. */
  75204. export class LensRenderingPipeline extends PostProcessRenderPipeline {
  75205. /**
  75206. * @ignore
  75207. * The chromatic aberration PostProcess id in the pipeline
  75208. */
  75209. LensChromaticAberrationEffect: string;
  75210. /**
  75211. * @ignore
  75212. * The highlights enhancing PostProcess id in the pipeline
  75213. */
  75214. HighlightsEnhancingEffect: string;
  75215. /**
  75216. * @ignore
  75217. * The depth-of-field PostProcess id in the pipeline
  75218. */
  75219. LensDepthOfFieldEffect: string;
  75220. private _scene;
  75221. private _depthTexture;
  75222. private _grainTexture;
  75223. private _chromaticAberrationPostProcess;
  75224. private _highlightsPostProcess;
  75225. private _depthOfFieldPostProcess;
  75226. private _edgeBlur;
  75227. private _grainAmount;
  75228. private _chromaticAberration;
  75229. private _distortion;
  75230. private _highlightsGain;
  75231. private _highlightsThreshold;
  75232. private _dofDistance;
  75233. private _dofAperture;
  75234. private _dofDarken;
  75235. private _dofPentagon;
  75236. private _blurNoise;
  75237. /**
  75238. * @constructor
  75239. *
  75240. * Effect parameters are as follow:
  75241. * {
  75242. * chromatic_aberration: number; // from 0 to x (1 for realism)
  75243. * edge_blur: number; // from 0 to x (1 for realism)
  75244. * distortion: number; // from 0 to x (1 for realism)
  75245. * grain_amount: number; // from 0 to 1
  75246. * grain_texture: BABYLON.Texture; // texture to use for grain effect; if unset, use random B&W noise
  75247. * dof_focus_distance: number; // depth-of-field: focus distance; unset to disable (disabled by default)
  75248. * dof_aperture: number; // depth-of-field: focus blur bias (default: 1)
  75249. * dof_darken: number; // depth-of-field: darken that which is out of focus (from 0 to 1, disabled by default)
  75250. * dof_pentagon: boolean; // depth-of-field: makes a pentagon-like "bokeh" effect
  75251. * dof_gain: number; // depth-of-field: highlights gain; unset to disable (disabled by default)
  75252. * dof_threshold: number; // depth-of-field: highlights threshold (default: 1)
  75253. * blur_noise: boolean; // add a little bit of noise to the blur (default: true)
  75254. * }
  75255. * Note: if an effect parameter is unset, effect is disabled
  75256. *
  75257. * @param name The rendering pipeline name
  75258. * @param parameters - An object containing all parameters (see above)
  75259. * @param scene The scene linked to this pipeline
  75260. * @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)
  75261. * @param cameras The array of cameras that the rendering pipeline will be attached to
  75262. */
  75263. constructor(name: string, parameters: any, scene: Scene, ratio?: number, cameras?: Camera[]);
  75264. /**
  75265. * Get the class name
  75266. * @returns "LensRenderingPipeline"
  75267. */
  75268. getClassName(): string;
  75269. /**
  75270. * Gets associated scene
  75271. */
  75272. get scene(): Scene;
  75273. /**
  75274. * Gets or sets the edge blur
  75275. */
  75276. get edgeBlur(): number;
  75277. set edgeBlur(value: number);
  75278. /**
  75279. * Gets or sets the grain amount
  75280. */
  75281. get grainAmount(): number;
  75282. set grainAmount(value: number);
  75283. /**
  75284. * Gets or sets the chromatic aberration amount
  75285. */
  75286. get chromaticAberration(): number;
  75287. set chromaticAberration(value: number);
  75288. /**
  75289. * Gets or sets the depth of field aperture
  75290. */
  75291. get dofAperture(): number;
  75292. set dofAperture(value: number);
  75293. /**
  75294. * Gets or sets the edge distortion
  75295. */
  75296. get edgeDistortion(): number;
  75297. set edgeDistortion(value: number);
  75298. /**
  75299. * Gets or sets the depth of field distortion
  75300. */
  75301. get dofDistortion(): number;
  75302. set dofDistortion(value: number);
  75303. /**
  75304. * Gets or sets the darken out of focus amount
  75305. */
  75306. get darkenOutOfFocus(): number;
  75307. set darkenOutOfFocus(value: number);
  75308. /**
  75309. * Gets or sets a boolean indicating if blur noise is enabled
  75310. */
  75311. get blurNoise(): boolean;
  75312. set blurNoise(value: boolean);
  75313. /**
  75314. * Gets or sets a boolean indicating if pentagon bokeh is enabled
  75315. */
  75316. get pentagonBokeh(): boolean;
  75317. set pentagonBokeh(value: boolean);
  75318. /**
  75319. * Gets or sets the highlight grain amount
  75320. */
  75321. get highlightsGain(): number;
  75322. set highlightsGain(value: number);
  75323. /**
  75324. * Gets or sets the highlight threshold
  75325. */
  75326. get highlightsThreshold(): number;
  75327. set highlightsThreshold(value: number);
  75328. /**
  75329. * Sets the amount of blur at the edges
  75330. * @param amount blur amount
  75331. */
  75332. setEdgeBlur(amount: number): void;
  75333. /**
  75334. * Sets edge blur to 0
  75335. */
  75336. disableEdgeBlur(): void;
  75337. /**
  75338. * Sets the amout of grain
  75339. * @param amount Amount of grain
  75340. */
  75341. setGrainAmount(amount: number): void;
  75342. /**
  75343. * Set grain amount to 0
  75344. */
  75345. disableGrain(): void;
  75346. /**
  75347. * Sets the chromatic aberration amount
  75348. * @param amount amount of chromatic aberration
  75349. */
  75350. setChromaticAberration(amount: number): void;
  75351. /**
  75352. * Sets chromatic aberration amount to 0
  75353. */
  75354. disableChromaticAberration(): void;
  75355. /**
  75356. * Sets the EdgeDistortion amount
  75357. * @param amount amount of EdgeDistortion
  75358. */
  75359. setEdgeDistortion(amount: number): void;
  75360. /**
  75361. * Sets edge distortion to 0
  75362. */
  75363. disableEdgeDistortion(): void;
  75364. /**
  75365. * Sets the FocusDistance amount
  75366. * @param amount amount of FocusDistance
  75367. */
  75368. setFocusDistance(amount: number): void;
  75369. /**
  75370. * Disables depth of field
  75371. */
  75372. disableDepthOfField(): void;
  75373. /**
  75374. * Sets the Aperture amount
  75375. * @param amount amount of Aperture
  75376. */
  75377. setAperture(amount: number): void;
  75378. /**
  75379. * Sets the DarkenOutOfFocus amount
  75380. * @param amount amount of DarkenOutOfFocus
  75381. */
  75382. setDarkenOutOfFocus(amount: number): void;
  75383. private _pentagonBokehIsEnabled;
  75384. /**
  75385. * Creates a pentagon bokeh effect
  75386. */
  75387. enablePentagonBokeh(): void;
  75388. /**
  75389. * Disables the pentagon bokeh effect
  75390. */
  75391. disablePentagonBokeh(): void;
  75392. /**
  75393. * Enables noise blur
  75394. */
  75395. enableNoiseBlur(): void;
  75396. /**
  75397. * Disables noise blur
  75398. */
  75399. disableNoiseBlur(): void;
  75400. /**
  75401. * Sets the HighlightsGain amount
  75402. * @param amount amount of HighlightsGain
  75403. */
  75404. setHighlightsGain(amount: number): void;
  75405. /**
  75406. * Sets the HighlightsThreshold amount
  75407. * @param amount amount of HighlightsThreshold
  75408. */
  75409. setHighlightsThreshold(amount: number): void;
  75410. /**
  75411. * Disables highlights
  75412. */
  75413. disableHighlights(): void;
  75414. /**
  75415. * Removes the internal pipeline assets and detaches the pipeline from the scene cameras
  75416. * @param disableDepthRender If the scens depth rendering should be disabled (default: false)
  75417. */
  75418. dispose(disableDepthRender?: boolean): void;
  75419. private _createChromaticAberrationPostProcess;
  75420. private _createHighlightsPostProcess;
  75421. private _createDepthOfFieldPostProcess;
  75422. private _createGrainTexture;
  75423. }
  75424. }
  75425. declare module BABYLON {
  75426. /**
  75427. * Contains all parameters needed for the prepass to perform
  75428. * screen space subsurface scattering
  75429. */
  75430. export class SSAO2Configuration implements PrePassEffectConfiguration {
  75431. /**
  75432. * Is subsurface enabled
  75433. */
  75434. enabled: boolean;
  75435. /**
  75436. * Name of the configuration
  75437. */
  75438. name: string;
  75439. /**
  75440. * Textures that should be present in the MRT for this effect to work
  75441. */
  75442. readonly texturesRequired: number[];
  75443. }
  75444. }
  75445. declare module BABYLON {
  75446. /** @hidden */
  75447. export var ssao2PixelShader: {
  75448. name: string;
  75449. shader: string;
  75450. };
  75451. }
  75452. declare module BABYLON {
  75453. /** @hidden */
  75454. export var ssaoCombinePixelShader: {
  75455. name: string;
  75456. shader: string;
  75457. };
  75458. }
  75459. declare module BABYLON {
  75460. /**
  75461. * Render pipeline to produce ssao effect
  75462. */
  75463. export class SSAO2RenderingPipeline extends PostProcessRenderPipeline {
  75464. /**
  75465. * @ignore
  75466. * The PassPostProcess id in the pipeline that contains the original scene color
  75467. */
  75468. SSAOOriginalSceneColorEffect: string;
  75469. /**
  75470. * @ignore
  75471. * The SSAO PostProcess id in the pipeline
  75472. */
  75473. SSAORenderEffect: string;
  75474. /**
  75475. * @ignore
  75476. * The horizontal blur PostProcess id in the pipeline
  75477. */
  75478. SSAOBlurHRenderEffect: string;
  75479. /**
  75480. * @ignore
  75481. * The vertical blur PostProcess id in the pipeline
  75482. */
  75483. SSAOBlurVRenderEffect: string;
  75484. /**
  75485. * @ignore
  75486. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  75487. */
  75488. SSAOCombineRenderEffect: string;
  75489. /**
  75490. * The output strength of the SSAO post-process. Default value is 1.0.
  75491. */
  75492. totalStrength: number;
  75493. /**
  75494. * Maximum depth value to still render AO. A smooth falloff makes the dimming more natural, so there will be no abrupt shading change.
  75495. */
  75496. maxZ: number;
  75497. /**
  75498. * In order to save performances, SSAO radius is clamped on close geometry. This ratio changes by how much
  75499. */
  75500. minZAspect: number;
  75501. private _samples;
  75502. /**
  75503. * Number of samples used for the SSAO calculations. Default value is 8
  75504. */
  75505. set samples(n: number);
  75506. get samples(): number;
  75507. private _textureSamples;
  75508. /**
  75509. * Number of samples to use for antialiasing
  75510. */
  75511. set textureSamples(n: number);
  75512. get textureSamples(): number;
  75513. /**
  75514. * Force rendering the geometry through geometry buffer
  75515. */
  75516. private _forceGeometryBuffer;
  75517. /**
  75518. * Ratio object used for SSAO ratio and blur ratio
  75519. */
  75520. private _ratio;
  75521. /**
  75522. * Dynamically generated sphere sampler.
  75523. */
  75524. private _sampleSphere;
  75525. /**
  75526. * Blur filter offsets
  75527. */
  75528. private _samplerOffsets;
  75529. private _expensiveBlur;
  75530. /**
  75531. * If bilateral blur should be used
  75532. */
  75533. set expensiveBlur(b: boolean);
  75534. get expensiveBlur(): boolean;
  75535. /**
  75536. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 2.0
  75537. */
  75538. radius: number;
  75539. /**
  75540. * The base color of the SSAO post-process
  75541. * The final result is "base + ssao" between [0, 1]
  75542. */
  75543. base: number;
  75544. /**
  75545. * Support test.
  75546. */
  75547. static get IsSupported(): boolean;
  75548. private _scene;
  75549. private _randomTexture;
  75550. private _originalColorPostProcess;
  75551. private _ssaoPostProcess;
  75552. private _blurHPostProcess;
  75553. private _blurVPostProcess;
  75554. private _ssaoCombinePostProcess;
  75555. private _prePassRenderer;
  75556. /**
  75557. * Gets active scene
  75558. */
  75559. get scene(): Scene;
  75560. /**
  75561. * @constructor
  75562. * @param name The rendering pipeline name
  75563. * @param scene The scene linked to this pipeline
  75564. * @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 }
  75565. * @param cameras The array of cameras that the rendering pipeline will be attached to
  75566. * @param forceGeometryBuffer Set to true if you want to use the legacy geometry buffer renderer
  75567. */
  75568. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[], forceGeometryBuffer?: boolean);
  75569. /**
  75570. * Get the class name
  75571. * @returns "SSAO2RenderingPipeline"
  75572. */
  75573. getClassName(): string;
  75574. /**
  75575. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  75576. */
  75577. dispose(disableGeometryBufferRenderer?: boolean): void;
  75578. private _createBlurPostProcess;
  75579. /** @hidden */
  75580. _rebuild(): void;
  75581. private _bits;
  75582. private _radicalInverse_VdC;
  75583. private _hammersley;
  75584. private _hemisphereSample_uniform;
  75585. private _generateHemisphere;
  75586. private _getDefinesForSSAO;
  75587. private static readonly ORTHO_DEPTH_PROJECTION;
  75588. private static readonly PERSPECTIVE_DEPTH_PROJECTION;
  75589. private _createSSAOPostProcess;
  75590. private _createSSAOCombinePostProcess;
  75591. private _createRandomTexture;
  75592. /**
  75593. * Serialize the rendering pipeline (Used when exporting)
  75594. * @returns the serialized object
  75595. */
  75596. serialize(): any;
  75597. /**
  75598. * Parse the serialized pipeline
  75599. * @param source Source pipeline.
  75600. * @param scene The scene to load the pipeline to.
  75601. * @param rootUrl The URL of the serialized pipeline.
  75602. * @returns An instantiated pipeline from the serialized object.
  75603. */
  75604. static Parse(source: any, scene: Scene, rootUrl: string): SSAO2RenderingPipeline;
  75605. }
  75606. }
  75607. declare module BABYLON {
  75608. /** @hidden */
  75609. export var ssaoPixelShader: {
  75610. name: string;
  75611. shader: string;
  75612. };
  75613. }
  75614. declare module BABYLON {
  75615. /**
  75616. * Render pipeline to produce ssao effect
  75617. */
  75618. export class SSAORenderingPipeline extends PostProcessRenderPipeline {
  75619. /**
  75620. * @ignore
  75621. * The PassPostProcess id in the pipeline that contains the original scene color
  75622. */
  75623. SSAOOriginalSceneColorEffect: string;
  75624. /**
  75625. * @ignore
  75626. * The SSAO PostProcess id in the pipeline
  75627. */
  75628. SSAORenderEffect: string;
  75629. /**
  75630. * @ignore
  75631. * The horizontal blur PostProcess id in the pipeline
  75632. */
  75633. SSAOBlurHRenderEffect: string;
  75634. /**
  75635. * @ignore
  75636. * The vertical blur PostProcess id in the pipeline
  75637. */
  75638. SSAOBlurVRenderEffect: string;
  75639. /**
  75640. * @ignore
  75641. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  75642. */
  75643. SSAOCombineRenderEffect: string;
  75644. /**
  75645. * The output strength of the SSAO post-process. Default value is 1.0.
  75646. */
  75647. totalStrength: number;
  75648. /**
  75649. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 0.0006
  75650. */
  75651. radius: number;
  75652. /**
  75653. * Related to fallOff, used to interpolate SSAO samples (first interpolate function input) based on the occlusion difference of each pixel
  75654. * Must not be equal to fallOff and superior to fallOff.
  75655. * Default value is 0.0075
  75656. */
  75657. area: number;
  75658. /**
  75659. * Related to area, used to interpolate SSAO samples (second interpolate function input) based on the occlusion difference of each pixel
  75660. * Must not be equal to area and inferior to area.
  75661. * Default value is 0.000001
  75662. */
  75663. fallOff: number;
  75664. /**
  75665. * The base color of the SSAO post-process
  75666. * The final result is "base + ssao" between [0, 1]
  75667. */
  75668. base: number;
  75669. private _scene;
  75670. private _depthTexture;
  75671. private _randomTexture;
  75672. private _originalColorPostProcess;
  75673. private _ssaoPostProcess;
  75674. private _blurHPostProcess;
  75675. private _blurVPostProcess;
  75676. private _ssaoCombinePostProcess;
  75677. private _firstUpdate;
  75678. /**
  75679. * Gets active scene
  75680. */
  75681. get scene(): Scene;
  75682. /**
  75683. * @constructor
  75684. * @param name - The rendering pipeline name
  75685. * @param scene - The scene linked to this pipeline
  75686. * @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 }
  75687. * @param cameras - The array of cameras that the rendering pipeline will be attached to
  75688. */
  75689. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  75690. /**
  75691. * Get the class name
  75692. * @returns "SSAORenderingPipeline"
  75693. */
  75694. getClassName(): string;
  75695. /**
  75696. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  75697. */
  75698. dispose(disableDepthRender?: boolean): void;
  75699. private _createBlurPostProcess;
  75700. /** @hidden */
  75701. _rebuild(): void;
  75702. private _createSSAOPostProcess;
  75703. private _createSSAOCombinePostProcess;
  75704. private _createRandomTexture;
  75705. }
  75706. }
  75707. declare module BABYLON {
  75708. /**
  75709. * Contains all parameters needed for the prepass to perform
  75710. * screen space reflections
  75711. */
  75712. export class ScreenSpaceReflectionsConfiguration implements PrePassEffectConfiguration {
  75713. /**
  75714. * Is ssr enabled
  75715. */
  75716. enabled: boolean;
  75717. /**
  75718. * Name of the configuration
  75719. */
  75720. name: string;
  75721. /**
  75722. * Textures that should be present in the MRT for this effect to work
  75723. */
  75724. readonly texturesRequired: number[];
  75725. }
  75726. }
  75727. declare module BABYLON {
  75728. /** @hidden */
  75729. export var screenSpaceReflectionPixelShader: {
  75730. name: string;
  75731. shader: string;
  75732. };
  75733. }
  75734. declare module BABYLON {
  75735. /**
  75736. * The ScreenSpaceReflectionPostProcess performs realtime reflections using only and only the available informations on the screen (positions and normals).
  75737. * Basically, the screen space reflection post-process will compute reflections according the material's reflectivity.
  75738. */
  75739. export class ScreenSpaceReflectionPostProcess extends PostProcess {
  75740. /**
  75741. * Gets or sets a reflection threshold mainly used to adjust the reflection's height.
  75742. */
  75743. threshold: number;
  75744. /**
  75745. * Gets or sets the current reflection strength. 1.0 is an ideal value but can be increased/decreased for particular results.
  75746. */
  75747. strength: number;
  75748. /**
  75749. * Gets or sets the falloff exponent used while computing fresnel. More the exponent is high, more the reflections will be discrete.
  75750. */
  75751. reflectionSpecularFalloffExponent: number;
  75752. /**
  75753. * 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]
  75754. */
  75755. step: number;
  75756. /**
  75757. * Gets or sets the factor applied when computing roughness. Default value is 0.2.
  75758. */
  75759. roughnessFactor: number;
  75760. private _forceGeometryBuffer;
  75761. private _geometryBufferRenderer;
  75762. private _prePassRenderer;
  75763. private _enableSmoothReflections;
  75764. private _reflectionSamples;
  75765. private _smoothSteps;
  75766. /**
  75767. * Gets a string identifying the name of the class
  75768. * @returns "ScreenSpaceReflectionPostProcess" string
  75769. */
  75770. getClassName(): string;
  75771. /**
  75772. * Creates a new instance of ScreenSpaceReflectionPostProcess.
  75773. * @param name The name of the effect.
  75774. * @param scene The scene containing the objects to calculate reflections.
  75775. * @param options The required width/height ratio to downsize to before computing the render pass.
  75776. * @param camera The camera to apply the render pass to.
  75777. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  75778. * @param engine The engine which the post process will be applied. (default: current engine)
  75779. * @param reusable If the post process can be reused on the same frame. (default: false)
  75780. * @param textureType Type of textures used when performing the post process. (default: 0)
  75781. * @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)
  75782. * @param forceGeometryBuffer If this post process should use geometry buffer instead of prepass (default: false)
  75783. */
  75784. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean, forceGeometryBuffer?: boolean);
  75785. /**
  75786. * Gets wether or not smoothing reflections is enabled.
  75787. * Enabling smoothing will require more GPU power and can generate a drop in FPS.
  75788. */
  75789. get enableSmoothReflections(): boolean;
  75790. /**
  75791. * Sets wether or not smoothing reflections is enabled.
  75792. * Enabling smoothing will require more GPU power and can generate a drop in FPS.
  75793. */
  75794. set enableSmoothReflections(enabled: boolean);
  75795. /**
  75796. * Gets the number of samples taken while computing reflections. More samples count is high,
  75797. * more the post-process wil require GPU power and can generate a drop in FPS. Basically in interval [25, 100].
  75798. */
  75799. get reflectionSamples(): number;
  75800. /**
  75801. * Sets the number of samples taken while computing reflections. More samples count is high,
  75802. * more the post-process wil require GPU power and can generate a drop in FPS. Basically in interval [25, 100].
  75803. */
  75804. set reflectionSamples(samples: number);
  75805. /**
  75806. * Gets the number of samples taken while smoothing reflections. More samples count is high,
  75807. * more the post-process will require GPU power and can generate a drop in FPS.
  75808. * Default value (5.0) work pretty well in all cases but can be adjusted.
  75809. */
  75810. get smoothSteps(): number;
  75811. set smoothSteps(steps: number);
  75812. private _updateEffectDefines;
  75813. /** @hidden */
  75814. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): ScreenSpaceReflectionPostProcess;
  75815. }
  75816. }
  75817. declare module BABYLON {
  75818. /** @hidden */
  75819. export var standardPixelShader: {
  75820. name: string;
  75821. shader: string;
  75822. };
  75823. }
  75824. declare module BABYLON {
  75825. /**
  75826. * Standard rendering pipeline
  75827. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  75828. * @see https://doc.babylonjs.com/how_to/using_standard_rendering_pipeline
  75829. */
  75830. export class StandardRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  75831. /**
  75832. * Public members
  75833. */
  75834. /**
  75835. * Post-process which contains the original scene color before the pipeline applies all the effects
  75836. */
  75837. originalPostProcess: Nullable<PostProcess>;
  75838. /**
  75839. * Post-process used to down scale an image x4
  75840. */
  75841. downSampleX4PostProcess: Nullable<PostProcess>;
  75842. /**
  75843. * Post-process used to calculate the illuminated surfaces controlled by a threshold
  75844. */
  75845. brightPassPostProcess: Nullable<PostProcess>;
  75846. /**
  75847. * Post-process array storing all the horizontal blur post-processes used by the pipeline
  75848. */
  75849. blurHPostProcesses: PostProcess[];
  75850. /**
  75851. * Post-process array storing all the vertical blur post-processes used by the pipeline
  75852. */
  75853. blurVPostProcesses: PostProcess[];
  75854. /**
  75855. * Post-process used to add colors of 2 textures (typically brightness + real scene color)
  75856. */
  75857. textureAdderPostProcess: Nullable<PostProcess>;
  75858. /**
  75859. * Post-process used to create volumetric lighting effect
  75860. */
  75861. volumetricLightPostProcess: Nullable<PostProcess>;
  75862. /**
  75863. * Post-process used to smooth the previous volumetric light post-process on the X axis
  75864. */
  75865. volumetricLightSmoothXPostProcess: Nullable<BlurPostProcess>;
  75866. /**
  75867. * Post-process used to smooth the previous volumetric light post-process on the Y axis
  75868. */
  75869. volumetricLightSmoothYPostProcess: Nullable<BlurPostProcess>;
  75870. /**
  75871. * Post-process used to merge the volumetric light effect and the real scene color
  75872. */
  75873. volumetricLightMergePostProces: Nullable<PostProcess>;
  75874. /**
  75875. * Post-process used to store the final volumetric light post-process (attach/detach for debug purpose)
  75876. */
  75877. volumetricLightFinalPostProcess: Nullable<PostProcess>;
  75878. /**
  75879. * Base post-process used to calculate the average luminance of the final image for HDR
  75880. */
  75881. luminancePostProcess: Nullable<PostProcess>;
  75882. /**
  75883. * Post-processes used to create down sample post-processes in order to get
  75884. * the average luminance of the final image for HDR
  75885. * Array of length "StandardRenderingPipeline.LuminanceSteps"
  75886. */
  75887. luminanceDownSamplePostProcesses: PostProcess[];
  75888. /**
  75889. * Post-process used to create a HDR effect (light adaptation)
  75890. */
  75891. hdrPostProcess: Nullable<PostProcess>;
  75892. /**
  75893. * Post-process used to store the final texture adder post-process (attach/detach for debug purpose)
  75894. */
  75895. textureAdderFinalPostProcess: Nullable<PostProcess>;
  75896. /**
  75897. * Post-process used to store the final lens flare post-process (attach/detach for debug purpose)
  75898. */
  75899. lensFlareFinalPostProcess: Nullable<PostProcess>;
  75900. /**
  75901. * Post-process used to merge the final HDR post-process and the real scene color
  75902. */
  75903. hdrFinalPostProcess: Nullable<PostProcess>;
  75904. /**
  75905. * Post-process used to create a lens flare effect
  75906. */
  75907. lensFlarePostProcess: Nullable<PostProcess>;
  75908. /**
  75909. * Post-process that merges the result of the lens flare post-process and the real scene color
  75910. */
  75911. lensFlareComposePostProcess: Nullable<PostProcess>;
  75912. /**
  75913. * Post-process used to create a motion blur effect
  75914. */
  75915. motionBlurPostProcess: Nullable<PostProcess>;
  75916. /**
  75917. * Post-process used to create a depth of field effect
  75918. */
  75919. depthOfFieldPostProcess: Nullable<PostProcess>;
  75920. /**
  75921. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  75922. */
  75923. fxaaPostProcess: Nullable<FxaaPostProcess>;
  75924. /**
  75925. * Post-process used to simulate realtime reflections using the screen space and geometry renderer.
  75926. */
  75927. screenSpaceReflectionPostProcess: Nullable<ScreenSpaceReflectionPostProcess>;
  75928. /**
  75929. * Represents the brightness threshold in order to configure the illuminated surfaces
  75930. */
  75931. brightThreshold: number;
  75932. /**
  75933. * Configures the blur intensity used for surexposed surfaces are highlighted surfaces (light halo)
  75934. */
  75935. blurWidth: number;
  75936. /**
  75937. * Sets if the blur for highlighted surfaces must be only horizontal
  75938. */
  75939. horizontalBlur: boolean;
  75940. /**
  75941. * Gets the overall exposure used by the pipeline
  75942. */
  75943. get exposure(): number;
  75944. /**
  75945. * Sets the overall exposure used by the pipeline
  75946. */
  75947. set exposure(value: number);
  75948. /**
  75949. * Texture used typically to simulate "dirty" on camera lens
  75950. */
  75951. lensTexture: Nullable<Texture>;
  75952. /**
  75953. * Represents the offset coefficient based on Rayleigh principle. Typically in interval [-0.2, 0.2]
  75954. */
  75955. volumetricLightCoefficient: number;
  75956. /**
  75957. * The overall power of volumetric lights, typically in interval [0, 10] maximum
  75958. */
  75959. volumetricLightPower: number;
  75960. /**
  75961. * Used the set the blur intensity to smooth the volumetric lights
  75962. */
  75963. volumetricLightBlurScale: number;
  75964. /**
  75965. * Light (spot or directional) used to generate the volumetric lights rays
  75966. * The source light must have a shadow generate so the pipeline can get its
  75967. * depth map
  75968. */
  75969. sourceLight: Nullable<SpotLight | DirectionalLight>;
  75970. /**
  75971. * For eye adaptation, represents the minimum luminance the eye can see
  75972. */
  75973. hdrMinimumLuminance: number;
  75974. /**
  75975. * For eye adaptation, represents the decrease luminance speed
  75976. */
  75977. hdrDecreaseRate: number;
  75978. /**
  75979. * For eye adaptation, represents the increase luminance speed
  75980. */
  75981. hdrIncreaseRate: number;
  75982. /**
  75983. * Gets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  75984. */
  75985. get hdrAutoExposure(): boolean;
  75986. /**
  75987. * Sets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  75988. */
  75989. set hdrAutoExposure(value: boolean);
  75990. /**
  75991. * Lens color texture used by the lens flare effect. Mandatory if lens flare effect enabled
  75992. */
  75993. lensColorTexture: Nullable<Texture>;
  75994. /**
  75995. * The overall strengh for the lens flare effect
  75996. */
  75997. lensFlareStrength: number;
  75998. /**
  75999. * Dispersion coefficient for lens flare ghosts
  76000. */
  76001. lensFlareGhostDispersal: number;
  76002. /**
  76003. * Main lens flare halo width
  76004. */
  76005. lensFlareHaloWidth: number;
  76006. /**
  76007. * Based on the lens distortion effect, defines how much the lens flare result
  76008. * is distorted
  76009. */
  76010. lensFlareDistortionStrength: number;
  76011. /**
  76012. * Configures the blur intensity used for for lens flare (halo)
  76013. */
  76014. lensFlareBlurWidth: number;
  76015. /**
  76016. * Lens star texture must be used to simulate rays on the flares and is available
  76017. * in the documentation
  76018. */
  76019. lensStarTexture: Nullable<Texture>;
  76020. /**
  76021. * As the "lensTexture" (can be the same texture or different), it is used to apply the lens
  76022. * flare effect by taking account of the dirt texture
  76023. */
  76024. lensFlareDirtTexture: Nullable<Texture>;
  76025. /**
  76026. * Represents the focal length for the depth of field effect
  76027. */
  76028. depthOfFieldDistance: number;
  76029. /**
  76030. * Represents the blur intensity for the blurred part of the depth of field effect
  76031. */
  76032. depthOfFieldBlurWidth: number;
  76033. /**
  76034. * Gets how much the image is blurred by the movement while using the motion blur post-process
  76035. */
  76036. get motionStrength(): number;
  76037. /**
  76038. * Sets how much the image is blurred by the movement while using the motion blur post-process
  76039. */
  76040. set motionStrength(strength: number);
  76041. /**
  76042. * Gets wether or not the motion blur post-process is object based or screen based.
  76043. */
  76044. get objectBasedMotionBlur(): boolean;
  76045. /**
  76046. * Sets wether or not the motion blur post-process should be object based or screen based
  76047. */
  76048. set objectBasedMotionBlur(value: boolean);
  76049. /**
  76050. * List of animations for the pipeline (IAnimatable implementation)
  76051. */
  76052. animations: Animation[];
  76053. /**
  76054. * Private members
  76055. */
  76056. private _scene;
  76057. private _currentDepthOfFieldSource;
  76058. private _basePostProcess;
  76059. private _fixedExposure;
  76060. private _currentExposure;
  76061. private _hdrAutoExposure;
  76062. private _hdrCurrentLuminance;
  76063. private _motionStrength;
  76064. private _isObjectBasedMotionBlur;
  76065. private _floatTextureType;
  76066. private _camerasToBeAttached;
  76067. private _ratio;
  76068. private _bloomEnabled;
  76069. private _depthOfFieldEnabled;
  76070. private _vlsEnabled;
  76071. private _lensFlareEnabled;
  76072. private _hdrEnabled;
  76073. private _motionBlurEnabled;
  76074. private _fxaaEnabled;
  76075. private _screenSpaceReflectionsEnabled;
  76076. private _motionBlurSamples;
  76077. private _volumetricLightStepsCount;
  76078. private _samples;
  76079. /**
  76080. * @ignore
  76081. * Specifies if the bloom pipeline is enabled
  76082. */
  76083. get BloomEnabled(): boolean;
  76084. set BloomEnabled(enabled: boolean);
  76085. /**
  76086. * @ignore
  76087. * Specifies if the depth of field pipeline is enabed
  76088. */
  76089. get DepthOfFieldEnabled(): boolean;
  76090. set DepthOfFieldEnabled(enabled: boolean);
  76091. /**
  76092. * @ignore
  76093. * Specifies if the lens flare pipeline is enabed
  76094. */
  76095. get LensFlareEnabled(): boolean;
  76096. set LensFlareEnabled(enabled: boolean);
  76097. /**
  76098. * @ignore
  76099. * Specifies if the HDR pipeline is enabled
  76100. */
  76101. get HDREnabled(): boolean;
  76102. set HDREnabled(enabled: boolean);
  76103. /**
  76104. * @ignore
  76105. * Specifies if the volumetric lights scattering effect is enabled
  76106. */
  76107. get VLSEnabled(): boolean;
  76108. set VLSEnabled(enabled: boolean);
  76109. /**
  76110. * @ignore
  76111. * Specifies if the motion blur effect is enabled
  76112. */
  76113. get MotionBlurEnabled(): boolean;
  76114. set MotionBlurEnabled(enabled: boolean);
  76115. /**
  76116. * Specifies if anti-aliasing is enabled
  76117. */
  76118. get fxaaEnabled(): boolean;
  76119. set fxaaEnabled(enabled: boolean);
  76120. /**
  76121. * Specifies if screen space reflections are enabled.
  76122. */
  76123. get screenSpaceReflectionsEnabled(): boolean;
  76124. set screenSpaceReflectionsEnabled(enabled: boolean);
  76125. /**
  76126. * Specifies the number of steps used to calculate the volumetric lights
  76127. * Typically in interval [50, 200]
  76128. */
  76129. get volumetricLightStepsCount(): number;
  76130. set volumetricLightStepsCount(count: number);
  76131. /**
  76132. * Specifies the number of samples used for the motion blur effect
  76133. * Typically in interval [16, 64]
  76134. */
  76135. get motionBlurSamples(): number;
  76136. set motionBlurSamples(samples: number);
  76137. /**
  76138. * Specifies MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  76139. */
  76140. get samples(): number;
  76141. set samples(sampleCount: number);
  76142. /**
  76143. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  76144. * @constructor
  76145. * @param name The rendering pipeline name
  76146. * @param scene The scene linked to this pipeline
  76147. * @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)
  76148. * @param originalPostProcess the custom original color post-process. Must be "reusable". Can be null.
  76149. * @param cameras The array of cameras that the rendering pipeline will be attached to
  76150. */
  76151. constructor(name: string, scene: Scene, ratio: number, originalPostProcess?: Nullable<PostProcess>, cameras?: Camera[]);
  76152. private _buildPipeline;
  76153. private _createDownSampleX4PostProcess;
  76154. private _createBrightPassPostProcess;
  76155. private _createBlurPostProcesses;
  76156. private _createTextureAdderPostProcess;
  76157. private _createVolumetricLightPostProcess;
  76158. private _createLuminancePostProcesses;
  76159. private _createHdrPostProcess;
  76160. private _createLensFlarePostProcess;
  76161. private _createDepthOfFieldPostProcess;
  76162. private _createMotionBlurPostProcess;
  76163. private _getDepthTexture;
  76164. private _disposePostProcesses;
  76165. /**
  76166. * Dispose of the pipeline and stop all post processes
  76167. */
  76168. dispose(): void;
  76169. /**
  76170. * Serialize the rendering pipeline (Used when exporting)
  76171. * @returns the serialized object
  76172. */
  76173. serialize(): any;
  76174. /**
  76175. * Parse the serialized pipeline
  76176. * @param source Source pipeline.
  76177. * @param scene The scene to load the pipeline to.
  76178. * @param rootUrl The URL of the serialized pipeline.
  76179. * @returns An instantiated pipeline from the serialized object.
  76180. */
  76181. static Parse(source: any, scene: Scene, rootUrl: string): StandardRenderingPipeline;
  76182. /**
  76183. * Luminance steps
  76184. */
  76185. static LuminanceSteps: number;
  76186. }
  76187. }
  76188. declare module BABYLON {
  76189. /** @hidden */
  76190. export var tonemapPixelShader: {
  76191. name: string;
  76192. shader: string;
  76193. };
  76194. }
  76195. declare module BABYLON {
  76196. /** Defines operator used for tonemapping */
  76197. export enum TonemappingOperator {
  76198. /** Hable */
  76199. Hable = 0,
  76200. /** Reinhard */
  76201. Reinhard = 1,
  76202. /** HejiDawson */
  76203. HejiDawson = 2,
  76204. /** Photographic */
  76205. Photographic = 3
  76206. }
  76207. /**
  76208. * Defines a post process to apply tone mapping
  76209. */
  76210. export class TonemapPostProcess extends PostProcess {
  76211. private _operator;
  76212. /** Defines the required exposure adjustement */
  76213. exposureAdjustment: number;
  76214. /**
  76215. * Gets a string identifying the name of the class
  76216. * @returns "TonemapPostProcess" string
  76217. */
  76218. getClassName(): string;
  76219. /**
  76220. * Creates a new TonemapPostProcess
  76221. * @param name defines the name of the postprocess
  76222. * @param _operator defines the operator to use
  76223. * @param exposureAdjustment defines the required exposure adjustement
  76224. * @param camera defines the camera to use (can be null)
  76225. * @param samplingMode defines the required sampling mode (BABYLON.Texture.BILINEAR_SAMPLINGMODE by default)
  76226. * @param engine defines the hosting engine (can be ignore if camera is set)
  76227. * @param textureFormat defines the texture format to use (BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT by default)
  76228. */
  76229. constructor(name: string, _operator: TonemappingOperator,
  76230. /** Defines the required exposure adjustement */
  76231. exposureAdjustment: number, camera: Camera, samplingMode?: number, engine?: Engine, textureFormat?: number);
  76232. }
  76233. }
  76234. declare module BABYLON {
  76235. /** @hidden */
  76236. export var volumetricLightScatteringPixelShader: {
  76237. name: string;
  76238. shader: string;
  76239. };
  76240. }
  76241. declare module BABYLON {
  76242. /** @hidden */
  76243. export var volumetricLightScatteringPassVertexShader: {
  76244. name: string;
  76245. shader: string;
  76246. };
  76247. }
  76248. declare module BABYLON {
  76249. /** @hidden */
  76250. export var volumetricLightScatteringPassPixelShader: {
  76251. name: string;
  76252. shader: string;
  76253. };
  76254. }
  76255. declare module BABYLON {
  76256. /**
  76257. * Inspired by http://http.developer.nvidia.com/GPUGems3/gpugems3_ch13.html
  76258. */
  76259. export class VolumetricLightScatteringPostProcess extends PostProcess {
  76260. private _volumetricLightScatteringPass;
  76261. private _volumetricLightScatteringRTT;
  76262. private _viewPort;
  76263. private _screenCoordinates;
  76264. private _cachedDefines;
  76265. /**
  76266. * If not undefined, the mesh position is computed from the attached node position
  76267. */
  76268. attachedNode: {
  76269. position: Vector3;
  76270. };
  76271. /**
  76272. * Custom position of the mesh. Used if "useCustomMeshPosition" is set to "true"
  76273. */
  76274. customMeshPosition: Vector3;
  76275. /**
  76276. * Set if the post-process should use a custom position for the light source (true) or the internal mesh position (false)
  76277. */
  76278. useCustomMeshPosition: boolean;
  76279. /**
  76280. * If the post-process should inverse the light scattering direction
  76281. */
  76282. invert: boolean;
  76283. /**
  76284. * The internal mesh used by the post-process
  76285. */
  76286. mesh: Mesh;
  76287. /**
  76288. * @hidden
  76289. * VolumetricLightScatteringPostProcess.useDiffuseColor is no longer used, use the mesh material directly instead
  76290. */
  76291. get useDiffuseColor(): boolean;
  76292. set useDiffuseColor(useDiffuseColor: boolean);
  76293. /**
  76294. * Array containing the excluded meshes not rendered in the internal pass
  76295. */
  76296. excludedMeshes: AbstractMesh[];
  76297. /**
  76298. * Controls the overall intensity of the post-process
  76299. */
  76300. exposure: number;
  76301. /**
  76302. * Dissipates each sample's contribution in range [0, 1]
  76303. */
  76304. decay: number;
  76305. /**
  76306. * Controls the overall intensity of each sample
  76307. */
  76308. weight: number;
  76309. /**
  76310. * Controls the density of each sample
  76311. */
  76312. density: number;
  76313. /**
  76314. * @constructor
  76315. * @param name The post-process name
  76316. * @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)
  76317. * @param camera The camera that the post-process will be attached to
  76318. * @param mesh The mesh used to create the light scattering
  76319. * @param samples The post-process quality, default 100
  76320. * @param samplingModeThe post-process filtering mode
  76321. * @param engine The babylon engine
  76322. * @param reusable If the post-process is reusable
  76323. * @param scene The constructor needs a scene reference to initialize internal components. If "camera" is null a "scene" must be provided
  76324. */
  76325. constructor(name: string, ratio: any, camera: Camera, mesh?: Mesh, samples?: number, samplingMode?: number, engine?: Engine, reusable?: boolean, scene?: Scene);
  76326. /**
  76327. * Returns the string "VolumetricLightScatteringPostProcess"
  76328. * @returns "VolumetricLightScatteringPostProcess"
  76329. */
  76330. getClassName(): string;
  76331. private _isReady;
  76332. /**
  76333. * Sets the new light position for light scattering effect
  76334. * @param position The new custom light position
  76335. */
  76336. setCustomMeshPosition(position: Vector3): void;
  76337. /**
  76338. * Returns the light position for light scattering effect
  76339. * @return Vector3 The custom light position
  76340. */
  76341. getCustomMeshPosition(): Vector3;
  76342. /**
  76343. * Disposes the internal assets and detaches the post-process from the camera
  76344. */
  76345. dispose(camera: Camera): void;
  76346. /**
  76347. * Returns the render target texture used by the post-process
  76348. * @return the render target texture used by the post-process
  76349. */
  76350. getPass(): RenderTargetTexture;
  76351. private _meshExcluded;
  76352. private _createPass;
  76353. private _updateMeshScreenCoordinates;
  76354. /**
  76355. * Creates a default mesh for the Volumeric Light Scattering post-process
  76356. * @param name The mesh name
  76357. * @param scene The scene where to create the mesh
  76358. * @return the default mesh
  76359. */
  76360. static CreateDefaultMesh(name: string, scene: Scene): Mesh;
  76361. }
  76362. }
  76363. declare module BABYLON {
  76364. /** @hidden */
  76365. export var screenSpaceCurvaturePixelShader: {
  76366. name: string;
  76367. shader: string;
  76368. };
  76369. }
  76370. declare module BABYLON {
  76371. /**
  76372. * The Screen Space curvature effect can help highlighting ridge and valley of a model.
  76373. */
  76374. export class ScreenSpaceCurvaturePostProcess extends PostProcess {
  76375. /**
  76376. * Defines how much ridge the curvature effect displays.
  76377. */
  76378. ridge: number;
  76379. /**
  76380. * Defines how much valley the curvature effect displays.
  76381. */
  76382. valley: number;
  76383. private _geometryBufferRenderer;
  76384. /**
  76385. * Gets a string identifying the name of the class
  76386. * @returns "ScreenSpaceCurvaturePostProcess" string
  76387. */
  76388. getClassName(): string;
  76389. /**
  76390. * Creates a new instance ScreenSpaceCurvaturePostProcess
  76391. * @param name The name of the effect.
  76392. * @param scene The scene containing the objects to blur according to their velocity.
  76393. * @param options The required width/height ratio to downsize to before computing the render pass.
  76394. * @param camera The camera to apply the render pass to.
  76395. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  76396. * @param engine The engine which the post process will be applied. (default: current engine)
  76397. * @param reusable If the post process can be reused on the same frame. (default: false)
  76398. * @param textureType Type of textures used when performing the post process. (default: 0)
  76399. * @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)
  76400. */
  76401. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  76402. /**
  76403. * Support test.
  76404. */
  76405. static get IsSupported(): boolean;
  76406. /** @hidden */
  76407. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): ScreenSpaceCurvaturePostProcess;
  76408. }
  76409. }
  76410. declare module BABYLON {
  76411. interface Scene {
  76412. /** @hidden (Backing field) */
  76413. _boundingBoxRenderer: BoundingBoxRenderer;
  76414. /** @hidden (Backing field) */
  76415. _forceShowBoundingBoxes: boolean;
  76416. /**
  76417. * Gets or sets a boolean indicating if all bounding boxes must be rendered
  76418. */
  76419. forceShowBoundingBoxes: boolean;
  76420. /**
  76421. * Gets the bounding box renderer associated with the scene
  76422. * @returns a BoundingBoxRenderer
  76423. */
  76424. getBoundingBoxRenderer(): BoundingBoxRenderer;
  76425. }
  76426. interface AbstractMesh {
  76427. /** @hidden (Backing field) */
  76428. _showBoundingBox: boolean;
  76429. /**
  76430. * Gets or sets a boolean indicating if the bounding box must be rendered as well (false by default)
  76431. */
  76432. showBoundingBox: boolean;
  76433. }
  76434. /**
  76435. * Component responsible of rendering the bounding box of the meshes in a scene.
  76436. * This is usually used through the mesh.showBoundingBox or the scene.forceShowBoundingBoxes properties
  76437. */
  76438. export class BoundingBoxRenderer implements ISceneComponent {
  76439. /**
  76440. * The component name helpfull to identify the component in the list of scene components.
  76441. */
  76442. readonly name: string;
  76443. /**
  76444. * The scene the component belongs to.
  76445. */
  76446. scene: Scene;
  76447. /**
  76448. * Color of the bounding box lines placed in front of an object
  76449. */
  76450. frontColor: Color3;
  76451. /**
  76452. * Color of the bounding box lines placed behind an object
  76453. */
  76454. backColor: Color3;
  76455. /**
  76456. * Defines if the renderer should show the back lines or not
  76457. */
  76458. showBackLines: boolean;
  76459. /**
  76460. * Observable raised before rendering a bounding box
  76461. */
  76462. onBeforeBoxRenderingObservable: Observable<BoundingBox>;
  76463. /**
  76464. * Observable raised after rendering a bounding box
  76465. */
  76466. onAfterBoxRenderingObservable: Observable<BoundingBox>;
  76467. /**
  76468. * Observable raised after resources are created
  76469. */
  76470. onResourcesReadyObservable: Observable<BoundingBoxRenderer>;
  76471. /**
  76472. * When false, no bounding boxes will be rendered
  76473. */
  76474. enabled: boolean;
  76475. /**
  76476. * @hidden
  76477. */
  76478. renderList: SmartArray<BoundingBox>;
  76479. private _colorShader;
  76480. private _vertexBuffers;
  76481. private _indexBuffer;
  76482. private _fillIndexBuffer;
  76483. private _fillIndexData;
  76484. /**
  76485. * Instantiates a new bounding box renderer in a scene.
  76486. * @param scene the scene the renderer renders in
  76487. */
  76488. constructor(scene: Scene);
  76489. /**
  76490. * Registers the component in a given scene
  76491. */
  76492. register(): void;
  76493. private _evaluateSubMesh;
  76494. private _preActiveMesh;
  76495. private _prepareResources;
  76496. private _createIndexBuffer;
  76497. /**
  76498. * Rebuilds the elements related to this component in case of
  76499. * context lost for instance.
  76500. */
  76501. rebuild(): void;
  76502. /**
  76503. * @hidden
  76504. */
  76505. reset(): void;
  76506. /**
  76507. * Render the bounding boxes of a specific rendering group
  76508. * @param renderingGroupId defines the rendering group to render
  76509. */
  76510. render(renderingGroupId: number): void;
  76511. /**
  76512. * In case of occlusion queries, we can render the occlusion bounding box through this method
  76513. * @param mesh Define the mesh to render the occlusion bounding box for
  76514. */
  76515. renderOcclusionBoundingBox(mesh: AbstractMesh): void;
  76516. /**
  76517. * Dispose and release the resources attached to this renderer.
  76518. */
  76519. dispose(): void;
  76520. }
  76521. }
  76522. declare module BABYLON {
  76523. interface Scene {
  76524. /** @hidden (Backing field) */
  76525. _depthRenderer: {
  76526. [id: string]: DepthRenderer;
  76527. };
  76528. /**
  76529. * Creates a depth renderer a given camera which contains a depth map which can be used for post processing.
  76530. * @param camera The camera to create the depth renderer on (default: scene's active camera)
  76531. * @param storeNonLinearDepth Defines whether the depth is stored linearly like in Babylon Shadows or directly like glFragCoord.z
  76532. * @param force32bitsFloat Forces 32 bits float when supported (else 16 bits float is prioritized over 32 bits float if supported)
  76533. * @returns the created depth renderer
  76534. */
  76535. enableDepthRenderer(camera?: Nullable<Camera>, storeNonLinearDepth?: boolean, force32bitsFloat?: boolean): DepthRenderer;
  76536. /**
  76537. * Disables a depth renderer for a given camera
  76538. * @param camera The camera to disable the depth renderer on (default: scene's active camera)
  76539. */
  76540. disableDepthRenderer(camera?: Nullable<Camera>): void;
  76541. }
  76542. /**
  76543. * Defines the Depth Renderer scene component responsible to manage a depth buffer useful
  76544. * in several rendering techniques.
  76545. */
  76546. export class DepthRendererSceneComponent implements ISceneComponent {
  76547. /**
  76548. * The component name helpfull to identify the component in the list of scene components.
  76549. */
  76550. readonly name: string;
  76551. /**
  76552. * The scene the component belongs to.
  76553. */
  76554. scene: Scene;
  76555. /**
  76556. * Creates a new instance of the component for the given scene
  76557. * @param scene Defines the scene to register the component in
  76558. */
  76559. constructor(scene: Scene);
  76560. /**
  76561. * Registers the component in a given scene
  76562. */
  76563. register(): void;
  76564. /**
  76565. * Rebuilds the elements related to this component in case of
  76566. * context lost for instance.
  76567. */
  76568. rebuild(): void;
  76569. /**
  76570. * Disposes the component and the associated ressources
  76571. */
  76572. dispose(): void;
  76573. private _gatherRenderTargets;
  76574. private _gatherActiveCameraRenderTargets;
  76575. }
  76576. }
  76577. declare module BABYLON {
  76578. interface AbstractScene {
  76579. /** @hidden (Backing field) */
  76580. _prePassRenderer: Nullable<PrePassRenderer>;
  76581. /**
  76582. * Gets or Sets the current prepass renderer associated to the scene.
  76583. */
  76584. prePassRenderer: Nullable<PrePassRenderer>;
  76585. /**
  76586. * Enables the prepass and associates it with the scene
  76587. * @returns the PrePassRenderer
  76588. */
  76589. enablePrePassRenderer(): Nullable<PrePassRenderer>;
  76590. /**
  76591. * Disables the prepass associated with the scene
  76592. */
  76593. disablePrePassRenderer(): void;
  76594. }
  76595. interface RenderTargetTexture {
  76596. /** @hidden */
  76597. _prePassRenderTarget: PrePassRenderTarget;
  76598. }
  76599. /**
  76600. * Defines the Geometry Buffer scene component responsible to manage a G-Buffer useful
  76601. * in several rendering techniques.
  76602. */
  76603. export class PrePassRendererSceneComponent implements ISceneComponent {
  76604. /**
  76605. * The component name helpful to identify the component in the list of scene components.
  76606. */
  76607. readonly name: string;
  76608. /**
  76609. * The scene the component belongs to.
  76610. */
  76611. scene: Scene;
  76612. /**
  76613. * Creates a new instance of the component for the given scene
  76614. * @param scene Defines the scene to register the component in
  76615. */
  76616. constructor(scene: Scene);
  76617. /**
  76618. * Registers the component in a given scene
  76619. */
  76620. register(): void;
  76621. private _beforeRenderTargetDraw;
  76622. private _afterRenderTargetDraw;
  76623. private _beforeRenderTargetClearStage;
  76624. private _beforeCameraDraw;
  76625. private _afterCameraDraw;
  76626. private _beforeClearStage;
  76627. private _beforeRenderingMeshStage;
  76628. private _afterRenderingMeshStage;
  76629. /**
  76630. * Rebuilds the elements related to this component in case of
  76631. * context lost for instance.
  76632. */
  76633. rebuild(): void;
  76634. /**
  76635. * Disposes the component and the associated ressources
  76636. */
  76637. dispose(): void;
  76638. }
  76639. }
  76640. declare module BABYLON {
  76641. /** @hidden */
  76642. export var fibonacci: {
  76643. name: string;
  76644. shader: string;
  76645. };
  76646. }
  76647. declare module BABYLON {
  76648. /** @hidden */
  76649. export var diffusionProfile: {
  76650. name: string;
  76651. shader: string;
  76652. };
  76653. }
  76654. declare module BABYLON {
  76655. /** @hidden */
  76656. export var subSurfaceScatteringPixelShader: {
  76657. name: string;
  76658. shader: string;
  76659. };
  76660. }
  76661. declare module BABYLON {
  76662. /**
  76663. * Sub surface scattering post process
  76664. */
  76665. export class SubSurfaceScatteringPostProcess extends PostProcess {
  76666. /**
  76667. * Gets a string identifying the name of the class
  76668. * @returns "SubSurfaceScatteringPostProcess" string
  76669. */
  76670. getClassName(): string;
  76671. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  76672. }
  76673. }
  76674. declare module BABYLON {
  76675. /**
  76676. * Contains all parameters needed for the prepass to perform
  76677. * screen space subsurface scattering
  76678. */
  76679. export class SubSurfaceConfiguration implements PrePassEffectConfiguration {
  76680. /** @hidden */
  76681. static _SceneComponentInitialization: (scene: Scene) => void;
  76682. private _ssDiffusionS;
  76683. private _ssFilterRadii;
  76684. private _ssDiffusionD;
  76685. /**
  76686. * Post process to attach for screen space subsurface scattering
  76687. */
  76688. postProcess: SubSurfaceScatteringPostProcess;
  76689. /**
  76690. * Diffusion profile color for subsurface scattering
  76691. */
  76692. get ssDiffusionS(): number[];
  76693. /**
  76694. * Diffusion profile max color channel value for subsurface scattering
  76695. */
  76696. get ssDiffusionD(): number[];
  76697. /**
  76698. * Diffusion profile filter radius for subsurface scattering
  76699. */
  76700. get ssFilterRadii(): number[];
  76701. /**
  76702. * Is subsurface enabled
  76703. */
  76704. enabled: boolean;
  76705. /**
  76706. * Does the output of this prepass need to go through imageprocessing
  76707. */
  76708. needsImageProcessing: boolean;
  76709. /**
  76710. * Name of the configuration
  76711. */
  76712. name: string;
  76713. /**
  76714. * Diffusion profile colors for subsurface scattering
  76715. * You can add one diffusion color using `addDiffusionProfile` on `scene.prePassRenderer`
  76716. * See ...
  76717. * Note that you can only store up to 5 of them
  76718. */
  76719. ssDiffusionProfileColors: Color3[];
  76720. /**
  76721. * Defines the ratio real world => scene units.
  76722. * Used for subsurface scattering
  76723. */
  76724. metersPerUnit: number;
  76725. /**
  76726. * Textures that should be present in the MRT for this effect to work
  76727. */
  76728. readonly texturesRequired: number[];
  76729. private _scene;
  76730. /**
  76731. * Builds a subsurface configuration object
  76732. * @param scene The scene
  76733. */
  76734. constructor(scene: Scene);
  76735. /**
  76736. * Adds a new diffusion profile.
  76737. * Useful for more realistic subsurface scattering on diverse materials.
  76738. * @param color The color of the diffusion profile. Should be the average color of the material.
  76739. * @return The index of the diffusion profile for the material subsurface configuration
  76740. */
  76741. addDiffusionProfile(color: Color3): number;
  76742. /**
  76743. * Creates the sss post process
  76744. * @return The created post process
  76745. */
  76746. createPostProcess(): SubSurfaceScatteringPostProcess;
  76747. /**
  76748. * Deletes all diffusion profiles.
  76749. * Note that in order to render subsurface scattering, you should have at least 1 diffusion profile.
  76750. */
  76751. clearAllDiffusionProfiles(): void;
  76752. /**
  76753. * Disposes this object
  76754. */
  76755. dispose(): void;
  76756. /**
  76757. * @hidden
  76758. * https://zero-radiance.github.io/post/sampling-diffusion/
  76759. *
  76760. * Importance sample the normalized diffuse reflectance profile for the computed value of 's'.
  76761. * ------------------------------------------------------------------------------------
  76762. * R[r, phi, s] = s * (Exp[-r * s] + Exp[-r * s / 3]) / (8 * Pi * r)
  76763. * PDF[r, phi, s] = r * R[r, phi, s]
  76764. * CDF[r, s] = 1 - 1/4 * Exp[-r * s] - 3/4 * Exp[-r * s / 3]
  76765. * ------------------------------------------------------------------------------------
  76766. * We importance sample the color channel with the widest scattering distance.
  76767. */
  76768. getDiffusionProfileParameters(color: Color3): number;
  76769. /**
  76770. * Performs sampling of a Normalized Burley diffusion profile in polar coordinates.
  76771. * 'u' is the random number (the value of the CDF): [0, 1).
  76772. * rcp(s) = 1 / ShapeParam = ScatteringDistance.
  76773. * Returns the sampled radial distance, s.t. (u = 0 -> r = 0) and (u = 1 -> r = Inf).
  76774. */
  76775. private _sampleBurleyDiffusionProfile;
  76776. }
  76777. }
  76778. declare module BABYLON {
  76779. interface AbstractScene {
  76780. /** @hidden (Backing field) */
  76781. _subSurfaceConfiguration: Nullable<SubSurfaceConfiguration>;
  76782. /**
  76783. * Gets or Sets the current prepass renderer associated to the scene.
  76784. */
  76785. subSurfaceConfiguration: Nullable<SubSurfaceConfiguration>;
  76786. /**
  76787. * Enables the subsurface effect for prepass
  76788. * @returns the SubSurfaceConfiguration
  76789. */
  76790. enableSubSurfaceForPrePass(): Nullable<SubSurfaceConfiguration>;
  76791. /**
  76792. * Disables the subsurface effect for prepass
  76793. */
  76794. disableSubSurfaceForPrePass(): void;
  76795. }
  76796. /**
  76797. * Defines the Geometry Buffer scene component responsible to manage a G-Buffer useful
  76798. * in several rendering techniques.
  76799. */
  76800. export class SubSurfaceSceneComponent implements ISceneSerializableComponent {
  76801. /**
  76802. * The component name helpful to identify the component in the list of scene components.
  76803. */
  76804. readonly name: string;
  76805. /**
  76806. * The scene the component belongs to.
  76807. */
  76808. scene: Scene;
  76809. /**
  76810. * Creates a new instance of the component for the given scene
  76811. * @param scene Defines the scene to register the component in
  76812. */
  76813. constructor(scene: Scene);
  76814. /**
  76815. * Registers the component in a given scene
  76816. */
  76817. register(): void;
  76818. /**
  76819. * Serializes the component data to the specified json object
  76820. * @param serializationObject The object to serialize to
  76821. */
  76822. serialize(serializationObject: any): void;
  76823. /**
  76824. * Adds all the elements from the container to the scene
  76825. * @param container the container holding the elements
  76826. */
  76827. addFromContainer(container: AbstractScene): void;
  76828. /**
  76829. * Removes all the elements in the container from the scene
  76830. * @param container contains the elements to remove
  76831. * @param dispose if the removed element should be disposed (default: false)
  76832. */
  76833. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  76834. /**
  76835. * Rebuilds the elements related to this component in case of
  76836. * context lost for instance.
  76837. */
  76838. rebuild(): void;
  76839. /**
  76840. * Disposes the component and the associated ressources
  76841. */
  76842. dispose(): void;
  76843. }
  76844. }
  76845. declare module BABYLON {
  76846. /** @hidden */
  76847. export var outlinePixelShader: {
  76848. name: string;
  76849. shader: string;
  76850. };
  76851. }
  76852. declare module BABYLON {
  76853. /** @hidden */
  76854. export var outlineVertexShader: {
  76855. name: string;
  76856. shader: string;
  76857. };
  76858. }
  76859. declare module BABYLON {
  76860. interface Scene {
  76861. /** @hidden */
  76862. _outlineRenderer: OutlineRenderer;
  76863. /**
  76864. * Gets the outline renderer associated with the scene
  76865. * @returns a OutlineRenderer
  76866. */
  76867. getOutlineRenderer(): OutlineRenderer;
  76868. }
  76869. interface AbstractMesh {
  76870. /** @hidden (Backing field) */
  76871. _renderOutline: boolean;
  76872. /**
  76873. * Gets or sets a boolean indicating if the outline must be rendered as well
  76874. * @see https://www.babylonjs-playground.com/#10WJ5S#3
  76875. */
  76876. renderOutline: boolean;
  76877. /** @hidden (Backing field) */
  76878. _renderOverlay: boolean;
  76879. /**
  76880. * Gets or sets a boolean indicating if the overlay must be rendered as well
  76881. * @see https://www.babylonjs-playground.com/#10WJ5S#2
  76882. */
  76883. renderOverlay: boolean;
  76884. }
  76885. /**
  76886. * This class is responsible to draw bothe outline/overlay of meshes.
  76887. * It should not be used directly but through the available method on mesh.
  76888. */
  76889. export class OutlineRenderer implements ISceneComponent {
  76890. /**
  76891. * Stencil value used to avoid outline being seen within the mesh when the mesh is transparent
  76892. */
  76893. private static _StencilReference;
  76894. /**
  76895. * The name of the component. Each component must have a unique name.
  76896. */
  76897. name: string;
  76898. /**
  76899. * The scene the component belongs to.
  76900. */
  76901. scene: Scene;
  76902. /**
  76903. * Defines a zOffset to prevent zFighting between the overlay and the mesh.
  76904. */
  76905. zOffset: number;
  76906. private _engine;
  76907. private _effect;
  76908. private _cachedDefines;
  76909. private _savedDepthWrite;
  76910. /**
  76911. * Instantiates a new outline renderer. (There could be only one per scene).
  76912. * @param scene Defines the scene it belongs to
  76913. */
  76914. constructor(scene: Scene);
  76915. /**
  76916. * Register the component to one instance of a scene.
  76917. */
  76918. register(): void;
  76919. /**
  76920. * Rebuilds the elements related to this component in case of
  76921. * context lost for instance.
  76922. */
  76923. rebuild(): void;
  76924. /**
  76925. * Disposes the component and the associated ressources.
  76926. */
  76927. dispose(): void;
  76928. /**
  76929. * Renders the outline in the canvas.
  76930. * @param subMesh Defines the sumesh to render
  76931. * @param batch Defines the batch of meshes in case of instances
  76932. * @param useOverlay Defines if the rendering is for the overlay or the outline
  76933. */
  76934. render(subMesh: SubMesh, batch: _InstancesBatch, useOverlay?: boolean): void;
  76935. /**
  76936. * Returns whether or not the outline renderer is ready for a given submesh.
  76937. * All the dependencies e.g. submeshes, texture, effect... mus be ready
  76938. * @param subMesh Defines the submesh to check readyness for
  76939. * @param useInstances Defines wheter wee are trying to render instances or not
  76940. * @returns true if ready otherwise false
  76941. */
  76942. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  76943. private _beforeRenderingMesh;
  76944. private _afterRenderingMesh;
  76945. }
  76946. }
  76947. declare module BABYLON {
  76948. /**
  76949. * Defines the basic options interface of a Sprite Frame Source Size.
  76950. */
  76951. export interface ISpriteJSONSpriteSourceSize {
  76952. /**
  76953. * number of the original width of the Frame
  76954. */
  76955. w: number;
  76956. /**
  76957. * number of the original height of the Frame
  76958. */
  76959. h: number;
  76960. }
  76961. /**
  76962. * Defines the basic options interface of a Sprite Frame Data.
  76963. */
  76964. export interface ISpriteJSONSpriteFrameData {
  76965. /**
  76966. * number of the x offset of the Frame
  76967. */
  76968. x: number;
  76969. /**
  76970. * number of the y offset of the Frame
  76971. */
  76972. y: number;
  76973. /**
  76974. * number of the width of the Frame
  76975. */
  76976. w: number;
  76977. /**
  76978. * number of the height of the Frame
  76979. */
  76980. h: number;
  76981. }
  76982. /**
  76983. * Defines the basic options interface of a JSON Sprite.
  76984. */
  76985. export interface ISpriteJSONSprite {
  76986. /**
  76987. * string name of the Frame
  76988. */
  76989. filename: string;
  76990. /**
  76991. * ISpriteJSONSpriteFrame basic object of the frame data
  76992. */
  76993. frame: ISpriteJSONSpriteFrameData;
  76994. /**
  76995. * boolean to flag is the frame was rotated.
  76996. */
  76997. rotated: boolean;
  76998. /**
  76999. * boolean to flag is the frame was trimmed.
  77000. */
  77001. trimmed: boolean;
  77002. /**
  77003. * ISpriteJSONSpriteFrame basic object of the source data
  77004. */
  77005. spriteSourceSize: ISpriteJSONSpriteFrameData;
  77006. /**
  77007. * ISpriteJSONSpriteFrame basic object of the source data
  77008. */
  77009. sourceSize: ISpriteJSONSpriteSourceSize;
  77010. }
  77011. /**
  77012. * Defines the basic options interface of a JSON atlas.
  77013. */
  77014. export interface ISpriteJSONAtlas {
  77015. /**
  77016. * Array of objects that contain the frame data.
  77017. */
  77018. frames: Array<ISpriteJSONSprite>;
  77019. /**
  77020. * object basic object containing the sprite meta data.
  77021. */
  77022. meta?: object;
  77023. }
  77024. }
  77025. declare module BABYLON {
  77026. /** @hidden */
  77027. export var spriteMapPixelShader: {
  77028. name: string;
  77029. shader: string;
  77030. };
  77031. }
  77032. declare module BABYLON {
  77033. /** @hidden */
  77034. export var spriteMapVertexShader: {
  77035. name: string;
  77036. shader: string;
  77037. };
  77038. }
  77039. declare module BABYLON {
  77040. /**
  77041. * Defines the basic options interface of a SpriteMap
  77042. */
  77043. export interface ISpriteMapOptions {
  77044. /**
  77045. * Vector2 of the number of cells in the grid.
  77046. */
  77047. stageSize?: Vector2;
  77048. /**
  77049. * Vector2 of the size of the output plane in World Units.
  77050. */
  77051. outputSize?: Vector2;
  77052. /**
  77053. * Vector3 of the position of the output plane in World Units.
  77054. */
  77055. outputPosition?: Vector3;
  77056. /**
  77057. * Vector3 of the rotation of the output plane.
  77058. */
  77059. outputRotation?: Vector3;
  77060. /**
  77061. * number of layers that the system will reserve in resources.
  77062. */
  77063. layerCount?: number;
  77064. /**
  77065. * number of max animation frames a single cell will reserve in resources.
  77066. */
  77067. maxAnimationFrames?: number;
  77068. /**
  77069. * number cell index of the base tile when the system compiles.
  77070. */
  77071. baseTile?: number;
  77072. /**
  77073. * boolean flip the sprite after its been repositioned by the framing data.
  77074. */
  77075. flipU?: boolean;
  77076. /**
  77077. * Vector3 scalar of the global RGB values of the SpriteMap.
  77078. */
  77079. colorMultiply?: Vector3;
  77080. }
  77081. /**
  77082. * Defines the IDisposable interface in order to be cleanable from resources.
  77083. */
  77084. export interface ISpriteMap extends IDisposable {
  77085. /**
  77086. * String name of the SpriteMap.
  77087. */
  77088. name: string;
  77089. /**
  77090. * The JSON Array file from a https://www.codeandweb.com/texturepacker export. Or similar structure.
  77091. */
  77092. atlasJSON: ISpriteJSONAtlas;
  77093. /**
  77094. * Texture of the SpriteMap.
  77095. */
  77096. spriteSheet: Texture;
  77097. /**
  77098. * The parameters to initialize the SpriteMap with.
  77099. */
  77100. options: ISpriteMapOptions;
  77101. }
  77102. /**
  77103. * Class used to manage a grid restricted sprite deployment on an Output plane.
  77104. */
  77105. export class SpriteMap implements ISpriteMap {
  77106. /** The Name of the spriteMap */
  77107. name: string;
  77108. /** The JSON file with the frame and meta data */
  77109. atlasJSON: ISpriteJSONAtlas;
  77110. /** The systems Sprite Sheet Texture */
  77111. spriteSheet: Texture;
  77112. /** Arguments passed with the Constructor */
  77113. options: ISpriteMapOptions;
  77114. /** Public Sprite Storage array, parsed from atlasJSON */
  77115. sprites: Array<ISpriteJSONSprite>;
  77116. /** Returns the Number of Sprites in the System */
  77117. get spriteCount(): number;
  77118. /** Returns the Position of Output Plane*/
  77119. get position(): Vector3;
  77120. /** Returns the Position of Output Plane*/
  77121. set position(v: Vector3);
  77122. /** Returns the Rotation of Output Plane*/
  77123. get rotation(): Vector3;
  77124. /** Returns the Rotation of Output Plane*/
  77125. set rotation(v: Vector3);
  77126. /** Sets the AnimationMap*/
  77127. get animationMap(): RawTexture;
  77128. /** Sets the AnimationMap*/
  77129. set animationMap(v: RawTexture);
  77130. /** Scene that the SpriteMap was created in */
  77131. private _scene;
  77132. /** Texture Buffer of Float32 that holds tile frame data*/
  77133. private _frameMap;
  77134. /** Texture Buffers of Float32 that holds tileMap data*/
  77135. private _tileMaps;
  77136. /** Texture Buffer of Float32 that holds Animation Data*/
  77137. private _animationMap;
  77138. /** Custom ShaderMaterial Central to the System*/
  77139. private _material;
  77140. /** Custom ShaderMaterial Central to the System*/
  77141. private _output;
  77142. /** Systems Time Ticker*/
  77143. private _time;
  77144. /**
  77145. * Creates a new SpriteMap
  77146. * @param name defines the SpriteMaps Name
  77147. * @param atlasJSON is the JSON file that controls the Sprites Frames and Meta
  77148. * @param spriteSheet is the Texture that the Sprites are on.
  77149. * @param options a basic deployment configuration
  77150. * @param scene The Scene that the map is deployed on
  77151. */
  77152. constructor(name: string, atlasJSON: ISpriteJSONAtlas, spriteSheet: Texture, options: ISpriteMapOptions, scene: Scene);
  77153. /**
  77154. * Returns tileID location
  77155. * @returns Vector2 the cell position ID
  77156. */
  77157. getTileID(): Vector2;
  77158. /**
  77159. * Gets the UV location of the mouse over the SpriteMap.
  77160. * @returns Vector2 the UV position of the mouse interaction
  77161. */
  77162. getMousePosition(): Vector2;
  77163. /**
  77164. * Creates the "frame" texture Buffer
  77165. * -------------------------------------
  77166. * Structure of frames
  77167. * "filename": "Falling-Water-2.png",
  77168. * "frame": {"x":69,"y":103,"w":24,"h":32},
  77169. * "rotated": true,
  77170. * "trimmed": true,
  77171. * "spriteSourceSize": {"x":4,"y":0,"w":24,"h":32},
  77172. * "sourceSize": {"w":32,"h":32}
  77173. * @returns RawTexture of the frameMap
  77174. */
  77175. private _createFrameBuffer;
  77176. /**
  77177. * Creates the tileMap texture Buffer
  77178. * @param buffer normally and array of numbers, or a false to generate from scratch
  77179. * @param _layer indicates what layer for a logic trigger dealing with the baseTile. The system uses this
  77180. * @returns RawTexture of the tileMap
  77181. */
  77182. private _createTileBuffer;
  77183. /**
  77184. * Modifies the data of the tileMaps
  77185. * @param _layer is the ID of the layer you want to edit on the SpriteMap
  77186. * @param pos is the iVector2 Coordinates of the Tile
  77187. * @param tile The SpriteIndex of the new Tile
  77188. */
  77189. changeTiles(_layer: number | undefined, pos: Vector2 | Vector2[], tile?: number): void;
  77190. /**
  77191. * Creates the animationMap texture Buffer
  77192. * @param buffer normally and array of numbers, or a false to generate from scratch
  77193. * @returns RawTexture of the animationMap
  77194. */
  77195. private _createTileAnimationBuffer;
  77196. /**
  77197. * Modifies the data of the animationMap
  77198. * @param cellID is the Index of the Sprite
  77199. * @param _frame is the target Animation frame
  77200. * @param toCell is the Target Index of the next frame of the animation
  77201. * @param time is a value between 0-1 that is the trigger for when the frame should change tiles
  77202. * @param speed is a global scalar of the time variable on the map.
  77203. */
  77204. addAnimationToTile(cellID?: number, _frame?: number, toCell?: number, time?: number, speed?: number): void;
  77205. /**
  77206. * Exports the .tilemaps file
  77207. */
  77208. saveTileMaps(): void;
  77209. /**
  77210. * Imports the .tilemaps file
  77211. * @param url of the .tilemaps file
  77212. */
  77213. loadTileMaps(url: string): void;
  77214. /**
  77215. * Release associated resources
  77216. */
  77217. dispose(): void;
  77218. }
  77219. }
  77220. declare module BABYLON {
  77221. /**
  77222. * Class used to manage multiple sprites of different sizes on the same spritesheet
  77223. * @see https://doc.babylonjs.com/babylon101/sprites
  77224. */
  77225. export class SpritePackedManager extends SpriteManager {
  77226. /** defines the packed manager's name */
  77227. name: string;
  77228. /**
  77229. * Creates a new sprite manager from a packed sprite sheet
  77230. * @param name defines the manager's name
  77231. * @param imgUrl defines the sprite sheet url
  77232. * @param capacity defines the maximum allowed number of sprites
  77233. * @param scene defines the hosting scene
  77234. * @param spriteJSON null otherwise a JSON object defining sprite sheet data
  77235. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  77236. * @param samplingMode defines the smapling mode to use with spritesheet
  77237. * @param fromPacked set to true; do not alter
  77238. */
  77239. constructor(
  77240. /** defines the packed manager's name */
  77241. name: string, imgUrl: string, capacity: number, scene: Scene, spriteJSON?: string | null, epsilon?: number, samplingMode?: number);
  77242. }
  77243. }
  77244. declare module BABYLON {
  77245. /**
  77246. * Defines the list of states available for a task inside a AssetsManager
  77247. */
  77248. export enum AssetTaskState {
  77249. /**
  77250. * Initialization
  77251. */
  77252. INIT = 0,
  77253. /**
  77254. * Running
  77255. */
  77256. RUNNING = 1,
  77257. /**
  77258. * Done
  77259. */
  77260. DONE = 2,
  77261. /**
  77262. * Error
  77263. */
  77264. ERROR = 3
  77265. }
  77266. /**
  77267. * Define an abstract asset task used with a AssetsManager class to load assets into a scene
  77268. */
  77269. export abstract class AbstractAssetTask {
  77270. /**
  77271. * Task name
  77272. */ name: string;
  77273. /**
  77274. * Callback called when the task is successful
  77275. */
  77276. onSuccess: (task: any) => void;
  77277. /**
  77278. * Callback called when the task is not successful
  77279. */
  77280. onError: (task: any, message?: string, exception?: any) => void;
  77281. /**
  77282. * Creates a new AssetsManager
  77283. * @param name defines the name of the task
  77284. */
  77285. constructor(
  77286. /**
  77287. * Task name
  77288. */ name: string);
  77289. private _isCompleted;
  77290. private _taskState;
  77291. private _errorObject;
  77292. /**
  77293. * Get if the task is completed
  77294. */
  77295. get isCompleted(): boolean;
  77296. /**
  77297. * Gets the current state of the task
  77298. */
  77299. get taskState(): AssetTaskState;
  77300. /**
  77301. * Gets the current error object (if task is in error)
  77302. */
  77303. get errorObject(): {
  77304. message?: string;
  77305. exception?: any;
  77306. };
  77307. /**
  77308. * Internal only
  77309. * @hidden
  77310. */
  77311. _setErrorObject(message?: string, exception?: any): void;
  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. run(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  77319. /**
  77320. * Execute the current task
  77321. * @param scene defines the scene where you want your assets to be loaded
  77322. * @param onSuccess is a callback called when the task is successfully executed
  77323. * @param onError is a callback called if an error occurs
  77324. */
  77325. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  77326. /**
  77327. * Reset will set the task state back to INIT, so the next load call of the assets manager will execute this task again.
  77328. * This can be used with failed tasks that have the reason for failure fixed.
  77329. */
  77330. reset(): void;
  77331. private onErrorCallback;
  77332. private onDoneCallback;
  77333. }
  77334. /**
  77335. * Define the interface used by progress events raised during assets loading
  77336. */
  77337. export interface IAssetsProgressEvent {
  77338. /**
  77339. * Defines the number of remaining tasks to process
  77340. */
  77341. remainingCount: number;
  77342. /**
  77343. * Defines the total number of tasks
  77344. */
  77345. totalCount: number;
  77346. /**
  77347. * Defines the task that was just processed
  77348. */
  77349. task: AbstractAssetTask;
  77350. }
  77351. /**
  77352. * Class used to share progress information about assets loading
  77353. */
  77354. export class AssetsProgressEvent implements IAssetsProgressEvent {
  77355. /**
  77356. * Defines the number of remaining tasks to process
  77357. */
  77358. remainingCount: number;
  77359. /**
  77360. * Defines the total number of tasks
  77361. */
  77362. totalCount: number;
  77363. /**
  77364. * Defines the task that was just processed
  77365. */
  77366. task: AbstractAssetTask;
  77367. /**
  77368. * Creates a AssetsProgressEvent
  77369. * @param remainingCount defines the number of remaining tasks to process
  77370. * @param totalCount defines the total number of tasks
  77371. * @param task defines the task that was just processed
  77372. */
  77373. constructor(remainingCount: number, totalCount: number, task: AbstractAssetTask);
  77374. }
  77375. /**
  77376. * Define a task used by AssetsManager to load assets into a container
  77377. */
  77378. export class ContainerAssetTask extends AbstractAssetTask {
  77379. /**
  77380. * Defines the name of the task
  77381. */
  77382. name: string;
  77383. /**
  77384. * Defines the list of mesh's names you want to load
  77385. */
  77386. meshesNames: any;
  77387. /**
  77388. * Defines the root url to use as a base to load your meshes and associated resources
  77389. */
  77390. rootUrl: string;
  77391. /**
  77392. * Defines the filename or File of the scene to load from
  77393. */
  77394. sceneFilename: string | File;
  77395. /**
  77396. * Get the loaded asset container
  77397. */
  77398. loadedContainer: AssetContainer;
  77399. /**
  77400. * Gets the list of loaded meshes
  77401. */
  77402. loadedMeshes: Array<AbstractMesh>;
  77403. /**
  77404. * Gets the list of loaded particle systems
  77405. */
  77406. loadedParticleSystems: Array<IParticleSystem>;
  77407. /**
  77408. * Gets the list of loaded skeletons
  77409. */
  77410. loadedSkeletons: Array<Skeleton>;
  77411. /**
  77412. * Gets the list of loaded animation groups
  77413. */
  77414. loadedAnimationGroups: Array<AnimationGroup>;
  77415. /**
  77416. * Callback called when the task is successful
  77417. */
  77418. onSuccess: (task: ContainerAssetTask) => void;
  77419. /**
  77420. * Callback called when the task is successful
  77421. */
  77422. onError: (task: ContainerAssetTask, message?: string, exception?: any) => void;
  77423. /**
  77424. * Creates a new ContainerAssetTask
  77425. * @param name defines the name of the task
  77426. * @param meshesNames defines the list of mesh's names you want to load
  77427. * @param rootUrl defines the root url to use as a base to load your meshes and associated resources
  77428. * @param sceneFilename defines the filename or File of the scene to load from
  77429. */
  77430. constructor(
  77431. /**
  77432. * Defines the name of the task
  77433. */
  77434. name: string,
  77435. /**
  77436. * Defines the list of mesh's names you want to load
  77437. */
  77438. meshesNames: any,
  77439. /**
  77440. * Defines the root url to use as a base to load your meshes and associated resources
  77441. */
  77442. rootUrl: string,
  77443. /**
  77444. * Defines the filename or File of the scene to load from
  77445. */
  77446. sceneFilename: string | File);
  77447. /**
  77448. * Execute the current task
  77449. * @param scene defines the scene where you want your assets to be loaded
  77450. * @param onSuccess is a callback called when the task is successfully executed
  77451. * @param onError is a callback called if an error occurs
  77452. */
  77453. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  77454. }
  77455. /**
  77456. * Define a task used by AssetsManager to load meshes
  77457. */
  77458. export class MeshAssetTask extends AbstractAssetTask {
  77459. /**
  77460. * Defines the name of the task
  77461. */
  77462. name: string;
  77463. /**
  77464. * Defines the list of mesh's names you want to load
  77465. */
  77466. meshesNames: any;
  77467. /**
  77468. * Defines the root url to use as a base to load your meshes and associated resources
  77469. */
  77470. rootUrl: string;
  77471. /**
  77472. * Defines the filename or File of the scene to load from
  77473. */
  77474. sceneFilename: string | File;
  77475. /**
  77476. * Gets the list of loaded meshes
  77477. */
  77478. loadedMeshes: Array<AbstractMesh>;
  77479. /**
  77480. * Gets the list of loaded particle systems
  77481. */
  77482. loadedParticleSystems: Array<IParticleSystem>;
  77483. /**
  77484. * Gets the list of loaded skeletons
  77485. */
  77486. loadedSkeletons: Array<Skeleton>;
  77487. /**
  77488. * Gets the list of loaded animation groups
  77489. */
  77490. loadedAnimationGroups: Array<AnimationGroup>;
  77491. /**
  77492. * Callback called when the task is successful
  77493. */
  77494. onSuccess: (task: MeshAssetTask) => void;
  77495. /**
  77496. * Callback called when the task is successful
  77497. */
  77498. onError: (task: MeshAssetTask, message?: string, exception?: any) => void;
  77499. /**
  77500. * Creates a new MeshAssetTask
  77501. * @param name defines the name of the task
  77502. * @param meshesNames defines the list of mesh's names you want to load
  77503. * @param rootUrl defines the root url to use as a base to load your meshes and associated resources
  77504. * @param sceneFilename defines the filename or File of the scene to load from
  77505. */
  77506. constructor(
  77507. /**
  77508. * Defines the name of the task
  77509. */
  77510. name: string,
  77511. /**
  77512. * Defines the list of mesh's names you want to load
  77513. */
  77514. meshesNames: any,
  77515. /**
  77516. * Defines the root url to use as a base to load your meshes and associated resources
  77517. */
  77518. rootUrl: string,
  77519. /**
  77520. * Defines the filename or File of the scene to load from
  77521. */
  77522. sceneFilename: string | File);
  77523. /**
  77524. * Execute the current task
  77525. * @param scene defines the scene where you want your assets to be loaded
  77526. * @param onSuccess is a callback called when the task is successfully executed
  77527. * @param onError is a callback called if an error occurs
  77528. */
  77529. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  77530. }
  77531. /**
  77532. * Define a task used by AssetsManager to load text content
  77533. */
  77534. export class TextFileAssetTask extends AbstractAssetTask {
  77535. /**
  77536. * Defines the name of the task
  77537. */
  77538. name: string;
  77539. /**
  77540. * Defines the location of the file to load
  77541. */
  77542. url: string;
  77543. /**
  77544. * Gets the loaded text string
  77545. */
  77546. text: string;
  77547. /**
  77548. * Callback called when the task is successful
  77549. */
  77550. onSuccess: (task: TextFileAssetTask) => void;
  77551. /**
  77552. * Callback called when the task is successful
  77553. */
  77554. onError: (task: TextFileAssetTask, message?: string, exception?: any) => void;
  77555. /**
  77556. * Creates a new TextFileAssetTask object
  77557. * @param name defines the name of the task
  77558. * @param url defines the location of the file to load
  77559. */
  77560. constructor(
  77561. /**
  77562. * Defines the name of the task
  77563. */
  77564. name: string,
  77565. /**
  77566. * Defines the location of the file to load
  77567. */
  77568. url: string);
  77569. /**
  77570. * Execute the current task
  77571. * @param scene defines the scene where you want your assets to be loaded
  77572. * @param onSuccess is a callback called when the task is successfully executed
  77573. * @param onError is a callback called if an error occurs
  77574. */
  77575. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  77576. }
  77577. /**
  77578. * Define a task used by AssetsManager to load binary data
  77579. */
  77580. export class BinaryFileAssetTask extends AbstractAssetTask {
  77581. /**
  77582. * Defines the name of the task
  77583. */
  77584. name: string;
  77585. /**
  77586. * Defines the location of the file to load
  77587. */
  77588. url: string;
  77589. /**
  77590. * Gets the lodaded data (as an array buffer)
  77591. */
  77592. data: ArrayBuffer;
  77593. /**
  77594. * Callback called when the task is successful
  77595. */
  77596. onSuccess: (task: BinaryFileAssetTask) => void;
  77597. /**
  77598. * Callback called when the task is successful
  77599. */
  77600. onError: (task: BinaryFileAssetTask, message?: string, exception?: any) => void;
  77601. /**
  77602. * Creates a new BinaryFileAssetTask object
  77603. * @param name defines the name of the new task
  77604. * @param url defines the location of the file to load
  77605. */
  77606. constructor(
  77607. /**
  77608. * Defines the name of the task
  77609. */
  77610. name: string,
  77611. /**
  77612. * Defines the location of the file to load
  77613. */
  77614. url: string);
  77615. /**
  77616. * Execute the current task
  77617. * @param scene defines the scene where you want your assets to be loaded
  77618. * @param onSuccess is a callback called when the task is successfully executed
  77619. * @param onError is a callback called if an error occurs
  77620. */
  77621. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  77622. }
  77623. /**
  77624. * Define a task used by AssetsManager to load images
  77625. */
  77626. export class ImageAssetTask extends AbstractAssetTask {
  77627. /**
  77628. * Defines the name of the task
  77629. */
  77630. name: string;
  77631. /**
  77632. * Defines the location of the image to load
  77633. */
  77634. url: string;
  77635. /**
  77636. * Gets the loaded images
  77637. */
  77638. image: HTMLImageElement;
  77639. /**
  77640. * Callback called when the task is successful
  77641. */
  77642. onSuccess: (task: ImageAssetTask) => void;
  77643. /**
  77644. * Callback called when the task is successful
  77645. */
  77646. onError: (task: ImageAssetTask, message?: string, exception?: any) => void;
  77647. /**
  77648. * Creates a new ImageAssetTask
  77649. * @param name defines the name of the task
  77650. * @param url defines the location of the image to load
  77651. */
  77652. constructor(
  77653. /**
  77654. * Defines the name of the task
  77655. */
  77656. name: string,
  77657. /**
  77658. * Defines the location of the image to load
  77659. */
  77660. url: string);
  77661. /**
  77662. * Execute the current task
  77663. * @param scene defines the scene where you want your assets to be loaded
  77664. * @param onSuccess is a callback called when the task is successfully executed
  77665. * @param onError is a callback called if an error occurs
  77666. */
  77667. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  77668. }
  77669. /**
  77670. * Defines the interface used by texture loading tasks
  77671. */
  77672. export interface ITextureAssetTask<TEX extends BaseTexture> {
  77673. /**
  77674. * Gets the loaded texture
  77675. */
  77676. texture: TEX;
  77677. }
  77678. /**
  77679. * Define a task used by AssetsManager to load 2D textures
  77680. */
  77681. export class TextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<Texture> {
  77682. /**
  77683. * Defines the name of the task
  77684. */
  77685. name: string;
  77686. /**
  77687. * Defines the location of the file to load
  77688. */
  77689. url: string;
  77690. /**
  77691. * Defines if mipmap should not be generated (default is false)
  77692. */
  77693. noMipmap?: boolean | undefined;
  77694. /**
  77695. * Defines if texture must be inverted on Y axis (default is true)
  77696. */
  77697. invertY: boolean;
  77698. /**
  77699. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  77700. */
  77701. samplingMode: number;
  77702. /**
  77703. * Gets the loaded texture
  77704. */
  77705. texture: Texture;
  77706. /**
  77707. * Callback called when the task is successful
  77708. */
  77709. onSuccess: (task: TextureAssetTask) => void;
  77710. /**
  77711. * Callback called when the task is successful
  77712. */
  77713. onError: (task: TextureAssetTask, message?: string, exception?: any) => void;
  77714. /**
  77715. * Creates a new TextureAssetTask object
  77716. * @param name defines the name of the task
  77717. * @param url defines the location of the file to load
  77718. * @param noMipmap defines if mipmap should not be generated (default is false)
  77719. * @param invertY defines if texture must be inverted on Y axis (default is true)
  77720. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  77721. */
  77722. constructor(
  77723. /**
  77724. * Defines the name of the task
  77725. */
  77726. name: string,
  77727. /**
  77728. * Defines the location of the file to load
  77729. */
  77730. url: string,
  77731. /**
  77732. * Defines if mipmap should not be generated (default is false)
  77733. */
  77734. noMipmap?: boolean | undefined,
  77735. /**
  77736. * Defines if texture must be inverted on Y axis (default is true)
  77737. */
  77738. invertY?: boolean,
  77739. /**
  77740. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  77741. */
  77742. samplingMode?: number);
  77743. /**
  77744. * Execute the current task
  77745. * @param scene defines the scene where you want your assets to be loaded
  77746. * @param onSuccess is a callback called when the task is successfully executed
  77747. * @param onError is a callback called if an error occurs
  77748. */
  77749. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  77750. }
  77751. /**
  77752. * Define a task used by AssetsManager to load cube textures
  77753. */
  77754. export class CubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<CubeTexture> {
  77755. /**
  77756. * Defines the name of the task
  77757. */
  77758. name: string;
  77759. /**
  77760. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  77761. */
  77762. url: string;
  77763. /**
  77764. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  77765. */
  77766. extensions?: string[] | undefined;
  77767. /**
  77768. * Defines if mipmaps should not be generated (default is false)
  77769. */
  77770. noMipmap?: boolean | undefined;
  77771. /**
  77772. * Defines the explicit list of files (undefined by default)
  77773. */
  77774. files?: string[] | undefined;
  77775. /**
  77776. * Gets the loaded texture
  77777. */
  77778. texture: CubeTexture;
  77779. /**
  77780. * Callback called when the task is successful
  77781. */
  77782. onSuccess: (task: CubeTextureAssetTask) => void;
  77783. /**
  77784. * Callback called when the task is successful
  77785. */
  77786. onError: (task: CubeTextureAssetTask, message?: string, exception?: any) => void;
  77787. /**
  77788. * Creates a new CubeTextureAssetTask
  77789. * @param name defines the name of the task
  77790. * @param url defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  77791. * @param extensions defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  77792. * @param noMipmap defines if mipmaps should not be generated (default is false)
  77793. * @param files defines the explicit list of files (undefined by default)
  77794. */
  77795. constructor(
  77796. /**
  77797. * Defines the name of the task
  77798. */
  77799. name: string,
  77800. /**
  77801. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  77802. */
  77803. url: string,
  77804. /**
  77805. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  77806. */
  77807. extensions?: string[] | undefined,
  77808. /**
  77809. * Defines if mipmaps should not be generated (default is false)
  77810. */
  77811. noMipmap?: boolean | undefined,
  77812. /**
  77813. * Defines the explicit list of files (undefined by default)
  77814. */
  77815. files?: string[] | undefined);
  77816. /**
  77817. * Execute the current task
  77818. * @param scene defines the scene where you want your assets to be loaded
  77819. * @param onSuccess is a callback called when the task is successfully executed
  77820. * @param onError is a callback called if an error occurs
  77821. */
  77822. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  77823. }
  77824. /**
  77825. * Define a task used by AssetsManager to load HDR cube textures
  77826. */
  77827. export class HDRCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<HDRCubeTexture> {
  77828. /**
  77829. * Defines the name of the task
  77830. */
  77831. name: string;
  77832. /**
  77833. * Defines the location of the file to load
  77834. */
  77835. url: string;
  77836. /**
  77837. * Defines the desired size (the more it increases the longer the generation will be)
  77838. */
  77839. size: number;
  77840. /**
  77841. * Defines if mipmaps should not be generated (default is false)
  77842. */
  77843. noMipmap: boolean;
  77844. /**
  77845. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  77846. */
  77847. generateHarmonics: boolean;
  77848. /**
  77849. * 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)
  77850. */
  77851. gammaSpace: boolean;
  77852. /**
  77853. * Internal Use Only
  77854. */
  77855. reserved: boolean;
  77856. /**
  77857. * Gets the loaded texture
  77858. */
  77859. texture: HDRCubeTexture;
  77860. /**
  77861. * Callback called when the task is successful
  77862. */
  77863. onSuccess: (task: HDRCubeTextureAssetTask) => void;
  77864. /**
  77865. * Callback called when the task is successful
  77866. */
  77867. onError: (task: HDRCubeTextureAssetTask, message?: string, exception?: any) => void;
  77868. /**
  77869. * Creates a new HDRCubeTextureAssetTask object
  77870. * @param name defines the name of the task
  77871. * @param url defines the location of the file to load
  77872. * @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.
  77873. * @param noMipmap defines if mipmaps should not be generated (default is false)
  77874. * @param generateHarmonics specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  77875. * @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)
  77876. * @param reserved Internal use only
  77877. */
  77878. constructor(
  77879. /**
  77880. * Defines the name of the task
  77881. */
  77882. name: string,
  77883. /**
  77884. * Defines the location of the file to load
  77885. */
  77886. url: string,
  77887. /**
  77888. * Defines the desired size (the more it increases the longer the generation will be)
  77889. */
  77890. size: number,
  77891. /**
  77892. * Defines if mipmaps should not be generated (default is false)
  77893. */
  77894. noMipmap?: boolean,
  77895. /**
  77896. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  77897. */
  77898. generateHarmonics?: boolean,
  77899. /**
  77900. * 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)
  77901. */
  77902. gammaSpace?: boolean,
  77903. /**
  77904. * Internal Use Only
  77905. */
  77906. reserved?: boolean);
  77907. /**
  77908. * Execute the current task
  77909. * @param scene defines the scene where you want your assets to be loaded
  77910. * @param onSuccess is a callback called when the task is successfully executed
  77911. * @param onError is a callback called if an error occurs
  77912. */
  77913. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  77914. }
  77915. /**
  77916. * Define a task used by AssetsManager to load Equirectangular cube textures
  77917. */
  77918. export class EquiRectangularCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<EquiRectangularCubeTexture> {
  77919. /**
  77920. * Defines the name of the task
  77921. */
  77922. name: string;
  77923. /**
  77924. * Defines the location of the file to load
  77925. */
  77926. url: string;
  77927. /**
  77928. * Defines the desired size (the more it increases the longer the generation will be)
  77929. */
  77930. size: number;
  77931. /**
  77932. * Defines if mipmaps should not be generated (default is false)
  77933. */
  77934. noMipmap: boolean;
  77935. /**
  77936. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  77937. * but the standard material would require them in Gamma space) (default is true)
  77938. */
  77939. gammaSpace: boolean;
  77940. /**
  77941. * Gets the loaded texture
  77942. */
  77943. texture: EquiRectangularCubeTexture;
  77944. /**
  77945. * Callback called when the task is successful
  77946. */
  77947. onSuccess: (task: EquiRectangularCubeTextureAssetTask) => void;
  77948. /**
  77949. * Callback called when the task is successful
  77950. */
  77951. onError: (task: EquiRectangularCubeTextureAssetTask, message?: string, exception?: any) => void;
  77952. /**
  77953. * Creates a new EquiRectangularCubeTextureAssetTask object
  77954. * @param name defines the name of the task
  77955. * @param url defines the location of the file to load
  77956. * @param size defines the desired size (the more it increases the longer the generation will be)
  77957. * If the size is omitted this implies you are using a preprocessed cubemap.
  77958. * @param noMipmap defines if mipmaps should not be generated (default is false)
  77959. * @param gammaSpace specifies if the texture will be used in gamma or linear space
  77960. * (the PBR material requires those texture in linear space, but the standard material would require them in Gamma space)
  77961. * (default is true)
  77962. */
  77963. constructor(
  77964. /**
  77965. * Defines the name of the task
  77966. */
  77967. name: string,
  77968. /**
  77969. * Defines the location of the file to load
  77970. */
  77971. url: string,
  77972. /**
  77973. * Defines the desired size (the more it increases the longer the generation will be)
  77974. */
  77975. size: number,
  77976. /**
  77977. * Defines if mipmaps should not be generated (default is false)
  77978. */
  77979. noMipmap?: boolean,
  77980. /**
  77981. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  77982. * but the standard material would require them in Gamma space) (default is true)
  77983. */
  77984. gammaSpace?: boolean);
  77985. /**
  77986. * Execute the current task
  77987. * @param scene defines the scene where you want your assets to be loaded
  77988. * @param onSuccess is a callback called when the task is successfully executed
  77989. * @param onError is a callback called if an error occurs
  77990. */
  77991. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  77992. }
  77993. /**
  77994. * This class can be used to easily import assets into a scene
  77995. * @see https://doc.babylonjs.com/how_to/how_to_use_assetsmanager
  77996. */
  77997. export class AssetsManager {
  77998. private _scene;
  77999. private _isLoading;
  78000. protected _tasks: AbstractAssetTask[];
  78001. protected _waitingTasksCount: number;
  78002. protected _totalTasksCount: number;
  78003. /**
  78004. * Callback called when all tasks are processed
  78005. */
  78006. onFinish: (tasks: AbstractAssetTask[]) => void;
  78007. /**
  78008. * Callback called when a task is successful
  78009. */
  78010. onTaskSuccess: (task: AbstractAssetTask) => void;
  78011. /**
  78012. * Callback called when a task had an error
  78013. */
  78014. onTaskError: (task: AbstractAssetTask) => void;
  78015. /**
  78016. * Callback called when a task is done (whatever the result is)
  78017. */
  78018. onProgress: (remainingCount: number, totalCount: number, task: AbstractAssetTask) => void;
  78019. /**
  78020. * Observable called when all tasks are processed
  78021. */
  78022. onTaskSuccessObservable: Observable<AbstractAssetTask>;
  78023. /**
  78024. * Observable called when a task had an error
  78025. */
  78026. onTaskErrorObservable: Observable<AbstractAssetTask>;
  78027. /**
  78028. * Observable called when all tasks were executed
  78029. */
  78030. onTasksDoneObservable: Observable<AbstractAssetTask[]>;
  78031. /**
  78032. * Observable called when a task is done (whatever the result is)
  78033. */
  78034. onProgressObservable: Observable<IAssetsProgressEvent>;
  78035. /**
  78036. * Gets or sets a boolean defining if the AssetsManager should use the default loading screen
  78037. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  78038. */
  78039. useDefaultLoadingScreen: boolean;
  78040. /**
  78041. * Gets or sets a boolean defining if the AssetsManager should automatically hide the loading screen
  78042. * when all assets have been downloaded.
  78043. * If set to false, you need to manually call in hideLoadingUI() once your scene is ready.
  78044. */
  78045. autoHideLoadingUI: boolean;
  78046. /**
  78047. * Creates a new AssetsManager
  78048. * @param scene defines the scene to work on
  78049. */
  78050. constructor(scene: Scene);
  78051. /**
  78052. * Add a ContainerAssetTask to the list of active tasks
  78053. * @param taskName defines the name of the new task
  78054. * @param meshesNames defines the name of meshes to load
  78055. * @param rootUrl defines the root url to use to locate files
  78056. * @param sceneFilename defines the filename of the scene file
  78057. * @returns a new ContainerAssetTask object
  78058. */
  78059. addContainerTask(taskName: string, meshesNames: any, rootUrl: string, sceneFilename: string): ContainerAssetTask;
  78060. /**
  78061. * Add a MeshAssetTask to the list of active tasks
  78062. * @param taskName defines the name of the new task
  78063. * @param meshesNames defines the name of meshes to load
  78064. * @param rootUrl defines the root url to use to locate files
  78065. * @param sceneFilename defines the filename of the scene file
  78066. * @returns a new MeshAssetTask object
  78067. */
  78068. addMeshTask(taskName: string, meshesNames: any, rootUrl: string, sceneFilename: string): MeshAssetTask;
  78069. /**
  78070. * Add a TextFileAssetTask to the list of active tasks
  78071. * @param taskName defines the name of the new task
  78072. * @param url defines the url of the file to load
  78073. * @returns a new TextFileAssetTask object
  78074. */
  78075. addTextFileTask(taskName: string, url: string): TextFileAssetTask;
  78076. /**
  78077. * Add a BinaryFileAssetTask to the list of active tasks
  78078. * @param taskName defines the name of the new task
  78079. * @param url defines the url of the file to load
  78080. * @returns a new BinaryFileAssetTask object
  78081. */
  78082. addBinaryFileTask(taskName: string, url: string): BinaryFileAssetTask;
  78083. /**
  78084. * Add a ImageAssetTask to the list of active tasks
  78085. * @param taskName defines the name of the new task
  78086. * @param url defines the url of the file to load
  78087. * @returns a new ImageAssetTask object
  78088. */
  78089. addImageTask(taskName: string, url: string): ImageAssetTask;
  78090. /**
  78091. * Add a TextureAssetTask to the list of active tasks
  78092. * @param taskName defines the name of the new task
  78093. * @param url defines the url of the file to load
  78094. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  78095. * @param invertY defines if you want to invert Y axis of the loaded texture (false by default)
  78096. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  78097. * @returns a new TextureAssetTask object
  78098. */
  78099. addTextureTask(taskName: string, url: string, noMipmap?: boolean, invertY?: boolean, samplingMode?: number): TextureAssetTask;
  78100. /**
  78101. * Add a CubeTextureAssetTask to the list of active tasks
  78102. * @param taskName defines the name of the new task
  78103. * @param url defines the url of the file to load
  78104. * @param extensions defines the extension to use to load the cube map (can be null)
  78105. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  78106. * @param files defines the list of files to load (can be null)
  78107. * @returns a new CubeTextureAssetTask object
  78108. */
  78109. addCubeTextureTask(taskName: string, url: string, extensions?: string[], noMipmap?: boolean, files?: string[]): CubeTextureAssetTask;
  78110. /**
  78111. *
  78112. * Add a HDRCubeTextureAssetTask to the list of active tasks
  78113. * @param taskName defines the name of the new task
  78114. * @param url defines the url of the file to load
  78115. * @param size defines the size you want for the cubemap (can be null)
  78116. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  78117. * @param generateHarmonics defines if you want to automatically generate (true by default)
  78118. * @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)
  78119. * @param reserved Internal use only
  78120. * @returns a new HDRCubeTextureAssetTask object
  78121. */
  78122. addHDRCubeTextureTask(taskName: string, url: string, size: number, noMipmap?: boolean, generateHarmonics?: boolean, gammaSpace?: boolean, reserved?: boolean): HDRCubeTextureAssetTask;
  78123. /**
  78124. *
  78125. * Add a EquiRectangularCubeTextureAssetTask to the list of active tasks
  78126. * @param taskName defines the name of the new task
  78127. * @param url defines the url of the file to load
  78128. * @param size defines the size you want for the cubemap (can be null)
  78129. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  78130. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  78131. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  78132. * @returns a new EquiRectangularCubeTextureAssetTask object
  78133. */
  78134. addEquiRectangularCubeTextureAssetTask(taskName: string, url: string, size: number, noMipmap?: boolean, gammaSpace?: boolean): EquiRectangularCubeTextureAssetTask;
  78135. /**
  78136. * Remove a task from the assets manager.
  78137. * @param task the task to remove
  78138. */
  78139. removeTask(task: AbstractAssetTask): void;
  78140. private _decreaseWaitingTasksCount;
  78141. private _runTask;
  78142. /**
  78143. * Reset the AssetsManager and remove all tasks
  78144. * @return the current instance of the AssetsManager
  78145. */
  78146. reset(): AssetsManager;
  78147. /**
  78148. * Start the loading process
  78149. * @return the current instance of the AssetsManager
  78150. */
  78151. load(): AssetsManager;
  78152. /**
  78153. * Start the loading process as an async operation
  78154. * @return a promise returning the list of failed tasks
  78155. */
  78156. loadAsync(): Promise<void>;
  78157. }
  78158. }
  78159. declare module BABYLON {
  78160. /**
  78161. * Wrapper class for promise with external resolve and reject.
  78162. */
  78163. export class Deferred<T> {
  78164. /**
  78165. * The promise associated with this deferred object.
  78166. */
  78167. readonly promise: Promise<T>;
  78168. private _resolve;
  78169. private _reject;
  78170. /**
  78171. * The resolve method of the promise associated with this deferred object.
  78172. */
  78173. get resolve(): (value: T | PromiseLike<T>) => void;
  78174. /**
  78175. * The reject method of the promise associated with this deferred object.
  78176. */
  78177. get reject(): (reason?: any) => void;
  78178. /**
  78179. * Constructor for this deferred object.
  78180. */
  78181. constructor();
  78182. }
  78183. }
  78184. declare module BABYLON {
  78185. /**
  78186. * Class used to explode meshes (ie. to have a center and move them away from that center to better see the overall organization)
  78187. */
  78188. export class MeshExploder {
  78189. private _centerMesh;
  78190. private _meshes;
  78191. private _meshesOrigins;
  78192. private _toCenterVectors;
  78193. private _scaledDirection;
  78194. private _newPosition;
  78195. private _centerPosition;
  78196. /**
  78197. * Explodes meshes from a center mesh.
  78198. * @param meshes The meshes to explode.
  78199. * @param centerMesh The mesh to be center of explosion.
  78200. */
  78201. constructor(meshes: Array<Mesh>, centerMesh?: Mesh);
  78202. private _setCenterMesh;
  78203. /**
  78204. * Get class name
  78205. * @returns "MeshExploder"
  78206. */
  78207. getClassName(): string;
  78208. /**
  78209. * "Exploded meshes"
  78210. * @returns Array of meshes with the centerMesh at index 0.
  78211. */
  78212. getMeshes(): Array<Mesh>;
  78213. /**
  78214. * Explodes meshes giving a specific direction
  78215. * @param direction Number to multiply distance of each mesh's origin from center. Use a negative number to implode, or zero to reset.
  78216. */
  78217. explode(direction?: number): void;
  78218. }
  78219. }
  78220. declare module BABYLON {
  78221. /**
  78222. * Class used to help managing file picking and drag'n'drop
  78223. */
  78224. export class FilesInput {
  78225. /**
  78226. * List of files ready to be loaded
  78227. */
  78228. static get FilesToLoad(): {
  78229. [key: string]: File;
  78230. };
  78231. /**
  78232. * Callback called when a file is processed
  78233. */
  78234. onProcessFileCallback: (file: File, name: string, extension: string, setSceneFileToLoad: (sceneFile: File) => void) => boolean;
  78235. /**
  78236. * Function used when loading the scene file
  78237. */
  78238. loadAsync: (sceneFile: File, onProgress: Nullable<(event: ISceneLoaderProgressEvent) => void>) => Promise<Scene>;
  78239. private _engine;
  78240. private _currentScene;
  78241. private _sceneLoadedCallback;
  78242. private _progressCallback;
  78243. private _additionalRenderLoopLogicCallback;
  78244. private _textureLoadingCallback;
  78245. private _startingProcessingFilesCallback;
  78246. private _onReloadCallback;
  78247. private _errorCallback;
  78248. private _elementToMonitor;
  78249. private _sceneFileToLoad;
  78250. private _filesToLoad;
  78251. /**
  78252. * Creates a new FilesInput
  78253. * @param engine defines the rendering engine
  78254. * @param scene defines the hosting scene
  78255. * @param sceneLoadedCallback callback called when scene is loaded
  78256. * @param progressCallback callback called to track progress
  78257. * @param additionalRenderLoopLogicCallback callback called to add user logic to the rendering loop
  78258. * @param textureLoadingCallback callback called when a texture is loading
  78259. * @param startingProcessingFilesCallback callback called when the system is about to process all files
  78260. * @param onReloadCallback callback called when a reload is requested
  78261. * @param errorCallback callback call if an error occurs
  78262. */
  78263. 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>);
  78264. private _dragEnterHandler;
  78265. private _dragOverHandler;
  78266. private _dropHandler;
  78267. /**
  78268. * Calls this function to listen to drag'n'drop events on a specific DOM element
  78269. * @param elementToMonitor defines the DOM element to track
  78270. */
  78271. monitorElementForDragNDrop(elementToMonitor: HTMLElement): void;
  78272. /** Gets the current list of files to load */
  78273. get filesToLoad(): File[];
  78274. /**
  78275. * Release all associated resources
  78276. */
  78277. dispose(): void;
  78278. private renderFunction;
  78279. private drag;
  78280. private drop;
  78281. private _traverseFolder;
  78282. private _processFiles;
  78283. /**
  78284. * Load files from a drop event
  78285. * @param event defines the drop event to use as source
  78286. */
  78287. loadFiles(event: any): void;
  78288. private _processReload;
  78289. /**
  78290. * Reload the current scene from the loaded files
  78291. */
  78292. reload(): void;
  78293. }
  78294. }
  78295. declare module BABYLON {
  78296. /**
  78297. * Defines the root class used to create scene optimization to use with SceneOptimizer
  78298. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  78299. */
  78300. export class SceneOptimization {
  78301. /**
  78302. * Defines the priority of this optimization (0 by default which means first in the list)
  78303. */
  78304. priority: number;
  78305. /**
  78306. * Gets a string describing the action executed by the current optimization
  78307. * @returns description string
  78308. */
  78309. getDescription(): string;
  78310. /**
  78311. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  78312. * @param scene defines the current scene where to apply this optimization
  78313. * @param optimizer defines the current optimizer
  78314. * @returns true if everything that can be done was applied
  78315. */
  78316. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  78317. /**
  78318. * Creates the SceneOptimization object
  78319. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  78320. * @param desc defines the description associated with the optimization
  78321. */
  78322. constructor(
  78323. /**
  78324. * Defines the priority of this optimization (0 by default which means first in the list)
  78325. */
  78326. priority?: number);
  78327. }
  78328. /**
  78329. * Defines an optimization used to reduce the size of render target textures
  78330. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  78331. */
  78332. export class TextureOptimization extends SceneOptimization {
  78333. /**
  78334. * Defines the priority of this optimization (0 by default which means first in the list)
  78335. */
  78336. priority: number;
  78337. /**
  78338. * 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
  78339. */
  78340. maximumSize: number;
  78341. /**
  78342. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  78343. */
  78344. step: number;
  78345. /**
  78346. * Gets a string describing the action executed by the current optimization
  78347. * @returns description string
  78348. */
  78349. getDescription(): string;
  78350. /**
  78351. * Creates the TextureOptimization object
  78352. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  78353. * @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
  78354. * @param step defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  78355. */
  78356. constructor(
  78357. /**
  78358. * Defines the priority of this optimization (0 by default which means first in the list)
  78359. */
  78360. priority?: number,
  78361. /**
  78362. * 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
  78363. */
  78364. maximumSize?: number,
  78365. /**
  78366. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  78367. */
  78368. step?: number);
  78369. /**
  78370. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  78371. * @param scene defines the current scene where to apply this optimization
  78372. * @param optimizer defines the current optimizer
  78373. * @returns true if everything that can be done was applied
  78374. */
  78375. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  78376. }
  78377. /**
  78378. * Defines an optimization used to increase or decrease the rendering resolution
  78379. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  78380. */
  78381. export class HardwareScalingOptimization extends SceneOptimization {
  78382. /**
  78383. * Defines the priority of this optimization (0 by default which means first in the list)
  78384. */
  78385. priority: number;
  78386. /**
  78387. * Defines the maximum scale to use (2 by default)
  78388. */
  78389. maximumScale: number;
  78390. /**
  78391. * Defines the step to use between two passes (0.5 by default)
  78392. */
  78393. step: number;
  78394. private _currentScale;
  78395. private _directionOffset;
  78396. /**
  78397. * Gets a string describing the action executed by the current optimization
  78398. * @return description string
  78399. */
  78400. getDescription(): string;
  78401. /**
  78402. * Creates the HardwareScalingOptimization object
  78403. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  78404. * @param maximumScale defines the maximum scale to use (2 by default)
  78405. * @param step defines the step to use between two passes (0.5 by default)
  78406. */
  78407. constructor(
  78408. /**
  78409. * Defines the priority of this optimization (0 by default which means first in the list)
  78410. */
  78411. priority?: number,
  78412. /**
  78413. * Defines the maximum scale to use (2 by default)
  78414. */
  78415. maximumScale?: number,
  78416. /**
  78417. * Defines the step to use between two passes (0.5 by default)
  78418. */
  78419. step?: number);
  78420. /**
  78421. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  78422. * @param scene defines the current scene where to apply this optimization
  78423. * @param optimizer defines the current optimizer
  78424. * @returns true if everything that can be done was applied
  78425. */
  78426. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  78427. }
  78428. /**
  78429. * Defines an optimization used to remove shadows
  78430. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  78431. */
  78432. export class ShadowsOptimization extends SceneOptimization {
  78433. /**
  78434. * Gets a string describing the action executed by the current optimization
  78435. * @return description string
  78436. */
  78437. getDescription(): string;
  78438. /**
  78439. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  78440. * @param scene defines the current scene where to apply this optimization
  78441. * @param optimizer defines the current optimizer
  78442. * @returns true if everything that can be done was applied
  78443. */
  78444. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  78445. }
  78446. /**
  78447. * Defines an optimization used to turn post-processes off
  78448. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  78449. */
  78450. export class PostProcessesOptimization extends SceneOptimization {
  78451. /**
  78452. * Gets a string describing the action executed by the current optimization
  78453. * @return description string
  78454. */
  78455. getDescription(): string;
  78456. /**
  78457. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  78458. * @param scene defines the current scene where to apply this optimization
  78459. * @param optimizer defines the current optimizer
  78460. * @returns true if everything that can be done was applied
  78461. */
  78462. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  78463. }
  78464. /**
  78465. * Defines an optimization used to turn lens flares off
  78466. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  78467. */
  78468. export class LensFlaresOptimization extends SceneOptimization {
  78469. /**
  78470. * Gets a string describing the action executed by the current optimization
  78471. * @return description string
  78472. */
  78473. getDescription(): string;
  78474. /**
  78475. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  78476. * @param scene defines the current scene where to apply this optimization
  78477. * @param optimizer defines the current optimizer
  78478. * @returns true if everything that can be done was applied
  78479. */
  78480. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  78481. }
  78482. /**
  78483. * Defines an optimization based on user defined callback.
  78484. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  78485. */
  78486. export class CustomOptimization extends SceneOptimization {
  78487. /**
  78488. * Callback called to apply the custom optimization.
  78489. */
  78490. onApply: (scene: Scene, optimizer: SceneOptimizer) => boolean;
  78491. /**
  78492. * Callback called to get custom description
  78493. */
  78494. onGetDescription: () => string;
  78495. /**
  78496. * Gets a string describing the action executed by the current optimization
  78497. * @returns description string
  78498. */
  78499. getDescription(): string;
  78500. /**
  78501. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  78502. * @param scene defines the current scene where to apply this optimization
  78503. * @param optimizer defines the current optimizer
  78504. * @returns true if everything that can be done was applied
  78505. */
  78506. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  78507. }
  78508. /**
  78509. * Defines an optimization used to turn particles off
  78510. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  78511. */
  78512. export class ParticlesOptimization extends SceneOptimization {
  78513. /**
  78514. * Gets a string describing the action executed by the current optimization
  78515. * @return description string
  78516. */
  78517. getDescription(): string;
  78518. /**
  78519. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  78520. * @param scene defines the current scene where to apply this optimization
  78521. * @param optimizer defines the current optimizer
  78522. * @returns true if everything that can be done was applied
  78523. */
  78524. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  78525. }
  78526. /**
  78527. * Defines an optimization used to turn render targets off
  78528. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  78529. */
  78530. export class RenderTargetsOptimization extends SceneOptimization {
  78531. /**
  78532. * Gets a string describing the action executed by the current optimization
  78533. * @return description string
  78534. */
  78535. getDescription(): string;
  78536. /**
  78537. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  78538. * @param scene defines the current scene where to apply this optimization
  78539. * @param optimizer defines the current optimizer
  78540. * @returns true if everything that can be done was applied
  78541. */
  78542. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  78543. }
  78544. /**
  78545. * Defines an optimization used to merge meshes with compatible materials
  78546. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  78547. */
  78548. export class MergeMeshesOptimization extends SceneOptimization {
  78549. private static _UpdateSelectionTree;
  78550. /**
  78551. * Gets or sets a boolean which defines if optimization octree has to be updated
  78552. */
  78553. static get UpdateSelectionTree(): boolean;
  78554. /**
  78555. * Gets or sets a boolean which defines if optimization octree has to be updated
  78556. */
  78557. static set UpdateSelectionTree(value: boolean);
  78558. /**
  78559. * Gets a string describing the action executed by the current optimization
  78560. * @return description string
  78561. */
  78562. getDescription(): string;
  78563. private _canBeMerged;
  78564. /**
  78565. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  78566. * @param scene defines the current scene where to apply this optimization
  78567. * @param optimizer defines the current optimizer
  78568. * @param updateSelectionTree defines that the selection octree has to be updated (false by default)
  78569. * @returns true if everything that can be done was applied
  78570. */
  78571. apply(scene: Scene, optimizer: SceneOptimizer, updateSelectionTree?: boolean): boolean;
  78572. }
  78573. /**
  78574. * Defines a list of options used by SceneOptimizer
  78575. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  78576. */
  78577. export class SceneOptimizerOptions {
  78578. /**
  78579. * Defines the target frame rate to reach (60 by default)
  78580. */
  78581. targetFrameRate: number;
  78582. /**
  78583. * Defines the interval between two checks (2000ms by default)
  78584. */
  78585. trackerDuration: number;
  78586. /**
  78587. * Gets the list of optimizations to apply
  78588. */
  78589. optimizations: SceneOptimization[];
  78590. /**
  78591. * Creates a new list of options used by SceneOptimizer
  78592. * @param targetFrameRate defines the target frame rate to reach (60 by default)
  78593. * @param trackerDuration defines the interval between two checks (2000ms by default)
  78594. */
  78595. constructor(
  78596. /**
  78597. * Defines the target frame rate to reach (60 by default)
  78598. */
  78599. targetFrameRate?: number,
  78600. /**
  78601. * Defines the interval between two checks (2000ms by default)
  78602. */
  78603. trackerDuration?: number);
  78604. /**
  78605. * Add a new optimization
  78606. * @param optimization defines the SceneOptimization to add to the list of active optimizations
  78607. * @returns the current SceneOptimizerOptions
  78608. */
  78609. addOptimization(optimization: SceneOptimization): SceneOptimizerOptions;
  78610. /**
  78611. * Add a new custom optimization
  78612. * @param onApply defines the callback called to apply the custom optimization (true if everything that can be done was applied)
  78613. * @param onGetDescription defines the callback called to get the description attached with the optimization.
  78614. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  78615. * @returns the current SceneOptimizerOptions
  78616. */
  78617. addCustomOptimization(onApply: (scene: Scene) => boolean, onGetDescription: () => string, priority?: number): SceneOptimizerOptions;
  78618. /**
  78619. * Creates a list of pre-defined optimizations aimed to reduce the visual impact on the scene
  78620. * @param targetFrameRate defines the target frame rate (60 by default)
  78621. * @returns a SceneOptimizerOptions object
  78622. */
  78623. static LowDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  78624. /**
  78625. * Creates a list of pre-defined optimizations aimed to have a moderate impact on the scene visual
  78626. * @param targetFrameRate defines the target frame rate (60 by default)
  78627. * @returns a SceneOptimizerOptions object
  78628. */
  78629. static ModerateDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  78630. /**
  78631. * Creates a list of pre-defined optimizations aimed to have a big impact on the scene visual
  78632. * @param targetFrameRate defines the target frame rate (60 by default)
  78633. * @returns a SceneOptimizerOptions object
  78634. */
  78635. static HighDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  78636. }
  78637. /**
  78638. * Class used to run optimizations in order to reach a target frame rate
  78639. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  78640. */
  78641. export class SceneOptimizer implements IDisposable {
  78642. private _isRunning;
  78643. private _options;
  78644. private _scene;
  78645. private _currentPriorityLevel;
  78646. private _targetFrameRate;
  78647. private _trackerDuration;
  78648. private _currentFrameRate;
  78649. private _sceneDisposeObserver;
  78650. private _improvementMode;
  78651. /**
  78652. * Defines an observable called when the optimizer reaches the target frame rate
  78653. */
  78654. onSuccessObservable: Observable<SceneOptimizer>;
  78655. /**
  78656. * Defines an observable called when the optimizer enables an optimization
  78657. */
  78658. onNewOptimizationAppliedObservable: Observable<SceneOptimization>;
  78659. /**
  78660. * Defines an observable called when the optimizer is not able to reach the target frame rate
  78661. */
  78662. onFailureObservable: Observable<SceneOptimizer>;
  78663. /**
  78664. * Gets a boolean indicating if the optimizer is in improvement mode
  78665. */
  78666. get isInImprovementMode(): boolean;
  78667. /**
  78668. * Gets the current priority level (0 at start)
  78669. */
  78670. get currentPriorityLevel(): number;
  78671. /**
  78672. * Gets the current frame rate checked by the SceneOptimizer
  78673. */
  78674. get currentFrameRate(): number;
  78675. /**
  78676. * Gets or sets the current target frame rate (60 by default)
  78677. */
  78678. get targetFrameRate(): number;
  78679. /**
  78680. * Gets or sets the current target frame rate (60 by default)
  78681. */
  78682. set targetFrameRate(value: number);
  78683. /**
  78684. * Gets or sets the current interval between two checks (every 2000ms by default)
  78685. */
  78686. get trackerDuration(): number;
  78687. /**
  78688. * Gets or sets the current interval between two checks (every 2000ms by default)
  78689. */
  78690. set trackerDuration(value: number);
  78691. /**
  78692. * Gets the list of active optimizations
  78693. */
  78694. get optimizations(): SceneOptimization[];
  78695. /**
  78696. * Creates a new SceneOptimizer
  78697. * @param scene defines the scene to work on
  78698. * @param options defines the options to use with the SceneOptimizer
  78699. * @param autoGeneratePriorities defines if priorities must be generated and not read from SceneOptimization property (true by default)
  78700. * @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)
  78701. */
  78702. constructor(scene: Scene, options?: SceneOptimizerOptions, autoGeneratePriorities?: boolean, improvementMode?: boolean);
  78703. /**
  78704. * Stops the current optimizer
  78705. */
  78706. stop(): void;
  78707. /**
  78708. * Reset the optimizer to initial step (current priority level = 0)
  78709. */
  78710. reset(): void;
  78711. /**
  78712. * Start the optimizer. By default it will try to reach a specific framerate
  78713. * but if the optimizer is set with improvementMode === true then it will run all optimization while frame rate is above the target frame rate
  78714. */
  78715. start(): void;
  78716. private _checkCurrentState;
  78717. /**
  78718. * Release all resources
  78719. */
  78720. dispose(): void;
  78721. /**
  78722. * Helper function to create a SceneOptimizer with one single line of code
  78723. * @param scene defines the scene to work on
  78724. * @param options defines the options to use with the SceneOptimizer
  78725. * @param onSuccess defines a callback to call on success
  78726. * @param onFailure defines a callback to call on failure
  78727. * @returns the new SceneOptimizer object
  78728. */
  78729. static OptimizeAsync(scene: Scene, options?: SceneOptimizerOptions, onSuccess?: () => void, onFailure?: () => void): SceneOptimizer;
  78730. }
  78731. }
  78732. declare module BABYLON {
  78733. /**
  78734. * Class used to serialize a scene into a string
  78735. */
  78736. export class SceneSerializer {
  78737. /**
  78738. * Clear cache used by a previous serialization
  78739. */
  78740. static ClearCache(): void;
  78741. /**
  78742. * Serialize a scene into a JSON compatible object
  78743. * Note that if the current engine does not support synchronous texture reading (like WebGPU), you should use SerializeAsync instead
  78744. * as else you may not retrieve the proper base64 encoded texture data (when using the Texture.ForceSerializeBuffers flag)
  78745. * @param scene defines the scene to serialize
  78746. * @returns a JSON compatible object
  78747. */
  78748. static Serialize(scene: Scene): any;
  78749. private static _Serialize;
  78750. /**
  78751. * Serialize a scene into a JSON compatible object
  78752. * @param scene defines the scene to serialize
  78753. * @returns a JSON promise compatible object
  78754. */
  78755. static SerializeAsync(scene: Scene): Promise<any>;
  78756. private static _CollectPromises;
  78757. /**
  78758. * Serialize a mesh into a JSON compatible object
  78759. * @param toSerialize defines the mesh to serialize
  78760. * @param withParents defines if parents must be serialized as well
  78761. * @param withChildren defines if children must be serialized as well
  78762. * @returns a JSON compatible object
  78763. */
  78764. static SerializeMesh(toSerialize: any, withParents?: boolean, withChildren?: boolean): any;
  78765. }
  78766. }
  78767. declare module BABYLON {
  78768. /**
  78769. * This represents the different options available for the video capture.
  78770. */
  78771. export interface VideoRecorderOptions {
  78772. /** Defines the mime type of the video. */
  78773. mimeType: string;
  78774. /** Defines the FPS the video should be recorded at. */
  78775. fps: number;
  78776. /** Defines the chunk size for the recording data. */
  78777. recordChunckSize: number;
  78778. /** The audio tracks to attach to the recording. */
  78779. audioTracks?: MediaStreamTrack[];
  78780. }
  78781. /**
  78782. * This can help with recording videos from BabylonJS.
  78783. * This is based on the available WebRTC functionalities of the browser.
  78784. *
  78785. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_video
  78786. */
  78787. export class VideoRecorder {
  78788. private static readonly _defaultOptions;
  78789. /**
  78790. * Returns whether or not the VideoRecorder is available in your browser.
  78791. * @param engine Defines the Babylon Engine.
  78792. * @returns true if supported otherwise false.
  78793. */
  78794. static IsSupported(engine: Engine): boolean;
  78795. private readonly _options;
  78796. private _canvas;
  78797. private _mediaRecorder;
  78798. private _recordedChunks;
  78799. private _fileName;
  78800. private _resolve;
  78801. private _reject;
  78802. /**
  78803. * True when a recording is already in progress.
  78804. */
  78805. get isRecording(): boolean;
  78806. /**
  78807. * Create a new VideoCapture object which can help converting what you see in Babylon to a video file.
  78808. * @param engine Defines the BabylonJS Engine you wish to record.
  78809. * @param options Defines options that can be used to customize the capture.
  78810. */
  78811. constructor(engine: Engine, options?: Nullable<VideoRecorderOptions>);
  78812. /**
  78813. * Stops the current recording before the default capture timeout passed in the startRecording function.
  78814. */
  78815. stopRecording(): void;
  78816. /**
  78817. * Starts recording the canvas for a max duration specified in parameters.
  78818. * @param fileName Defines the name of the file to be downloaded when the recording stop.
  78819. * If null no automatic download will start and you can rely on the promise to get the data back.
  78820. * @param maxDuration Defines the maximum recording time in seconds.
  78821. * It defaults to 7 seconds. A value of zero will not stop automatically, you would need to call stopRecording manually.
  78822. * @return A promise callback at the end of the recording with the video data in Blob.
  78823. */
  78824. startRecording(fileName?: Nullable<string>, maxDuration?: number): Promise<Blob>;
  78825. /**
  78826. * Releases internal resources used during the recording.
  78827. */
  78828. dispose(): void;
  78829. private _handleDataAvailable;
  78830. private _handleError;
  78831. private _handleStop;
  78832. }
  78833. }
  78834. declare module BABYLON {
  78835. /**
  78836. * Class containing a set of static utilities functions for screenshots
  78837. */
  78838. export class ScreenshotTools {
  78839. /**
  78840. * Captures a screenshot of the current rendering
  78841. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  78842. * @param engine defines the rendering engine
  78843. * @param camera defines the source camera
  78844. * @param size This parameter can be set to a single number or to an object with the
  78845. * following (optional) properties: precision, width, height. If a single number is passed,
  78846. * it will be used for both width and height. If an object is passed, the screenshot size
  78847. * will be derived from the parameters. The precision property is a multiplier allowing
  78848. * rendering at a higher or lower resolution
  78849. * @param successCallback defines the callback receives a single parameter which contains the
  78850. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  78851. * src parameter of an <img> to display it
  78852. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  78853. * Check your browser for supported MIME types
  78854. * @param forceDownload force the system to download the image even if a successCallback is provided
  78855. */
  78856. static CreateScreenshot(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string, forceDownload?: boolean): void;
  78857. /**
  78858. * Captures a screenshot of the current rendering
  78859. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  78860. * @param engine defines the rendering engine
  78861. * @param camera defines the source camera
  78862. * @param size This parameter can be set to a single number or to an object with the
  78863. * following (optional) properties: precision, width, height. If a single number is passed,
  78864. * it will be used for both width and height. If an object is passed, the screenshot size
  78865. * will be derived from the parameters. The precision property is a multiplier allowing
  78866. * rendering at a higher or lower resolution
  78867. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  78868. * Check your browser for supported MIME types
  78869. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  78870. * to the src parameter of an <img> to display it
  78871. */
  78872. static CreateScreenshotAsync(engine: Engine, camera: Camera, size: any, mimeType?: string): Promise<string>;
  78873. /**
  78874. * Captures a screenshot of the current rendering for a specific size. This will render the entire canvas but will generate a blink (due to canvas resize)
  78875. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  78876. * @param engine defines the rendering engine
  78877. * @param camera defines the source camera
  78878. * @param width defines the expected width
  78879. * @param height defines the expected height
  78880. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  78881. * Check your browser for supported MIME types
  78882. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  78883. * to the src parameter of an <img> to display it
  78884. */
  78885. static CreateScreenshotWithResizeAsync(engine: Engine, camera: Camera, width: number, height: number, mimeType?: string): Promise<void>;
  78886. /**
  78887. * Generates an image screenshot from the specified camera.
  78888. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  78889. * @param engine The engine to use for rendering
  78890. * @param camera The camera to use for rendering
  78891. * @param size This parameter can be set to a single number or to an object with the
  78892. * following (optional) properties: precision, width, height. If a single number is passed,
  78893. * it will be used for both width and height. If an object is passed, the screenshot size
  78894. * will be derived from the parameters. The precision property is a multiplier allowing
  78895. * rendering at a higher or lower resolution
  78896. * @param successCallback The callback receives a single parameter which contains the
  78897. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  78898. * src parameter of an <img> to display it
  78899. * @param mimeType The MIME type of the screenshot image (default: image/png).
  78900. * Check your browser for supported MIME types
  78901. * @param samples Texture samples (default: 1)
  78902. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  78903. * @param fileName A name for for the downloaded file.
  78904. * @param renderSprites Whether the sprites should be rendered or not (default: false)
  78905. * @param enableStencilBuffer Whether the stencil buffer should be enabled or not (default: false)
  78906. */
  78907. 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;
  78908. /**
  78909. * Generates an image screenshot from the specified camera.
  78910. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  78911. * @param engine The engine to use for rendering
  78912. * @param camera The camera to use for rendering
  78913. * @param size This parameter can be set to a single number or to an object with the
  78914. * following (optional) properties: precision, width, height. If a single number is passed,
  78915. * it will be used for both width and height. If an object is passed, the screenshot size
  78916. * will be derived from the parameters. The precision property is a multiplier allowing
  78917. * rendering at a higher or lower resolution
  78918. * @param mimeType The MIME type of the screenshot image (default: image/png).
  78919. * Check your browser for supported MIME types
  78920. * @param samples Texture samples (default: 1)
  78921. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  78922. * @param fileName A name for for the downloaded file.
  78923. * @param renderSprites Whether the sprites should be rendered or not (default: false)
  78924. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  78925. * to the src parameter of an <img> to display it
  78926. */
  78927. static CreateScreenshotUsingRenderTargetAsync(engine: Engine, camera: Camera, size: any, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string, renderSprites?: boolean): Promise<string>;
  78928. /**
  78929. * Gets height and width for screenshot size
  78930. * @private
  78931. */
  78932. private static _getScreenshotSize;
  78933. }
  78934. }
  78935. declare module BABYLON {
  78936. /**
  78937. * Interface for a data buffer
  78938. */
  78939. export interface IDataBuffer {
  78940. /**
  78941. * Reads bytes from the data buffer.
  78942. * @param byteOffset The byte offset to read
  78943. * @param byteLength The byte length to read
  78944. * @returns A promise that resolves when the bytes are read
  78945. */
  78946. readAsync(byteOffset: number, byteLength: number): Promise<ArrayBufferView>;
  78947. /**
  78948. * The byte length of the buffer.
  78949. */
  78950. readonly byteLength: number;
  78951. }
  78952. /**
  78953. * Utility class for reading from a data buffer
  78954. */
  78955. export class DataReader {
  78956. /**
  78957. * The data buffer associated with this data reader.
  78958. */
  78959. readonly buffer: IDataBuffer;
  78960. /**
  78961. * The current byte offset from the beginning of the data buffer.
  78962. */
  78963. byteOffset: number;
  78964. private _dataView;
  78965. private _dataByteOffset;
  78966. /**
  78967. * Constructor
  78968. * @param buffer The buffer to read
  78969. */
  78970. constructor(buffer: IDataBuffer);
  78971. /**
  78972. * Loads the given byte length.
  78973. * @param byteLength The byte length to load
  78974. * @returns A promise that resolves when the load is complete
  78975. */
  78976. loadAsync(byteLength: number): Promise<void>;
  78977. /**
  78978. * Read a unsigned 32-bit integer from the currently loaded data range.
  78979. * @returns The 32-bit integer read
  78980. */
  78981. readUint32(): number;
  78982. /**
  78983. * Read a byte array from the currently loaded data range.
  78984. * @param byteLength The byte length to read
  78985. * @returns The byte array read
  78986. */
  78987. readUint8Array(byteLength: number): Uint8Array;
  78988. /**
  78989. * Read a string from the currently loaded data range.
  78990. * @param byteLength The byte length to read
  78991. * @returns The string read
  78992. */
  78993. readString(byteLength: number): string;
  78994. /**
  78995. * Skips the given byte length the currently loaded data range.
  78996. * @param byteLength The byte length to skip
  78997. */
  78998. skipBytes(byteLength: number): void;
  78999. }
  79000. }
  79001. declare module BABYLON {
  79002. /**
  79003. * Class for storing data to local storage if available or in-memory storage otherwise
  79004. */
  79005. export class DataStorage {
  79006. private static _Storage;
  79007. private static _GetStorage;
  79008. /**
  79009. * Reads a string from the data storage
  79010. * @param key The key to read
  79011. * @param defaultValue The value if the key doesn't exist
  79012. * @returns The string value
  79013. */
  79014. static ReadString(key: string, defaultValue: string): string;
  79015. /**
  79016. * Writes a string to the data storage
  79017. * @param key The key to write
  79018. * @param value The value to write
  79019. */
  79020. static WriteString(key: string, value: string): void;
  79021. /**
  79022. * Reads a boolean from the data storage
  79023. * @param key The key to read
  79024. * @param defaultValue The value if the key doesn't exist
  79025. * @returns The boolean value
  79026. */
  79027. static ReadBoolean(key: string, defaultValue: boolean): boolean;
  79028. /**
  79029. * Writes a boolean to the data storage
  79030. * @param key The key to write
  79031. * @param value The value to write
  79032. */
  79033. static WriteBoolean(key: string, value: boolean): void;
  79034. /**
  79035. * Reads a number from the data storage
  79036. * @param key The key to read
  79037. * @param defaultValue The value if the key doesn't exist
  79038. * @returns The number value
  79039. */
  79040. static ReadNumber(key: string, defaultValue: number): number;
  79041. /**
  79042. * Writes a number to the data storage
  79043. * @param key The key to write
  79044. * @param value The value to write
  79045. */
  79046. static WriteNumber(key: string, value: number): void;
  79047. }
  79048. }
  79049. declare module BABYLON {
  79050. /**
  79051. * Class used to record delta files between 2 scene states
  79052. */
  79053. export class SceneRecorder {
  79054. private _trackedScene;
  79055. private _savedJSON;
  79056. /**
  79057. * Track a given scene. This means the current scene state will be considered the original state
  79058. * @param scene defines the scene to track
  79059. */
  79060. track(scene: Scene): void;
  79061. /**
  79062. * Get the delta between current state and original state
  79063. * @returns a any containing the delta
  79064. */
  79065. getDelta(): any;
  79066. private _compareArray;
  79067. private _compareObjects;
  79068. private _compareCollections;
  79069. private static GetShadowGeneratorById;
  79070. /**
  79071. * Apply a given delta to a given scene
  79072. * @param deltaJSON defines the JSON containing the delta
  79073. * @param scene defines the scene to apply the delta to
  79074. */
  79075. static ApplyDelta(deltaJSON: any | string, scene: Scene): void;
  79076. private static _ApplyPropertiesToEntity;
  79077. private static _ApplyDeltaForEntity;
  79078. }
  79079. }
  79080. declare module BABYLON {
  79081. /**
  79082. * A 3D trajectory consisting of an order list of vectors describing a
  79083. * path of motion through 3D space.
  79084. */
  79085. export class Trajectory {
  79086. private _points;
  79087. private readonly _segmentLength;
  79088. /**
  79089. * Serialize to JSON.
  79090. * @returns serialized JSON string
  79091. */
  79092. serialize(): string;
  79093. /**
  79094. * Deserialize from JSON.
  79095. * @param json serialized JSON string
  79096. * @returns deserialized Trajectory
  79097. */
  79098. static Deserialize(json: string): Trajectory;
  79099. /**
  79100. * Create a new empty Trajectory.
  79101. * @param segmentLength radius of discretization for Trajectory points
  79102. */
  79103. constructor(segmentLength?: number);
  79104. /**
  79105. * Get the length of the Trajectory.
  79106. * @returns length of the Trajectory
  79107. */
  79108. getLength(): number;
  79109. /**
  79110. * Append a new point to the Trajectory.
  79111. * NOTE: This implementation has many allocations.
  79112. * @param point point to append to the Trajectory
  79113. */
  79114. add(point: DeepImmutable<Vector3>): void;
  79115. /**
  79116. * Create a new Trajectory with a segment length chosen to make it
  79117. * probable that the new Trajectory will have a specified number of
  79118. * segments. This operation is imprecise.
  79119. * @param targetResolution number of segments desired
  79120. * @returns new Trajectory with approximately the requested number of segments
  79121. */
  79122. resampleAtTargetResolution(targetResolution: number): Trajectory;
  79123. /**
  79124. * Convert Trajectory segments into tokenized representation. This
  79125. * representation is an array of numbers where each nth number is the
  79126. * index of the token which is most similar to the nth segment of the
  79127. * Trajectory.
  79128. * @param tokens list of vectors which serve as discrete tokens
  79129. * @returns list of indices of most similar token per segment
  79130. */
  79131. tokenize(tokens: DeepImmutable<Vector3[]>): number[];
  79132. private static _forwardDir;
  79133. private static _inverseFromVec;
  79134. private static _upDir;
  79135. private static _fromToVec;
  79136. private static _lookMatrix;
  79137. /**
  79138. * Transform the rotation (i.e., direction) of a segment to isolate
  79139. * the relative transformation represented by the segment. This operation
  79140. * may or may not succeed due to singularities in the equations that define
  79141. * motion relativity in this context.
  79142. * @param priorVec the origin of the prior segment
  79143. * @param fromVec the origin of the current segment
  79144. * @param toVec the destination of the current segment
  79145. * @param result reference to output variable
  79146. * @returns whether or not transformation was successful
  79147. */
  79148. private static _transformSegmentDirToRef;
  79149. private static _bestMatch;
  79150. private static _score;
  79151. private static _bestScore;
  79152. /**
  79153. * Determine which token vector is most similar to the
  79154. * segment vector.
  79155. * @param segment segment vector
  79156. * @param tokens token vector list
  79157. * @returns index of the most similar token to the segment
  79158. */
  79159. private static _tokenizeSegment;
  79160. }
  79161. /**
  79162. * Class representing a set of known, named trajectories to which Trajectories can be
  79163. * added and using which Trajectories can be recognized.
  79164. */
  79165. export class TrajectoryClassifier {
  79166. private _maximumAllowableMatchCost;
  79167. private _vector3Alphabet;
  79168. private _levenshteinAlphabet;
  79169. private _nameToDescribedTrajectory;
  79170. /**
  79171. * Serialize to JSON.
  79172. * @returns JSON serialization
  79173. */
  79174. serialize(): string;
  79175. /**
  79176. * Deserialize from JSON.
  79177. * @param json JSON serialization
  79178. * @returns deserialized TrajectorySet
  79179. */
  79180. static Deserialize(json: string): TrajectoryClassifier;
  79181. /**
  79182. * Initialize a new empty TrajectorySet with auto-generated Alphabets.
  79183. * VERY naive, need to be generating these things from known
  79184. * sets. Better version later, probably eliminating this one.
  79185. * @returns auto-generated TrajectorySet
  79186. */
  79187. static Generate(): TrajectoryClassifier;
  79188. private constructor();
  79189. /**
  79190. * Add a new Trajectory to the set with a given name.
  79191. * @param trajectory new Trajectory to be added
  79192. * @param classification name to which to add the Trajectory
  79193. */
  79194. addTrajectoryToClassification(trajectory: Trajectory, classification: string): void;
  79195. /**
  79196. * Remove a known named trajectory and all Trajectories associated with it.
  79197. * @param classification name to remove
  79198. * @returns whether anything was removed
  79199. */
  79200. deleteClassification(classification: string): boolean;
  79201. /**
  79202. * Attempt to recognize a Trajectory from among all the classifications
  79203. * already known to the classifier.
  79204. * @param trajectory Trajectory to be recognized
  79205. * @returns classification of Trajectory if recognized, null otherwise
  79206. */
  79207. classifyTrajectory(trajectory: Trajectory): Nullable<string>;
  79208. }
  79209. }
  79210. declare module BABYLON {
  79211. /**
  79212. * An interface for all Hit test features
  79213. */
  79214. export interface IWebXRHitTestFeature<T extends IWebXRLegacyHitResult> extends IWebXRFeature {
  79215. /**
  79216. * Triggered when new babylon (transformed) hit test results are available
  79217. */
  79218. onHitTestResultObservable: Observable<T[]>;
  79219. }
  79220. /**
  79221. * Options used for hit testing
  79222. */
  79223. export interface IWebXRLegacyHitTestOptions {
  79224. /**
  79225. * Only test when user interacted with the scene. Default - hit test every frame
  79226. */
  79227. testOnPointerDownOnly?: boolean;
  79228. /**
  79229. * The node to use to transform the local results to world coordinates
  79230. */
  79231. worldParentNode?: TransformNode;
  79232. }
  79233. /**
  79234. * Interface defining the babylon result of raycasting/hit-test
  79235. */
  79236. export interface IWebXRLegacyHitResult {
  79237. /**
  79238. * Transformation matrix that can be applied to a node that will put it in the hit point location
  79239. */
  79240. transformationMatrix: Matrix;
  79241. /**
  79242. * The native hit test result
  79243. */
  79244. xrHitResult: XRHitResult | XRHitTestResult;
  79245. }
  79246. /**
  79247. * The currently-working hit-test module.
  79248. * Hit test (or Ray-casting) is used to interact with the real world.
  79249. * For further information read here - https://github.com/immersive-web/hit-test
  79250. */
  79251. export class WebXRHitTestLegacy extends WebXRAbstractFeature implements IWebXRHitTestFeature<IWebXRLegacyHitResult> {
  79252. /**
  79253. * options to use when constructing this feature
  79254. */
  79255. readonly options: IWebXRLegacyHitTestOptions;
  79256. private _direction;
  79257. private _mat;
  79258. private _onSelectEnabled;
  79259. private _origin;
  79260. /**
  79261. * The module's name
  79262. */
  79263. static readonly Name: string;
  79264. /**
  79265. * The (Babylon) version of this module.
  79266. * This is an integer representing the implementation version.
  79267. * This number does not correspond to the WebXR specs version
  79268. */
  79269. static readonly Version: number;
  79270. /**
  79271. * Populated with the last native XR Hit Results
  79272. */
  79273. lastNativeXRHitResults: XRHitResult[];
  79274. /**
  79275. * Triggered when new babylon (transformed) hit test results are available
  79276. */
  79277. onHitTestResultObservable: Observable<IWebXRLegacyHitResult[]>;
  79278. /**
  79279. * Creates a new instance of the (legacy version) hit test feature
  79280. * @param _xrSessionManager an instance of WebXRSessionManager
  79281. * @param options options to use when constructing this feature
  79282. */
  79283. constructor(_xrSessionManager: WebXRSessionManager,
  79284. /**
  79285. * options to use when constructing this feature
  79286. */
  79287. options?: IWebXRLegacyHitTestOptions);
  79288. /**
  79289. * execute a hit test with an XR Ray
  79290. *
  79291. * @param xrSession a native xrSession that will execute this hit test
  79292. * @param xrRay the ray (position and direction) to use for ray-casting
  79293. * @param referenceSpace native XR reference space to use for the hit-test
  79294. * @param filter filter function that will filter the results
  79295. * @returns a promise that resolves with an array of native XR hit result in xr coordinates system
  79296. */
  79297. static XRHitTestWithRay(xrSession: XRSession, xrRay: XRRay, referenceSpace: XRReferenceSpace, filter?: (result: XRHitResult) => boolean): Promise<XRHitResult[]>;
  79298. /**
  79299. * Execute a hit test on the current running session using a select event returned from a transient input (such as touch)
  79300. * @param event the (select) event to use to select with
  79301. * @param referenceSpace the reference space to use for this hit test
  79302. * @returns a promise that resolves with an array of native XR hit result in xr coordinates system
  79303. */
  79304. static XRHitTestWithSelectEvent(event: XRInputSourceEvent, referenceSpace: XRReferenceSpace): Promise<XRHitResult[]>;
  79305. /**
  79306. * attach this feature
  79307. * Will usually be called by the features manager
  79308. *
  79309. * @returns true if successful.
  79310. */
  79311. attach(): boolean;
  79312. /**
  79313. * detach this feature.
  79314. * Will usually be called by the features manager
  79315. *
  79316. * @returns true if successful.
  79317. */
  79318. detach(): boolean;
  79319. /**
  79320. * Dispose this feature and all of the resources attached
  79321. */
  79322. dispose(): void;
  79323. protected _onXRFrame(frame: XRFrame): void;
  79324. private _onHitTestResults;
  79325. private _onSelect;
  79326. }
  79327. }
  79328. declare module BABYLON {
  79329. /**
  79330. * Options used for hit testing (version 2)
  79331. */
  79332. export interface IWebXRHitTestOptions extends IWebXRLegacyHitTestOptions {
  79333. /**
  79334. * Do not create a permanent hit test. Will usually be used when only
  79335. * transient inputs are needed.
  79336. */
  79337. disablePermanentHitTest?: boolean;
  79338. /**
  79339. * Enable transient (for example touch-based) hit test inspections
  79340. */
  79341. enableTransientHitTest?: boolean;
  79342. /**
  79343. * Offset ray for the permanent hit test
  79344. */
  79345. offsetRay?: Vector3;
  79346. /**
  79347. * Offset ray for the transient hit test
  79348. */
  79349. transientOffsetRay?: Vector3;
  79350. /**
  79351. * Instead of using viewer space for hit tests, use the reference space defined in the session manager
  79352. */
  79353. useReferenceSpace?: boolean;
  79354. /**
  79355. * Override the default entity type(s) of the hit-test result
  79356. */
  79357. entityTypes?: XRHitTestTrackableType[];
  79358. }
  79359. /**
  79360. * Interface defining the babylon result of hit-test
  79361. */
  79362. export interface IWebXRHitResult extends IWebXRLegacyHitResult {
  79363. /**
  79364. * The input source that generated this hit test (if transient)
  79365. */
  79366. inputSource?: XRInputSource;
  79367. /**
  79368. * Is this a transient hit test
  79369. */
  79370. isTransient?: boolean;
  79371. /**
  79372. * Position of the hit test result
  79373. */
  79374. position: Vector3;
  79375. /**
  79376. * Rotation of the hit test result
  79377. */
  79378. rotationQuaternion: Quaternion;
  79379. /**
  79380. * The native hit test result
  79381. */
  79382. xrHitResult: XRHitTestResult;
  79383. }
  79384. /**
  79385. * The currently-working hit-test module.
  79386. * Hit test (or Ray-casting) is used to interact with the real world.
  79387. * For further information read here - https://github.com/immersive-web/hit-test
  79388. *
  79389. * Tested on chrome (mobile) 80.
  79390. */
  79391. export class WebXRHitTest extends WebXRAbstractFeature implements IWebXRHitTestFeature<IWebXRHitResult> {
  79392. /**
  79393. * options to use when constructing this feature
  79394. */
  79395. readonly options: IWebXRHitTestOptions;
  79396. private _tmpMat;
  79397. private _tmpPos;
  79398. private _tmpQuat;
  79399. private _transientXrHitTestSource;
  79400. private _xrHitTestSource;
  79401. private initHitTestSource;
  79402. /**
  79403. * The module's name
  79404. */
  79405. static readonly Name: string;
  79406. /**
  79407. * The (Babylon) version of this module.
  79408. * This is an integer representing the implementation version.
  79409. * This number does not correspond to the WebXR specs version
  79410. */
  79411. static readonly Version: number;
  79412. /**
  79413. * When set to true, each hit test will have its own position/rotation objects
  79414. * When set to false, position and rotation objects will be reused for each hit test. It is expected that
  79415. * the developers will clone them or copy them as they see fit.
  79416. */
  79417. autoCloneTransformation: boolean;
  79418. /**
  79419. * Triggered when new babylon (transformed) hit test results are available
  79420. * Note - this will be called when results come back from the device. It can be an empty array!!
  79421. */
  79422. onHitTestResultObservable: Observable<IWebXRHitResult[]>;
  79423. /**
  79424. * Use this to temporarily pause hit test checks.
  79425. */
  79426. paused: boolean;
  79427. /**
  79428. * Creates a new instance of the hit test feature
  79429. * @param _xrSessionManager an instance of WebXRSessionManager
  79430. * @param options options to use when constructing this feature
  79431. */
  79432. constructor(_xrSessionManager: WebXRSessionManager,
  79433. /**
  79434. * options to use when constructing this feature
  79435. */
  79436. options?: IWebXRHitTestOptions);
  79437. /**
  79438. * attach this feature
  79439. * Will usually be called by the features manager
  79440. *
  79441. * @returns true if successful.
  79442. */
  79443. attach(): boolean;
  79444. /**
  79445. * detach this feature.
  79446. * Will usually be called by the features manager
  79447. *
  79448. * @returns true if successful.
  79449. */
  79450. detach(): boolean;
  79451. /**
  79452. * Dispose this feature and all of the resources attached
  79453. */
  79454. dispose(): void;
  79455. protected _onXRFrame(frame: XRFrame): void;
  79456. private _processWebXRHitTestResult;
  79457. }
  79458. }
  79459. declare module BABYLON {
  79460. /**
  79461. * Configuration options of the anchor system
  79462. */
  79463. export interface IWebXRAnchorSystemOptions {
  79464. /**
  79465. * a node that will be used to convert local to world coordinates
  79466. */
  79467. worldParentNode?: TransformNode;
  79468. /**
  79469. * If set to true a reference of the created anchors will be kept until the next session starts
  79470. * If not defined, anchors will be removed from the array when the feature is detached or the session ended.
  79471. */
  79472. doNotRemoveAnchorsOnSessionEnded?: boolean;
  79473. }
  79474. /**
  79475. * A babylon container for an XR Anchor
  79476. */
  79477. export interface IWebXRAnchor {
  79478. /**
  79479. * A babylon-assigned ID for this anchor
  79480. */
  79481. id: number;
  79482. /**
  79483. * Transformation matrix to apply to an object attached to this anchor
  79484. */
  79485. transformationMatrix: Matrix;
  79486. /**
  79487. * The native anchor object
  79488. */
  79489. xrAnchor: XRAnchor;
  79490. /**
  79491. * if defined, this object will be constantly updated by the anchor's position and rotation
  79492. */
  79493. attachedNode?: TransformNode;
  79494. /**
  79495. * Remove this anchor from the scene
  79496. */
  79497. remove(): void;
  79498. }
  79499. /**
  79500. * An implementation of the anchor system for WebXR.
  79501. * For further information see https://github.com/immersive-web/anchors/
  79502. */
  79503. export class WebXRAnchorSystem extends WebXRAbstractFeature {
  79504. private _options;
  79505. private _lastFrameDetected;
  79506. private _trackedAnchors;
  79507. private _referenceSpaceForFrameAnchors;
  79508. private _futureAnchors;
  79509. /**
  79510. * The module's name
  79511. */
  79512. static readonly Name: string;
  79513. /**
  79514. * The (Babylon) version of this module.
  79515. * This is an integer representing the implementation version.
  79516. * This number does not correspond to the WebXR specs version
  79517. */
  79518. static readonly Version: number;
  79519. /**
  79520. * Observers registered here will be executed when a new anchor was added to the session
  79521. */
  79522. onAnchorAddedObservable: Observable<IWebXRAnchor>;
  79523. /**
  79524. * Observers registered here will be executed when an anchor was removed from the session
  79525. */
  79526. onAnchorRemovedObservable: Observable<IWebXRAnchor>;
  79527. /**
  79528. * Observers registered here will be executed when an existing anchor updates
  79529. * This can execute N times every frame
  79530. */
  79531. onAnchorUpdatedObservable: Observable<IWebXRAnchor>;
  79532. /**
  79533. * Set the reference space to use for anchor creation, when not using a hit test.
  79534. * Will default to the session's reference space if not defined
  79535. */
  79536. set referenceSpaceForFrameAnchors(referenceSpace: XRReferenceSpace);
  79537. /**
  79538. * constructs a new anchor system
  79539. * @param _xrSessionManager an instance of WebXRSessionManager
  79540. * @param _options configuration object for this feature
  79541. */
  79542. constructor(_xrSessionManager: WebXRSessionManager, _options?: IWebXRAnchorSystemOptions);
  79543. private _tmpVector;
  79544. private _tmpQuaternion;
  79545. private _populateTmpTransformation;
  79546. /**
  79547. * Create a new anchor point using a hit test result at a specific point in the scene
  79548. * An anchor is tracked only after it is added to the trackerAnchors in xrFrame. The promise returned here does not yet guaranty that.
  79549. * Use onAnchorAddedObservable to get newly added anchors if you require tracking guaranty.
  79550. *
  79551. * @param hitTestResult The hit test result to use for this anchor creation
  79552. * @param position an optional position offset for this anchor
  79553. * @param rotationQuaternion an optional rotation offset for this anchor
  79554. * @returns A promise that fulfills when babylon has created the corresponding WebXRAnchor object and tracking has begun
  79555. */
  79556. addAnchorPointUsingHitTestResultAsync(hitTestResult: IWebXRHitResult, position?: Vector3, rotationQuaternion?: Quaternion): Promise<IWebXRAnchor>;
  79557. /**
  79558. * Add a new anchor at a specific position and rotation
  79559. * This function will add a new anchor per default in the next available frame. Unless forced, the createAnchor function
  79560. * will be called in the next xrFrame loop to make sure that the anchor can be created correctly.
  79561. * An anchor is tracked only after it is added to the trackerAnchors in xrFrame. The promise returned here does not yet guaranty that.
  79562. * Use onAnchorAddedObservable to get newly added anchors if you require tracking guaranty.
  79563. *
  79564. * @param position the position in which to add an anchor
  79565. * @param rotationQuaternion an optional rotation for the anchor transformation
  79566. * @param forceCreateInCurrentFrame force the creation of this anchor in the current frame. Must be called inside xrFrame loop!
  79567. * @returns A promise that fulfills when babylon has created the corresponding WebXRAnchor object and tracking has begun
  79568. */
  79569. addAnchorAtPositionAndRotationAsync(position: Vector3, rotationQuaternion?: Quaternion, forceCreateInCurrentFrame?: boolean): Promise<IWebXRAnchor>;
  79570. /**
  79571. * Get the list of anchors currently being tracked by the system
  79572. */
  79573. get anchors(): IWebXRAnchor[];
  79574. /**
  79575. * detach this feature.
  79576. * Will usually be called by the features manager
  79577. *
  79578. * @returns true if successful.
  79579. */
  79580. detach(): boolean;
  79581. /**
  79582. * Dispose this feature and all of the resources attached
  79583. */
  79584. dispose(): void;
  79585. protected _onXRFrame(frame: XRFrame): void;
  79586. /**
  79587. * avoiding using Array.find for global support.
  79588. * @param xrAnchor the plane to find in the array
  79589. */
  79590. private _findIndexInAnchorArray;
  79591. private _updateAnchorWithXRFrame;
  79592. private _createAnchorAtTransformation;
  79593. }
  79594. }
  79595. declare module BABYLON {
  79596. /**
  79597. * Options used in the plane detector module
  79598. */
  79599. export interface IWebXRPlaneDetectorOptions {
  79600. /**
  79601. * The node to use to transform the local results to world coordinates
  79602. */
  79603. worldParentNode?: TransformNode;
  79604. /**
  79605. * If set to true a reference of the created planes will be kept until the next session starts
  79606. * If not defined, planes will be removed from the array when the feature is detached or the session ended.
  79607. */
  79608. doNotRemovePlanesOnSessionEnded?: boolean;
  79609. /**
  79610. * Preferred detector configuration, not all preferred options will be supported by all platforms.
  79611. */
  79612. preferredDetectorOptions?: XRGeometryDetectorOptions;
  79613. }
  79614. /**
  79615. * A babylon interface for a WebXR plane.
  79616. * A Plane is actually a polygon, built from N points in space
  79617. *
  79618. * Supported in chrome 79, not supported in canary 81 ATM
  79619. */
  79620. export interface IWebXRPlane {
  79621. /**
  79622. * a babylon-assigned ID for this polygon
  79623. */
  79624. id: number;
  79625. /**
  79626. * an array of vector3 points in babylon space. right/left hand system is taken into account.
  79627. */
  79628. polygonDefinition: Array<Vector3>;
  79629. /**
  79630. * A transformation matrix to apply on the mesh that will be built using the polygonDefinition
  79631. * Local vs. World are decided if worldParentNode was provided or not in the options when constructing the module
  79632. */
  79633. transformationMatrix: Matrix;
  79634. /**
  79635. * the native xr-plane object
  79636. */
  79637. xrPlane: XRPlane;
  79638. }
  79639. /**
  79640. * The plane detector is used to detect planes in the real world when in AR
  79641. * For more information see https://github.com/immersive-web/real-world-geometry/
  79642. */
  79643. export class WebXRPlaneDetector extends WebXRAbstractFeature {
  79644. private _options;
  79645. private _detectedPlanes;
  79646. private _enabled;
  79647. private _lastFrameDetected;
  79648. /**
  79649. * The module's name
  79650. */
  79651. static readonly Name: string;
  79652. /**
  79653. * The (Babylon) version of this module.
  79654. * This is an integer representing the implementation version.
  79655. * This number does not correspond to the WebXR specs version
  79656. */
  79657. static readonly Version: number;
  79658. /**
  79659. * Observers registered here will be executed when a new plane was added to the session
  79660. */
  79661. onPlaneAddedObservable: Observable<IWebXRPlane>;
  79662. /**
  79663. * Observers registered here will be executed when a plane is no longer detected in the session
  79664. */
  79665. onPlaneRemovedObservable: Observable<IWebXRPlane>;
  79666. /**
  79667. * Observers registered here will be executed when an existing plane updates (for example - expanded)
  79668. * This can execute N times every frame
  79669. */
  79670. onPlaneUpdatedObservable: Observable<IWebXRPlane>;
  79671. /**
  79672. * construct a new Plane Detector
  79673. * @param _xrSessionManager an instance of xr Session manager
  79674. * @param _options configuration to use when constructing this feature
  79675. */
  79676. constructor(_xrSessionManager: WebXRSessionManager, _options?: IWebXRPlaneDetectorOptions);
  79677. /**
  79678. * detach this feature.
  79679. * Will usually be called by the features manager
  79680. *
  79681. * @returns true if successful.
  79682. */
  79683. detach(): boolean;
  79684. /**
  79685. * Dispose this feature and all of the resources attached
  79686. */
  79687. dispose(): void;
  79688. /**
  79689. * Check if the needed objects are defined.
  79690. * This does not mean that the feature is enabled, but that the objects needed are well defined.
  79691. */
  79692. isCompatible(): boolean;
  79693. protected _onXRFrame(frame: XRFrame): void;
  79694. private _init;
  79695. private _updatePlaneWithXRPlane;
  79696. /**
  79697. * avoiding using Array.find for global support.
  79698. * @param xrPlane the plane to find in the array
  79699. */
  79700. private _findIndexInPlaneArray;
  79701. }
  79702. }
  79703. declare module BABYLON {
  79704. /**
  79705. * Options interface for the background remover plugin
  79706. */
  79707. export interface IWebXRBackgroundRemoverOptions {
  79708. /**
  79709. * Further background meshes to disable when entering AR
  79710. */
  79711. backgroundMeshes?: AbstractMesh[];
  79712. /**
  79713. * flags to configure the removal of the environment helper.
  79714. * If not set, the entire background will be removed. If set, flags should be set as well.
  79715. */
  79716. environmentHelperRemovalFlags?: {
  79717. /**
  79718. * Should the skybox be removed (default false)
  79719. */
  79720. skyBox?: boolean;
  79721. /**
  79722. * Should the ground be removed (default false)
  79723. */
  79724. ground?: boolean;
  79725. };
  79726. /**
  79727. * don't disable the environment helper
  79728. */
  79729. ignoreEnvironmentHelper?: boolean;
  79730. }
  79731. /**
  79732. * A module that will automatically disable background meshes when entering AR and will enable them when leaving AR.
  79733. */
  79734. export class WebXRBackgroundRemover extends WebXRAbstractFeature {
  79735. /**
  79736. * read-only options to be used in this module
  79737. */
  79738. readonly options: IWebXRBackgroundRemoverOptions;
  79739. /**
  79740. * The module's name
  79741. */
  79742. static readonly Name: string;
  79743. /**
  79744. * The (Babylon) version of this module.
  79745. * This is an integer representing the implementation version.
  79746. * This number does not correspond to the WebXR specs version
  79747. */
  79748. static readonly Version: number;
  79749. /**
  79750. * registered observers will be triggered when the background state changes
  79751. */
  79752. onBackgroundStateChangedObservable: Observable<boolean>;
  79753. /**
  79754. * constructs a new background remover module
  79755. * @param _xrSessionManager the session manager for this module
  79756. * @param options read-only options to be used in this module
  79757. */
  79758. constructor(_xrSessionManager: WebXRSessionManager,
  79759. /**
  79760. * read-only options to be used in this module
  79761. */
  79762. options?: IWebXRBackgroundRemoverOptions);
  79763. /**
  79764. * attach this feature
  79765. * Will usually be called by the features manager
  79766. *
  79767. * @returns true if successful.
  79768. */
  79769. attach(): boolean;
  79770. /**
  79771. * detach this feature.
  79772. * Will usually be called by the features manager
  79773. *
  79774. * @returns true if successful.
  79775. */
  79776. detach(): boolean;
  79777. /**
  79778. * Dispose this feature and all of the resources attached
  79779. */
  79780. dispose(): void;
  79781. protected _onXRFrame(_xrFrame: XRFrame): void;
  79782. private _setBackgroundState;
  79783. }
  79784. }
  79785. declare module BABYLON {
  79786. /**
  79787. * Options for the controller physics feature
  79788. */
  79789. export class IWebXRControllerPhysicsOptions {
  79790. /**
  79791. * Should the headset get its own impostor
  79792. */
  79793. enableHeadsetImpostor?: boolean;
  79794. /**
  79795. * Optional parameters for the headset impostor
  79796. */
  79797. headsetImpostorParams?: {
  79798. /**
  79799. * The type of impostor to create. Default is sphere
  79800. */
  79801. impostorType: number;
  79802. /**
  79803. * the size of the impostor. Defaults to 10cm
  79804. */
  79805. impostorSize?: number | {
  79806. width: number;
  79807. height: number;
  79808. depth: number;
  79809. };
  79810. /**
  79811. * Friction definitions
  79812. */
  79813. friction?: number;
  79814. /**
  79815. * Restitution
  79816. */
  79817. restitution?: number;
  79818. };
  79819. /**
  79820. * The physics properties of the future impostors
  79821. */
  79822. physicsProperties?: {
  79823. /**
  79824. * If set to true, a mesh impostor will be created when the controller mesh was loaded
  79825. * Note that this requires a physics engine that supports mesh impostors!
  79826. */
  79827. useControllerMesh?: boolean;
  79828. /**
  79829. * The type of impostor to create. Default is sphere
  79830. */
  79831. impostorType?: number;
  79832. /**
  79833. * the size of the impostor. Defaults to 10cm
  79834. */
  79835. impostorSize?: number | {
  79836. width: number;
  79837. height: number;
  79838. depth: number;
  79839. };
  79840. /**
  79841. * Friction definitions
  79842. */
  79843. friction?: number;
  79844. /**
  79845. * Restitution
  79846. */
  79847. restitution?: number;
  79848. };
  79849. /**
  79850. * the xr input to use with this pointer selection
  79851. */
  79852. xrInput: WebXRInput;
  79853. }
  79854. /**
  79855. * Add physics impostor to your webxr controllers,
  79856. * including naive calculation of their linear and angular velocity
  79857. */
  79858. export class WebXRControllerPhysics extends WebXRAbstractFeature {
  79859. private readonly _options;
  79860. private _attachController;
  79861. private _controllers;
  79862. private _debugMode;
  79863. private _delta;
  79864. private _headsetImpostor?;
  79865. private _headsetMesh?;
  79866. private _lastTimestamp;
  79867. private _tmpQuaternion;
  79868. private _tmpVector;
  79869. /**
  79870. * The module's name
  79871. */
  79872. static readonly Name: string;
  79873. /**
  79874. * The (Babylon) version of this module.
  79875. * This is an integer representing the implementation version.
  79876. * This number does not correspond to the webxr specs version
  79877. */
  79878. static readonly Version: number;
  79879. /**
  79880. * Construct a new Controller Physics Feature
  79881. * @param _xrSessionManager the corresponding xr session manager
  79882. * @param _options options to create this feature with
  79883. */
  79884. constructor(_xrSessionManager: WebXRSessionManager, _options: IWebXRControllerPhysicsOptions);
  79885. /**
  79886. * @hidden
  79887. * enable debugging - will show console outputs and the impostor mesh
  79888. */
  79889. _enablePhysicsDebug(): void;
  79890. /**
  79891. * Manually add a controller (if no xrInput was provided or physics engine was not enabled)
  79892. * @param xrController the controller to add
  79893. */
  79894. addController(xrController: WebXRInputSource): void;
  79895. /**
  79896. * attach this feature
  79897. * Will usually be called by the features manager
  79898. *
  79899. * @returns true if successful.
  79900. */
  79901. attach(): boolean;
  79902. /**
  79903. * detach this feature.
  79904. * Will usually be called by the features manager
  79905. *
  79906. * @returns true if successful.
  79907. */
  79908. detach(): boolean;
  79909. /**
  79910. * Get the headset impostor, if enabled
  79911. * @returns the impostor
  79912. */
  79913. getHeadsetImpostor(): PhysicsImpostor | undefined;
  79914. /**
  79915. * Get the physics impostor of a specific controller.
  79916. * The impostor is not attached to a mesh because a mesh for each controller is not obligatory
  79917. * @param controller the controller or the controller id of which to get the impostor
  79918. * @returns the impostor or null
  79919. */
  79920. getImpostorForController(controller: WebXRInputSource | string): Nullable<PhysicsImpostor>;
  79921. /**
  79922. * Update the physics properties provided in the constructor
  79923. * @param newProperties the new properties object
  79924. */
  79925. setPhysicsProperties(newProperties: {
  79926. impostorType?: number;
  79927. impostorSize?: number | {
  79928. width: number;
  79929. height: number;
  79930. depth: number;
  79931. };
  79932. friction?: number;
  79933. restitution?: number;
  79934. }): void;
  79935. protected _onXRFrame(_xrFrame: any): void;
  79936. private _detachController;
  79937. }
  79938. }
  79939. declare module BABYLON {
  79940. /**
  79941. * A babylon interface for a "WebXR" feature point.
  79942. * Represents the position and confidence value of a given feature point.
  79943. */
  79944. export interface IWebXRFeaturePoint {
  79945. /**
  79946. * Represents the position of the feature point in world space.
  79947. */
  79948. position: Vector3;
  79949. /**
  79950. * Represents the confidence value of the feature point in world space. 0 being least confident, and 1 being most confident.
  79951. */
  79952. confidenceValue: number;
  79953. }
  79954. /**
  79955. * The feature point system is used to detect feature points from real world geometry.
  79956. * This feature is currently experimental and only supported on BabylonNative, and should not be used in the browser.
  79957. * The newly introduced API can be seen in webxr.nativeextensions.d.ts and described in FeaturePoints.md.
  79958. */
  79959. export class WebXRFeaturePointSystem extends WebXRAbstractFeature {
  79960. private _enabled;
  79961. private _featurePointCloud;
  79962. /**
  79963. * The module's name
  79964. */
  79965. static readonly Name: string;
  79966. /**
  79967. * The (Babylon) version of this module.
  79968. * This is an integer representing the implementation version.
  79969. * This number does not correspond to the WebXR specs version
  79970. */
  79971. static readonly Version: number;
  79972. /**
  79973. * Observers registered here will be executed whenever new feature points are added (on XRFrame while the session is tracking).
  79974. * Will notify the observers about which feature points have been added.
  79975. */
  79976. readonly onFeaturePointsAddedObservable: Observable<number[]>;
  79977. /**
  79978. * Observers registered here will be executed whenever a feature point has been updated (on XRFrame while the session is tracking).
  79979. * Will notify the observers about which feature points have been updated.
  79980. */
  79981. readonly onFeaturePointsUpdatedObservable: Observable<number[]>;
  79982. /**
  79983. * The current feature point cloud maintained across frames.
  79984. */
  79985. get featurePointCloud(): Array<IWebXRFeaturePoint>;
  79986. /**
  79987. * construct the feature point system
  79988. * @param _xrSessionManager an instance of xr Session manager
  79989. */
  79990. constructor(_xrSessionManager: WebXRSessionManager);
  79991. /**
  79992. * Detach this feature.
  79993. * Will usually be called by the features manager
  79994. *
  79995. * @returns true if successful.
  79996. */
  79997. detach(): boolean;
  79998. /**
  79999. * Dispose this feature and all of the resources attached
  80000. */
  80001. dispose(): void;
  80002. /**
  80003. * On receiving a new XR frame if this feature is attached notify observers new feature point data is available.
  80004. */
  80005. protected _onXRFrame(frame: XRFrame): void;
  80006. /**
  80007. * Initializes the feature. If the feature point feature is not available for this environment do not mark the feature as enabled.
  80008. */
  80009. private _init;
  80010. }
  80011. }
  80012. declare module BABYLON {
  80013. /**
  80014. * Configuration interface for the hand tracking feature
  80015. */
  80016. export interface IWebXRHandTrackingOptions {
  80017. /**
  80018. * The xrInput that will be used as source for new hands
  80019. */
  80020. xrInput: WebXRInput;
  80021. /**
  80022. * Configuration object for the joint meshes
  80023. */
  80024. jointMeshes?: {
  80025. /**
  80026. * Should the meshes created be invisible (defaults to false)
  80027. */
  80028. invisible?: boolean;
  80029. /**
  80030. * A source mesh to be used to create instances. Defaults to a sphere.
  80031. * This mesh will be the source for all other (25) meshes.
  80032. * It should have the general size of a single unit, as the instances will be scaled according to the provided radius
  80033. */
  80034. sourceMesh?: Mesh;
  80035. /**
  80036. * This function will be called after a mesh was created for a specific joint.
  80037. * Using this function you can either manipulate the instance or return a new mesh.
  80038. * When returning a new mesh the instance created before will be disposed
  80039. */
  80040. onHandJointMeshGenerated?: (meshInstance: InstancedMesh, jointId: number, controllerId: string) => Mesh | undefined;
  80041. /**
  80042. * Should the source mesh stay visible. Defaults to false
  80043. */
  80044. keepOriginalVisible?: boolean;
  80045. /**
  80046. * Scale factor for all instances (defaults to 2)
  80047. */
  80048. scaleFactor?: number;
  80049. /**
  80050. * Should each instance have its own physics impostor
  80051. */
  80052. enablePhysics?: boolean;
  80053. /**
  80054. * If enabled, override default physics properties
  80055. */
  80056. physicsProps?: {
  80057. friction?: number;
  80058. restitution?: number;
  80059. impostorType?: number;
  80060. };
  80061. /**
  80062. * Should the default hand mesh be disabled. In this case, the spheres will be visible (unless set invisible).
  80063. */
  80064. disableDefaultHandMesh?: boolean;
  80065. /**
  80066. * a rigged hand-mesh that will be updated according to the XRHand data provided. This will override the default hand mesh
  80067. */
  80068. handMeshes?: {
  80069. right: AbstractMesh;
  80070. left: AbstractMesh;
  80071. };
  80072. /**
  80073. * If a hand mesh was provided, this array will define what axis will update which node. This will override the default hand mesh
  80074. */
  80075. rigMapping?: {
  80076. right: string[];
  80077. left: string[];
  80078. };
  80079. };
  80080. }
  80081. /**
  80082. * Parts of the hands divided to writs and finger names
  80083. */
  80084. export const enum HandPart {
  80085. /**
  80086. * HandPart - Wrist
  80087. */
  80088. WRIST = "wrist",
  80089. /**
  80090. * HandPart - The THumb
  80091. */
  80092. THUMB = "thumb",
  80093. /**
  80094. * HandPart - Index finger
  80095. */
  80096. INDEX = "index",
  80097. /**
  80098. * HandPart - Middle finger
  80099. */
  80100. MIDDLE = "middle",
  80101. /**
  80102. * HandPart - Ring finger
  80103. */
  80104. RING = "ring",
  80105. /**
  80106. * HandPart - Little finger
  80107. */
  80108. LITTLE = "little"
  80109. }
  80110. /**
  80111. * Representing a single hand (with its corresponding native XRHand object)
  80112. */
  80113. export class WebXRHand implements IDisposable {
  80114. /** the controller to which the hand correlates */
  80115. readonly xrController: WebXRInputSource;
  80116. /** the meshes to be used to track the hand joints */
  80117. readonly trackedMeshes: AbstractMesh[];
  80118. private _handMesh?;
  80119. private _rigMapping?;
  80120. private _scene;
  80121. private _defaultHandMesh;
  80122. private _transformNodeMapping;
  80123. /**
  80124. * Hand-parts definition (key is HandPart)
  80125. */
  80126. handPartsDefinition: {
  80127. [key: string]: number[];
  80128. };
  80129. /**
  80130. * Observers will be triggered when the mesh for this hand was initialized.
  80131. */
  80132. onHandMeshReadyObservable: Observable<WebXRHand>;
  80133. /**
  80134. * Populate the HandPartsDefinition object.
  80135. * This is called as a side effect since certain browsers don't have XRHand defined.
  80136. */
  80137. private generateHandPartsDefinition;
  80138. /**
  80139. * Construct a new hand object
  80140. * @param xrController the controller to which the hand correlates
  80141. * @param trackedMeshes the meshes to be used to track the hand joints
  80142. * @param _handMesh an optional hand mesh. if not provided, ours will be used
  80143. * @param _rigMapping an optional rig mapping for the hand mesh. if not provided, ours will be used
  80144. * @param disableDefaultHandMesh should the default mesh creation be disabled
  80145. */
  80146. constructor(
  80147. /** the controller to which the hand correlates */
  80148. xrController: WebXRInputSource,
  80149. /** the meshes to be used to track the hand joints */
  80150. trackedMeshes: AbstractMesh[], _handMesh?: AbstractMesh | undefined, _rigMapping?: string[] | undefined, disableDefaultHandMesh?: boolean);
  80151. /**
  80152. * Get the hand mesh. It is possible that the hand mesh is not yet ready!
  80153. */
  80154. get handMesh(): AbstractMesh | undefined;
  80155. /**
  80156. * Update this hand from the latest xr frame
  80157. * @param xrFrame xrFrame to update from
  80158. * @param referenceSpace The current viewer reference space
  80159. * @param scaleFactor optional scale factor for the meshes
  80160. */
  80161. updateFromXRFrame(xrFrame: XRFrame, referenceSpace: XRReferenceSpace, scaleFactor?: number): void;
  80162. /**
  80163. * Get meshes of part of the hand
  80164. * @param part the part of hand to get
  80165. * @returns An array of meshes that correlate to the hand part requested
  80166. */
  80167. getHandPartMeshes(part: HandPart): AbstractMesh[];
  80168. /**
  80169. * Dispose this Hand object
  80170. */
  80171. dispose(): void;
  80172. private _generateDefaultHandMesh;
  80173. }
  80174. /**
  80175. * WebXR Hand Joint tracking feature, available for selected browsers and devices
  80176. */
  80177. export class WebXRHandTracking extends WebXRAbstractFeature {
  80178. /**
  80179. * options to use when constructing this feature
  80180. */
  80181. readonly options: IWebXRHandTrackingOptions;
  80182. private static _idCounter;
  80183. /**
  80184. * The module's name
  80185. */
  80186. static readonly Name: string;
  80187. /**
  80188. * The (Babylon) version of this module.
  80189. * This is an integer representing the implementation version.
  80190. * This number does not correspond to the WebXR specs version
  80191. */
  80192. static readonly Version: number;
  80193. /**
  80194. * This observable will notify registered observers when a new hand object was added and initialized
  80195. */
  80196. onHandAddedObservable: Observable<WebXRHand>;
  80197. /**
  80198. * This observable will notify its observers right before the hand object is disposed
  80199. */
  80200. onHandRemovedObservable: Observable<WebXRHand>;
  80201. private _hands;
  80202. /**
  80203. * Creates a new instance of the hit test feature
  80204. * @param _xrSessionManager an instance of WebXRSessionManager
  80205. * @param options options to use when constructing this feature
  80206. */
  80207. constructor(_xrSessionManager: WebXRSessionManager,
  80208. /**
  80209. * options to use when constructing this feature
  80210. */
  80211. options: IWebXRHandTrackingOptions);
  80212. /**
  80213. * Check if the needed objects are defined.
  80214. * This does not mean that the feature is enabled, but that the objects needed are well defined.
  80215. */
  80216. isCompatible(): boolean;
  80217. /**
  80218. * attach this feature
  80219. * Will usually be called by the features manager
  80220. *
  80221. * @returns true if successful.
  80222. */
  80223. attach(): boolean;
  80224. /**
  80225. * detach this feature.
  80226. * Will usually be called by the features manager
  80227. *
  80228. * @returns true if successful.
  80229. */
  80230. detach(): boolean;
  80231. /**
  80232. * Dispose this feature and all of the resources attached
  80233. */
  80234. dispose(): void;
  80235. /**
  80236. * Get the hand object according to the controller id
  80237. * @param controllerId the controller id to which we want to get the hand
  80238. * @returns null if not found or the WebXRHand object if found
  80239. */
  80240. getHandByControllerId(controllerId: string): Nullable<WebXRHand>;
  80241. /**
  80242. * Get a hand object according to the requested handedness
  80243. * @param handedness the handedness to request
  80244. * @returns null if not found or the WebXRHand object if found
  80245. */
  80246. getHandByHandedness(handedness: XRHandedness): Nullable<WebXRHand>;
  80247. protected _onXRFrame(_xrFrame: XRFrame): void;
  80248. private _attachHand;
  80249. private _detachHand;
  80250. }
  80251. }
  80252. declare module BABYLON {
  80253. /**
  80254. * Options used in the mesh detector module
  80255. */
  80256. export interface IWebXRMeshDetectorOptions {
  80257. /**
  80258. * The node to use to transform the local results to world coordinates
  80259. */
  80260. worldParentNode?: TransformNode;
  80261. /**
  80262. * If set to true a reference of the created meshes will be kept until the next session starts
  80263. * If not defined, meshes will be removed from the array when the feature is detached or the session ended.
  80264. */
  80265. doNotRemoveMeshesOnSessionEnded?: boolean;
  80266. /**
  80267. * Preferred detector configuration, not all preferred options will be supported by all platforms.
  80268. */
  80269. preferredDetectorOptions?: XRGeometryDetectorOptions;
  80270. /**
  80271. * If set to true, WebXRMeshDetector will convert coordinate systems for meshes.
  80272. * If not defined, mesh conversions from right handed to left handed coordinate systems won't be conducted.
  80273. * Right handed mesh data will be available through IWebXRVertexData.xrMesh.
  80274. */
  80275. convertCoordinateSystems?: boolean;
  80276. }
  80277. /**
  80278. * A babylon interface for a XR mesh's vertex data.
  80279. *
  80280. * Currently not supported by WebXR, available only with BabylonNative
  80281. */
  80282. export interface IWebXRVertexData {
  80283. /**
  80284. * A babylon-assigned ID for this mesh
  80285. */
  80286. id: number;
  80287. /**
  80288. * Data required for constructing a mesh in Babylon.js.
  80289. */
  80290. xrMesh: XRMesh;
  80291. /**
  80292. * The node to use to transform the local results to world coordinates.
  80293. * WorldParentNode will only exist if it was declared in the IWebXRMeshDetectorOptions.
  80294. */
  80295. worldParentNode?: TransformNode;
  80296. /**
  80297. * An array of vertex positions in babylon space. right/left hand system is taken into account.
  80298. * Positions will only be calculated if convertCoordinateSystems is set to true in the IWebXRMeshDetectorOptions.
  80299. */
  80300. positions?: Float32Array;
  80301. /**
  80302. * An array of indices in babylon space. Indices have a counterclockwise winding order.
  80303. * Indices will only be populated if convertCoordinateSystems is set to true in the IWebXRMeshDetectorOptions.
  80304. */
  80305. indices?: Uint32Array;
  80306. /**
  80307. * An array of vertex normals in babylon space. right/left hand system is taken into account.
  80308. * Normals will not be calculated if convertCoordinateSystems is undefined in the IWebXRMeshDetectorOptions.
  80309. * Different platforms may or may not support mesh normals when convertCoordinateSystems is set to true.
  80310. */
  80311. normals?: Float32Array;
  80312. /**
  80313. * A transformation matrix to apply on the mesh that will be built using the meshDefinition.
  80314. * Local vs. World are decided if worldParentNode was provided or not in the options when constructing the module.
  80315. * TransformationMatrix will only be calculated if convertCoordinateSystems is set to true in the IWebXRMeshDetectorOptions.
  80316. */
  80317. transformationMatrix?: Matrix;
  80318. }
  80319. /**
  80320. * The mesh detector is used to detect meshes in the real world when in AR
  80321. */
  80322. export class WebXRMeshDetector extends WebXRAbstractFeature {
  80323. private _options;
  80324. private _detectedMeshes;
  80325. /**
  80326. * The module's name
  80327. */
  80328. static readonly Name: string;
  80329. /**
  80330. * The (Babylon) version of this module.
  80331. * This is an integer representing the implementation version.
  80332. * This number does not correspond to the WebXR specs version
  80333. */
  80334. static readonly Version: number;
  80335. /**
  80336. * Observers registered here will be executed when a new mesh was added to the session
  80337. */
  80338. onMeshAddedObservable: Observable<IWebXRVertexData>;
  80339. /**
  80340. * Observers registered here will be executed when a mesh is no longer detected in the session
  80341. */
  80342. onMeshRemovedObservable: Observable<IWebXRVertexData>;
  80343. /**
  80344. * Observers registered here will be executed when an existing mesh updates
  80345. */
  80346. onMeshUpdatedObservable: Observable<IWebXRVertexData>;
  80347. constructor(_xrSessionManager: WebXRSessionManager, _options?: IWebXRMeshDetectorOptions);
  80348. detach(): boolean;
  80349. dispose(): void;
  80350. protected _onXRFrame(frame: XRFrame): void;
  80351. private _init;
  80352. private _updateVertexDataWithXRMesh;
  80353. }
  80354. }
  80355. declare module BABYLON {
  80356. /**
  80357. * Options interface for the background remover plugin
  80358. */
  80359. export interface IWebXRImageTrackingOptions {
  80360. /**
  80361. * A required array with images to track
  80362. */
  80363. images: {
  80364. /**
  80365. * The source of the image. can be a URL or an image bitmap
  80366. */
  80367. src: string | ImageBitmap;
  80368. /**
  80369. * The estimated width in the real world (in meters)
  80370. */
  80371. estimatedRealWorldWidth: number;
  80372. }[];
  80373. }
  80374. /**
  80375. * An object representing an image tracked by the system
  80376. */
  80377. export interface IWebXRTrackedImage {
  80378. /**
  80379. * The ID of this image (which is the same as the position in the array that was used to initialize the feature)
  80380. */
  80381. id: number;
  80382. /**
  80383. * Is the transformation provided emulated. If it is, the system "guesses" its real position. Otherwise it can be considered as exact position.
  80384. */
  80385. emulated?: boolean;
  80386. /**
  80387. * Just in case it is needed - the image bitmap that is being tracked
  80388. */
  80389. originalBitmap: ImageBitmap;
  80390. /**
  80391. * The native XR result image tracking result, untouched
  80392. */
  80393. xrTrackingResult?: XRImageTrackingResult;
  80394. /**
  80395. * Width in real world (meters)
  80396. */
  80397. realWorldWidth?: number;
  80398. /**
  80399. * A transformation matrix of this current image in the current reference space.
  80400. */
  80401. transformationMatrix: Matrix;
  80402. /**
  80403. * The width/height ratio of this image. can be used to calculate the size of the detected object/image
  80404. */
  80405. ratio?: number;
  80406. }
  80407. /**
  80408. * Image tracking for immersive AR sessions.
  80409. * Providing a list of images and their estimated widths will enable tracking those images in the real world.
  80410. */
  80411. export class WebXRImageTracking extends WebXRAbstractFeature {
  80412. /**
  80413. * read-only options to be used in this module
  80414. */
  80415. readonly options: IWebXRImageTrackingOptions;
  80416. /**
  80417. * The module's name
  80418. */
  80419. static readonly Name: string;
  80420. /**
  80421. * The (Babylon) version of this module.
  80422. * This is an integer representing the implementation version.
  80423. * This number does not correspond to the WebXR specs version
  80424. */
  80425. static readonly Version: number;
  80426. /**
  80427. * This will be triggered if the underlying system deems an image untrackable.
  80428. * The index is the index of the image from the array used to initialize the feature.
  80429. */
  80430. onUntrackableImageFoundObservable: Observable<number>;
  80431. /**
  80432. * An image was deemed trackable, and the system will start tracking it.
  80433. */
  80434. onTrackableImageFoundObservable: Observable<IWebXRTrackedImage>;
  80435. /**
  80436. * The image was found and its state was updated.
  80437. */
  80438. onTrackedImageUpdatedObservable: Observable<IWebXRTrackedImage>;
  80439. private _trackedImages;
  80440. private _originalTrackingRequest;
  80441. /**
  80442. * constructs the image tracking feature
  80443. * @param _xrSessionManager the session manager for this module
  80444. * @param options read-only options to be used in this module
  80445. */
  80446. constructor(_xrSessionManager: WebXRSessionManager,
  80447. /**
  80448. * read-only options to be used in this module
  80449. */
  80450. options: IWebXRImageTrackingOptions);
  80451. /**
  80452. * attach this feature
  80453. * Will usually be called by the features manager
  80454. *
  80455. * @returns true if successful.
  80456. */
  80457. attach(): boolean;
  80458. /**
  80459. * detach this feature.
  80460. * Will usually be called by the features manager
  80461. *
  80462. * @returns true if successful.
  80463. */
  80464. detach(): boolean;
  80465. /**
  80466. * Check if the needed objects are defined.
  80467. * This does not mean that the feature is enabled, but that the objects needed are well defined.
  80468. */
  80469. isCompatible(): boolean;
  80470. /**
  80471. * Get a tracked image by its ID.
  80472. *
  80473. * @param id the id of the image to load (position in the init array)
  80474. * @returns a trackable image, if exists in this location
  80475. */
  80476. getTrackedImageById(id: number): Nullable<IWebXRTrackedImage>;
  80477. /**
  80478. * Dispose this feature and all of the resources attached
  80479. */
  80480. dispose(): void;
  80481. /**
  80482. * Extends the session init object if needed
  80483. * @returns augmentation object fo the xr session init object.
  80484. */
  80485. getXRSessionInitExtension(): Promise<Partial<XRSessionInit>>;
  80486. protected _onXRFrame(_xrFrame: XRFrame): void;
  80487. private _init;
  80488. }
  80489. }
  80490. declare module BABYLON {
  80491. /**
  80492. * The motion controller class for all microsoft mixed reality controllers
  80493. */
  80494. export class WebXRMicrosoftMixedRealityController extends WebXRAbstractMotionController {
  80495. protected readonly _mapping: {
  80496. defaultButton: {
  80497. valueNodeName: string;
  80498. unpressedNodeName: string;
  80499. pressedNodeName: string;
  80500. };
  80501. defaultAxis: {
  80502. valueNodeName: string;
  80503. minNodeName: string;
  80504. maxNodeName: string;
  80505. };
  80506. buttons: {
  80507. "xr-standard-trigger": {
  80508. rootNodeName: string;
  80509. componentProperty: string;
  80510. states: string[];
  80511. };
  80512. "xr-standard-squeeze": {
  80513. rootNodeName: string;
  80514. componentProperty: string;
  80515. states: string[];
  80516. };
  80517. "xr-standard-touchpad": {
  80518. rootNodeName: string;
  80519. labelAnchorNodeName: string;
  80520. touchPointNodeName: string;
  80521. };
  80522. "xr-standard-thumbstick": {
  80523. rootNodeName: string;
  80524. componentProperty: string;
  80525. states: string[];
  80526. };
  80527. };
  80528. axes: {
  80529. "xr-standard-touchpad": {
  80530. "x-axis": {
  80531. rootNodeName: string;
  80532. };
  80533. "y-axis": {
  80534. rootNodeName: string;
  80535. };
  80536. };
  80537. "xr-standard-thumbstick": {
  80538. "x-axis": {
  80539. rootNodeName: string;
  80540. };
  80541. "y-axis": {
  80542. rootNodeName: string;
  80543. };
  80544. };
  80545. };
  80546. };
  80547. /**
  80548. * The base url used to load the left and right controller models
  80549. */
  80550. static MODEL_BASE_URL: string;
  80551. /**
  80552. * The name of the left controller model file
  80553. */
  80554. static MODEL_LEFT_FILENAME: string;
  80555. /**
  80556. * The name of the right controller model file
  80557. */
  80558. static MODEL_RIGHT_FILENAME: string;
  80559. profileId: string;
  80560. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handedness: MotionControllerHandedness);
  80561. protected _getFilenameAndPath(): {
  80562. filename: string;
  80563. path: string;
  80564. };
  80565. protected _getModelLoadingConstraints(): boolean;
  80566. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  80567. protected _setRootMesh(meshes: AbstractMesh[]): void;
  80568. protected _updateModel(): void;
  80569. }
  80570. }
  80571. declare module BABYLON {
  80572. /**
  80573. * The motion controller class for oculus touch (quest, rift).
  80574. * This class supports legacy mapping as well the standard xr mapping
  80575. */
  80576. export class WebXROculusTouchMotionController extends WebXRAbstractMotionController {
  80577. private _forceLegacyControllers;
  80578. private _modelRootNode;
  80579. /**
  80580. * The base url used to load the left and right controller models
  80581. */
  80582. static MODEL_BASE_URL: string;
  80583. /**
  80584. * The name of the left controller model file
  80585. */
  80586. static MODEL_LEFT_FILENAME: string;
  80587. /**
  80588. * The name of the right controller model file
  80589. */
  80590. static MODEL_RIGHT_FILENAME: string;
  80591. /**
  80592. * Base Url for the Quest controller model.
  80593. */
  80594. static QUEST_MODEL_BASE_URL: string;
  80595. profileId: string;
  80596. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handedness: MotionControllerHandedness, legacyMapping?: boolean, _forceLegacyControllers?: boolean);
  80597. protected _getFilenameAndPath(): {
  80598. filename: string;
  80599. path: string;
  80600. };
  80601. protected _getModelLoadingConstraints(): boolean;
  80602. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  80603. protected _setRootMesh(meshes: AbstractMesh[]): void;
  80604. protected _updateModel(): void;
  80605. /**
  80606. * Is this the new type of oculus touch. At the moment both have the same profile and it is impossible to differentiate
  80607. * between the touch and touch 2.
  80608. */
  80609. private _isQuest;
  80610. }
  80611. }
  80612. declare module BABYLON {
  80613. /**
  80614. * The motion controller class for the standard HTC-Vive controllers
  80615. */
  80616. export class WebXRHTCViveMotionController extends WebXRAbstractMotionController {
  80617. private _modelRootNode;
  80618. /**
  80619. * The base url used to load the left and right controller models
  80620. */
  80621. static MODEL_BASE_URL: string;
  80622. /**
  80623. * File name for the controller model.
  80624. */
  80625. static MODEL_FILENAME: string;
  80626. profileId: string;
  80627. /**
  80628. * Create a new Vive motion controller object
  80629. * @param scene the scene to use to create this controller
  80630. * @param gamepadObject the corresponding gamepad object
  80631. * @param handedness the handedness of the controller
  80632. */
  80633. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handedness: MotionControllerHandedness);
  80634. protected _getFilenameAndPath(): {
  80635. filename: string;
  80636. path: string;
  80637. };
  80638. protected _getModelLoadingConstraints(): boolean;
  80639. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  80640. protected _setRootMesh(meshes: AbstractMesh[]): void;
  80641. protected _updateModel(): void;
  80642. }
  80643. }
  80644. declare module BABYLON {
  80645. /**
  80646. * A cursor which tracks a point on a path
  80647. */
  80648. export class PathCursor {
  80649. private path;
  80650. /**
  80651. * Stores path cursor callbacks for when an onchange event is triggered
  80652. */
  80653. private _onchange;
  80654. /**
  80655. * The value of the path cursor
  80656. */
  80657. value: number;
  80658. /**
  80659. * The animation array of the path cursor
  80660. */
  80661. animations: Animation[];
  80662. /**
  80663. * Initializes the path cursor
  80664. * @param path The path to track
  80665. */
  80666. constructor(path: Path2);
  80667. /**
  80668. * Gets the cursor point on the path
  80669. * @returns A point on the path cursor at the cursor location
  80670. */
  80671. getPoint(): Vector3;
  80672. /**
  80673. * Moves the cursor ahead by the step amount
  80674. * @param step The amount to move the cursor forward
  80675. * @returns This path cursor
  80676. */
  80677. moveAhead(step?: number): PathCursor;
  80678. /**
  80679. * Moves the cursor behind by the step amount
  80680. * @param step The amount to move the cursor back
  80681. * @returns This path cursor
  80682. */
  80683. moveBack(step?: number): PathCursor;
  80684. /**
  80685. * Moves the cursor by the step amount
  80686. * If the step amount is greater than one, an exception is thrown
  80687. * @param step The amount to move the cursor
  80688. * @returns This path cursor
  80689. */
  80690. move(step: number): PathCursor;
  80691. /**
  80692. * Ensures that the value is limited between zero and one
  80693. * @returns This path cursor
  80694. */
  80695. private ensureLimits;
  80696. /**
  80697. * Runs onchange callbacks on change (used by the animation engine)
  80698. * @returns This path cursor
  80699. */
  80700. private raiseOnChange;
  80701. /**
  80702. * Executes a function on change
  80703. * @param f A path cursor onchange callback
  80704. * @returns This path cursor
  80705. */
  80706. onchange(f: (cursor: PathCursor) => void): PathCursor;
  80707. }
  80708. }
  80709. declare module BABYLON {
  80710. /** @hidden */
  80711. export var blurPixelShader: {
  80712. name: string;
  80713. shader: string;
  80714. };
  80715. }
  80716. declare module BABYLON {
  80717. /** @hidden */
  80718. export var pointCloudVertexDeclaration: {
  80719. name: string;
  80720. shader: string;
  80721. };
  80722. }
  80723. // Mixins
  80724. interface Window {
  80725. mozIndexedDB: IDBFactory;
  80726. webkitIndexedDB: IDBFactory;
  80727. msIndexedDB: IDBFactory;
  80728. webkitURL: typeof URL;
  80729. mozRequestAnimationFrame(callback: FrameRequestCallback): number;
  80730. oRequestAnimationFrame(callback: FrameRequestCallback): number;
  80731. WebGLRenderingContext: WebGLRenderingContext;
  80732. MSGesture: MSGesture;
  80733. CANNON: any;
  80734. AudioContext: AudioContext;
  80735. webkitAudioContext: AudioContext;
  80736. PointerEvent: any;
  80737. Math: Math;
  80738. Uint8Array: Uint8ArrayConstructor;
  80739. Float32Array: Float32ArrayConstructor;
  80740. mozURL: typeof URL;
  80741. msURL: typeof URL;
  80742. VRFrameData: any; // WebVR, from specs 1.1
  80743. DracoDecoderModule: any;
  80744. setImmediate(handler: (...args: any[]) => void): number;
  80745. }
  80746. interface HTMLCanvasElement {
  80747. requestPointerLock(): void;
  80748. msRequestPointerLock?(): void;
  80749. mozRequestPointerLock?(): void;
  80750. webkitRequestPointerLock?(): void;
  80751. /** Track whether a record is in progress */
  80752. isRecording: boolean;
  80753. /** Capture Stream method defined by some browsers */
  80754. captureStream(fps?: number): MediaStream;
  80755. }
  80756. interface CanvasRenderingContext2D {
  80757. msImageSmoothingEnabled: boolean;
  80758. }
  80759. interface MouseEvent {
  80760. mozMovementX: number;
  80761. mozMovementY: number;
  80762. webkitMovementX: number;
  80763. webkitMovementY: number;
  80764. msMovementX: number;
  80765. msMovementY: number;
  80766. }
  80767. interface Navigator {
  80768. mozGetVRDevices: (any: any) => any;
  80769. webkitGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  80770. mozGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  80771. msGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  80772. webkitGetGamepads(): Gamepad[];
  80773. msGetGamepads(): Gamepad[];
  80774. webkitGamepads(): Gamepad[];
  80775. }
  80776. interface HTMLVideoElement {
  80777. mozSrcObject: any;
  80778. }
  80779. interface Math {
  80780. fround(x: number): number;
  80781. imul(a: number, b: number): number;
  80782. log2(x: number): number;
  80783. }
  80784. interface WebGLRenderingContext {
  80785. drawArraysInstanced(mode: number, first: number, count: number, primcount: number): void;
  80786. drawElementsInstanced(mode: number, count: number, type: number, offset: number, primcount: number): void;
  80787. vertexAttribDivisor(index: number, divisor: number): void;
  80788. createVertexArray(): any;
  80789. bindVertexArray(vao?: WebGLVertexArrayObject | null): void;
  80790. deleteVertexArray(vao: WebGLVertexArrayObject): void;
  80791. blitFramebuffer(srcX0: number, srcY0: number, srcX1: number, srcY1: number, dstX0: number, dstY0: number, dstX1: number, dstY1: number, mask: number, filter: number): void;
  80792. renderbufferStorageMultisample?(target: number, samples: number, internalformat: number, width: number, height: number): void;
  80793. bindBufferBase(target: number, index: number, buffer: WebGLBuffer | null): void;
  80794. getUniformBlockIndex(program: WebGLProgram, uniformBlockName: string): number;
  80795. uniformBlockBinding(program: WebGLProgram, uniformBlockIndex: number, uniformBlockBinding: number): void;
  80796. // Queries
  80797. createQuery(): WebGLQuery;
  80798. deleteQuery(query: WebGLQuery): void;
  80799. beginQuery(target: number, query: WebGLQuery): void;
  80800. endQuery(target: number): void;
  80801. getQueryParameter(query: WebGLQuery, pname: number): any;
  80802. getQuery(target: number, pname: number): any;
  80803. MAX_SAMPLES: number;
  80804. RGBA8: number;
  80805. READ_FRAMEBUFFER: number;
  80806. DRAW_FRAMEBUFFER: number;
  80807. UNIFORM_BUFFER: number;
  80808. HALF_FLOAT_OES: number;
  80809. RGBA16F: number;
  80810. RGBA32F: number;
  80811. R32F: number;
  80812. RG32F: number;
  80813. RGB32F: number;
  80814. R16F: number;
  80815. RG16F: number;
  80816. RGB16F: number;
  80817. RED: number;
  80818. RG: number;
  80819. R8: number;
  80820. RG8: number;
  80821. UNSIGNED_INT_24_8: number;
  80822. DEPTH24_STENCIL8: number;
  80823. MIN: number;
  80824. MAX: number;
  80825. /* Multiple Render Targets */
  80826. drawBuffers(buffers: number[]): void;
  80827. readBuffer(src: number): void;
  80828. readonly COLOR_ATTACHMENT0: number; // 0x8CE1
  80829. readonly COLOR_ATTACHMENT1: number; // 0x8CE2
  80830. readonly COLOR_ATTACHMENT2: number; // 0x8CE3
  80831. readonly COLOR_ATTACHMENT3: number; // 0x8CE4
  80832. // Occlusion Query
  80833. ANY_SAMPLES_PASSED_CONSERVATIVE: number;
  80834. ANY_SAMPLES_PASSED: number;
  80835. QUERY_RESULT_AVAILABLE: number;
  80836. QUERY_RESULT: number;
  80837. }
  80838. interface WebGLProgram {
  80839. __SPECTOR_rebuildProgram?: ((vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (program: WebGLProgram) => void, onError: (message: string) => void) => void) | null;
  80840. }
  80841. interface EXT_disjoint_timer_query {
  80842. QUERY_COUNTER_BITS_EXT: number;
  80843. TIME_ELAPSED_EXT: number;
  80844. TIMESTAMP_EXT: number;
  80845. GPU_DISJOINT_EXT: number;
  80846. QUERY_RESULT_EXT: number;
  80847. QUERY_RESULT_AVAILABLE_EXT: number;
  80848. queryCounterEXT(query: WebGLQuery, target: number): void;
  80849. createQueryEXT(): WebGLQuery;
  80850. beginQueryEXT(target: number, query: WebGLQuery): void;
  80851. endQueryEXT(target: number): void;
  80852. getQueryObjectEXT(query: WebGLQuery, target: number): any;
  80853. deleteQueryEXT(query: WebGLQuery): void;
  80854. }
  80855. interface WebGLUniformLocation {
  80856. _currentState: any;
  80857. }
  80858. // Type definitions for WebGL 2, Editor's Draft Fri Feb 24 16:10:18 2017 -0800
  80859. // Project: https://www.khronos.org/registry/webgl/specs/latest/2.0/
  80860. // Definitions by: Nico Kemnitz <https://github.com/nkemnitz/>
  80861. // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
  80862. interface WebGLRenderingContext {
  80863. readonly RASTERIZER_DISCARD: number;
  80864. readonly DEPTH_COMPONENT24: number;
  80865. readonly TEXTURE_3D: number;
  80866. readonly TEXTURE_2D_ARRAY: number;
  80867. readonly TEXTURE_COMPARE_FUNC: number;
  80868. readonly TEXTURE_COMPARE_MODE: number;
  80869. readonly COMPARE_REF_TO_TEXTURE: number;
  80870. readonly TEXTURE_WRAP_R: number;
  80871. readonly HALF_FLOAT: number;
  80872. readonly RGB8: number;
  80873. readonly RED_INTEGER: number;
  80874. readonly RG_INTEGER: number;
  80875. readonly RGB_INTEGER: number;
  80876. readonly RGBA_INTEGER: number;
  80877. readonly R8_SNORM: number;
  80878. readonly RG8_SNORM: number;
  80879. readonly RGB8_SNORM: number;
  80880. readonly RGBA8_SNORM: number;
  80881. readonly R8I: number;
  80882. readonly RG8I: number;
  80883. readonly RGB8I: number;
  80884. readonly RGBA8I: number;
  80885. readonly R8UI: number;
  80886. readonly RG8UI: number;
  80887. readonly RGB8UI: number;
  80888. readonly RGBA8UI: number;
  80889. readonly R16I: number;
  80890. readonly RG16I: number;
  80891. readonly RGB16I: number;
  80892. readonly RGBA16I: number;
  80893. readonly R16UI: number;
  80894. readonly RG16UI: number;
  80895. readonly RGB16UI: number;
  80896. readonly RGBA16UI: number;
  80897. readonly R32I: number;
  80898. readonly RG32I: number;
  80899. readonly RGB32I: number;
  80900. readonly RGBA32I: number;
  80901. readonly R32UI: number;
  80902. readonly RG32UI: number;
  80903. readonly RGB32UI: number;
  80904. readonly RGBA32UI: number;
  80905. readonly RGB10_A2UI: number;
  80906. readonly R11F_G11F_B10F: number;
  80907. readonly RGB9_E5: number;
  80908. readonly RGB10_A2: number;
  80909. readonly UNSIGNED_INT_2_10_10_10_REV: number;
  80910. readonly UNSIGNED_INT_10F_11F_11F_REV: number;
  80911. readonly UNSIGNED_INT_5_9_9_9_REV: number;
  80912. readonly FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  80913. readonly DEPTH_COMPONENT32F: number;
  80914. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView | null): void;
  80915. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView, offset: number): void;
  80916. 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;
  80917. framebufferTextureLayer(target: number, attachment: number, texture: WebGLTexture | null, level: number, layer: number): void;
  80918. compressedTexImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, data: ArrayBufferView, offset?: number, length?: number): void;
  80919. readonly TRANSFORM_FEEDBACK: number;
  80920. readonly INTERLEAVED_ATTRIBS: number;
  80921. readonly TRANSFORM_FEEDBACK_BUFFER: number;
  80922. createTransformFeedback(): WebGLTransformFeedback;
  80923. deleteTransformFeedback(transformFeedbac: WebGLTransformFeedback): void;
  80924. bindTransformFeedback(target: number, transformFeedback: WebGLTransformFeedback | null): void;
  80925. beginTransformFeedback(primitiveMode: number): void;
  80926. endTransformFeedback(): void;
  80927. transformFeedbackVaryings(program: WebGLProgram, varyings: string[], bufferMode: number): void;
  80928. clearBufferfv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  80929. clearBufferiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  80930. clearBufferuiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  80931. clearBufferfi(buffer: number, drawbuffer: number, depth: number, stencil: number): void;
  80932. }
  80933. interface ImageBitmap {
  80934. readonly width: number;
  80935. readonly height: number;
  80936. close(): void;
  80937. }
  80938. interface WebGLQuery extends WebGLObject {
  80939. }
  80940. declare var WebGLQuery: {
  80941. prototype: WebGLQuery;
  80942. new(): WebGLQuery;
  80943. };
  80944. interface WebGLSampler extends WebGLObject {
  80945. }
  80946. declare var WebGLSampler: {
  80947. prototype: WebGLSampler;
  80948. new(): WebGLSampler;
  80949. };
  80950. interface WebGLSync extends WebGLObject {
  80951. }
  80952. declare var WebGLSync: {
  80953. prototype: WebGLSync;
  80954. new(): WebGLSync;
  80955. };
  80956. interface WebGLTransformFeedback extends WebGLObject {
  80957. }
  80958. declare var WebGLTransformFeedback: {
  80959. prototype: WebGLTransformFeedback;
  80960. new(): WebGLTransformFeedback;
  80961. };
  80962. interface WebGLVertexArrayObject extends WebGLObject {
  80963. }
  80964. declare var WebGLVertexArrayObject: {
  80965. prototype: WebGLVertexArrayObject;
  80966. new(): WebGLVertexArrayObject;
  80967. };
  80968. interface Navigator {
  80969. readonly gpu: GPU | undefined;
  80970. }
  80971. interface GPUColorDict {
  80972. a: number;
  80973. b: number;
  80974. g: number;
  80975. r: number;
  80976. }
  80977. type GPUColor = [number, number, number, number] | GPUColorDict;
  80978. interface GPUOrigin2DDict {
  80979. x?: number;
  80980. y?: number;
  80981. }
  80982. type GPUOrigin2D = [number, number] | GPUOrigin2DDict;
  80983. interface GPUOrigin3DDict {
  80984. x?: number;
  80985. y?: number;
  80986. z?: number;
  80987. }
  80988. type GPUOrigin3D = [number, number, number] | GPUOrigin3DDict;
  80989. interface GPUExtent3DDict {
  80990. width: number;
  80991. height: number;
  80992. depth: number;
  80993. }
  80994. type GPUExtent3D = [number, number, number] | GPUExtent3DDict;
  80995. type GPUBindingResource =
  80996. | GPUSampler
  80997. | GPUTextureView
  80998. | GPUBufferBinding;
  80999. type GPUExtensionName =
  81000. | "texture-compression-bc"
  81001. | "timestamp-query"
  81002. | "pipeline-statistics-query"
  81003. | "depth-clamping"
  81004. | "depth24unorm-stencil8"
  81005. | "depth32float-stencil8";
  81006. type GPUAddressMode = "clamp-to-edge" | "repeat" | "mirror-repeat";
  81007. type GPUBindingType =
  81008. | "uniform-buffer"
  81009. | "storage-buffer"
  81010. | "readonly-storage-buffer"
  81011. | "sampler"
  81012. | "comparison-sampler"
  81013. | "sampled-texture"
  81014. | "readonly-storage-texture"
  81015. | "writeonly-storage-texture";
  81016. type GPUBlendFactor =
  81017. | "zero"
  81018. | "one"
  81019. | "src-color"
  81020. | "one-minus-src-color"
  81021. | "src-alpha"
  81022. | "one-minus-src-alpha"
  81023. | "dst-color"
  81024. | "one-minus-dst-color"
  81025. | "dst-alpha"
  81026. | "one-minus-dst-alpha"
  81027. | "src-alpha-saturated"
  81028. | "blend-color"
  81029. | "one-minus-blend-color";
  81030. type GPUBlendOperation =
  81031. | "add"
  81032. | "subtract"
  81033. | "reverse-subtract"
  81034. | "min"
  81035. | "max";
  81036. type GPUCompareFunction =
  81037. | "never"
  81038. | "less"
  81039. | "equal"
  81040. | "less-equal"
  81041. | "greater"
  81042. | "not-equal"
  81043. | "greater-equal"
  81044. | "always";
  81045. type GPUCullMode = "none" | "front" | "back";
  81046. type GPUFilterMode = "nearest" | "linear";
  81047. type GPUFrontFace = "ccw" | "cw";
  81048. type GPUIndexFormat = "uint16" | "uint32";
  81049. type GPUInputStepMode = "vertex" | "instance";
  81050. type GPULoadOp = "load";
  81051. type GPUPrimitiveTopology =
  81052. | "point-list"
  81053. | "line-list"
  81054. | "line-strip"
  81055. | "triangle-list"
  81056. | "triangle-strip";
  81057. type GPUStencilOperation =
  81058. | "keep"
  81059. | "zero"
  81060. | "replace"
  81061. | "invert"
  81062. | "increment-clamp"
  81063. | "decrement-clamp"
  81064. | "increment-wrap"
  81065. | "decrement-wrap";
  81066. type GPUStoreOp = "store" | "clear";
  81067. type GPUTextureDimension = "1d" | "2d" | "3d";
  81068. type GPUTextureFormat =
  81069. | "r8unorm"
  81070. | "r8snorm"
  81071. | "r8uint"
  81072. | "r8sint"
  81073. | "r16uint"
  81074. | "r16sint"
  81075. | "r16float"
  81076. | "rg8unorm"
  81077. | "rg8snorm"
  81078. | "rg8uint"
  81079. | "rg8sint"
  81080. | "r32uint"
  81081. | "r32sint"
  81082. | "r32float"
  81083. | "rg16uint"
  81084. | "rg16sint"
  81085. | "rg16float"
  81086. | "rgba8unorm"
  81087. | "rgba8unorm-srgb"
  81088. | "rgba8snorm"
  81089. | "rgba8uint"
  81090. | "rgba8sint"
  81091. | "bgra8unorm"
  81092. | "bgra8unorm-srgb"
  81093. | "rgb9e5ufloat"
  81094. | "rgb10a2unorm"
  81095. | "rg11b10ufloat"
  81096. | "rg32uint"
  81097. | "rg32sint"
  81098. | "rg32float"
  81099. | "rgba16uint"
  81100. | "rgba16sint"
  81101. | "rgba16float"
  81102. | "rgba32uint"
  81103. | "rgba32sint"
  81104. | "rgba32float"
  81105. | "stencil8"
  81106. | "depth16unorm"
  81107. | "depth24plus"
  81108. | "depth24plus-stencil8"
  81109. | "depth32float"
  81110. | "bc1-rgba-unorm"
  81111. | "bc1-rgba-unorm-srgb"
  81112. | "bc2-rgba-unorm"
  81113. | "bc2-rgba-unorm-srgb"
  81114. | "bc3-rgba-unorm"
  81115. | "bc3-rgba-unorm-srgb"
  81116. | "bc4-r-unorm"
  81117. | "bc4-r-snorm"
  81118. | "bc5-rg-unorm"
  81119. | "bc5-rg-snorm"
  81120. | "bc6h-rgb-ufloat"
  81121. | "bc6h-rgb-float"
  81122. | "bc7-rgba-unorm"
  81123. | "bc7-rgba-unorm-srgb"
  81124. | "depth24unorm-stencil8"
  81125. | "depth32float-stencil8";
  81126. type GPUTextureComponentType = "float" | "sint" | "uint" | "depth-comparison";
  81127. type GPUTextureViewDimension =
  81128. | "1d"
  81129. | "2d"
  81130. | "2d-array"
  81131. | "cube"
  81132. | "cube-array"
  81133. | "3d";
  81134. type GPUVertexFormat =
  81135. | "uchar2"
  81136. | "uchar4"
  81137. | "char2"
  81138. | "char4"
  81139. | "uchar2norm"
  81140. | "uchar4norm"
  81141. | "char2norm"
  81142. | "char4norm"
  81143. | "ushort2"
  81144. | "ushort4"
  81145. | "short2"
  81146. | "short4"
  81147. | "ushort2norm"
  81148. | "ushort4norm"
  81149. | "short2norm"
  81150. | "short4norm"
  81151. | "half2"
  81152. | "half4"
  81153. | "float"
  81154. | "float2"
  81155. | "float3"
  81156. | "float4"
  81157. | "uint"
  81158. | "uint2"
  81159. | "uint3"
  81160. | "uint4"
  81161. | "int"
  81162. | "int2"
  81163. | "int3"
  81164. | "int4";
  81165. type GPUTextureAspect = "all" | "stencil-only" | "depth-only";
  81166. type GPUBufferUsageFlags = number;
  81167. type GPUColorWriteFlags = number;
  81168. type GPUShaderStageFlags = number;
  81169. type GPUTextureUsageFlags = number;
  81170. type GPUMapModeFlags = number;
  81171. interface GPUBindGroupEntry {
  81172. binding: number;
  81173. resource: GPUBindingResource;
  81174. }
  81175. interface GPUBindGroupDescriptor extends GPUObjectDescriptorBase {
  81176. layout: GPUBindGroupLayout;
  81177. entries: Iterable<GPUBindGroupEntry>;
  81178. }
  81179. interface GPUBindGroupLayoutEntry {
  81180. binding: number;
  81181. visibility: GPUShaderStageFlags;
  81182. type: GPUBindingType;
  81183. hasDynamicOffset?: boolean;
  81184. minBufferBindingSize?: number;
  81185. viewDimension?: GPUTextureViewDimension;
  81186. textureComponentType?: GPUTextureComponentType;
  81187. storageTextureFormat?: GPUTextureFormat;
  81188. }
  81189. interface GPUBindGroupLayoutDescriptor
  81190. extends GPUObjectDescriptorBase {
  81191. entries: Iterable<GPUBindGroupLayoutEntry>;
  81192. }
  81193. interface GPUBlendDescriptor {
  81194. dstFactor?: GPUBlendFactor;
  81195. operation?: GPUBlendOperation;
  81196. srcFactor?: GPUBlendFactor;
  81197. }
  81198. interface GPUColorStateDescriptor {
  81199. format: GPUTextureFormat;
  81200. alphaBlend?: GPUBlendDescriptor;
  81201. colorBlend?: GPUBlendDescriptor;
  81202. writeMask?: GPUColorWriteFlags;
  81203. }
  81204. interface GPUBufferBinding {
  81205. buffer: GPUBuffer;
  81206. offset?: number;
  81207. size?: number;
  81208. }
  81209. interface GPUTextureDataLayout {
  81210. offset?: number;
  81211. bytesPerRow: number;
  81212. rowsPerImage?: number;
  81213. }
  81214. interface GPUBufferCopyView extends GPUTextureDataLayout {
  81215. buffer: GPUBuffer;
  81216. }
  81217. interface GPUTextureCopyView {
  81218. texture: GPUTexture;
  81219. mipLevel?: number;
  81220. origin?: GPUOrigin3D;
  81221. }
  81222. interface GPUImageBitmapCopyView {
  81223. imageBitmap: ImageBitmap;
  81224. origin?: GPUOrigin2D;
  81225. }
  81226. interface GPUBufferDescriptor extends GPUObjectDescriptorBase {
  81227. size: number;
  81228. usage: GPUBufferUsageFlags;
  81229. mappedAtCreation?: boolean;
  81230. }
  81231. interface GPUCommandEncoderDescriptor extends GPUObjectDescriptorBase {
  81232. label?: string;
  81233. measureExecutionTime?: boolean;
  81234. }
  81235. interface GPUComputePipelineDescriptor
  81236. extends GPUPipelineDescriptorBase {
  81237. computeStage: GPUProgrammableStageDescriptor;
  81238. }
  81239. interface GPUDepthStencilStateDescriptor {
  81240. format: GPUTextureFormat;
  81241. depthWriteEnabled?: boolean;
  81242. depthCompare?: GPUCompareFunction;
  81243. stencilFront?: GPUStencilStateFaceDescriptor;
  81244. stencilBack?: GPUStencilStateFaceDescriptor;
  81245. stencilReadMask?: number;
  81246. stencilWriteMask?: number;
  81247. }
  81248. interface GPUDeviceDescriptor extends GPUObjectDescriptorBase {
  81249. extensions?: Iterable<GPUExtensionName>;
  81250. limits?: GPULimits;
  81251. }
  81252. interface GPUFenceDescriptor extends GPUObjectDescriptorBase {
  81253. initialValue?: number;
  81254. label?: string;
  81255. signalQueue?: GPUQueue;
  81256. }
  81257. interface GPUVertexAttributeDescriptor {
  81258. format: GPUVertexFormat;
  81259. offset: number;
  81260. shaderLocation: number;
  81261. }
  81262. interface GPUVertexBufferLayoutDescriptor {
  81263. arrayStride: number;
  81264. stepMode?: GPUInputStepMode;
  81265. attributes: Iterable<GPUVertexAttributeDescriptor>;
  81266. }
  81267. interface GPUVertexStateDescriptor {
  81268. indexFormat?: GPUIndexFormat;
  81269. vertexBuffers?: Iterable<GPUVertexBufferLayoutDescriptor>;
  81270. }
  81271. interface GPULimits {
  81272. maxBindGroups?: number;
  81273. maxDynamicUniformBuffersPerPipelineLayout?: number;
  81274. maxDynamicStorageBuffersPerPipelineLayout?: number;
  81275. maxSampledTexturesPerShaderStage?: number;
  81276. maxSamplersPerShaderStage?: number;
  81277. maxStorageBuffersPerShaderStage?: number;
  81278. maxStorageTexturesPerShaderStage?: number;
  81279. maxUniformBuffersPerShaderStage?: number;
  81280. maxUniformBufferBindingSize?: number;
  81281. }
  81282. interface GPUPipelineDescriptorBase {
  81283. label?: string;
  81284. layout?: GPUPipelineLayout;
  81285. }
  81286. interface GPUPipelineLayoutDescriptor extends GPUObjectDescriptorBase {
  81287. bindGroupLayouts: Iterable<GPUBindGroupLayout>;
  81288. }
  81289. interface GPUProgrammableStageDescriptor {
  81290. module: GPUShaderModule;
  81291. entryPoint: string;
  81292. }
  81293. interface GPURasterizationStateDescriptor {
  81294. frontFace?: GPUFrontFace;
  81295. cullMode?: GPUCullMode;
  81296. clampDepth?: boolean;
  81297. depthBias?: number;
  81298. depthBiasSlopeScale?: number;
  81299. depthBiasClamp?: number;
  81300. }
  81301. interface GPURenderPassColorAttachmentDescriptor {
  81302. attachment: GPUTextureView;
  81303. resolveTarget?: GPUTextureView;
  81304. loadValue: GPULoadOp | GPUColor;
  81305. storeOp?: GPUStoreOp;
  81306. }
  81307. interface GPURenderPassDepthStencilAttachmentDescriptor {
  81308. attachment: GPUTextureView;
  81309. depthLoadValue: GPULoadOp | number;
  81310. depthStoreOp: GPUStoreOp;
  81311. depthReadOnly?: boolean;
  81312. stencilLoadValue: GPULoadOp | number;
  81313. stencilStoreOp: GPUStoreOp;
  81314. stencilReadOnly?: boolean;
  81315. }
  81316. interface GPURenderPassDescriptor extends GPUObjectDescriptorBase {
  81317. colorAttachments: Iterable<GPURenderPassColorAttachmentDescriptor>;
  81318. depthStencilAttachment?: GPURenderPassDepthStencilAttachmentDescriptor;
  81319. }
  81320. interface GPURenderPipelineDescriptor
  81321. extends GPUPipelineDescriptorBase {
  81322. vertexStage: GPUProgrammableStageDescriptor;
  81323. fragmentStage?: GPUProgrammableStageDescriptor;
  81324. primitiveTopology: GPUPrimitiveTopology;
  81325. rasterizationState?: GPURasterizationStateDescriptor;
  81326. colorStates: Iterable<GPUColorStateDescriptor>;
  81327. depthStencilState?: GPUDepthStencilStateDescriptor;
  81328. vertexState?: GPUVertexStateDescriptor;
  81329. sampleCount?: number;
  81330. sampleMask?: number;
  81331. alphaToCoverageEnabled?: boolean;
  81332. }
  81333. interface GPUSamplerDescriptor extends GPUObjectDescriptorBase {
  81334. addressModeU?: GPUAddressMode;
  81335. addressModeV?: GPUAddressMode;
  81336. addressModeW?: GPUAddressMode;
  81337. magFilter?: GPUFilterMode;
  81338. minFilter?: GPUFilterMode;
  81339. mipmapFilter?: GPUFilterMode;
  81340. lodMinClamp?: number;
  81341. lodMaxClamp?: number;
  81342. compare?: GPUCompareFunction;
  81343. maxAnisotropy?: number;
  81344. }
  81345. interface GPUShaderModuleDescriptor extends GPUObjectDescriptorBase {
  81346. code: Uint32Array | string;
  81347. label?: string;
  81348. sourceMap?: object;
  81349. }
  81350. interface GPUStencilStateFaceDescriptor {
  81351. compare?: GPUCompareFunction;
  81352. depthFailOp?: GPUStencilOperation;
  81353. passOp?: GPUStencilOperation;
  81354. failOp?: GPUStencilOperation;
  81355. }
  81356. interface GPUSwapChainDescriptor extends GPUObjectDescriptorBase {
  81357. device: GPUDevice;
  81358. format: GPUTextureFormat;
  81359. usage?: GPUTextureUsageFlags;
  81360. }
  81361. interface GPUTextureDescriptor extends GPUObjectDescriptorBase {
  81362. size: GPUExtent3D;
  81363. mipLevelCount?: number;
  81364. sampleCount?: number;
  81365. dimension?: GPUTextureDimension;
  81366. format: GPUTextureFormat;
  81367. usage: GPUTextureUsageFlags;
  81368. }
  81369. interface GPUTextureViewDescriptor extends GPUObjectDescriptorBase {
  81370. format?: GPUTextureFormat;
  81371. dimension?: GPUTextureViewDimension;
  81372. aspect?: GPUTextureAspect;
  81373. baseArrayLayer?: number;
  81374. baseMipLevel?: number;
  81375. arrayLayerCount?: number;
  81376. mipLevelCount?: number;
  81377. }
  81378. declare class GPUAdapter {
  81379. // https://michalzalecki.com/nominal-typing-in-typescript/#approach-1-class-with-a-private-property
  81380. private __brand: void;
  81381. readonly name: string;
  81382. readonly extensions: GPUExtensionName[];
  81383. readonly limits: Required<GPULimits>;
  81384. requestDevice(descriptor?: GPUDeviceDescriptor): Promise<GPUDevice | null>;
  81385. }
  81386. declare class GPUBindGroup implements GPUObjectBase {
  81387. private __brand: void;
  81388. label: string | undefined;
  81389. }
  81390. declare class GPUBindGroupLayout implements GPUObjectBase {
  81391. private __brand: void;
  81392. label: string | undefined;
  81393. }
  81394. declare class GPUBuffer implements GPUObjectBase {
  81395. private __brand: void;
  81396. label: string | undefined;
  81397. destroy(): void;
  81398. unmap(): void;
  81399. mapAsync(mode: GPUMapModeFlags, offset?: number, size?: number): Promise<void>;
  81400. getMappedRange(offset?: number, size?: number): ArrayBuffer;
  81401. }
  81402. declare class GPUCommandBuffer implements GPUObjectBase {
  81403. private __brand: void;
  81404. label: string | undefined;
  81405. readonly executionTime: Promise<number>;
  81406. }
  81407. interface GPUCommandBufferDescriptor extends GPUObjectDescriptorBase { }
  81408. declare class GPUCommandEncoder implements GPUObjectBase {
  81409. private __brand: void;
  81410. label: string | undefined;
  81411. beginComputePass(
  81412. descriptor?: GPUComputePassDescriptor
  81413. ): GPUComputePassEncoder;
  81414. beginRenderPass(descriptor: GPURenderPassDescriptor): GPURenderPassEncoder;
  81415. copyBufferToBuffer(
  81416. source: GPUBuffer,
  81417. sourceOffset: number,
  81418. destination: GPUBuffer,
  81419. destinationOffset: number,
  81420. size: number
  81421. ): void;
  81422. copyBufferToTexture(
  81423. source: GPUBufferCopyView,
  81424. destination: GPUTextureCopyView,
  81425. copySize: GPUExtent3D
  81426. ): void;
  81427. copyTextureToBuffer(
  81428. source: GPUTextureCopyView,
  81429. destination: GPUBufferCopyView,
  81430. copySize: GPUExtent3D
  81431. ): void;
  81432. copyTextureToTexture(
  81433. source: GPUTextureCopyView,
  81434. destination: GPUTextureCopyView,
  81435. copySize: GPUExtent3D
  81436. ): void;
  81437. finish(descriptor?: GPUCommandBufferDescriptor): GPUCommandBuffer;
  81438. writeTimestamp(querySet: GPUQuerySet, queryIndex: number): void;
  81439. popDebugGroup(): void;
  81440. pushDebugGroup(groupLabel: string): void;
  81441. insertDebugMarker(markerLabel: string): void;
  81442. }
  81443. interface GPUComputePassDescriptor extends GPUObjectDescriptorBase { }
  81444. declare class GPUComputePassEncoder implements GPUObjectBase, GPUProgrammablePassEncoder {
  81445. private __brand: void;
  81446. label: string | undefined;
  81447. setBindGroup(
  81448. index: number,
  81449. bindGroup: GPUBindGroup,
  81450. dynamicOffsets?: Iterable<number>
  81451. ): void;
  81452. popDebugGroup(): void;
  81453. pushDebugGroup(groupLabel: string): void;
  81454. insertDebugMarker(markerLabel: string): void;
  81455. setPipeline(pipeline: GPUComputePipeline): void;
  81456. dispatch(x: number, y?: number, z?: number): void;
  81457. dispatchIndirect(indirectBuffer: GPUBuffer, indirectOffset: number): void;
  81458. writeTimestamp(querySet: GPUQuerySet, queryIndex: number): void;
  81459. beginPipelineStatisticsQuery(querySet: GPUQuerySet, queryIndex: number): void;
  81460. endPipelineStatisticsQuery(querySet: GPUQuerySet, queryIndex: number): void;
  81461. endPass(): void;
  81462. }
  81463. declare class GPUComputePipeline implements GPUPipelineBase {
  81464. private __brand: void;
  81465. label: string | undefined;
  81466. getBindGroupLayout(index: number): GPUBindGroupLayout;
  81467. }
  81468. interface GPUObjectBase {
  81469. label: string | undefined;
  81470. }
  81471. interface GPUObjectDescriptorBase {
  81472. label?: string;
  81473. }
  81474. // SwapChain / CanvasContext
  81475. declare class GPUCanvasContext {
  81476. private __brand: void;
  81477. configureSwapChain(descriptor: GPUSwapChainDescriptor): GPUSwapChain;
  81478. getSwapChainPreferredFormat(device: GPUDevice): Promise<GPUTextureFormat>;
  81479. }
  81480. declare class GPUDevice extends EventTarget implements GPUObjectBase {
  81481. private __brand: void;
  81482. label: string | undefined;
  81483. readonly adapter: GPUAdapter;
  81484. readonly extensions: GPUExtensionName[];
  81485. readonly limits: Required<GPULimits>;
  81486. createBindGroup(descriptor: GPUBindGroupDescriptor): GPUBindGroup;
  81487. createBindGroupLayout(
  81488. descriptor: GPUBindGroupLayoutDescriptor
  81489. ): GPUBindGroupLayout;
  81490. createBuffer(descriptor: GPUBufferDescriptor): GPUBuffer;
  81491. createPipelineLayout(
  81492. descriptor: GPUPipelineLayoutDescriptor
  81493. ): GPUPipelineLayout;
  81494. createSampler(descriptor?: GPUSamplerDescriptor): GPUSampler;
  81495. createShaderModule(descriptor: GPUShaderModuleDescriptor): GPUShaderModule;
  81496. createTexture(descriptor: GPUTextureDescriptor): GPUTexture;
  81497. createComputePipeline(
  81498. descriptor: GPUComputePipelineDescriptor
  81499. ): GPUComputePipeline;
  81500. createRenderPipeline(
  81501. descriptor: GPURenderPipelineDescriptor
  81502. ): GPURenderPipeline;
  81503. createReadyComputePipeline(
  81504. descriptor: GPUComputePipelineDescriptor
  81505. ): Promise<GPUComputePipeline>;
  81506. createReadyRenderPipeline(
  81507. descriptor: GPURenderPipelineDescriptor
  81508. ): Promise<GPURenderPipeline>;
  81509. createCommandEncoder(
  81510. descriptor?: GPUCommandEncoderDescriptor
  81511. ): GPUCommandEncoder;
  81512. createRenderBundleEncoder(
  81513. descriptor: GPURenderBundleEncoderDescriptor
  81514. ): GPURenderBundleEncoder;
  81515. createQuerySet(descriptor: GPUQuerySetDescriptor): GPUQuerySet;
  81516. defaultQueue: GPUQueue;
  81517. pushErrorScope(filter: GPUErrorFilter): void;
  81518. popErrorScope(): Promise<GPUError | null>;
  81519. onuncapturederror: Event | undefined;
  81520. readonly lost: Promise<GPUDeviceLostInfo>;
  81521. }
  81522. declare class GPUFence implements GPUObjectBase {
  81523. private __brand: void;
  81524. label: string | undefined;
  81525. getCompletedValue(): number;
  81526. onCompletion(completionValue: number): Promise<void>;
  81527. }
  81528. interface GPUPipelineBase extends GPUObjectBase {
  81529. getBindGroupLayout(index: number): GPUBindGroupLayout;
  81530. }
  81531. declare class GPUPipelineLayout implements GPUObjectBase {
  81532. private __brand: void;
  81533. label: string | undefined;
  81534. }
  81535. interface GPUProgrammablePassEncoder {
  81536. setBindGroup(
  81537. index: number,
  81538. bindGroup: GPUBindGroup,
  81539. dynamicOffsets?: Iterable<number>
  81540. ): void;
  81541. popDebugGroup(): void;
  81542. pushDebugGroup(groupLabel: string): void;
  81543. insertDebugMarker(markerLabel: string): void;
  81544. }
  81545. declare class GPUQueue implements GPUObjectBase {
  81546. private __brand: void;
  81547. label: string | undefined;
  81548. signal(fence: GPUFence, signalValue: number): void;
  81549. submit(commandBuffers: Iterable<GPUCommandBuffer>): void;
  81550. createFence(descriptor?: GPUFenceDescriptor): GPUFence;
  81551. writeBuffer(buffer: GPUBuffer,
  81552. bufferOffset: number,
  81553. data: BufferSource | ArrayBuffer,
  81554. dataOffset?: number,
  81555. size?: number): void;
  81556. writeTexture(destination: GPUTextureCopyView,
  81557. data: BufferSource | ArrayBuffer,
  81558. dataLayout: GPUTextureDataLayout,
  81559. size: GPUExtent3D): void;
  81560. copyImageBitmapToTexture(
  81561. source: GPUImageBitmapCopyView,
  81562. destination: GPUTextureCopyView,
  81563. copySize: GPUExtent3D
  81564. ): void;
  81565. }
  81566. type GPUQueryType =
  81567. | "occlusion"
  81568. | "timestamp"
  81569. | "pipeline-statistics";
  81570. type GPUPipelineStatisticName =
  81571. | "vertex-shader-invocations"
  81572. | "clipper-invocations"
  81573. | "clipper-primitives-out"
  81574. | "fragment-shader-invocations"
  81575. | "compute-shader-invocations";
  81576. interface GPUQuerySetDescriptor extends GPUObjectDescriptorBase {
  81577. type: GPUQueryType;
  81578. count: number;
  81579. pipelineStatistics?: Iterable<GPUPipelineStatisticName>;
  81580. }
  81581. declare class GPUQuerySet implements GPUObjectBase {
  81582. private __brand: void;
  81583. label: string | undefined;
  81584. destroy(): void;
  81585. }
  81586. interface GPURenderEncoderBase {
  81587. setPipeline(pipeline: GPURenderPipeline): void;
  81588. setIndexBuffer(buffer: GPUBuffer, offset?: number, size?: number): void;
  81589. setIndexBuffer(buffer: GPUBuffer, indexFormat: GPUIndexFormat, offset?: number, size?: number): void;
  81590. setVertexBuffer(slot: number, buffer: GPUBuffer, offset?: number, size?: number): void;
  81591. draw(
  81592. vertexCount: number,
  81593. instanceCount?: number,
  81594. firstVertex?: number,
  81595. firstInstance?: number
  81596. ): void;
  81597. drawIndexed(
  81598. indexCount: number,
  81599. instanceCount?: number,
  81600. firstIndex?: number,
  81601. baseVertex?: number,
  81602. firstInstance?: number
  81603. ): void;
  81604. drawIndirect(indirectBuffer: GPUBuffer, indirectOffset: number): void;
  81605. drawIndexedIndirect(
  81606. indirectBuffer: GPUBuffer,
  81607. indirectOffset: number
  81608. ): void;
  81609. }
  81610. declare class GPURenderPassEncoder implements GPUObjectBase, GPUProgrammablePassEncoder, GPURenderEncoderBase {
  81611. private __brand: void;
  81612. label: string | undefined;
  81613. setBindGroup(
  81614. index: number,
  81615. bindGroup: GPUBindGroup,
  81616. dynamicOffsets?: Iterable<number>
  81617. ): void;
  81618. popDebugGroup(): void;
  81619. pushDebugGroup(groupLabel: string): void;
  81620. insertDebugMarker(markerLabel: string): void;
  81621. setPipeline(pipeline: GPURenderPipeline): void;
  81622. setIndexBuffer(buffer: GPUBuffer, offset?: number): void;
  81623. setIndexBuffer(buffer: GPUBuffer, indexFormat: GPUIndexFormat, offset?: number, size?: number): void;
  81624. setVertexBuffer(slot: number, buffer: GPUBuffer, offset?: number): void;
  81625. draw(
  81626. vertexCount: number,
  81627. instanceCount?: number,
  81628. firstVertex?: number,
  81629. firstInstance?: number
  81630. ): void;
  81631. drawIndexed(
  81632. indexCount: number,
  81633. instanceCount?: number,
  81634. firstIndex?: number,
  81635. baseVertex?: number,
  81636. firstInstance?: number
  81637. ): void;
  81638. drawIndirect(indirectBuffer: GPUBuffer, indirectOffset: number): void;
  81639. drawIndexedIndirect(
  81640. indirectBuffer: GPUBuffer,
  81641. indirectOffset: number
  81642. ): void;
  81643. setViewport(
  81644. x: number,
  81645. y: number,
  81646. width: number,
  81647. height: number,
  81648. minDepth: number,
  81649. maxDepth: number
  81650. ): void;
  81651. setScissorRect(x: number, y: number, width: number, height: number): void;
  81652. setBlendColor(color: GPUColor): void;
  81653. setStencilReference(reference: number): void;
  81654. writeTimestamp(querySet: GPUQuerySet, queryIndex: number): void;
  81655. beginOcclusionQuery(queryIndex: number): void;
  81656. endOcclusionQuery(): void;
  81657. beginPipelineStatisticsQuery(querySet: GPUQuerySet, queryIndex: number): void;
  81658. endPipelineStatisticsQuery(querySet: GPUQuerySet, queryIndex: number): void;
  81659. executeBundles(bundles: Iterable<GPURenderBundle>): void;
  81660. endPass(): void;
  81661. }
  81662. interface GPURenderBundleDescriptor extends GPUObjectDescriptorBase { }
  81663. declare class GPURenderBundle implements GPUObjectBase {
  81664. private __brand: void;
  81665. label: string | undefined;
  81666. }
  81667. declare class GPURenderBundleEncoder implements GPURenderEncoderBase {
  81668. private __brand: void;
  81669. label: string | undefined;
  81670. setBindGroup(
  81671. index: number,
  81672. bindGroup: GPUBindGroup,
  81673. dynamicOffsets?: Iterable<number>
  81674. ): void;
  81675. popDebugGroup(): void;
  81676. pushDebugGroup(groupLabel: string): void;
  81677. insertDebugMarker(markerLabel: string): void;
  81678. setPipeline(pipeline: GPURenderPipeline): void;
  81679. setIndexBuffer(buffer: GPUBuffer, offset?: number): void;
  81680. setIndexBuffer(buffer: GPUBuffer, indexFormat: GPUIndexFormat, offset?: number, size?: number): void;
  81681. setVertexBuffer(slot: number, buffer: GPUBuffer, offset?: number): void;
  81682. draw(
  81683. vertexCount: number,
  81684. instanceCount?: number,
  81685. firstVertex?: number,
  81686. firstInstance?: number
  81687. ): void;
  81688. drawIndexed(
  81689. indexCount: number,
  81690. instanceCount?: number,
  81691. firstIndex?: number,
  81692. baseVertex?: number,
  81693. firstInstance?: number
  81694. ): void;
  81695. drawIndirect(indirectBuffer: GPUBuffer, indirectOffset: number): void;
  81696. drawIndexedIndirect(
  81697. indirectBuffer: GPUBuffer,
  81698. indirectOffset: number
  81699. ): void;
  81700. finish(descriptor?: GPURenderBundleDescriptor): GPURenderBundle;
  81701. }
  81702. interface GPURenderBundleEncoderDescriptor
  81703. extends GPUObjectDescriptorBase {
  81704. colorFormats: Iterable<GPUTextureFormat>;
  81705. depthStencilFormat?: GPUTextureFormat;
  81706. sampleCount?: number;
  81707. }
  81708. declare class GPURenderPipeline implements GPUPipelineBase {
  81709. private __brand: void;
  81710. label: string | undefined;
  81711. getBindGroupLayout(index: number): GPUBindGroupLayout;
  81712. }
  81713. declare class GPUSampler implements GPUObjectBase {
  81714. private __brand: void;
  81715. label: string | undefined;
  81716. }
  81717. type GPUCompilationMessageType =
  81718. | "error"
  81719. | "warning"
  81720. | "info";
  81721. interface GPUCompilationMessage {
  81722. readonly message: string;
  81723. readonly type: GPUCompilationMessageType;
  81724. readonly lineNum: number;
  81725. readonly linePos: number;
  81726. }
  81727. interface GPUCompilationInfo {
  81728. readonly messages: readonly GPUCompilationMessage[];
  81729. }
  81730. declare class GPUShaderModule implements GPUObjectBase {
  81731. private __brand: void;
  81732. label: string | undefined;
  81733. compilationInfo(): Promise<GPUCompilationInfo>;
  81734. }
  81735. declare class GPUSwapChain implements GPUObjectBase {
  81736. private __brand: void;
  81737. label: string | undefined;
  81738. getCurrentTexture(): GPUTexture;
  81739. }
  81740. declare class GPUTexture implements GPUObjectBase {
  81741. private __brand: void;
  81742. label: string | undefined;
  81743. createView(descriptor?: GPUTextureViewDescriptor): GPUTextureView;
  81744. destroy(): void;
  81745. }
  81746. declare class GPUTextureView implements GPUObjectBase {
  81747. private __brand: void;
  81748. label: string | undefined;
  81749. }
  81750. type GPUPowerPreference = "low-power" | "high-performance";
  81751. interface GPURequestAdapterOptions {
  81752. powerPreference?: GPUPowerPreference;
  81753. }
  81754. declare class GPU {
  81755. private __brand: void;
  81756. requestAdapter(options?: GPURequestAdapterOptions): Promise<GPUAdapter | null>;
  81757. }
  81758. // ****************************************************************************
  81759. // ERROR SCOPES
  81760. // ****************************************************************************
  81761. type GPUErrorFilter = "out-of-memory" | "validation";
  81762. declare class GPUOutOfMemoryError {
  81763. private __brand: void;
  81764. constructor();
  81765. }
  81766. declare class GPUValidationError {
  81767. private __brand: void;
  81768. constructor(message: string);
  81769. readonly message: string;
  81770. }
  81771. type GPUError = GPUOutOfMemoryError | GPUValidationError;
  81772. // ****************************************************************************
  81773. // TELEMETRY
  81774. // ****************************************************************************
  81775. declare class GPUUncapturedErrorEvent extends Event {
  81776. private __brand: void;
  81777. constructor(
  81778. type: string,
  81779. gpuUncapturedErrorEventInitDict: GPUUncapturedErrorEventInit
  81780. );
  81781. readonly error: GPUError;
  81782. }
  81783. interface GPUUncapturedErrorEventInit extends EventInit {
  81784. error: GPUError;
  81785. }
  81786. declare class GPUDeviceLostInfo {
  81787. private __brand: void;
  81788. readonly message: string;
  81789. }
  81790. // Type definitions for WebVR API
  81791. // Project: https://w3c.github.io/webvr/
  81792. // Definitions by: six a <https://github.com/lostfictions>
  81793. // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
  81794. interface VRDisplay extends EventTarget {
  81795. /**
  81796. * Dictionary of capabilities describing the VRDisplay.
  81797. */
  81798. readonly capabilities: VRDisplayCapabilities;
  81799. /**
  81800. * z-depth defining the far plane of the eye view frustum
  81801. * enables mapping of values in the render target depth
  81802. * attachment to scene coordinates. Initially set to 10000.0.
  81803. */
  81804. depthFar: number;
  81805. /**
  81806. * z-depth defining the near plane of the eye view frustum
  81807. * enables mapping of values in the render target depth
  81808. * attachment to scene coordinates. Initially set to 0.01.
  81809. */
  81810. depthNear: number;
  81811. /**
  81812. * An identifier for this distinct VRDisplay. Used as an
  81813. * association point in the Gamepad API.
  81814. */
  81815. readonly displayId: number;
  81816. /**
  81817. * A display name, a user-readable name identifying it.
  81818. */
  81819. readonly displayName: string;
  81820. readonly isConnected: boolean;
  81821. readonly isPresenting: boolean;
  81822. /**
  81823. * If this VRDisplay supports room-scale experiences, the optional
  81824. * stage attribute contains details on the room-scale parameters.
  81825. */
  81826. readonly stageParameters: VRStageParameters | null;
  81827. /**
  81828. * Passing the value returned by `requestAnimationFrame` to
  81829. * `cancelAnimationFrame` will unregister the callback.
  81830. * @param handle Define the hanle of the request to cancel
  81831. */
  81832. cancelAnimationFrame(handle: number): void;
  81833. /**
  81834. * Stops presenting to the VRDisplay.
  81835. * @returns a promise to know when it stopped
  81836. */
  81837. exitPresent(): Promise<void>;
  81838. /**
  81839. * Return the current VREyeParameters for the given eye.
  81840. * @param whichEye Define the eye we want the parameter for
  81841. * @returns the eye parameters
  81842. */
  81843. getEyeParameters(whichEye: string): VREyeParameters;
  81844. /**
  81845. * Populates the passed VRFrameData with the information required to render
  81846. * the current frame.
  81847. * @param frameData Define the data structure to populate
  81848. * @returns true if ok otherwise false
  81849. */
  81850. getFrameData(frameData: VRFrameData): boolean;
  81851. /**
  81852. * Get the layers currently being presented.
  81853. * @returns the list of VR layers
  81854. */
  81855. getLayers(): VRLayer[];
  81856. /**
  81857. * Return a VRPose containing the future predicted pose of the VRDisplay
  81858. * when the current frame will be presented. The value returned will not
  81859. * change until JavaScript has returned control to the browser.
  81860. *
  81861. * The VRPose will contain the position, orientation, velocity,
  81862. * and acceleration of each of these properties.
  81863. * @returns the pose object
  81864. */
  81865. getPose(): VRPose;
  81866. /**
  81867. * Return the current instantaneous pose of the VRDisplay, with no
  81868. * prediction applied.
  81869. * @returns the current instantaneous pose
  81870. */
  81871. getImmediatePose(): VRPose;
  81872. /**
  81873. * The callback passed to `requestAnimationFrame` will be called
  81874. * any time a new frame should be rendered. When the VRDisplay is
  81875. * presenting the callback will be called at the native refresh
  81876. * rate of the HMD. When not presenting this function acts
  81877. * identically to how window.requestAnimationFrame acts. Content should
  81878. * make no assumptions of frame rate or vsync behavior as the HMD runs
  81879. * asynchronously from other displays and at differing refresh rates.
  81880. * @param callback Define the action to run next frame
  81881. * @returns the request handle it
  81882. */
  81883. requestAnimationFrame(callback: FrameRequestCallback): number;
  81884. /**
  81885. * Begin presenting to the VRDisplay. Must be called in response to a user gesture.
  81886. * Repeat calls while already presenting will update the VRLayers being displayed.
  81887. * @param layers Define the list of layer to present
  81888. * @returns a promise to know when the request has been fulfilled
  81889. */
  81890. requestPresent(layers: VRLayer[]): Promise<void>;
  81891. /**
  81892. * Reset the pose for this display, treating its current position and
  81893. * orientation as the "origin/zero" values. VRPose.position,
  81894. * VRPose.orientation, and VRStageParameters.sittingToStandingTransform may be
  81895. * updated when calling resetPose(). This should be called in only
  81896. * sitting-space experiences.
  81897. */
  81898. resetPose(): void;
  81899. /**
  81900. * The VRLayer provided to the VRDisplay will be captured and presented
  81901. * in the HMD. Calling this function has the same effect on the source
  81902. * canvas as any other operation that uses its source image, and canvases
  81903. * created without preserveDrawingBuffer set to true will be cleared.
  81904. * @param pose Define the pose to submit
  81905. */
  81906. submitFrame(pose?: VRPose): void;
  81907. }
  81908. declare var VRDisplay: {
  81909. prototype: VRDisplay;
  81910. new(): VRDisplay;
  81911. };
  81912. interface VRLayer {
  81913. leftBounds?: number[] | Float32Array | null;
  81914. rightBounds?: number[] | Float32Array | null;
  81915. source?: HTMLCanvasElement | null;
  81916. }
  81917. interface VRDisplayCapabilities {
  81918. readonly canPresent: boolean;
  81919. readonly hasExternalDisplay: boolean;
  81920. readonly hasOrientation: boolean;
  81921. readonly hasPosition: boolean;
  81922. readonly maxLayers: number;
  81923. }
  81924. interface VREyeParameters {
  81925. /** @deprecated */
  81926. readonly fieldOfView: VRFieldOfView;
  81927. readonly offset: Float32Array;
  81928. readonly renderHeight: number;
  81929. readonly renderWidth: number;
  81930. }
  81931. interface VRFieldOfView {
  81932. readonly downDegrees: number;
  81933. readonly leftDegrees: number;
  81934. readonly rightDegrees: number;
  81935. readonly upDegrees: number;
  81936. }
  81937. interface VRFrameData {
  81938. readonly leftProjectionMatrix: Float32Array;
  81939. readonly leftViewMatrix: Float32Array;
  81940. readonly pose: VRPose;
  81941. readonly rightProjectionMatrix: Float32Array;
  81942. readonly rightViewMatrix: Float32Array;
  81943. readonly timestamp: number;
  81944. }
  81945. interface VRPose {
  81946. readonly angularAcceleration: Float32Array | null;
  81947. readonly angularVelocity: Float32Array | null;
  81948. readonly linearAcceleration: Float32Array | null;
  81949. readonly linearVelocity: Float32Array | null;
  81950. readonly orientation: Float32Array | null;
  81951. readonly position: Float32Array | null;
  81952. readonly timestamp: number;
  81953. }
  81954. interface VRStageParameters {
  81955. sittingToStandingTransform?: Float32Array;
  81956. sizeX?: number;
  81957. sizeY?: number;
  81958. }
  81959. interface Navigator {
  81960. getVRDisplays(): Promise<VRDisplay[]>;
  81961. readonly activeVRDisplays: ReadonlyArray<VRDisplay>;
  81962. }
  81963. interface Window {
  81964. onvrdisplayconnected: ((this: Window, ev: Event) => any) | null;
  81965. onvrdisplaydisconnected: ((this: Window, ev: Event) => any) | null;
  81966. onvrdisplaypresentchange: ((this: Window, ev: Event) => any) | null;
  81967. addEventListener(type: "vrdisplayconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  81968. addEventListener(type: "vrdisplaydisconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  81969. addEventListener(type: "vrdisplaypresentchange", listener: (ev: Event) => any, useCapture?: boolean): void;
  81970. }
  81971. interface Gamepad {
  81972. readonly displayId: number;
  81973. }
  81974. /**
  81975. * Available session modes
  81976. */
  81977. type XRSessionMode = "inline" | "immersive-vr" | "immersive-ar";
  81978. /**
  81979. * Reference space types
  81980. */
  81981. type XRReferenceSpaceType = "viewer" | "local" | "local-floor" | "bounded-floor" | "unbounded";
  81982. type XREnvironmentBlendMode = "opaque" | "additive" | "alpha-blend";
  81983. type XRVisibilityState = "visible" | "visible-blurred" | "hidden";
  81984. /**
  81985. * Handedness types
  81986. */
  81987. type XRHandedness = "none" | "left" | "right";
  81988. /**
  81989. * InputSource target ray modes
  81990. */
  81991. type XRTargetRayMode = "gaze" | "tracked-pointer" | "screen";
  81992. /**
  81993. * Eye types
  81994. */
  81995. type XREye = "none" | "left" | "right";
  81996. /**
  81997. * Type of XR events available
  81998. */
  81999. type XREventType = "devicechange" | "visibilitychange" | "end" | "inputsourceschange" | "select" | "selectstart" | "selectend" | "squeeze" | "squeezestart" | "squeezeend" | "reset";
  82000. type XRFrameRequestCallback = (time: DOMHighResTimeStamp, frame: XRFrame) => void;
  82001. type XRPlaneSet = Set<XRPlane>;
  82002. type XRAnchorSet = Set<XRAnchor>;
  82003. type XREventHandler = (callback: any) => void;
  82004. interface XRLayer extends EventTarget {}
  82005. interface XRSessionInit {
  82006. optionalFeatures?: string[];
  82007. requiredFeatures?: string[];
  82008. trackedImages?: XRTrackedImageInit[];
  82009. }
  82010. interface XRSessionEvent extends Event {
  82011. readonly session: XRSession;
  82012. }
  82013. interface XRSystem {
  82014. isSessionSupported: (sessionMode: XRSessionMode) => Promise<boolean>;
  82015. requestSession: (sessionMode: XRSessionMode, sessionInit?: any) => Promise<XRSession>;
  82016. }
  82017. interface XRViewport {
  82018. readonly x: number;
  82019. readonly y: number;
  82020. readonly width: number;
  82021. readonly height: number;
  82022. }
  82023. interface XRWebGLLayerInit {
  82024. antialias?: boolean;
  82025. depth?: boolean;
  82026. stencil?: boolean;
  82027. alpha?: boolean;
  82028. multiview?: boolean;
  82029. framebufferScaleFactor?: number;
  82030. }
  82031. declare class XRWebGLLayer {
  82032. static getNativeFramebufferScaleFactor(session: XRSession): number;
  82033. constructor(session: XRSession, context: WebGLRenderingContext | WebGL2RenderingContext, layerInit?: XRWebGLLayerInit);
  82034. readonly antialias: boolean;
  82035. readonly framebuffer: WebGLFramebuffer;
  82036. readonly framebufferWidth: number;
  82037. readonly framebufferHeight: number;
  82038. readonly ignoreDepthValues: boolean;
  82039. getViewport: (view: XRView) => XRViewport;
  82040. }
  82041. // tslint:disable-next-line no-empty-interface
  82042. interface XRSpace extends EventTarget {}
  82043. interface XRRenderState {
  82044. readonly baseLayer?: XRWebGLLayer;
  82045. readonly depthFar: number;
  82046. readonly depthNear: number;
  82047. readonly inlineVerticalFieldOfView?: number;
  82048. }
  82049. interface XRRenderStateInit extends XRRenderState {
  82050. baseLayer: XRWebGLLayer;
  82051. depthFar: number;
  82052. depthNear: number;
  82053. inlineVerticalFieldOfView?: number;
  82054. layers?: XRLayer[];
  82055. }
  82056. interface XRReferenceSpace extends XRSpace {
  82057. getOffsetReferenceSpace(originOffset: XRRigidTransform): XRReferenceSpace;
  82058. onreset: XREventHandler;
  82059. }
  82060. interface XRBoundedReferenceSpace extends XRSpace {
  82061. readonly boundsGeometry: DOMPointReadOnly[];
  82062. }
  82063. interface XRInputSource {
  82064. readonly handedness: XRHandedness;
  82065. readonly targetRayMode: XRTargetRayMode;
  82066. readonly targetRaySpace: XRSpace;
  82067. readonly gripSpace?: XRSpace;
  82068. readonly gamepad?: Gamepad;
  82069. readonly profiles: Array<string>;
  82070. readonly hand?: XRHand;
  82071. }
  82072. interface XRPose {
  82073. readonly transform: XRRigidTransform;
  82074. readonly emulatedPosition: boolean;
  82075. }
  82076. interface XRWorldInformation {
  82077. detectedPlanes?: XRPlaneSet;
  82078. }
  82079. interface XRFrame {
  82080. readonly session: XRSession;
  82081. getPose(space: XRSpace, baseSpace: XRSpace): XRPose | undefined;
  82082. getViewerPose(referenceSpace: XRReferenceSpace): XRViewerPose | undefined;
  82083. // AR
  82084. getHitTestResults(hitTestSource: XRHitTestSource): Array<XRHitTestResult>;
  82085. getHitTestResultsForTransientInput(hitTestSource: XRTransientInputHitTestSource): Array<XRTransientInputHitTestResult>;
  82086. // Anchors
  82087. trackedAnchors?: XRAnchorSet;
  82088. createAnchor?(pose: XRRigidTransform, space: XRSpace): Promise<XRAnchor>;
  82089. // World geometries
  82090. worldInformation?: XRWorldInformation;
  82091. // Hand tracking
  82092. getJointPose?(joint: XRJointSpace, baseSpace: XRSpace): XRJointPose;
  82093. // Image tracking
  82094. getImageTrackingResults?(): Array<XRImageTrackingResult>;
  82095. }
  82096. interface XRInputSourceEvent extends Event {
  82097. readonly frame: XRFrame;
  82098. readonly inputSource: XRInputSource;
  82099. }
  82100. type XRInputSourceArray = XRInputSource[];
  82101. interface XRSession {
  82102. addEventListener(type: XREventType, listener: XREventHandler, options?: boolean | AddEventListenerOptions): void;
  82103. removeEventListener(type: XREventType, listener: XREventHandler, options?: boolean | EventListenerOptions): void;
  82104. /**
  82105. * Returns a list of this session's XRInputSources, each representing an input device
  82106. * used to control the camera and/or scene.
  82107. */
  82108. readonly inputSources: Array<XRInputSource>;
  82109. /**
  82110. * object which contains options affecting how the imagery is rendered.
  82111. * This includes things such as the near and far clipping planes
  82112. */
  82113. readonly renderState: XRRenderState;
  82114. readonly visibilityState: XRVisibilityState;
  82115. /**
  82116. * Removes a callback from the animation frame painting callback from
  82117. * XRSession's set of animation frame rendering callbacks, given the
  82118. * identifying handle returned by a previous call to requestAnimationFrame().
  82119. */
  82120. cancelAnimationFrame: (handle: number) => void;
  82121. /**
  82122. * Ends the WebXR session. Returns a promise which resolves when the
  82123. * session has been shut down.
  82124. */
  82125. end(): Promise<void>;
  82126. /**
  82127. * Schedules the specified method to be called the next time the user agent
  82128. * is working on rendering an animation frame for the WebXR device. Returns an
  82129. * integer value which can be used to identify the request for the purposes of
  82130. * canceling the callback using cancelAnimationFrame(). This method is comparable
  82131. * to the Window.requestAnimationFrame() method.
  82132. */
  82133. requestAnimationFrame: XRFrameRequestCallback;
  82134. /**
  82135. * Requests that a new XRReferenceSpace of the specified type be created.
  82136. * Returns a promise which resolves with the XRReferenceSpace or
  82137. * XRBoundedReferenceSpace which was requested, or throws a NotSupportedError if
  82138. * the requested space type isn't supported by the device.
  82139. */
  82140. requestReferenceSpace(type: XRReferenceSpaceType): Promise<XRReferenceSpace | XRBoundedReferenceSpace>;
  82141. updateRenderState(XRRenderStateInit: XRRenderState): Promise<void>;
  82142. onend: XREventHandler;
  82143. oninputsourceschange: XREventHandler;
  82144. onselect: XREventHandler;
  82145. onselectstart: XREventHandler;
  82146. onselectend: XREventHandler;
  82147. onsqueeze: XREventHandler;
  82148. onsqueezestart: XREventHandler;
  82149. onsqueezeend: XREventHandler;
  82150. onvisibilitychange: XREventHandler;
  82151. // hit test
  82152. requestHitTestSource?(options: XRHitTestOptionsInit): Promise<XRHitTestSource>;
  82153. requestHitTestSourceForTransientInput?(options: XRTransientInputHitTestOptionsInit): Promise<XRTransientInputHitTestSource>;
  82154. // legacy AR hit test
  82155. requestHitTest?(ray: XRRay, referenceSpace: XRReferenceSpace): Promise<XRHitResult[]>;
  82156. // legacy plane detection
  82157. updateWorldTrackingState?(options: { planeDetectionState?: { enabled: boolean } }): void;
  82158. // image tracking
  82159. getTrackedImageScores?(): XRImageTrackingScore[];
  82160. }
  82161. interface XRViewerPose extends XRPose {
  82162. readonly views: Array<XRView>;
  82163. }
  82164. declare class XRRigidTransform {
  82165. constructor(position?: DOMPointInit, direction?: DOMPointInit);
  82166. position: DOMPointReadOnly;
  82167. orientation: DOMPointReadOnly;
  82168. matrix: Float32Array;
  82169. inverse: XRRigidTransform;
  82170. }
  82171. interface XRView {
  82172. readonly eye: XREye;
  82173. readonly projectionMatrix: Float32Array;
  82174. readonly transform: XRRigidTransform;
  82175. readonly recommendedViewportScale?: number;
  82176. requestViewportScale(scale: number): void;
  82177. }
  82178. interface XRInputSourceChangeEvent extends Event {
  82179. session: XRSession;
  82180. removed: Array<XRInputSource>;
  82181. added: Array<XRInputSource>;
  82182. }
  82183. // Experimental/Draft features
  82184. declare class XRRay {
  82185. constructor(transformOrOrigin: XRRigidTransform | DOMPointInit, direction?: DOMPointInit);
  82186. origin: DOMPointReadOnly;
  82187. direction: DOMPointReadOnly;
  82188. matrix: Float32Array;
  82189. }
  82190. declare enum XRHitTestTrackableType {
  82191. "point",
  82192. "plane",
  82193. "mesh",
  82194. }
  82195. interface XRHitResult {
  82196. hitMatrix: Float32Array;
  82197. }
  82198. interface XRTransientInputHitTestResult {
  82199. readonly inputSource: XRInputSource;
  82200. readonly results: Array<XRHitTestResult>;
  82201. }
  82202. interface XRHitTestResult {
  82203. getPose(baseSpace: XRSpace): XRPose | undefined;
  82204. // When anchor system is enabled
  82205. createAnchor?(pose: XRRigidTransform): Promise<XRAnchor>;
  82206. }
  82207. interface XRHitTestSource {
  82208. cancel(): void;
  82209. }
  82210. interface XRTransientInputHitTestSource {
  82211. cancel(): void;
  82212. }
  82213. interface XRHitTestOptionsInit {
  82214. space: XRSpace;
  82215. entityTypes?: Array<XRHitTestTrackableType>;
  82216. offsetRay?: XRRay;
  82217. }
  82218. interface XRTransientInputHitTestOptionsInit {
  82219. profile: string;
  82220. entityTypes?: Array<XRHitTestTrackableType>;
  82221. offsetRay?: XRRay;
  82222. }
  82223. interface XRAnchor {
  82224. anchorSpace: XRSpace;
  82225. delete(): void;
  82226. }
  82227. interface XRPlane {
  82228. orientation: "Horizontal" | "Vertical";
  82229. planeSpace: XRSpace;
  82230. polygon: Array<DOMPointReadOnly>;
  82231. lastChangedTime: number;
  82232. }
  82233. interface XRJointSpace extends XRSpace {}
  82234. interface XRJointPose extends XRPose {
  82235. radius: number | undefined;
  82236. }
  82237. interface XRHand extends Iterable<XRJointSpace> {
  82238. readonly length: number;
  82239. [index: number]: XRJointSpace;
  82240. readonly WRIST: number;
  82241. readonly THUMB_METACARPAL: number;
  82242. readonly THUMB_PHALANX_PROXIMAL: number;
  82243. readonly THUMB_PHALANX_DISTAL: number;
  82244. readonly THUMB_PHALANX_TIP: number;
  82245. readonly INDEX_METACARPAL: number;
  82246. readonly INDEX_PHALANX_PROXIMAL: number;
  82247. readonly INDEX_PHALANX_INTERMEDIATE: number;
  82248. readonly INDEX_PHALANX_DISTAL: number;
  82249. readonly INDEX_PHALANX_TIP: number;
  82250. readonly MIDDLE_METACARPAL: number;
  82251. readonly MIDDLE_PHALANX_PROXIMAL: number;
  82252. readonly MIDDLE_PHALANX_INTERMEDIATE: number;
  82253. readonly MIDDLE_PHALANX_DISTAL: number;
  82254. readonly MIDDLE_PHALANX_TIP: number;
  82255. readonly RING_METACARPAL: number;
  82256. readonly RING_PHALANX_PROXIMAL: number;
  82257. readonly RING_PHALANX_INTERMEDIATE: number;
  82258. readonly RING_PHALANX_DISTAL: number;
  82259. readonly RING_PHALANX_TIP: number;
  82260. readonly LITTLE_METACARPAL: number;
  82261. readonly LITTLE_PHALANX_PROXIMAL: number;
  82262. readonly LITTLE_PHALANX_INTERMEDIATE: number;
  82263. readonly LITTLE_PHALANX_DISTAL: number;
  82264. readonly LITTLE_PHALANX_TIP: number;
  82265. }
  82266. type XRImageTrackingState = "tracked" | "emulated";
  82267. type XRImageTrackingScore = "untrackable" | "trackable";
  82268. interface XRTrackedImageInit {
  82269. image: ImageBitmap;
  82270. widthInMeters: number;
  82271. }
  82272. interface XRImageTrackingResult {
  82273. readonly imageSpace: XRSpace;
  82274. readonly index: number;
  82275. readonly trackingState: XRImageTrackingState;
  82276. readonly measuredWidthInMeters: number;
  82277. }
  82278. // This file contains native only extensions for WebXR. These APIs are not supported in the browser yet.
  82279. // They are intended for use with either Babylon Native https://github.com/BabylonJS/BabylonNative or
  82280. // Babylon React Native: https://github.com/BabylonJS/BabylonReactNative
  82281. type XRSceneObjectType = "unknown" | "background" | "wall" | "floor" | "ceiling" | "platform";
  82282. interface XRSceneObject {
  82283. type: XRSceneObjectType;
  82284. }
  82285. interface XRFieldOfView {
  82286. angleLeft: number;
  82287. angleRight: number;
  82288. angleUp: number;
  82289. angleDown: number;
  82290. }
  82291. interface XRFrustum {
  82292. position: DOMPointReadOnly;
  82293. orientation: DOMPointReadOnly;
  82294. fieldOfView: XRFieldOfView;
  82295. farDistance: number;
  82296. }
  82297. interface XRPlane {
  82298. parentSceneObject?: XRSceneObject;
  82299. }
  82300. interface XRMesh {
  82301. meshSpace: XRSpace;
  82302. positions: Float32Array;
  82303. indices: Uint32Array;
  82304. normals?: Float32Array;
  82305. lastChangedTime: number;
  82306. parentSceneObject?: XRSceneObject;
  82307. }
  82308. interface XRFrustumDetectionBoundary {
  82309. type: "frustum";
  82310. frustum: XRFrustum;
  82311. }
  82312. interface XRSphereDetectionBoundary {
  82313. type: "sphere";
  82314. radius: number;
  82315. }
  82316. interface XRBoxDetectionBoundary {
  82317. type: "box";
  82318. extent: DOMPointReadOnly;
  82319. }
  82320. type XRDetectionBoundary = XRFrustumDetectionBoundary | XRSphereDetectionBoundary | XRBoxDetectionBoundary;
  82321. interface XRGeometryDetectorOptions {
  82322. detectionBoundary?: XRDetectionBoundary;
  82323. updateInterval?: number;
  82324. }
  82325. interface XRSession {
  82326. trySetFeaturePointCloudEnabled(enabled: boolean): boolean;
  82327. trySetPreferredPlaneDetectorOptions(preferredOptions: XRGeometryDetectorOptions): boolean;
  82328. trySetMeshDetectorEnabled(enabled: boolean): boolean;
  82329. trySetPreferredMeshDetectorOptions(preferredOptions: XRGeometryDetectorOptions): boolean;
  82330. }
  82331. interface XRFrame {
  82332. featurePointCloud?: Array<number>;
  82333. }
  82334. type XRMeshSet = Set<XRMesh>;
  82335. interface XRWorldInformation {
  82336. detectedMeshes?: XRMeshSet;
  82337. }
  82338. /**
  82339. * @ignore
  82340. */
  82341. declare module BABYLON.GLTF2.Exporter {
  82342. }
  82343. /**
  82344. * @ignore
  82345. */
  82346. declare module BABYLON.GLTF1 {
  82347. }
  82348. declare module BABYLON.GUI {
  82349. /**
  82350. * Interface used to define a control that can receive focus
  82351. */
  82352. export interface IFocusableControl {
  82353. /**
  82354. * Function called when the control receives the focus
  82355. */
  82356. onFocus(): void;
  82357. /**
  82358. * Function called when the control loses the focus
  82359. */
  82360. onBlur(): void;
  82361. /**
  82362. * Function called to let the control handle keyboard events
  82363. * @param evt defines the current keyboard event
  82364. */
  82365. processKeyboard(evt: KeyboardEvent): void;
  82366. /**
  82367. * Function called to get the list of controls that should not steal the focus from this control
  82368. * @returns an array of controls
  82369. */
  82370. keepsFocusWith(): BABYLON.Nullable<Control[]>;
  82371. /**
  82372. * Function to focus the control programmatically
  82373. */
  82374. focus(): void;
  82375. /**
  82376. * Function to unfocus the control programmatically
  82377. */
  82378. blur(): void;
  82379. }
  82380. }
  82381. declare module BABYLON.GUI {
  82382. /**
  82383. * Class used to specific a value and its associated unit
  82384. */
  82385. export class ValueAndUnit {
  82386. /** defines the unit to store */
  82387. unit: number;
  82388. /** defines a boolean indicating if the value can be negative */
  82389. negativeValueAllowed: boolean;
  82390. private _value;
  82391. private _originalUnit;
  82392. /**
  82393. * Gets or sets a value indicating that this value will not scale accordingly with adaptive scaling property
  82394. * @see https://doc.babylonjs.com/how_to/gui#adaptive-scaling
  82395. */
  82396. ignoreAdaptiveScaling: boolean;
  82397. /**
  82398. * Creates a new ValueAndUnit
  82399. * @param value defines the value to store
  82400. * @param unit defines the unit to store
  82401. * @param negativeValueAllowed defines a boolean indicating if the value can be negative
  82402. */
  82403. constructor(value: number,
  82404. /** defines the unit to store */
  82405. unit?: number,
  82406. /** defines a boolean indicating if the value can be negative */
  82407. negativeValueAllowed?: boolean);
  82408. /** Gets a boolean indicating if the value is a percentage */
  82409. get isPercentage(): boolean;
  82410. /** Gets a boolean indicating if the value is store as pixel */
  82411. get isPixel(): boolean;
  82412. /** Gets direct internal value */
  82413. get internalValue(): number;
  82414. /**
  82415. * Gets value as pixel
  82416. * @param host defines the root host
  82417. * @param refValue defines the reference value for percentages
  82418. * @returns the value as pixel
  82419. */
  82420. getValueInPixel(host: AdvancedDynamicTexture, refValue: number): number;
  82421. /**
  82422. * Update the current value and unit. This should be done cautiously as the GUi won't be marked as dirty with this function.
  82423. * @param value defines the value to store
  82424. * @param unit defines the unit to store
  82425. * @returns the current ValueAndUnit
  82426. */
  82427. updateInPlace(value: number, unit?: number): ValueAndUnit;
  82428. /**
  82429. * Gets the value accordingly to its unit
  82430. * @param host defines the root host
  82431. * @returns the value
  82432. */
  82433. getValue(host: AdvancedDynamicTexture): number;
  82434. /**
  82435. * Gets a string representation of the value
  82436. * @param host defines the root host
  82437. * @param decimals defines an optional number of decimals to display
  82438. * @returns a string
  82439. */
  82440. toString(host: AdvancedDynamicTexture, decimals?: number): string;
  82441. /**
  82442. * Store a value parsed from a string
  82443. * @param source defines the source string
  82444. * @returns true if the value was successfully parsed
  82445. */
  82446. fromString(source: string | number): boolean;
  82447. private static _Regex;
  82448. private static _UNITMODE_PERCENTAGE;
  82449. private static _UNITMODE_PIXEL;
  82450. /** UNITMODE_PERCENTAGE */
  82451. static get UNITMODE_PERCENTAGE(): number;
  82452. /** UNITMODE_PIXEL */
  82453. static get UNITMODE_PIXEL(): number;
  82454. }
  82455. }
  82456. declare module BABYLON.GUI {
  82457. /**
  82458. * Define a style used by control to automatically setup properties based on a template.
  82459. * Only support font related properties so far
  82460. */
  82461. export class Style implements BABYLON.IDisposable {
  82462. private _fontFamily;
  82463. private _fontStyle;
  82464. private _fontWeight;
  82465. /** @hidden */
  82466. _host: AdvancedDynamicTexture;
  82467. /** @hidden */
  82468. _fontSize: ValueAndUnit;
  82469. /**
  82470. * BABYLON.Observable raised when the style values are changed
  82471. */
  82472. onChangedObservable: BABYLON.Observable<Style>;
  82473. /**
  82474. * Creates a new style object
  82475. * @param host defines the AdvancedDynamicTexture which hosts this style
  82476. */
  82477. constructor(host: AdvancedDynamicTexture);
  82478. /**
  82479. * Gets or sets the font size
  82480. */
  82481. get fontSize(): string | number;
  82482. set fontSize(value: string | number);
  82483. /**
  82484. * Gets or sets the font family
  82485. */
  82486. get fontFamily(): string;
  82487. set fontFamily(value: string);
  82488. /**
  82489. * Gets or sets the font style
  82490. */
  82491. get fontStyle(): string;
  82492. set fontStyle(value: string);
  82493. /** Gets or sets font weight */
  82494. get fontWeight(): string;
  82495. set fontWeight(value: string);
  82496. /** Dispose all associated resources */
  82497. dispose(): void;
  82498. }
  82499. }
  82500. declare module BABYLON.GUI {
  82501. /**
  82502. * Class used to transport BABYLON.Vector2 information for pointer events
  82503. */
  82504. export class Vector2WithInfo extends BABYLON.Vector2 {
  82505. /** defines the current mouse button index */
  82506. buttonIndex: number;
  82507. /**
  82508. * Creates a new Vector2WithInfo
  82509. * @param source defines the vector2 data to transport
  82510. * @param buttonIndex defines the current mouse button index
  82511. */
  82512. constructor(source: BABYLON.Vector2,
  82513. /** defines the current mouse button index */
  82514. buttonIndex?: number);
  82515. }
  82516. /** Class used to provide 2D matrix features */
  82517. export class Matrix2D {
  82518. /** Gets the internal array of 6 floats used to store matrix data */
  82519. m: Float32Array;
  82520. /**
  82521. * Creates a new matrix
  82522. * @param m00 defines value for (0, 0)
  82523. * @param m01 defines value for (0, 1)
  82524. * @param m10 defines value for (1, 0)
  82525. * @param m11 defines value for (1, 1)
  82526. * @param m20 defines value for (2, 0)
  82527. * @param m21 defines value for (2, 1)
  82528. */
  82529. constructor(m00: number, m01: number, m10: number, m11: number, m20: number, m21: number);
  82530. /**
  82531. * Fills the matrix from direct values
  82532. * @param m00 defines value for (0, 0)
  82533. * @param m01 defines value for (0, 1)
  82534. * @param m10 defines value for (1, 0)
  82535. * @param m11 defines value for (1, 1)
  82536. * @param m20 defines value for (2, 0)
  82537. * @param m21 defines value for (2, 1)
  82538. * @returns the current modified matrix
  82539. */
  82540. fromValues(m00: number, m01: number, m10: number, m11: number, m20: number, m21: number): Matrix2D;
  82541. /**
  82542. * Gets matrix determinant
  82543. * @returns the determinant
  82544. */
  82545. determinant(): number;
  82546. /**
  82547. * Inverses the matrix and stores it in a target matrix
  82548. * @param result defines the target matrix
  82549. * @returns the current matrix
  82550. */
  82551. invertToRef(result: Matrix2D): Matrix2D;
  82552. /**
  82553. * Multiplies the current matrix with another one
  82554. * @param other defines the second operand
  82555. * @param result defines the target matrix
  82556. * @returns the current matrix
  82557. */
  82558. multiplyToRef(other: Matrix2D, result: Matrix2D): Matrix2D;
  82559. /**
  82560. * Applies the current matrix to a set of 2 floats and stores the result in a vector2
  82561. * @param x defines the x coordinate to transform
  82562. * @param y defines the x coordinate to transform
  82563. * @param result defines the target vector2
  82564. * @returns the current matrix
  82565. */
  82566. transformCoordinates(x: number, y: number, result: BABYLON.Vector2): Matrix2D;
  82567. /**
  82568. * Creates an identity matrix
  82569. * @returns a new matrix
  82570. */
  82571. static Identity(): Matrix2D;
  82572. /**
  82573. * Creates a translation matrix and stores it in a target matrix
  82574. * @param x defines the x coordinate of the translation
  82575. * @param y defines the y coordinate of the translation
  82576. * @param result defines the target matrix
  82577. */
  82578. static TranslationToRef(x: number, y: number, result: Matrix2D): void;
  82579. /**
  82580. * Creates a scaling matrix and stores it in a target matrix
  82581. * @param x defines the x coordinate of the scaling
  82582. * @param y defines the y coordinate of the scaling
  82583. * @param result defines the target matrix
  82584. */
  82585. static ScalingToRef(x: number, y: number, result: Matrix2D): void;
  82586. /**
  82587. * Creates a rotation matrix and stores it in a target matrix
  82588. * @param angle defines the rotation angle
  82589. * @param result defines the target matrix
  82590. */
  82591. static RotationToRef(angle: number, result: Matrix2D): void;
  82592. private static _TempPreTranslationMatrix;
  82593. private static _TempPostTranslationMatrix;
  82594. private static _TempRotationMatrix;
  82595. private static _TempScalingMatrix;
  82596. private static _TempCompose0;
  82597. private static _TempCompose1;
  82598. private static _TempCompose2;
  82599. /**
  82600. * Composes a matrix from translation, rotation, scaling and parent matrix and stores it in a target matrix
  82601. * @param tx defines the x coordinate of the translation
  82602. * @param ty defines the y coordinate of the translation
  82603. * @param angle defines the rotation angle
  82604. * @param scaleX defines the x coordinate of the scaling
  82605. * @param scaleY defines the y coordinate of the scaling
  82606. * @param parentMatrix defines the parent matrix to multiply by (can be null)
  82607. * @param result defines the target matrix
  82608. */
  82609. static ComposeToRef(tx: number, ty: number, angle: number, scaleX: number, scaleY: number, parentMatrix: BABYLON.Nullable<Matrix2D>, result: Matrix2D): void;
  82610. }
  82611. }
  82612. declare module BABYLON.GUI {
  82613. /**
  82614. * Class used to store 2D control sizes
  82615. */
  82616. export class Measure {
  82617. /** defines left coordinate */
  82618. left: number;
  82619. /** defines top coordinate */
  82620. top: number;
  82621. /** defines width dimension */
  82622. width: number;
  82623. /** defines height dimension */
  82624. height: number;
  82625. /**
  82626. * Creates a new measure
  82627. * @param left defines left coordinate
  82628. * @param top defines top coordinate
  82629. * @param width defines width dimension
  82630. * @param height defines height dimension
  82631. */
  82632. constructor(
  82633. /** defines left coordinate */
  82634. left: number,
  82635. /** defines top coordinate */
  82636. top: number,
  82637. /** defines width dimension */
  82638. width: number,
  82639. /** defines height dimension */
  82640. height: number);
  82641. /**
  82642. * Copy from another measure
  82643. * @param other defines the other measure to copy from
  82644. */
  82645. copyFrom(other: Measure): void;
  82646. /**
  82647. * Copy from a group of 4 floats
  82648. * @param left defines left coordinate
  82649. * @param top defines top coordinate
  82650. * @param width defines width dimension
  82651. * @param height defines height dimension
  82652. */
  82653. copyFromFloats(left: number, top: number, width: number, height: number): void;
  82654. /**
  82655. * Computes the axis aligned bounding box measure for two given measures
  82656. * @param a Input measure
  82657. * @param b Input measure
  82658. * @param result the resulting bounding measure
  82659. */
  82660. static CombineToRef(a: Measure, b: Measure, result: Measure): void;
  82661. /**
  82662. * Computes the axis aligned bounding box of the measure after it is modified by a given transform
  82663. * @param transform the matrix to transform the measure before computing the AABB
  82664. * @param addX number to add to left
  82665. * @param addY number to add to top
  82666. * @param addWidth number to add to width
  82667. * @param addHeight number to add to height
  82668. * @param result the resulting AABB
  82669. */
  82670. addAndTransformToRef(transform: Matrix2D, addX: number, addY: number, addWidth: number, addHeight: number, result: Measure): void;
  82671. /**
  82672. * Computes the axis aligned bounding box of the measure after it is modified by a given transform
  82673. * @param transform the matrix to transform the measure before computing the AABB
  82674. * @param result the resulting AABB
  82675. */
  82676. transformToRef(transform: Matrix2D, result: Measure): void;
  82677. /**
  82678. * Check equality between this measure and another one
  82679. * @param other defines the other measures
  82680. * @returns true if both measures are equals
  82681. */
  82682. isEqualsTo(other: Measure): boolean;
  82683. /**
  82684. * Creates an empty measure
  82685. * @returns a new measure
  82686. */
  82687. static Empty(): Measure;
  82688. }
  82689. }
  82690. declare module BABYLON.GUI {
  82691. /**
  82692. * Class used to create texture to support 2D GUI elements
  82693. * @see https://doc.babylonjs.com/how_to/gui
  82694. */
  82695. export class AdvancedDynamicTexture extends BABYLON.DynamicTexture {
  82696. /** Define the Uurl to load snippets */
  82697. static SnippetUrl: string;
  82698. /** Snippet ID if the content was created from the snippet server */
  82699. snippetId: string;
  82700. private _isDirty;
  82701. private _renderObserver;
  82702. private _resizeObserver;
  82703. private _preKeyboardObserver;
  82704. private _pointerMoveObserver;
  82705. private _pointerObserver;
  82706. private _canvasPointerOutObserver;
  82707. private _canvasBlurObserver;
  82708. private _background;
  82709. /** @hidden */
  82710. _rootContainer: Container;
  82711. /** @hidden */
  82712. _lastPickedControl: Control;
  82713. /** @hidden */
  82714. _lastControlOver: {
  82715. [pointerId: number]: Control;
  82716. };
  82717. /** @hidden */
  82718. _lastControlDown: {
  82719. [pointerId: number]: Control;
  82720. };
  82721. /** @hidden */
  82722. _capturingControl: {
  82723. [pointerId: number]: Control;
  82724. };
  82725. /** @hidden */
  82726. _shouldBlockPointer: boolean;
  82727. /** @hidden */
  82728. _layerToDispose: BABYLON.Nullable<BABYLON.Layer>;
  82729. /** @hidden */
  82730. _linkedControls: Control[];
  82731. private _isFullscreen;
  82732. private _fullscreenViewport;
  82733. private _idealWidth;
  82734. private _idealHeight;
  82735. private _useSmallestIdeal;
  82736. private _renderAtIdealSize;
  82737. private _focusedControl;
  82738. private _blockNextFocusCheck;
  82739. private _renderScale;
  82740. private _rootElement;
  82741. private _cursorChanged;
  82742. private _defaultMousePointerId;
  82743. /** @hidden */
  82744. _numLayoutCalls: number;
  82745. /** Gets the number of layout calls made the last time the ADT has been rendered */
  82746. get numLayoutCalls(): number;
  82747. /** @hidden */
  82748. _numRenderCalls: number;
  82749. /** Gets the number of render calls made the last time the ADT has been rendered */
  82750. get numRenderCalls(): number;
  82751. /**
  82752. * Define type to string to ensure compatibility across browsers
  82753. * Safari doesn't support DataTransfer constructor
  82754. */
  82755. private _clipboardData;
  82756. /**
  82757. * BABYLON.Observable event triggered each time an clipboard event is received from the rendering canvas
  82758. */
  82759. onClipboardObservable: BABYLON.Observable<BABYLON.ClipboardInfo>;
  82760. /**
  82761. * BABYLON.Observable event triggered each time a pointer down is intercepted by a control
  82762. */
  82763. onControlPickedObservable: BABYLON.Observable<Control>;
  82764. /**
  82765. * BABYLON.Observable event triggered before layout is evaluated
  82766. */
  82767. onBeginLayoutObservable: BABYLON.Observable<AdvancedDynamicTexture>;
  82768. /**
  82769. * BABYLON.Observable event triggered after the layout was evaluated
  82770. */
  82771. onEndLayoutObservable: BABYLON.Observable<AdvancedDynamicTexture>;
  82772. /**
  82773. * BABYLON.Observable event triggered before the texture is rendered
  82774. */
  82775. onBeginRenderObservable: BABYLON.Observable<AdvancedDynamicTexture>;
  82776. /**
  82777. * BABYLON.Observable event triggered after the texture was rendered
  82778. */
  82779. onEndRenderObservable: BABYLON.Observable<AdvancedDynamicTexture>;
  82780. /**
  82781. * Gets or sets a boolean defining if alpha is stored as premultiplied
  82782. */
  82783. premulAlpha: boolean;
  82784. /**
  82785. * Gets or sets a boolean indicating that the canvas must be reverted on Y when updating the texture
  82786. */
  82787. applyYInversionOnUpdate: boolean;
  82788. /**
  82789. * Gets or sets a number used to scale rendering size (2 means that the texture will be twice bigger).
  82790. * Useful when you want more antialiasing
  82791. */
  82792. get renderScale(): number;
  82793. set renderScale(value: number);
  82794. /** Gets or sets the background color */
  82795. get background(): string;
  82796. set background(value: string);
  82797. /**
  82798. * Gets or sets the ideal width used to design controls.
  82799. * The GUI will then rescale everything accordingly
  82800. * @see https://doc.babylonjs.com/how_to/gui#adaptive-scaling
  82801. */
  82802. get idealWidth(): number;
  82803. set idealWidth(value: number);
  82804. /**
  82805. * Gets or sets the ideal height used to design controls.
  82806. * The GUI will then rescale everything accordingly
  82807. * @see https://doc.babylonjs.com/how_to/gui#adaptive-scaling
  82808. */
  82809. get idealHeight(): number;
  82810. set idealHeight(value: number);
  82811. /**
  82812. * Gets or sets a boolean indicating if the smallest ideal value must be used if idealWidth and idealHeight are both set
  82813. * @see https://doc.babylonjs.com/how_to/gui#adaptive-scaling
  82814. */
  82815. get useSmallestIdeal(): boolean;
  82816. set useSmallestIdeal(value: boolean);
  82817. /**
  82818. * Gets or sets a boolean indicating if adaptive scaling must be used
  82819. * @see https://doc.babylonjs.com/how_to/gui#adaptive-scaling
  82820. */
  82821. get renderAtIdealSize(): boolean;
  82822. set renderAtIdealSize(value: boolean);
  82823. /**
  82824. * Gets the ratio used when in "ideal mode"
  82825. * @see https://doc.babylonjs.com/how_to/gui#adaptive-scaling
  82826. * */
  82827. get idealRatio(): number;
  82828. /**
  82829. * Gets the underlying layer used to render the texture when in fullscreen mode
  82830. */
  82831. get layer(): BABYLON.Nullable<BABYLON.Layer>;
  82832. /**
  82833. * Gets the root container control
  82834. */
  82835. get rootContainer(): Container;
  82836. /**
  82837. * Returns an array containing the root container.
  82838. * This is mostly used to let the Inspector introspects the ADT
  82839. * @returns an array containing the rootContainer
  82840. */
  82841. getChildren(): Array<Container>;
  82842. /**
  82843. * Will return all controls that are inside this texture
  82844. * @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
  82845. * @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
  82846. * @return all child controls
  82847. */
  82848. getDescendants(directDescendantsOnly?: boolean, predicate?: (control: Control) => boolean): Control[];
  82849. /**
  82850. * Gets or sets the current focused control
  82851. */
  82852. get focusedControl(): BABYLON.Nullable<IFocusableControl>;
  82853. set focusedControl(control: BABYLON.Nullable<IFocusableControl>);
  82854. /**
  82855. * Gets or sets a boolean indicating if the texture must be rendered in background or foreground when in fullscreen mode
  82856. */
  82857. get isForeground(): boolean;
  82858. set isForeground(value: boolean);
  82859. /**
  82860. * Gets or set information about clipboardData
  82861. */
  82862. get clipboardData(): string;
  82863. set clipboardData(value: string);
  82864. /**
  82865. * Creates a new AdvancedDynamicTexture
  82866. * @param name defines the name of the texture
  82867. * @param width defines the width of the texture
  82868. * @param height defines the height of the texture
  82869. * @param scene defines the hosting scene
  82870. * @param generateMipMaps defines a boolean indicating if mipmaps must be generated (false by default)
  82871. * @param samplingMode defines the texture sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  82872. * @param invertY defines if the texture needs to be inverted on the y axis during loading (true by default)
  82873. */
  82874. constructor(name: string, width: number | undefined, height: number | undefined, scene: BABYLON.Nullable<BABYLON.Scene>, generateMipMaps?: boolean, samplingMode?: number, invertY?: boolean);
  82875. /**
  82876. * Get the current class name of the texture useful for serialization or dynamic coding.
  82877. * @returns "AdvancedDynamicTexture"
  82878. */
  82879. getClassName(): string;
  82880. /**
  82881. * Function used to execute a function on all controls
  82882. * @param func defines the function to execute
  82883. * @param container defines the container where controls belong. If null the root container will be used
  82884. */
  82885. executeOnAllControls(func: (control: Control) => void, container?: Container): void;
  82886. private _useInvalidateRectOptimization;
  82887. /**
  82888. * Gets or sets a boolean indicating if the InvalidateRect optimization should be turned on
  82889. */
  82890. get useInvalidateRectOptimization(): boolean;
  82891. set useInvalidateRectOptimization(value: boolean);
  82892. private _invalidatedRectangle;
  82893. /**
  82894. * Invalidates a rectangle area on the gui texture
  82895. * @param invalidMinX left most position of the rectangle to invalidate in the texture
  82896. * @param invalidMinY top most position of the rectangle to invalidate in the texture
  82897. * @param invalidMaxX right most position of the rectangle to invalidate in the texture
  82898. * @param invalidMaxY bottom most position of the rectangle to invalidate in the texture
  82899. */
  82900. invalidateRect(invalidMinX: number, invalidMinY: number, invalidMaxX: number, invalidMaxY: number): void;
  82901. /**
  82902. * Marks the texture as dirty forcing a complete update
  82903. */
  82904. markAsDirty(): void;
  82905. /**
  82906. * Helper function used to create a new style
  82907. * @returns a new style
  82908. * @see https://doc.babylonjs.com/how_to/gui#styles
  82909. */
  82910. createStyle(): Style;
  82911. /**
  82912. * Adds a new control to the root container
  82913. * @param control defines the control to add
  82914. * @returns the current texture
  82915. */
  82916. addControl(control: Control): AdvancedDynamicTexture;
  82917. /**
  82918. * Removes a control from the root container
  82919. * @param control defines the control to remove
  82920. * @returns the current texture
  82921. */
  82922. removeControl(control: Control): AdvancedDynamicTexture;
  82923. /**
  82924. * Release all resources
  82925. */
  82926. dispose(): void;
  82927. private _onResize;
  82928. /** @hidden */
  82929. _getGlobalViewport(scene: BABYLON.Scene): BABYLON.Viewport;
  82930. /**
  82931. * Get screen coordinates for a vector3
  82932. * @param position defines the position to project
  82933. * @param worldMatrix defines the world matrix to use
  82934. * @returns the projected position
  82935. */
  82936. getProjectedPosition(position: BABYLON.Vector3, worldMatrix: BABYLON.Matrix): BABYLON.Vector2;
  82937. /**
  82938. * Get screen coordinates for a vector3
  82939. * @param position defines the position to project
  82940. * @param worldMatrix defines the world matrix to use
  82941. * @returns the projected position with Z
  82942. */
  82943. getProjectedPositionWithZ(position: BABYLON.Vector3, worldMatrix: BABYLON.Matrix): BABYLON.Vector3;
  82944. private _checkUpdate;
  82945. private _clearMeasure;
  82946. private _render;
  82947. /** @hidden */
  82948. _changeCursor(cursor: string): void;
  82949. /** @hidden */
  82950. _registerLastControlDown(control: Control, pointerId: number): void;
  82951. private _doPicking;
  82952. /** @hidden */
  82953. _cleanControlAfterRemovalFromList(list: {
  82954. [pointerId: number]: Control;
  82955. }, control: Control): void;
  82956. /** @hidden */
  82957. _cleanControlAfterRemoval(control: Control): void;
  82958. /** Attach to all scene events required to support pointer events */
  82959. attach(): void;
  82960. /** @hidden */
  82961. private onClipboardCopy;
  82962. /** @hidden */
  82963. private onClipboardCut;
  82964. /** @hidden */
  82965. private onClipboardPaste;
  82966. /**
  82967. * Register the clipboard Events onto the canvas
  82968. */
  82969. registerClipboardEvents(): void;
  82970. /**
  82971. * Unregister the clipboard Events from the canvas
  82972. */
  82973. unRegisterClipboardEvents(): void;
  82974. /**
  82975. * Connect the texture to a hosting mesh to enable interactions
  82976. * @param mesh defines the mesh to attach to
  82977. * @param supportPointerMove defines a boolean indicating if pointer move events must be catched as well
  82978. */
  82979. attachToMesh(mesh: BABYLON.AbstractMesh, supportPointerMove?: boolean): void;
  82980. /**
  82981. * Move the focus to a specific control
  82982. * @param control defines the control which will receive the focus
  82983. */
  82984. moveFocusToControl(control: IFocusableControl): void;
  82985. private _manageFocus;
  82986. private _attachToOnPointerOut;
  82987. private _attachToOnBlur;
  82988. /**
  82989. * Serializes the entire GUI system
  82990. * @returns an object with the JSON serialized data
  82991. */
  82992. serializeContent(): any;
  82993. /**
  82994. * Recreate the content of the ADT from a JSON object
  82995. * @param serializedObject define the JSON serialized object to restore from
  82996. */
  82997. parseContent(serializedObject: any): void;
  82998. /**
  82999. * Recreate the content of the ADT from a snippet saved by the GUI editor
  83000. * @param snippetId defines the snippet to load
  83001. * @returns a promise that will resolve on success
  83002. */
  83003. parseFromSnippetAsync(snippetId: string): Promise<void>;
  83004. /**
  83005. * Creates a new AdvancedDynamicTexture in projected mode (ie. attached to a mesh)
  83006. * @param mesh defines the mesh which will receive the texture
  83007. * @param width defines the texture width (1024 by default)
  83008. * @param height defines the texture height (1024 by default)
  83009. * @param supportPointerMove defines a boolean indicating if the texture must capture move events (true by default)
  83010. * @param onlyAlphaTesting defines a boolean indicating that alpha blending will not be used (only alpha testing) (false by default)
  83011. * @param invertY defines if the texture needs to be inverted on the y axis during loading (true by default)
  83012. * @returns a new AdvancedDynamicTexture
  83013. */
  83014. static CreateForMesh(mesh: BABYLON.AbstractMesh, width?: number, height?: number, supportPointerMove?: boolean, onlyAlphaTesting?: boolean, invertY?: boolean): AdvancedDynamicTexture;
  83015. /**
  83016. * 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
  83017. * @param mesh defines the mesh which will receive the texture
  83018. * @param width defines the texture width (1024 by default)
  83019. * @param height defines the texture height (1024 by default)
  83020. * @param supportPointerMove defines a boolean indicating if the texture must capture move events (true by default)
  83021. * @param invertY defines if the texture needs to be inverted on the y axis during loading (true by default)
  83022. * @returns a new AdvancedDynamicTexture
  83023. */
  83024. static CreateForMeshTexture(mesh: BABYLON.AbstractMesh, width?: number, height?: number, supportPointerMove?: boolean, invertY?: boolean): AdvancedDynamicTexture;
  83025. /**
  83026. * Creates a new AdvancedDynamicTexture in fullscreen mode.
  83027. * In this mode the texture will rely on a layer for its rendering.
  83028. * This allows it to be treated like any other layer.
  83029. * As such, if you have a multi camera setup, you can set the layerMask on the GUI as well.
  83030. * LayerMask is set through advancedTexture.layer.layerMask
  83031. * @param name defines name for the texture
  83032. * @param foreground defines a boolean indicating if the texture must be rendered in foreground (default is true)
  83033. * @param scene defines the hsoting scene
  83034. * @param sampling defines the texture sampling mode (Texture.BILINEAR_SAMPLINGMODE by default)
  83035. * @returns a new AdvancedDynamicTexture
  83036. */
  83037. static CreateFullscreenUI(name: string, foreground?: boolean, scene?: BABYLON.Nullable<BABYLON.Scene>, sampling?: number): AdvancedDynamicTexture;
  83038. }
  83039. }
  83040. declare module BABYLON.GUI {
  83041. /**
  83042. * Root class used for all 2D controls
  83043. * @see https://doc.babylonjs.com/how_to/gui#controls
  83044. */
  83045. export class Control {
  83046. /** defines the name of the control */
  83047. name?: string | undefined;
  83048. /**
  83049. * Gets or sets a boolean indicating if alpha must be an inherited value (false by default)
  83050. */
  83051. static AllowAlphaInheritance: boolean;
  83052. private _alpha;
  83053. private _alphaSet;
  83054. private _zIndex;
  83055. /** @hidden */
  83056. _host: AdvancedDynamicTexture;
  83057. /** Gets or sets the control parent */
  83058. parent: BABYLON.Nullable<Container>;
  83059. /** @hidden */
  83060. _currentMeasure: Measure;
  83061. private _fontFamily;
  83062. private _fontStyle;
  83063. private _fontWeight;
  83064. private _fontSize;
  83065. private _font;
  83066. /** @hidden */
  83067. _width: ValueAndUnit;
  83068. /** @hidden */
  83069. _height: ValueAndUnit;
  83070. /** @hidden */
  83071. protected _fontOffset: {
  83072. ascent: number;
  83073. height: number;
  83074. descent: number;
  83075. };
  83076. private _color;
  83077. private _style;
  83078. private _styleObserver;
  83079. /** @hidden */
  83080. protected _horizontalAlignment: number;
  83081. /** @hidden */
  83082. protected _verticalAlignment: number;
  83083. /** @hidden */
  83084. protected _isDirty: boolean;
  83085. /** @hidden */
  83086. protected _wasDirty: boolean;
  83087. /** @hidden */
  83088. _tempParentMeasure: Measure;
  83089. /** @hidden */
  83090. _prevCurrentMeasureTransformedIntoGlobalSpace: Measure;
  83091. /** @hidden */
  83092. protected _cachedParentMeasure: Measure;
  83093. private _paddingLeft;
  83094. private _paddingRight;
  83095. private _paddingTop;
  83096. private _paddingBottom;
  83097. /** @hidden */
  83098. _left: ValueAndUnit;
  83099. /** @hidden */
  83100. _top: ValueAndUnit;
  83101. private _scaleX;
  83102. private _scaleY;
  83103. private _rotation;
  83104. private _transformCenterX;
  83105. private _transformCenterY;
  83106. /** @hidden */
  83107. _transformMatrix: Matrix2D;
  83108. /** @hidden */
  83109. protected _invertTransformMatrix: Matrix2D;
  83110. /** @hidden */
  83111. protected _transformedPosition: BABYLON.Vector2;
  83112. private _isMatrixDirty;
  83113. private _cachedOffsetX;
  83114. private _cachedOffsetY;
  83115. private _isVisible;
  83116. private _isHighlighted;
  83117. /** @hidden */
  83118. _linkedMesh: BABYLON.Nullable<BABYLON.TransformNode>;
  83119. private _fontSet;
  83120. private _dummyVector2;
  83121. private _downCount;
  83122. private _enterCount;
  83123. private _doNotRender;
  83124. private _downPointerIds;
  83125. protected _isEnabled: boolean;
  83126. protected _disabledColor: string;
  83127. protected _disabledColorItem: string;
  83128. /** @hidden */
  83129. protected _rebuildLayout: boolean;
  83130. /** @hidden */
  83131. _customData: any;
  83132. /** @hidden */
  83133. _isClipped: boolean;
  83134. /** @hidden */
  83135. _automaticSize: boolean;
  83136. /** @hidden */
  83137. _tag: any;
  83138. /**
  83139. * 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
  83140. */
  83141. uniqueId: number;
  83142. /**
  83143. * Gets or sets an object used to store user defined information for the node
  83144. */
  83145. metadata: any;
  83146. /** Gets or sets a boolean indicating if the control can be hit with pointer events */
  83147. isHitTestVisible: boolean;
  83148. /** Gets or sets a boolean indicating if the control can block pointer events */
  83149. isPointerBlocker: boolean;
  83150. /** Gets or sets a boolean indicating if the control can be focusable */
  83151. isFocusInvisible: boolean;
  83152. /**
  83153. * Gets or sets a boolean indicating if the children are clipped to the current control bounds.
  83154. * 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
  83155. */
  83156. clipChildren: boolean;
  83157. /**
  83158. * Gets or sets a boolean indicating that control content must be clipped
  83159. * 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
  83160. */
  83161. clipContent: boolean;
  83162. /**
  83163. * Gets or sets a boolean indicating that the current control should cache its rendering (useful when the control does not change often)
  83164. */
  83165. useBitmapCache: boolean;
  83166. private _cacheData;
  83167. private _shadowOffsetX;
  83168. /** Gets or sets a value indicating the offset to apply on X axis to render the shadow */
  83169. get shadowOffsetX(): number;
  83170. set shadowOffsetX(value: number);
  83171. private _shadowOffsetY;
  83172. /** Gets or sets a value indicating the offset to apply on Y axis to render the shadow */
  83173. get shadowOffsetY(): number;
  83174. set shadowOffsetY(value: number);
  83175. private _shadowBlur;
  83176. /** Gets or sets a value indicating the amount of blur to use to render the shadow */
  83177. get shadowBlur(): number;
  83178. set shadowBlur(value: number);
  83179. private _shadowColor;
  83180. /** Gets or sets a value indicating the color of the shadow (black by default ie. "#000") */
  83181. get shadowColor(): string;
  83182. set shadowColor(value: string);
  83183. /** Gets or sets the cursor to use when the control is hovered */
  83184. hoverCursor: string;
  83185. /** @hidden */
  83186. protected _linkOffsetX: ValueAndUnit;
  83187. /** @hidden */
  83188. protected _linkOffsetY: ValueAndUnit;
  83189. /** Gets the control type name */
  83190. get typeName(): string;
  83191. /**
  83192. * Get the current class name of the control.
  83193. * @returns current class name
  83194. */
  83195. getClassName(): string;
  83196. /**
  83197. * An event triggered when pointer wheel is scrolled
  83198. */
  83199. onWheelObservable: BABYLON.Observable<BABYLON.Vector2>;
  83200. /**
  83201. * An event triggered when the pointer move over the control.
  83202. */
  83203. onPointerMoveObservable: BABYLON.Observable<BABYLON.Vector2>;
  83204. /**
  83205. * An event triggered when the pointer move out of the control.
  83206. */
  83207. onPointerOutObservable: BABYLON.Observable<Control>;
  83208. /**
  83209. * An event triggered when the pointer taps the control
  83210. */
  83211. onPointerDownObservable: BABYLON.Observable<Vector2WithInfo>;
  83212. /**
  83213. * An event triggered when pointer up
  83214. */
  83215. onPointerUpObservable: BABYLON.Observable<Vector2WithInfo>;
  83216. /**
  83217. * An event triggered when a control is clicked on
  83218. */
  83219. onPointerClickObservable: BABYLON.Observable<Vector2WithInfo>;
  83220. /**
  83221. * An event triggered when pointer enters the control
  83222. */
  83223. onPointerEnterObservable: BABYLON.Observable<Control>;
  83224. /**
  83225. * An event triggered when the control is marked as dirty
  83226. */
  83227. onDirtyObservable: BABYLON.Observable<Control>;
  83228. /**
  83229. * An event triggered before drawing the control
  83230. */
  83231. onBeforeDrawObservable: BABYLON.Observable<Control>;
  83232. /**
  83233. * An event triggered after the control was drawn
  83234. */
  83235. onAfterDrawObservable: BABYLON.Observable<Control>;
  83236. /**
  83237. * An event triggered when the control has been disposed
  83238. */
  83239. onDisposeObservable: BABYLON.Observable<Control>;
  83240. /**
  83241. * Get the hosting AdvancedDynamicTexture
  83242. */
  83243. get host(): AdvancedDynamicTexture;
  83244. /** Gets or set information about font offsets (used to render and align text) */
  83245. get fontOffset(): {
  83246. ascent: number;
  83247. height: number;
  83248. descent: number;
  83249. };
  83250. set fontOffset(offset: {
  83251. ascent: number;
  83252. height: number;
  83253. descent: number;
  83254. });
  83255. /** Gets or sets alpha value for the control (1 means opaque and 0 means entirely transparent) */
  83256. get alpha(): number;
  83257. set alpha(value: number);
  83258. /**
  83259. * Gets or sets a boolean indicating that we want to highlight the control (mostly for debugging purpose)
  83260. */
  83261. get isHighlighted(): boolean;
  83262. set isHighlighted(value: boolean);
  83263. /** Gets or sets a value indicating the scale factor on X axis (1 by default)
  83264. * @see https://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  83265. */
  83266. get scaleX(): number;
  83267. set scaleX(value: number);
  83268. /** Gets or sets a value indicating the scale factor on Y axis (1 by default)
  83269. * @see https://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  83270. */
  83271. get scaleY(): number;
  83272. set scaleY(value: number);
  83273. /** Gets or sets the rotation angle (0 by default)
  83274. * @see https://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  83275. */
  83276. get rotation(): number;
  83277. set rotation(value: number);
  83278. /** Gets or sets the transformation center on Y axis (0 by default)
  83279. * @see https://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  83280. */
  83281. get transformCenterY(): number;
  83282. set transformCenterY(value: number);
  83283. /** Gets or sets the transformation center on X axis (0 by default)
  83284. * @see https://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  83285. */
  83286. get transformCenterX(): number;
  83287. set transformCenterX(value: number);
  83288. /**
  83289. * Gets or sets the horizontal alignment
  83290. * @see https://doc.babylonjs.com/how_to/gui#alignments
  83291. */
  83292. get horizontalAlignment(): number;
  83293. set horizontalAlignment(value: number);
  83294. /**
  83295. * Gets or sets the vertical alignment
  83296. * @see https://doc.babylonjs.com/how_to/gui#alignments
  83297. */
  83298. get verticalAlignment(): number;
  83299. set verticalAlignment(value: number);
  83300. /**
  83301. * Gets or sets a fixed ratio for this control.
  83302. * When different from 0, the ratio is used to compute the "second" dimension.
  83303. * The first dimension used in the computation is the last one set (by setting width / widthInPixels or height / heightInPixels), and the
  83304. * second dimension is computed as first dimension * fixedRatio
  83305. */
  83306. fixedRatio: number;
  83307. private _fixedRatioMasterIsWidth;
  83308. /**
  83309. * Gets or sets control width
  83310. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  83311. */
  83312. get width(): string | number;
  83313. set width(value: string | number);
  83314. /**
  83315. * Gets or sets the control width in pixel
  83316. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  83317. */
  83318. get widthInPixels(): number;
  83319. set widthInPixels(value: number);
  83320. /**
  83321. * Gets or sets control height
  83322. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  83323. */
  83324. get height(): string | number;
  83325. set height(value: string | number);
  83326. /**
  83327. * Gets or sets control height in pixel
  83328. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  83329. */
  83330. get heightInPixels(): number;
  83331. set heightInPixels(value: number);
  83332. /** Gets or set font family */
  83333. get fontFamily(): string;
  83334. set fontFamily(value: string);
  83335. /** Gets or sets font style */
  83336. get fontStyle(): string;
  83337. set fontStyle(value: string);
  83338. /** Gets or sets font weight */
  83339. get fontWeight(): string;
  83340. set fontWeight(value: string);
  83341. /**
  83342. * Gets or sets style
  83343. * @see https://doc.babylonjs.com/how_to/gui#styles
  83344. */
  83345. get style(): BABYLON.Nullable<Style>;
  83346. set style(value: BABYLON.Nullable<Style>);
  83347. /** @hidden */
  83348. get _isFontSizeInPercentage(): boolean;
  83349. /** Gets or sets font size in pixels */
  83350. get fontSizeInPixels(): number;
  83351. set fontSizeInPixels(value: number);
  83352. /** Gets or sets font size */
  83353. get fontSize(): string | number;
  83354. set fontSize(value: string | number);
  83355. /** Gets or sets foreground color */
  83356. get color(): string;
  83357. set color(value: string);
  83358. /** Gets or sets z index which is used to reorder controls on the z axis */
  83359. get zIndex(): number;
  83360. set zIndex(value: number);
  83361. /** Gets or sets a boolean indicating if the control can be rendered */
  83362. get notRenderable(): boolean;
  83363. set notRenderable(value: boolean);
  83364. /** Gets or sets a boolean indicating if the control is visible */
  83365. get isVisible(): boolean;
  83366. set isVisible(value: boolean);
  83367. /** Gets a boolean indicating that the control needs to update its rendering */
  83368. get isDirty(): boolean;
  83369. /**
  83370. * Gets the current linked mesh (or null if none)
  83371. */
  83372. get linkedMesh(): BABYLON.Nullable<BABYLON.TransformNode>;
  83373. /**
  83374. * Gets or sets a value indicating the padding to use on the left of the control
  83375. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  83376. */
  83377. get paddingLeft(): string | number;
  83378. set paddingLeft(value: string | number);
  83379. /**
  83380. * Gets or sets a value indicating the padding in pixels to use on the left of the control
  83381. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  83382. */
  83383. get paddingLeftInPixels(): number;
  83384. set paddingLeftInPixels(value: number);
  83385. /**
  83386. * Gets or sets a value indicating the padding to use on the right of the control
  83387. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  83388. */
  83389. get paddingRight(): string | number;
  83390. set paddingRight(value: string | number);
  83391. /**
  83392. * Gets or sets a value indicating the padding in pixels to use on the right of the control
  83393. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  83394. */
  83395. get paddingRightInPixels(): number;
  83396. set paddingRightInPixels(value: number);
  83397. /**
  83398. * Gets or sets a value indicating the padding to use on the top of the control
  83399. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  83400. */
  83401. get paddingTop(): string | number;
  83402. set paddingTop(value: string | number);
  83403. /**
  83404. * Gets or sets a value indicating the padding in pixels to use on the top of the control
  83405. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  83406. */
  83407. get paddingTopInPixels(): number;
  83408. set paddingTopInPixels(value: number);
  83409. /**
  83410. * Gets or sets a value indicating the padding to use on the bottom of the control
  83411. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  83412. */
  83413. get paddingBottom(): string | number;
  83414. set paddingBottom(value: string | number);
  83415. /**
  83416. * Gets or sets a value indicating the padding in pixels to use on the bottom of the control
  83417. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  83418. */
  83419. get paddingBottomInPixels(): number;
  83420. set paddingBottomInPixels(value: number);
  83421. /**
  83422. * Gets or sets a value indicating the left coordinate of the control
  83423. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  83424. */
  83425. get left(): string | number;
  83426. set left(value: string | number);
  83427. /**
  83428. * Gets or sets a value indicating the left coordinate in pixels of the control
  83429. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  83430. */
  83431. get leftInPixels(): number;
  83432. set leftInPixels(value: number);
  83433. /**
  83434. * Gets or sets a value indicating the top coordinate of the control
  83435. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  83436. */
  83437. get top(): string | number;
  83438. set top(value: string | number);
  83439. /**
  83440. * Gets or sets a value indicating the top coordinate in pixels of the control
  83441. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  83442. */
  83443. get topInPixels(): number;
  83444. set topInPixels(value: number);
  83445. /**
  83446. * Gets or sets a value indicating the offset on X axis to the linked mesh
  83447. * @see https://doc.babylonjs.com/how_to/gui#tracking-positions
  83448. */
  83449. get linkOffsetX(): string | number;
  83450. set linkOffsetX(value: string | number);
  83451. /**
  83452. * Gets or sets a value indicating the offset in pixels on X axis to the linked mesh
  83453. * @see https://doc.babylonjs.com/how_to/gui#tracking-positions
  83454. */
  83455. get linkOffsetXInPixels(): number;
  83456. set linkOffsetXInPixels(value: number);
  83457. /**
  83458. * Gets or sets a value indicating the offset on Y axis to the linked mesh
  83459. * @see https://doc.babylonjs.com/how_to/gui#tracking-positions
  83460. */
  83461. get linkOffsetY(): string | number;
  83462. set linkOffsetY(value: string | number);
  83463. /**
  83464. * Gets or sets a value indicating the offset in pixels on Y axis to the linked mesh
  83465. * @see https://doc.babylonjs.com/how_to/gui#tracking-positions
  83466. */
  83467. get linkOffsetYInPixels(): number;
  83468. set linkOffsetYInPixels(value: number);
  83469. /** Gets the center coordinate on X axis */
  83470. get centerX(): number;
  83471. /** Gets the center coordinate on Y axis */
  83472. get centerY(): number;
  83473. /** Gets or sets if control is Enabled */
  83474. get isEnabled(): boolean;
  83475. set isEnabled(value: boolean);
  83476. /** Gets or sets background color of control if it's disabled */
  83477. get disabledColor(): string;
  83478. set disabledColor(value: string);
  83479. /** Gets or sets front color of control if it's disabled */
  83480. get disabledColorItem(): string;
  83481. set disabledColorItem(value: string);
  83482. /**
  83483. * Creates a new control
  83484. * @param name defines the name of the control
  83485. */
  83486. constructor(
  83487. /** defines the name of the control */
  83488. name?: string | undefined);
  83489. /** @hidden */
  83490. protected _getTypeName(): string;
  83491. /**
  83492. * Gets the first ascendant in the hierarchy of the given type
  83493. * @param className defines the required type
  83494. * @returns the ascendant or null if not found
  83495. */
  83496. getAscendantOfClass(className: string): BABYLON.Nullable<Control>;
  83497. /** @hidden */
  83498. _resetFontCache(): void;
  83499. /**
  83500. * Determines if a container is an ascendant of the current control
  83501. * @param container defines the container to look for
  83502. * @returns true if the container is one of the ascendant of the control
  83503. */
  83504. isAscendant(container: Control): boolean;
  83505. /**
  83506. * Gets coordinates in local control space
  83507. * @param globalCoordinates defines the coordinates to transform
  83508. * @returns the new coordinates in local space
  83509. */
  83510. getLocalCoordinates(globalCoordinates: BABYLON.Vector2): BABYLON.Vector2;
  83511. /**
  83512. * Gets coordinates in local control space
  83513. * @param globalCoordinates defines the coordinates to transform
  83514. * @param result defines the target vector2 where to store the result
  83515. * @returns the current control
  83516. */
  83517. getLocalCoordinatesToRef(globalCoordinates: BABYLON.Vector2, result: BABYLON.Vector2): Control;
  83518. /**
  83519. * Gets coordinates in parent local control space
  83520. * @param globalCoordinates defines the coordinates to transform
  83521. * @returns the new coordinates in parent local space
  83522. */
  83523. getParentLocalCoordinates(globalCoordinates: BABYLON.Vector2): BABYLON.Vector2;
  83524. /**
  83525. * Move the current control to a vector3 position projected onto the screen.
  83526. * @param position defines the target position
  83527. * @param scene defines the hosting scene
  83528. */
  83529. moveToVector3(position: BABYLON.Vector3, scene: BABYLON.Scene): void;
  83530. /**
  83531. * Will store all controls that have this control as ascendant in a given array
  83532. * @param results defines the array where to store the descendants
  83533. * @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
  83534. * @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
  83535. */
  83536. getDescendantsToRef(results: Control[], directDescendantsOnly?: boolean, predicate?: (control: Control) => boolean): void;
  83537. /**
  83538. * Will return all controls that have this control as ascendant
  83539. * @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
  83540. * @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
  83541. * @return all child controls
  83542. */
  83543. getDescendants(directDescendantsOnly?: boolean, predicate?: (control: Control) => boolean): Control[];
  83544. /**
  83545. * Link current control with a target mesh
  83546. * @param mesh defines the mesh to link with
  83547. * @see https://doc.babylonjs.com/how_to/gui#tracking-positions
  83548. */
  83549. linkWithMesh(mesh: BABYLON.Nullable<BABYLON.TransformNode>): void;
  83550. /**
  83551. * Shorthand funtion to set the top, right, bottom, and left padding values on the control.
  83552. * @param { string | number} paddingTop - The value of the top padding.
  83553. * @param { string | number} paddingRight - The value of the right padding. If omitted, top is used.
  83554. * @param { string | number} paddingBottom - The value of the bottom padding. If omitted, top is used.
  83555. * @param { string | number} paddingLeft - The value of the left padding. If omitted, right is used.
  83556. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  83557. */
  83558. setPadding(paddingTop: string | number, paddingRight?: string | number, paddingBottom?: string | number, paddingLeft?: string | number): void;
  83559. /**
  83560. * Shorthand funtion to set the top, right, bottom, and left padding values in pixels on the control.
  83561. * @param { number} paddingTop - The value in pixels of the top padding.
  83562. * @param { number} paddingRight - The value in pixels of the right padding. If omitted, top is used.
  83563. * @param { number} paddingBottom - The value in pixels of the bottom padding. If omitted, top is used.
  83564. * @param { number} paddingLeft - The value in pixels of the left padding. If omitted, right is used.
  83565. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  83566. */
  83567. setPaddingInPixels(paddingTop: number, paddingRight?: number, paddingBottom?: number, paddingLeft?: number): void;
  83568. /** @hidden */
  83569. _moveToProjectedPosition(projectedPosition: BABYLON.Vector3): void;
  83570. /** @hidden */
  83571. _offsetLeft(offset: number): void;
  83572. /** @hidden */
  83573. _offsetTop(offset: number): void;
  83574. /** @hidden */
  83575. _markMatrixAsDirty(): void;
  83576. /** @hidden */
  83577. _flagDescendantsAsMatrixDirty(): void;
  83578. /** @hidden */
  83579. _intersectsRect(rect: Measure): boolean;
  83580. /** @hidden */
  83581. protected invalidateRect(): void;
  83582. /** @hidden */
  83583. _markAsDirty(force?: boolean): void;
  83584. /** @hidden */
  83585. _markAllAsDirty(): void;
  83586. /** @hidden */
  83587. _link(host: AdvancedDynamicTexture): void;
  83588. /** @hidden */
  83589. protected _transform(context?: CanvasRenderingContext2D): void;
  83590. /** @hidden */
  83591. _renderHighlight(context: CanvasRenderingContext2D): void;
  83592. /** @hidden */
  83593. _renderHighlightSpecific(context: CanvasRenderingContext2D): void;
  83594. /** @hidden */
  83595. protected _applyStates(context: CanvasRenderingContext2D): void;
  83596. /** @hidden */
  83597. _layout(parentMeasure: Measure, context: CanvasRenderingContext2D): boolean;
  83598. /** @hidden */
  83599. protected _processMeasures(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  83600. protected _evaluateClippingState(parentMeasure: Measure): void;
  83601. /** @hidden */
  83602. _measure(): void;
  83603. /** @hidden */
  83604. protected _computeAlignment(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  83605. /** @hidden */
  83606. protected _preMeasure(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  83607. /** @hidden */
  83608. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  83609. /** @hidden */
  83610. protected _clipForChildren(context: CanvasRenderingContext2D): void;
  83611. private static _ClipMeasure;
  83612. private _tmpMeasureA;
  83613. private _clip;
  83614. /** @hidden */
  83615. _render(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): boolean;
  83616. /** @hidden */
  83617. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): void;
  83618. /**
  83619. * Tests if a given coordinates belong to the current control
  83620. * @param x defines x coordinate to test
  83621. * @param y defines y coordinate to test
  83622. * @returns true if the coordinates are inside the control
  83623. */
  83624. contains(x: number, y: number): boolean;
  83625. /** @hidden */
  83626. _processPicking(x: number, y: number, pi: BABYLON.PointerInfoBase, type: number, pointerId: number, buttonIndex: number, deltaX?: number, deltaY?: number): boolean;
  83627. /** @hidden */
  83628. _onPointerMove(target: Control, coordinates: BABYLON.Vector2, pointerId: number, pi: BABYLON.PointerInfoBase): void;
  83629. /** @hidden */
  83630. _onPointerEnter(target: Control, pi: BABYLON.PointerInfoBase): boolean;
  83631. /** @hidden */
  83632. _onPointerOut(target: Control, pi: BABYLON.Nullable<BABYLON.PointerInfoBase>, force?: boolean): void;
  83633. /** @hidden */
  83634. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, pi: BABYLON.PointerInfoBase): boolean;
  83635. /** @hidden */
  83636. _onPointerUp(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, notifyClick: boolean, pi?: BABYLON.PointerInfoBase): void;
  83637. /** @hidden */
  83638. _forcePointerUp(pointerId?: BABYLON.Nullable<number>): void;
  83639. /** @hidden */
  83640. _onWheelScroll(deltaX?: number, deltaY?: number): void;
  83641. /** @hidden */
  83642. _onCanvasBlur(): void;
  83643. /** @hidden */
  83644. _processObservables(type: number, x: number, y: number, pi: BABYLON.PointerInfoBase, pointerId: number, buttonIndex: number, deltaX?: number, deltaY?: number): boolean;
  83645. private _prepareFont;
  83646. /**
  83647. * Serializes the current control
  83648. * @param serializationObject defined the JSON serialized object
  83649. */
  83650. serialize(serializationObject: any): void;
  83651. /** @hidden */
  83652. _parseFromContent(serializedObject: any, host: AdvancedDynamicTexture): void;
  83653. /** Releases associated resources */
  83654. dispose(): void;
  83655. private static _HORIZONTAL_ALIGNMENT_LEFT;
  83656. private static _HORIZONTAL_ALIGNMENT_RIGHT;
  83657. private static _HORIZONTAL_ALIGNMENT_CENTER;
  83658. private static _VERTICAL_ALIGNMENT_TOP;
  83659. private static _VERTICAL_ALIGNMENT_BOTTOM;
  83660. private static _VERTICAL_ALIGNMENT_CENTER;
  83661. /** HORIZONTAL_ALIGNMENT_LEFT */
  83662. static get HORIZONTAL_ALIGNMENT_LEFT(): number;
  83663. /** HORIZONTAL_ALIGNMENT_RIGHT */
  83664. static get HORIZONTAL_ALIGNMENT_RIGHT(): number;
  83665. /** HORIZONTAL_ALIGNMENT_CENTER */
  83666. static get HORIZONTAL_ALIGNMENT_CENTER(): number;
  83667. /** VERTICAL_ALIGNMENT_TOP */
  83668. static get VERTICAL_ALIGNMENT_TOP(): number;
  83669. /** VERTICAL_ALIGNMENT_BOTTOM */
  83670. static get VERTICAL_ALIGNMENT_BOTTOM(): number;
  83671. /** VERTICAL_ALIGNMENT_CENTER */
  83672. static get VERTICAL_ALIGNMENT_CENTER(): number;
  83673. private static _FontHeightSizes;
  83674. /** @hidden */
  83675. static _GetFontOffset(font: string): {
  83676. ascent: number;
  83677. height: number;
  83678. descent: number;
  83679. };
  83680. /**
  83681. * Creates a Control from parsed data
  83682. * @param serializedObject defines parsed data
  83683. * @param host defines the hosting AdvancedDynamicTexture
  83684. * @returns a new Control
  83685. */
  83686. static Parse(serializedObject: any, host: AdvancedDynamicTexture): Control;
  83687. /**
  83688. * Creates a stack panel that can be used to render headers
  83689. * @param control defines the control to associate with the header
  83690. * @param text defines the text of the header
  83691. * @param size defines the size of the header
  83692. * @param options defines options used to configure the header
  83693. * @returns a new StackPanel
  83694. * @ignore
  83695. * @hidden
  83696. */
  83697. static AddHeader: (control: Control, text: string, size: string | number, options: {
  83698. isHorizontal: boolean;
  83699. controlFirst: boolean;
  83700. }) => any;
  83701. /** @hidden */
  83702. protected static drawEllipse(x: number, y: number, width: number, height: number, context: CanvasRenderingContext2D): void;
  83703. }
  83704. }
  83705. declare module BABYLON.GUI {
  83706. /**
  83707. * Root class for 2D containers
  83708. * @see https://doc.babylonjs.com/how_to/gui#containers
  83709. */
  83710. export class Container extends Control {
  83711. name?: string | undefined;
  83712. /** @hidden */
  83713. _children: Control[];
  83714. /** @hidden */
  83715. protected _measureForChildren: Measure;
  83716. /** @hidden */
  83717. protected _background: string;
  83718. /** @hidden */
  83719. protected _adaptWidthToChildren: boolean;
  83720. /** @hidden */
  83721. protected _adaptHeightToChildren: boolean;
  83722. /**
  83723. * Gets or sets a boolean indicating that layout cycle errors should be displayed on the console
  83724. */
  83725. logLayoutCycleErrors: boolean;
  83726. /**
  83727. * Gets or sets the number of layout cycles (a change involved by a control while evaluating the layout) allowed
  83728. */
  83729. maxLayoutCycle: number;
  83730. /** Gets or sets a boolean indicating if the container should try to adapt to its children height */
  83731. get adaptHeightToChildren(): boolean;
  83732. set adaptHeightToChildren(value: boolean);
  83733. /** Gets or sets a boolean indicating if the container should try to adapt to its children width */
  83734. get adaptWidthToChildren(): boolean;
  83735. set adaptWidthToChildren(value: boolean);
  83736. /** Gets or sets background color */
  83737. get background(): string;
  83738. set background(value: string);
  83739. /** Gets the list of children */
  83740. get children(): Control[];
  83741. /**
  83742. * Creates a new Container
  83743. * @param name defines the name of the container
  83744. */
  83745. constructor(name?: string | undefined);
  83746. protected _getTypeName(): string;
  83747. _flagDescendantsAsMatrixDirty(): void;
  83748. /**
  83749. * Gets a child using its name
  83750. * @param name defines the child name to look for
  83751. * @returns the child control if found
  83752. */
  83753. getChildByName(name: string): BABYLON.Nullable<Control>;
  83754. /**
  83755. * Gets a child using its type and its name
  83756. * @param name defines the child name to look for
  83757. * @param type defines the child type to look for
  83758. * @returns the child control if found
  83759. */
  83760. getChildByType(name: string, type: string): BABYLON.Nullable<Control>;
  83761. /**
  83762. * Search for a specific control in children
  83763. * @param control defines the control to look for
  83764. * @returns true if the control is in child list
  83765. */
  83766. containsControl(control: Control): boolean;
  83767. /**
  83768. * Adds a new control to the current container
  83769. * @param control defines the control to add
  83770. * @returns the current container
  83771. */
  83772. addControl(control: BABYLON.Nullable<Control>): Container;
  83773. /**
  83774. * Removes all controls from the current container
  83775. * @returns the current container
  83776. */
  83777. clearControls(): Container;
  83778. /**
  83779. * Removes a control from the current container
  83780. * @param control defines the control to remove
  83781. * @returns the current container
  83782. */
  83783. removeControl(control: Control): Container;
  83784. /** @hidden */
  83785. _reOrderControl(control: Control): void;
  83786. /** @hidden */
  83787. _offsetLeft(offset: number): void;
  83788. /** @hidden */
  83789. _offsetTop(offset: number): void;
  83790. /** @hidden */
  83791. _markAllAsDirty(): void;
  83792. /** @hidden */
  83793. protected _localDraw(context: CanvasRenderingContext2D): void;
  83794. /** @hidden */
  83795. _link(host: AdvancedDynamicTexture): void;
  83796. /** @hidden */
  83797. protected _beforeLayout(): void;
  83798. /** @hidden */
  83799. protected _processMeasures(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  83800. /** @hidden */
  83801. _layout(parentMeasure: Measure, context: CanvasRenderingContext2D): boolean;
  83802. protected _postMeasure(): void;
  83803. /** @hidden */
  83804. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: Measure): void;
  83805. getDescendantsToRef(results: Control[], directDescendantsOnly?: boolean, predicate?: (control: Control) => boolean): void;
  83806. /** @hidden */
  83807. _processPicking(x: number, y: number, pi: BABYLON.PointerInfoBase, type: number, pointerId: number, buttonIndex: number, deltaX?: number, deltaY?: number): boolean;
  83808. /** @hidden */
  83809. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  83810. /**
  83811. * Serializes the current control
  83812. * @param serializationObject defined the JSON serialized object
  83813. */
  83814. serialize(serializationObject: any): void;
  83815. /** Releases associated resources */
  83816. dispose(): void;
  83817. /** @hidden */
  83818. _parseFromContent(serializedObject: any, host: AdvancedDynamicTexture): void;
  83819. }
  83820. }
  83821. declare module BABYLON.GUI {
  83822. /** Class used to create rectangle container */
  83823. export class Rectangle extends Container {
  83824. name?: string | undefined;
  83825. private _thickness;
  83826. private _cornerRadius;
  83827. /** Gets or sets border thickness */
  83828. get thickness(): number;
  83829. set thickness(value: number);
  83830. /** Gets or sets the corner radius angle */
  83831. get cornerRadius(): number;
  83832. set cornerRadius(value: number);
  83833. /**
  83834. * Creates a new Rectangle
  83835. * @param name defines the control name
  83836. */
  83837. constructor(name?: string | undefined);
  83838. protected _getTypeName(): string;
  83839. protected _localDraw(context: CanvasRenderingContext2D): void;
  83840. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  83841. private _drawRoundedRect;
  83842. protected _clipForChildren(context: CanvasRenderingContext2D): void;
  83843. }
  83844. }
  83845. declare module BABYLON.GUI {
  83846. /**
  83847. * Enum that determines the text-wrapping mode to use.
  83848. */
  83849. export enum TextWrapping {
  83850. /**
  83851. * Clip the text when it's larger than Control.width; this is the default mode.
  83852. */
  83853. Clip = 0,
  83854. /**
  83855. * Wrap the text word-wise, i.e. try to add line-breaks at word boundary to fit within Control.width.
  83856. */
  83857. WordWrap = 1,
  83858. /**
  83859. * Ellipsize the text, i.e. shrink with trailing … when text is larger than Control.width.
  83860. */
  83861. Ellipsis = 2
  83862. }
  83863. /**
  83864. * Class used to create text block control
  83865. */
  83866. export class TextBlock extends Control {
  83867. /**
  83868. * Defines the name of the control
  83869. */
  83870. name?: string | undefined;
  83871. private _text;
  83872. private _textWrapping;
  83873. private _textHorizontalAlignment;
  83874. private _textVerticalAlignment;
  83875. private _lines;
  83876. private _resizeToFit;
  83877. private _lineSpacing;
  83878. private _outlineWidth;
  83879. private _outlineColor;
  83880. private _underline;
  83881. private _lineThrough;
  83882. /**
  83883. * An event triggered after the text is changed
  83884. */
  83885. onTextChangedObservable: BABYLON.Observable<TextBlock>;
  83886. /**
  83887. * An event triggered after the text was broken up into lines
  83888. */
  83889. onLinesReadyObservable: BABYLON.Observable<TextBlock>;
  83890. /**
  83891. * Function used to split a string into words. By default, a string is split at each space character found
  83892. */
  83893. wordSplittingFunction: BABYLON.Nullable<(line: string) => string[]>;
  83894. /**
  83895. * Return the line list (you may need to use the onLinesReadyObservable to make sure the list is ready)
  83896. */
  83897. get lines(): any[];
  83898. /**
  83899. * Gets or sets an boolean indicating that the TextBlock will be resized to fit container
  83900. */
  83901. get resizeToFit(): boolean;
  83902. /**
  83903. * Gets or sets an boolean indicating that the TextBlock will be resized to fit container
  83904. */
  83905. set resizeToFit(value: boolean);
  83906. /**
  83907. * Gets or sets a boolean indicating if text must be wrapped
  83908. */
  83909. get textWrapping(): TextWrapping | boolean;
  83910. /**
  83911. * Gets or sets a boolean indicating if text must be wrapped
  83912. */
  83913. set textWrapping(value: TextWrapping | boolean);
  83914. /**
  83915. * Gets or sets text to display
  83916. */
  83917. get text(): string;
  83918. /**
  83919. * Gets or sets text to display
  83920. */
  83921. set text(value: string);
  83922. /**
  83923. * Gets or sets text horizontal alignment (BABYLON.GUI.Control.HORIZONTAL_ALIGNMENT_CENTER by default)
  83924. */
  83925. get textHorizontalAlignment(): number;
  83926. /**
  83927. * Gets or sets text horizontal alignment (BABYLON.GUI.Control.HORIZONTAL_ALIGNMENT_CENTER by default)
  83928. */
  83929. set textHorizontalAlignment(value: number);
  83930. /**
  83931. * Gets or sets text vertical alignment (BABYLON.GUI.Control.VERTICAL_ALIGNMENT_CENTER by default)
  83932. */
  83933. get textVerticalAlignment(): number;
  83934. /**
  83935. * Gets or sets text vertical alignment (BABYLON.GUI.Control.VERTICAL_ALIGNMENT_CENTER by default)
  83936. */
  83937. set textVerticalAlignment(value: number);
  83938. /**
  83939. * Gets or sets line spacing value
  83940. */
  83941. set lineSpacing(value: string | number);
  83942. /**
  83943. * Gets or sets line spacing value
  83944. */
  83945. get lineSpacing(): string | number;
  83946. /**
  83947. * Gets or sets outlineWidth of the text to display
  83948. */
  83949. get outlineWidth(): number;
  83950. /**
  83951. * Gets or sets outlineWidth of the text to display
  83952. */
  83953. set outlineWidth(value: number);
  83954. /**
  83955. * Gets or sets a boolean indicating that text must have underline
  83956. */
  83957. get underline(): boolean;
  83958. /**
  83959. * Gets or sets a boolean indicating that text must have underline
  83960. */
  83961. set underline(value: boolean);
  83962. /**
  83963. * Gets or sets an boolean indicating that text must be crossed out
  83964. */
  83965. get lineThrough(): boolean;
  83966. /**
  83967. * Gets or sets an boolean indicating that text must be crossed out
  83968. */
  83969. set lineThrough(value: boolean);
  83970. /**
  83971. * Gets or sets outlineColor of the text to display
  83972. */
  83973. get outlineColor(): string;
  83974. /**
  83975. * Gets or sets outlineColor of the text to display
  83976. */
  83977. set outlineColor(value: string);
  83978. /**
  83979. * Creates a new TextBlock object
  83980. * @param name defines the name of the control
  83981. * @param text defines the text to display (emptry string by default)
  83982. */
  83983. constructor(
  83984. /**
  83985. * Defines the name of the control
  83986. */
  83987. name?: string | undefined, text?: string);
  83988. protected _getTypeName(): string;
  83989. protected _processMeasures(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  83990. private _drawText;
  83991. /** @hidden */
  83992. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): void;
  83993. protected _applyStates(context: CanvasRenderingContext2D): void;
  83994. protected _breakLines(refWidth: number, context: CanvasRenderingContext2D): object[];
  83995. protected _parseLine(line: string | undefined, context: CanvasRenderingContext2D): object;
  83996. protected _parseLineEllipsis(line: string | undefined, width: number, context: CanvasRenderingContext2D): object;
  83997. protected _parseLineWordWrap(line: string | undefined, width: number, context: CanvasRenderingContext2D): object[];
  83998. protected _renderLines(context: CanvasRenderingContext2D): void;
  83999. /**
  84000. * Given a width constraint applied on the text block, find the expected height
  84001. * @returns expected height
  84002. */
  84003. computeExpectedHeight(): number;
  84004. dispose(): void;
  84005. }
  84006. }
  84007. declare module BABYLON.GUI {
  84008. /**
  84009. * Class used to create 2D images
  84010. */
  84011. export class Image extends Control {
  84012. name?: string | undefined;
  84013. private _workingCanvas;
  84014. private _domImage;
  84015. private _imageWidth;
  84016. private _imageHeight;
  84017. private _loaded;
  84018. private _stretch;
  84019. private _source;
  84020. private _autoScale;
  84021. private _sourceLeft;
  84022. private _sourceTop;
  84023. private _sourceWidth;
  84024. private _sourceHeight;
  84025. private _svgAttributesComputationCompleted;
  84026. private _isSVG;
  84027. private _cellWidth;
  84028. private _cellHeight;
  84029. private _cellId;
  84030. private _populateNinePatchSlicesFromImage;
  84031. private _sliceLeft;
  84032. private _sliceRight;
  84033. private _sliceTop;
  84034. private _sliceBottom;
  84035. private _detectPointerOnOpaqueOnly;
  84036. private _imageDataCache;
  84037. /**
  84038. * BABYLON.Observable notified when the content is loaded
  84039. */
  84040. onImageLoadedObservable: BABYLON.Observable<Image>;
  84041. /**
  84042. * BABYLON.Observable notified when _sourceLeft, _sourceTop, _sourceWidth and _sourceHeight are computed
  84043. */
  84044. onSVGAttributesComputedObservable: BABYLON.Observable<Image>;
  84045. /**
  84046. * Gets a boolean indicating that the content is loaded
  84047. */
  84048. get isLoaded(): boolean;
  84049. /**
  84050. * Gets or sets a boolean indicating if nine patch slices (left, top, right, bottom) should be read from image data
  84051. */
  84052. get populateNinePatchSlicesFromImage(): boolean;
  84053. set populateNinePatchSlicesFromImage(value: boolean);
  84054. /**
  84055. * Gets or sets a boolean indicating if pointers should only be validated on pixels with alpha > 0.
  84056. * Beware using this as this will comsume more memory as the image has to be stored twice
  84057. */
  84058. get detectPointerOnOpaqueOnly(): boolean;
  84059. set detectPointerOnOpaqueOnly(value: boolean);
  84060. /**
  84061. * Gets or sets the left value for slicing (9-patch)
  84062. */
  84063. get sliceLeft(): number;
  84064. set sliceLeft(value: number);
  84065. /**
  84066. * Gets or sets the right value for slicing (9-patch)
  84067. */
  84068. get sliceRight(): number;
  84069. set sliceRight(value: number);
  84070. /**
  84071. * Gets or sets the top value for slicing (9-patch)
  84072. */
  84073. get sliceTop(): number;
  84074. set sliceTop(value: number);
  84075. /**
  84076. * Gets or sets the bottom value for slicing (9-patch)
  84077. */
  84078. get sliceBottom(): number;
  84079. set sliceBottom(value: number);
  84080. /**
  84081. * Gets or sets the left coordinate in the source image
  84082. */
  84083. get sourceLeft(): number;
  84084. set sourceLeft(value: number);
  84085. /**
  84086. * Gets or sets the top coordinate in the source image
  84087. */
  84088. get sourceTop(): number;
  84089. set sourceTop(value: number);
  84090. /**
  84091. * Gets or sets the width to capture in the source image
  84092. */
  84093. get sourceWidth(): number;
  84094. set sourceWidth(value: number);
  84095. /**
  84096. * Gets or sets the height to capture in the source image
  84097. */
  84098. get sourceHeight(): number;
  84099. set sourceHeight(value: number);
  84100. /** Indicates if the format of the image is SVG */
  84101. get isSVG(): boolean;
  84102. /** Gets the status of the SVG attributes computation (sourceLeft, sourceTop, sourceWidth, sourceHeight) */
  84103. get svgAttributesComputationCompleted(): boolean;
  84104. /**
  84105. * Gets or sets a boolean indicating if the image can force its container to adapt its size
  84106. * @see https://doc.babylonjs.com/how_to/gui#image
  84107. */
  84108. get autoScale(): boolean;
  84109. set autoScale(value: boolean);
  84110. /** Gets or sets the streching mode used by the image */
  84111. get stretch(): number;
  84112. set stretch(value: number);
  84113. /** @hidden */
  84114. _rotate90(n: number, preserveProperties?: boolean): Image;
  84115. private _handleRotationForSVGImage;
  84116. private _rotate90SourceProperties;
  84117. /**
  84118. * Gets or sets the internal DOM image used to render the control
  84119. */
  84120. set domImage(value: HTMLImageElement);
  84121. get domImage(): HTMLImageElement;
  84122. private _onImageLoaded;
  84123. private _extractNinePatchSliceDataFromImage;
  84124. /**
  84125. * Gets the image source url
  84126. */
  84127. get source(): BABYLON.Nullable<string>;
  84128. /**
  84129. * Gets or sets image source url
  84130. */
  84131. set source(value: BABYLON.Nullable<string>);
  84132. /**
  84133. * Checks for svg document with icon id present
  84134. */
  84135. private _svgCheck;
  84136. /**
  84137. * Sets sourceLeft, sourceTop, sourceWidth, sourceHeight automatically
  84138. * given external svg file and icon id
  84139. */
  84140. private _getSVGAttribs;
  84141. /**
  84142. * Gets or sets the cell width to use when animation sheet is enabled
  84143. * @see https://doc.babylonjs.com/how_to/gui#image
  84144. */
  84145. get cellWidth(): number;
  84146. set cellWidth(value: number);
  84147. /**
  84148. * Gets or sets the cell height to use when animation sheet is enabled
  84149. * @see https://doc.babylonjs.com/how_to/gui#image
  84150. */
  84151. get cellHeight(): number;
  84152. set cellHeight(value: number);
  84153. /**
  84154. * Gets or sets the cell id to use (this will turn on the animation sheet mode)
  84155. * @see https://doc.babylonjs.com/how_to/gui#image
  84156. */
  84157. get cellId(): number;
  84158. set cellId(value: number);
  84159. /**
  84160. * Creates a new Image
  84161. * @param name defines the control name
  84162. * @param url defines the image url
  84163. */
  84164. constructor(name?: string | undefined, url?: BABYLON.Nullable<string>);
  84165. /**
  84166. * Tests if a given coordinates belong to the current control
  84167. * @param x defines x coordinate to test
  84168. * @param y defines y coordinate to test
  84169. * @returns true if the coordinates are inside the control
  84170. */
  84171. contains(x: number, y: number): boolean;
  84172. protected _getTypeName(): string;
  84173. /** Force the control to synchronize with its content */
  84174. synchronizeSizeWithContent(): void;
  84175. protected _processMeasures(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  84176. private _prepareWorkingCanvasForOpaqueDetection;
  84177. private _drawImage;
  84178. _draw(context: CanvasRenderingContext2D): void;
  84179. private _renderCornerPatch;
  84180. private _renderNinePatch;
  84181. dispose(): void;
  84182. /** STRETCH_NONE */
  84183. static readonly STRETCH_NONE: number;
  84184. /** STRETCH_FILL */
  84185. static readonly STRETCH_FILL: number;
  84186. /** STRETCH_UNIFORM */
  84187. static readonly STRETCH_UNIFORM: number;
  84188. /** STRETCH_EXTEND */
  84189. static readonly STRETCH_EXTEND: number;
  84190. /** NINE_PATCH */
  84191. static readonly STRETCH_NINE_PATCH: number;
  84192. }
  84193. }
  84194. declare module BABYLON.GUI {
  84195. /**
  84196. * Class used to create 2D buttons
  84197. */
  84198. export class Button extends Rectangle {
  84199. name?: string | undefined;
  84200. /**
  84201. * Function called to generate a pointer enter animation
  84202. */
  84203. pointerEnterAnimation: () => void;
  84204. /**
  84205. * Function called to generate a pointer out animation
  84206. */
  84207. pointerOutAnimation: () => void;
  84208. /**
  84209. * Function called to generate a pointer down animation
  84210. */
  84211. pointerDownAnimation: () => void;
  84212. /**
  84213. * Function called to generate a pointer up animation
  84214. */
  84215. pointerUpAnimation: () => void;
  84216. /**
  84217. * Gets or sets a boolean indicating that the button will let internal controls handle picking instead of doing it directly using its bounding info
  84218. */
  84219. delegatePickingToChildren: boolean;
  84220. private _image;
  84221. /**
  84222. * Returns the image part of the button (if any)
  84223. */
  84224. get image(): BABYLON.Nullable<Image>;
  84225. private _textBlock;
  84226. /**
  84227. * Returns the image part of the button (if any)
  84228. */
  84229. get textBlock(): BABYLON.Nullable<TextBlock>;
  84230. /**
  84231. * Creates a new Button
  84232. * @param name defines the name of the button
  84233. */
  84234. constructor(name?: string | undefined);
  84235. protected _getTypeName(): string;
  84236. /** @hidden */
  84237. _processPicking(x: number, y: number, pi: BABYLON.PointerInfoBase, type: number, pointerId: number, buttonIndex: number, deltaX?: number, deltaY?: number): boolean;
  84238. /** @hidden */
  84239. _onPointerEnter(target: Control, pi: BABYLON.PointerInfoBase): boolean;
  84240. /** @hidden */
  84241. _onPointerOut(target: Control, pi: BABYLON.PointerInfoBase, force?: boolean): void;
  84242. /** @hidden */
  84243. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, pi: BABYLON.PointerInfoBase): boolean;
  84244. /** @hidden */
  84245. _onPointerUp(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, notifyClick: boolean, pi: BABYLON.PointerInfoBase): void;
  84246. /**
  84247. * Creates a new button made with an image and a text
  84248. * @param name defines the name of the button
  84249. * @param text defines the text of the button
  84250. * @param imageUrl defines the url of the image
  84251. * @returns a new Button
  84252. */
  84253. static CreateImageButton(name: string, text: string, imageUrl: string): Button;
  84254. /**
  84255. * Creates a new button made with an image
  84256. * @param name defines the name of the button
  84257. * @param imageUrl defines the url of the image
  84258. * @returns a new Button
  84259. */
  84260. static CreateImageOnlyButton(name: string, imageUrl: string): Button;
  84261. /**
  84262. * Creates a new button made with a text
  84263. * @param name defines the name of the button
  84264. * @param text defines the text of the button
  84265. * @returns a new Button
  84266. */
  84267. static CreateSimpleButton(name: string, text: string): Button;
  84268. /**
  84269. * Creates a new button made with an image and a centered text
  84270. * @param name defines the name of the button
  84271. * @param text defines the text of the button
  84272. * @param imageUrl defines the url of the image
  84273. * @returns a new Button
  84274. */
  84275. static CreateImageWithCenterTextButton(name: string, text: string, imageUrl: string): Button;
  84276. }
  84277. }
  84278. declare module BABYLON.GUI {
  84279. /**
  84280. * Class used to create a 2D stack panel container
  84281. */
  84282. export class StackPanel extends Container {
  84283. name?: string | undefined;
  84284. private _isVertical;
  84285. private _manualWidth;
  84286. private _manualHeight;
  84287. private _doNotTrackManualChanges;
  84288. /**
  84289. * Gets or sets a boolean indicating that layou warnings should be ignored
  84290. */
  84291. ignoreLayoutWarnings: boolean;
  84292. /** Gets or sets a boolean indicating if the stack panel is vertical or horizontal*/
  84293. get isVertical(): boolean;
  84294. set isVertical(value: boolean);
  84295. /**
  84296. * Gets or sets panel width.
  84297. * This value should not be set when in horizontal mode as it will be computed automatically
  84298. */
  84299. set width(value: string | number);
  84300. get width(): string | number;
  84301. /**
  84302. * Gets or sets panel height.
  84303. * This value should not be set when in vertical mode as it will be computed automatically
  84304. */
  84305. set height(value: string | number);
  84306. get height(): string | number;
  84307. /**
  84308. * Creates a new StackPanel
  84309. * @param name defines control name
  84310. */
  84311. constructor(name?: string | undefined);
  84312. protected _getTypeName(): string;
  84313. /** @hidden */
  84314. protected _preMeasure(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  84315. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  84316. protected _postMeasure(): void;
  84317. /**
  84318. * Serializes the current control
  84319. * @param serializationObject defined the JSON serialized object
  84320. */
  84321. serialize(serializationObject: any): void;
  84322. /** @hidden */
  84323. _parseFromContent(serializedObject: any, host: AdvancedDynamicTexture): void;
  84324. }
  84325. }
  84326. declare module BABYLON.GUI {
  84327. /**
  84328. * Class used to represent a 2D checkbox
  84329. */
  84330. export class Checkbox extends Control {
  84331. name?: string | undefined;
  84332. private _isChecked;
  84333. private _background;
  84334. private _checkSizeRatio;
  84335. private _thickness;
  84336. /** Gets or sets border thickness */
  84337. get thickness(): number;
  84338. set thickness(value: number);
  84339. /**
  84340. * BABYLON.Observable raised when isChecked property changes
  84341. */
  84342. onIsCheckedChangedObservable: BABYLON.Observable<boolean>;
  84343. /** Gets or sets a value indicating the ratio between overall size and check size */
  84344. get checkSizeRatio(): number;
  84345. set checkSizeRatio(value: number);
  84346. /** Gets or sets background color */
  84347. get background(): string;
  84348. set background(value: string);
  84349. /** Gets or sets a boolean indicating if the checkbox is checked or not */
  84350. get isChecked(): boolean;
  84351. set isChecked(value: boolean);
  84352. /**
  84353. * Creates a new CheckBox
  84354. * @param name defines the control name
  84355. */
  84356. constructor(name?: string | undefined);
  84357. protected _getTypeName(): string;
  84358. /** @hidden */
  84359. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): void;
  84360. /** @hidden */
  84361. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, pi: BABYLON.PointerInfoBase): boolean;
  84362. /**
  84363. * Utility function to easily create a checkbox with a header
  84364. * @param title defines the label to use for the header
  84365. * @param onValueChanged defines the callback to call when value changes
  84366. * @returns a StackPanel containing the checkbox and a textBlock
  84367. */
  84368. static AddCheckBoxWithHeader(title: string, onValueChanged: (value: boolean) => void): StackPanel;
  84369. }
  84370. }
  84371. declare module BABYLON.GUI {
  84372. /**
  84373. * Class used to store key control properties
  84374. */
  84375. export class KeyPropertySet {
  84376. /** Width */
  84377. width?: string;
  84378. /** Height */
  84379. height?: string;
  84380. /** Left padding */
  84381. paddingLeft?: string;
  84382. /** Right padding */
  84383. paddingRight?: string;
  84384. /** Top padding */
  84385. paddingTop?: string;
  84386. /** Bottom padding */
  84387. paddingBottom?: string;
  84388. /** Foreground color */
  84389. color?: string;
  84390. /** Background color */
  84391. background?: string;
  84392. }
  84393. /**
  84394. * Class used to create virtual keyboard
  84395. */
  84396. export class VirtualKeyboard extends StackPanel {
  84397. /** BABYLON.Observable raised when a key is pressed */
  84398. onKeyPressObservable: BABYLON.Observable<string>;
  84399. /** Gets or sets default key button width */
  84400. defaultButtonWidth: string;
  84401. /** Gets or sets default key button height */
  84402. defaultButtonHeight: string;
  84403. /** Gets or sets default key button left padding */
  84404. defaultButtonPaddingLeft: string;
  84405. /** Gets or sets default key button right padding */
  84406. defaultButtonPaddingRight: string;
  84407. /** Gets or sets default key button top padding */
  84408. defaultButtonPaddingTop: string;
  84409. /** Gets or sets default key button bottom padding */
  84410. defaultButtonPaddingBottom: string;
  84411. /** Gets or sets default key button foreground color */
  84412. defaultButtonColor: string;
  84413. /** Gets or sets default key button background color */
  84414. defaultButtonBackground: string;
  84415. /** Gets or sets shift button foreground color */
  84416. shiftButtonColor: string;
  84417. /** Gets or sets shift button thickness*/
  84418. selectedShiftThickness: number;
  84419. /** Gets shift key state */
  84420. shiftState: number;
  84421. protected _getTypeName(): string;
  84422. private _createKey;
  84423. /**
  84424. * Adds a new row of keys
  84425. * @param keys defines the list of keys to add
  84426. * @param propertySets defines the associated property sets
  84427. */
  84428. addKeysRow(keys: Array<string>, propertySets?: Array<KeyPropertySet>): void;
  84429. /**
  84430. * Set the shift key to a specific state
  84431. * @param shiftState defines the new shift state
  84432. */
  84433. applyShiftState(shiftState: number): void;
  84434. private _currentlyConnectedInputText;
  84435. private _connectedInputTexts;
  84436. private _onKeyPressObserver;
  84437. /** Gets the input text control currently attached to the keyboard */
  84438. get connectedInputText(): BABYLON.Nullable<InputText>;
  84439. /**
  84440. * Connects the keyboard with an input text control
  84441. *
  84442. * @param input defines the target control
  84443. */
  84444. connect(input: InputText): void;
  84445. /**
  84446. * Disconnects the keyboard from connected InputText controls
  84447. *
  84448. * @param input optionally defines a target control, otherwise all are disconnected
  84449. */
  84450. disconnect(input?: InputText): void;
  84451. private _removeConnectedInputObservables;
  84452. /**
  84453. * Release all resources
  84454. */
  84455. dispose(): void;
  84456. /**
  84457. * Creates a new keyboard using a default layout
  84458. *
  84459. * @param name defines control name
  84460. * @returns a new VirtualKeyboard
  84461. */
  84462. static CreateDefaultLayout(name?: string): VirtualKeyboard;
  84463. }
  84464. }
  84465. declare module BABYLON.GUI {
  84466. /** @hidden */
  84467. export class TextWrapper {
  84468. private _text;
  84469. private _characters;
  84470. get text(): string;
  84471. set text(txt: string);
  84472. get length(): number;
  84473. removePart(idxStart: number, idxEnd: number, insertTxt?: string): void;
  84474. charAt(idx: number): string;
  84475. substr(from: number, length?: number): string;
  84476. substring(from: number, to?: number): string;
  84477. isWord(index: number): boolean;
  84478. }
  84479. }
  84480. declare module BABYLON.GUI {
  84481. /**
  84482. * Class used to create input text control
  84483. */
  84484. export class InputText extends Control implements IFocusableControl {
  84485. name?: string | undefined;
  84486. private _textWrapper;
  84487. private _placeholderText;
  84488. private _background;
  84489. private _focusedBackground;
  84490. private _focusedColor;
  84491. private _placeholderColor;
  84492. private _thickness;
  84493. private _margin;
  84494. private _autoStretchWidth;
  84495. private _maxWidth;
  84496. private _isFocused;
  84497. private _blinkTimeout;
  84498. private _blinkIsEven;
  84499. private _cursorOffset;
  84500. private _scrollLeft;
  84501. private _textWidth;
  84502. private _clickedCoordinate;
  84503. private _deadKey;
  84504. private _addKey;
  84505. private _currentKey;
  84506. private _isTextHighlightOn;
  84507. private _textHighlightColor;
  84508. private _highligherOpacity;
  84509. private _highlightedText;
  84510. private _startHighlightIndex;
  84511. private _endHighlightIndex;
  84512. private _cursorIndex;
  84513. private _onFocusSelectAll;
  84514. private _isPointerDown;
  84515. private _onClipboardObserver;
  84516. private _onPointerDblTapObserver;
  84517. /** @hidden */
  84518. _connectedVirtualKeyboard: BABYLON.Nullable<VirtualKeyboard>;
  84519. /** Gets or sets a string representing the message displayed on mobile when the control gets the focus */
  84520. promptMessage: string;
  84521. /** Force disable prompt on mobile device */
  84522. disableMobilePrompt: boolean;
  84523. /** BABYLON.Observable raised when the text changes */
  84524. onTextChangedObservable: BABYLON.Observable<InputText>;
  84525. /** BABYLON.Observable raised just before an entered character is to be added */
  84526. onBeforeKeyAddObservable: BABYLON.Observable<InputText>;
  84527. /** BABYLON.Observable raised when the control gets the focus */
  84528. onFocusObservable: BABYLON.Observable<InputText>;
  84529. /** BABYLON.Observable raised when the control loses the focus */
  84530. onBlurObservable: BABYLON.Observable<InputText>;
  84531. /**Observable raised when the text is highlighted */
  84532. onTextHighlightObservable: BABYLON.Observable<InputText>;
  84533. /**Observable raised when copy event is triggered */
  84534. onTextCopyObservable: BABYLON.Observable<InputText>;
  84535. /** BABYLON.Observable raised when cut event is triggered */
  84536. onTextCutObservable: BABYLON.Observable<InputText>;
  84537. /** BABYLON.Observable raised when paste event is triggered */
  84538. onTextPasteObservable: BABYLON.Observable<InputText>;
  84539. /** BABYLON.Observable raised when a key event was processed */
  84540. onKeyboardEventProcessedObservable: BABYLON.Observable<KeyboardEvent>;
  84541. /** Gets or sets the maximum width allowed by the control */
  84542. get maxWidth(): string | number;
  84543. /** Gets the maximum width allowed by the control in pixels */
  84544. get maxWidthInPixels(): number;
  84545. set maxWidth(value: string | number);
  84546. /** Gets or sets the text highlighter transparency; default: 0.4 */
  84547. get highligherOpacity(): number;
  84548. set highligherOpacity(value: number);
  84549. /** Gets or sets a boolean indicating whether to select complete text by default on input focus */
  84550. get onFocusSelectAll(): boolean;
  84551. set onFocusSelectAll(value: boolean);
  84552. /** Gets or sets the text hightlight color */
  84553. get textHighlightColor(): string;
  84554. set textHighlightColor(value: string);
  84555. /** Gets or sets control margin */
  84556. get margin(): string;
  84557. /** Gets control margin in pixels */
  84558. get marginInPixels(): number;
  84559. set margin(value: string);
  84560. /** Gets or sets a boolean indicating if the control can auto stretch its width to adapt to the text */
  84561. get autoStretchWidth(): boolean;
  84562. set autoStretchWidth(value: boolean);
  84563. /** Gets or sets border thickness */
  84564. get thickness(): number;
  84565. set thickness(value: number);
  84566. /** Gets or sets the background color when focused */
  84567. get focusedBackground(): string;
  84568. set focusedBackground(value: string);
  84569. /** Gets or sets the background color when focused */
  84570. get focusedColor(): string;
  84571. set focusedColor(value: string);
  84572. /** Gets or sets the background color */
  84573. get background(): string;
  84574. set background(value: string);
  84575. /** Gets or sets the placeholder color */
  84576. get placeholderColor(): string;
  84577. set placeholderColor(value: string);
  84578. /** Gets or sets the text displayed when the control is empty */
  84579. get placeholderText(): string;
  84580. set placeholderText(value: string);
  84581. /** Gets or sets the dead key flag */
  84582. get deadKey(): boolean;
  84583. set deadKey(flag: boolean);
  84584. /** Gets or sets the highlight text */
  84585. get highlightedText(): string;
  84586. set highlightedText(text: string);
  84587. /** Gets or sets if the current key should be added */
  84588. get addKey(): boolean;
  84589. set addKey(flag: boolean);
  84590. /** Gets or sets the value of the current key being entered */
  84591. get currentKey(): string;
  84592. set currentKey(key: string);
  84593. /** Gets or sets the text displayed in the control */
  84594. get text(): string;
  84595. set text(value: string);
  84596. private _textHasChanged;
  84597. /** Gets or sets control width */
  84598. get width(): string | number;
  84599. set width(value: string | number);
  84600. /**
  84601. * Creates a new InputText
  84602. * @param name defines the control name
  84603. * @param text defines the text of the control
  84604. */
  84605. constructor(name?: string | undefined, text?: string);
  84606. /** @hidden */
  84607. onBlur(): void;
  84608. /** @hidden */
  84609. onFocus(): void;
  84610. /**
  84611. * Function to focus an inputText programmatically
  84612. */
  84613. focus(): void;
  84614. /**
  84615. * Function to unfocus an inputText programmatically
  84616. */
  84617. blur(): void;
  84618. protected _getTypeName(): string;
  84619. /**
  84620. * Function called to get the list of controls that should not steal the focus from this control
  84621. * @returns an array of controls
  84622. */
  84623. keepsFocusWith(): BABYLON.Nullable<Control[]>;
  84624. /** @hidden */
  84625. processKey(keyCode: number, key?: string, evt?: KeyboardEvent): void;
  84626. /** @hidden */
  84627. private _updateValueFromCursorIndex;
  84628. /** @hidden */
  84629. private _processDblClick;
  84630. /** @hidden */
  84631. private _selectAllText;
  84632. /**
  84633. * Handles the keyboard event
  84634. * @param evt Defines the KeyboardEvent
  84635. */
  84636. processKeyboard(evt: KeyboardEvent): void;
  84637. /** @hidden */
  84638. private _onCopyText;
  84639. /** @hidden */
  84640. private _onCutText;
  84641. /** @hidden */
  84642. private _onPasteText;
  84643. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): void;
  84644. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, pi: BABYLON.PointerInfoBase): boolean;
  84645. _onPointerMove(target: Control, coordinates: BABYLON.Vector2, pointerId: number, pi: BABYLON.PointerInfoBase): void;
  84646. _onPointerUp(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, notifyClick: boolean): void;
  84647. protected _beforeRenderText(textWrapper: TextWrapper): TextWrapper;
  84648. dispose(): void;
  84649. }
  84650. }
  84651. declare module BABYLON.GUI {
  84652. /**
  84653. * Class used to create a 2D grid container
  84654. */
  84655. export class Grid extends Container {
  84656. name?: string | undefined;
  84657. private _rowDefinitions;
  84658. private _columnDefinitions;
  84659. private _cells;
  84660. private _childControls;
  84661. /**
  84662. * Gets the number of columns
  84663. */
  84664. get columnCount(): number;
  84665. /**
  84666. * Gets the number of rows
  84667. */
  84668. get rowCount(): number;
  84669. /** Gets the list of children */
  84670. get children(): Control[];
  84671. /** Gets the list of cells (e.g. the containers) */
  84672. get cells(): {
  84673. [key: string]: Container;
  84674. };
  84675. /**
  84676. * Gets the definition of a specific row
  84677. * @param index defines the index of the row
  84678. * @returns the row definition
  84679. */
  84680. getRowDefinition(index: number): BABYLON.Nullable<ValueAndUnit>;
  84681. /**
  84682. * Gets the definition of a specific column
  84683. * @param index defines the index of the column
  84684. * @returns the column definition
  84685. */
  84686. getColumnDefinition(index: number): BABYLON.Nullable<ValueAndUnit>;
  84687. /**
  84688. * Adds a new row to the grid
  84689. * @param height defines the height of the row (either in pixel or a value between 0 and 1)
  84690. * @param isPixel defines if the height is expressed in pixel (or in percentage)
  84691. * @returns the current grid
  84692. */
  84693. addRowDefinition(height: number, isPixel?: boolean): Grid;
  84694. /**
  84695. * Adds a new column to the grid
  84696. * @param width defines the width of the column (either in pixel or a value between 0 and 1)
  84697. * @param isPixel defines if the width is expressed in pixel (or in percentage)
  84698. * @returns the current grid
  84699. */
  84700. addColumnDefinition(width: number, isPixel?: boolean): Grid;
  84701. /**
  84702. * Update a row definition
  84703. * @param index defines the index of the row to update
  84704. * @param height defines the height of the row (either in pixel or a value between 0 and 1)
  84705. * @param isPixel defines if the weight is expressed in pixel (or in percentage)
  84706. * @returns the current grid
  84707. */
  84708. setRowDefinition(index: number, height: number, isPixel?: boolean): Grid;
  84709. /**
  84710. * Update a column definition
  84711. * @param index defines the index of the column to update
  84712. * @param width defines the width of the column (either in pixel or a value between 0 and 1)
  84713. * @param isPixel defines if the width is expressed in pixel (or in percentage)
  84714. * @returns the current grid
  84715. */
  84716. setColumnDefinition(index: number, width: number, isPixel?: boolean): Grid;
  84717. /**
  84718. * Gets the list of children stored in a specific cell
  84719. * @param row defines the row to check
  84720. * @param column defines the column to check
  84721. * @returns the list of controls
  84722. */
  84723. getChildrenAt(row: number, column: number): BABYLON.Nullable<Array<Control>>;
  84724. /**
  84725. * Gets a string representing the child cell info (row x column)
  84726. * @param child defines the control to get info from
  84727. * @returns a string containing the child cell info (row x column)
  84728. */
  84729. getChildCellInfo(child: Control): string;
  84730. private _removeCell;
  84731. private _offsetCell;
  84732. /**
  84733. * Remove a column definition at specified index
  84734. * @param index defines the index of the column to remove
  84735. * @returns the current grid
  84736. */
  84737. removeColumnDefinition(index: number): Grid;
  84738. /**
  84739. * Remove a row definition at specified index
  84740. * @param index defines the index of the row to remove
  84741. * @returns the current grid
  84742. */
  84743. removeRowDefinition(index: number): Grid;
  84744. /**
  84745. * Adds a new control to the current grid
  84746. * @param control defines the control to add
  84747. * @param row defines the row where to add the control (0 by default)
  84748. * @param column defines the column where to add the control (0 by default)
  84749. * @returns the current grid
  84750. */
  84751. addControl(control: Control, row?: number, column?: number): Grid;
  84752. /**
  84753. * Removes a control from the current container
  84754. * @param control defines the control to remove
  84755. * @returns the current container
  84756. */
  84757. removeControl(control: Control): Container;
  84758. /**
  84759. * Creates a new Grid
  84760. * @param name defines control name
  84761. */
  84762. constructor(name?: string | undefined);
  84763. protected _getTypeName(): string;
  84764. protected _getGridDefinitions(definitionCallback: (lefts: number[], tops: number[], widths: number[], heights: number[]) => void): void;
  84765. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  84766. _flagDescendantsAsMatrixDirty(): void;
  84767. _renderHighlightSpecific(context: CanvasRenderingContext2D): void;
  84768. /** Releases associated resources */
  84769. dispose(): void;
  84770. }
  84771. }
  84772. declare module BABYLON.GUI {
  84773. /** Class used to create color pickers */
  84774. export class ColorPicker extends Control {
  84775. name?: string | undefined;
  84776. private static _Epsilon;
  84777. private _colorWheelCanvas;
  84778. private _value;
  84779. private _tmpColor;
  84780. private _pointerStartedOnSquare;
  84781. private _pointerStartedOnWheel;
  84782. private _squareLeft;
  84783. private _squareTop;
  84784. private _squareSize;
  84785. private _h;
  84786. private _s;
  84787. private _v;
  84788. private _lastPointerDownID;
  84789. /**
  84790. * BABYLON.Observable raised when the value changes
  84791. */
  84792. onValueChangedObservable: BABYLON.Observable<BABYLON.Color3>;
  84793. /** Gets or sets the color of the color picker */
  84794. get value(): BABYLON.Color3;
  84795. set value(value: BABYLON.Color3);
  84796. /**
  84797. * Gets or sets control width
  84798. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  84799. */
  84800. get width(): string | number;
  84801. set width(value: string | number);
  84802. /**
  84803. * Gets or sets control height
  84804. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  84805. */
  84806. get height(): string | number;
  84807. /** Gets or sets control height */
  84808. set height(value: string | number);
  84809. /** Gets or sets control size */
  84810. get size(): string | number;
  84811. set size(value: string | number);
  84812. /**
  84813. * Creates a new ColorPicker
  84814. * @param name defines the control name
  84815. */
  84816. constructor(name?: string | undefined);
  84817. protected _getTypeName(): string;
  84818. /** @hidden */
  84819. protected _preMeasure(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  84820. private _updateSquareProps;
  84821. private _drawGradientSquare;
  84822. private _drawCircle;
  84823. private _createColorWheelCanvas;
  84824. /** @hidden */
  84825. _draw(context: CanvasRenderingContext2D): void;
  84826. private _pointerIsDown;
  84827. private _updateValueFromPointer;
  84828. private _isPointOnSquare;
  84829. private _isPointOnWheel;
  84830. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, pi: BABYLON.PointerInfoBase): boolean;
  84831. _onPointerMove(target: Control, coordinates: BABYLON.Vector2, pointerId: number, pi: BABYLON.PointerInfoBase): void;
  84832. _onPointerUp(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, notifyClick: boolean, pi: BABYLON.PointerInfoBase): void;
  84833. _onCanvasBlur(): void;
  84834. /**
  84835. * This function expands the color picker by creating a color picker dialog with manual
  84836. * color value input and the ability to save colors into an array to be used later in
  84837. * subsequent launches of the dialogue.
  84838. * @param advancedTexture defines the AdvancedDynamicTexture the dialog is assigned to
  84839. * @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.
  84840. * @returns picked color as a hex string and the saved colors array as hex strings.
  84841. */
  84842. static ShowPickerDialogAsync(advancedTexture: AdvancedDynamicTexture, options: {
  84843. pickerWidth?: string;
  84844. pickerHeight?: string;
  84845. headerHeight?: string;
  84846. lastColor?: string;
  84847. swatchLimit?: number;
  84848. numSwatchesPerLine?: number;
  84849. savedColors?: Array<string>;
  84850. }): Promise<{
  84851. savedColors?: string[];
  84852. pickedColor: string;
  84853. }>;
  84854. }
  84855. }
  84856. declare module BABYLON.GUI {
  84857. /** Class used to create 2D ellipse containers */
  84858. export class Ellipse extends Container {
  84859. name?: string | undefined;
  84860. private _thickness;
  84861. /** Gets or sets border thickness */
  84862. get thickness(): number;
  84863. set thickness(value: number);
  84864. /**
  84865. * Creates a new Ellipse
  84866. * @param name defines the control name
  84867. */
  84868. constructor(name?: string | undefined);
  84869. protected _getTypeName(): string;
  84870. protected _localDraw(context: CanvasRenderingContext2D): void;
  84871. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  84872. protected _clipForChildren(context: CanvasRenderingContext2D): void;
  84873. }
  84874. }
  84875. declare module BABYLON.GUI {
  84876. /**
  84877. * Class used to create a focusable button that can easily handle keyboard events
  84878. */
  84879. export class FocusableButton extends Button implements IFocusableControl {
  84880. name?: string | undefined;
  84881. /** Highlight color when button is focused */
  84882. focusedColor: BABYLON.Nullable<string>;
  84883. private _isFocused;
  84884. private _unfocusedColor;
  84885. /** BABYLON.Observable raised when the control gets the focus */
  84886. onFocusObservable: BABYLON.Observable<Button>;
  84887. /** BABYLON.Observable raised when the control loses the focus */
  84888. onBlurObservable: BABYLON.Observable<Button>;
  84889. /** BABYLON.Observable raised when a key event was processed */
  84890. onKeyboardEventProcessedObservable: BABYLON.Observable<KeyboardEvent>;
  84891. constructor(name?: string | undefined);
  84892. /** @hidden */
  84893. onBlur(): void;
  84894. /** @hidden */
  84895. onFocus(): void;
  84896. /**
  84897. * Function called to get the list of controls that should not steal the focus from this control
  84898. * @returns an array of controls
  84899. */
  84900. keepsFocusWith(): BABYLON.Nullable<Control[]>;
  84901. /**
  84902. * Function to focus a button programmatically
  84903. */
  84904. focus(): void;
  84905. /**
  84906. * Function to unfocus a button programmatically
  84907. */
  84908. blur(): void;
  84909. /**
  84910. * Handles the keyboard event
  84911. * @param evt Defines the KeyboardEvent
  84912. */
  84913. processKeyboard(evt: KeyboardEvent): void;
  84914. /** @hidden */
  84915. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, pi: BABYLON.PointerInfoBase): boolean;
  84916. /** @hidden */
  84917. displose(): void;
  84918. }
  84919. }
  84920. declare module BABYLON.GUI {
  84921. /**
  84922. * Class used to create a password control
  84923. */
  84924. export class InputPassword extends InputText {
  84925. protected _beforeRenderText(textWrapper: TextWrapper): TextWrapper;
  84926. }
  84927. }
  84928. declare module BABYLON.GUI {
  84929. /** Class used to render 2D lines */
  84930. export class Line extends Control {
  84931. name?: string | undefined;
  84932. private _lineWidth;
  84933. private _x1;
  84934. private _y1;
  84935. private _x2;
  84936. private _y2;
  84937. private _dash;
  84938. private _connectedControl;
  84939. private _connectedControlDirtyObserver;
  84940. /** Gets or sets the dash pattern */
  84941. get dash(): Array<number>;
  84942. set dash(value: Array<number>);
  84943. /** Gets or sets the control connected with the line end */
  84944. get connectedControl(): Control;
  84945. set connectedControl(value: Control);
  84946. /** Gets or sets start coordinates on X axis */
  84947. get x1(): string | number;
  84948. set x1(value: string | number);
  84949. /** Gets or sets start coordinates on Y axis */
  84950. get y1(): string | number;
  84951. set y1(value: string | number);
  84952. /** Gets or sets end coordinates on X axis */
  84953. get x2(): string | number;
  84954. set x2(value: string | number);
  84955. /** Gets or sets end coordinates on Y axis */
  84956. get y2(): string | number;
  84957. set y2(value: string | number);
  84958. /** Gets or sets line width */
  84959. get lineWidth(): number;
  84960. set lineWidth(value: number);
  84961. /** Gets or sets horizontal alignment */
  84962. set horizontalAlignment(value: number);
  84963. /** Gets or sets vertical alignment */
  84964. set verticalAlignment(value: number);
  84965. private get _effectiveX2();
  84966. private get _effectiveY2();
  84967. /**
  84968. * Creates a new Line
  84969. * @param name defines the control name
  84970. */
  84971. constructor(name?: string | undefined);
  84972. protected _getTypeName(): string;
  84973. _draw(context: CanvasRenderingContext2D): void;
  84974. _measure(): void;
  84975. protected _computeAlignment(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  84976. /**
  84977. * Move one end of the line given 3D cartesian coordinates.
  84978. * @param position Targeted world position
  84979. * @param scene BABYLON.Scene
  84980. * @param end (opt) Set to true to assign x2 and y2 coordinates of the line. Default assign to x1 and y1.
  84981. */
  84982. moveToVector3(position: BABYLON.Vector3, scene: BABYLON.Scene, end?: boolean): void;
  84983. /**
  84984. * Move one end of the line to a position in screen absolute space.
  84985. * @param projectedPosition Position in screen absolute space (X, Y)
  84986. * @param end (opt) Set to true to assign x2 and y2 coordinates of the line. Default assign to x1 and y1.
  84987. */
  84988. _moveToProjectedPosition(projectedPosition: BABYLON.Vector3, end?: boolean): void;
  84989. }
  84990. }
  84991. declare module BABYLON.GUI {
  84992. /**
  84993. * Class used to store a point for a MultiLine object.
  84994. * The point can be pure 2D coordinates, a mesh or a control
  84995. */
  84996. export class MultiLinePoint {
  84997. private _multiLine;
  84998. private _x;
  84999. private _y;
  85000. private _control;
  85001. private _mesh;
  85002. private _controlObserver;
  85003. private _meshObserver;
  85004. /** @hidden */
  85005. _point: BABYLON.Vector3;
  85006. /**
  85007. * Creates a new MultiLinePoint
  85008. * @param multiLine defines the source MultiLine object
  85009. */
  85010. constructor(multiLine: MultiLine);
  85011. /** Gets or sets x coordinate */
  85012. get x(): string | number;
  85013. set x(value: string | number);
  85014. /** Gets or sets y coordinate */
  85015. get y(): string | number;
  85016. set y(value: string | number);
  85017. /** Gets or sets the control associated with this point */
  85018. get control(): BABYLON.Nullable<Control>;
  85019. set control(value: BABYLON.Nullable<Control>);
  85020. /** Gets or sets the mesh associated with this point */
  85021. get mesh(): BABYLON.Nullable<BABYLON.AbstractMesh>;
  85022. set mesh(value: BABYLON.Nullable<BABYLON.AbstractMesh>);
  85023. /** Resets links */
  85024. resetLinks(): void;
  85025. /**
  85026. * Gets a translation vector with Z component
  85027. * @returns the translation vector
  85028. */
  85029. translate(): BABYLON.Vector3;
  85030. private _translatePoint;
  85031. /** Release associated resources */
  85032. dispose(): void;
  85033. }
  85034. }
  85035. declare module BABYLON.GUI {
  85036. /**
  85037. * Class used to create multi line control
  85038. */
  85039. export class MultiLine extends Control {
  85040. name?: string | undefined;
  85041. private _lineWidth;
  85042. private _dash;
  85043. private _points;
  85044. private _minX;
  85045. private _minY;
  85046. private _maxX;
  85047. private _maxY;
  85048. /**
  85049. * Creates a new MultiLine
  85050. * @param name defines the control name
  85051. */
  85052. constructor(name?: string | undefined);
  85053. /** Gets or sets dash pattern */
  85054. get dash(): Array<number>;
  85055. set dash(value: Array<number>);
  85056. /**
  85057. * Gets point stored at specified index
  85058. * @param index defines the index to look for
  85059. * @returns the requested point if found
  85060. */
  85061. getAt(index: number): MultiLinePoint;
  85062. /** Function called when a point is updated */
  85063. onPointUpdate: () => void;
  85064. /**
  85065. * Adds new points to the point collection
  85066. * @param items defines the list of items (mesh, control or 2d coordiantes) to add
  85067. * @returns the list of created MultiLinePoint
  85068. */
  85069. add(...items: (AbstractMesh | Control | {
  85070. x: string | number;
  85071. y: string | number;
  85072. })[]): MultiLinePoint[];
  85073. /**
  85074. * Adds a new point to the point collection
  85075. * @param item defines the item (mesh, control or 2d coordiantes) to add
  85076. * @returns the created MultiLinePoint
  85077. */
  85078. push(item?: (AbstractMesh | Control | {
  85079. x: string | number;
  85080. y: string | number;
  85081. })): MultiLinePoint;
  85082. /**
  85083. * Remove a specific value or point from the active point collection
  85084. * @param value defines the value or point to remove
  85085. */
  85086. remove(value: number | MultiLinePoint): void;
  85087. /**
  85088. * Resets this object to initial state (no point)
  85089. */
  85090. reset(): void;
  85091. /**
  85092. * Resets all links
  85093. */
  85094. resetLinks(): void;
  85095. /** Gets or sets line width */
  85096. get lineWidth(): number;
  85097. set lineWidth(value: number);
  85098. set horizontalAlignment(value: number);
  85099. set verticalAlignment(value: number);
  85100. protected _getTypeName(): string;
  85101. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): void;
  85102. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  85103. _measure(): void;
  85104. protected _computeAlignment(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  85105. dispose(): void;
  85106. }
  85107. }
  85108. declare module BABYLON.GUI {
  85109. /**
  85110. * Class used to create radio button controls
  85111. */
  85112. export class RadioButton extends Control {
  85113. name?: string | undefined;
  85114. private _isChecked;
  85115. private _background;
  85116. private _checkSizeRatio;
  85117. private _thickness;
  85118. /** Gets or sets border thickness */
  85119. get thickness(): number;
  85120. set thickness(value: number);
  85121. /** Gets or sets group name */
  85122. group: string;
  85123. /** BABYLON.Observable raised when isChecked is changed */
  85124. onIsCheckedChangedObservable: BABYLON.Observable<boolean>;
  85125. /** Gets or sets a value indicating the ratio between overall size and check size */
  85126. get checkSizeRatio(): number;
  85127. set checkSizeRatio(value: number);
  85128. /** Gets or sets background color */
  85129. get background(): string;
  85130. set background(value: string);
  85131. /** Gets or sets a boolean indicating if the checkbox is checked or not */
  85132. get isChecked(): boolean;
  85133. set isChecked(value: boolean);
  85134. /**
  85135. * Creates a new RadioButton
  85136. * @param name defines the control name
  85137. */
  85138. constructor(name?: string | undefined);
  85139. protected _getTypeName(): string;
  85140. _draw(context: CanvasRenderingContext2D): void;
  85141. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, pi: BABYLON.PointerInfoBase): boolean;
  85142. /**
  85143. * Utility function to easily create a radio button with a header
  85144. * @param title defines the label to use for the header
  85145. * @param group defines the group to use for the radio button
  85146. * @param isChecked defines the initial state of the radio button
  85147. * @param onValueChanged defines the callback to call when value changes
  85148. * @returns a StackPanel containing the radio button and a textBlock
  85149. */
  85150. static AddRadioButtonWithHeader(title: string, group: string, isChecked: boolean, onValueChanged: (button: RadioButton, value: boolean) => void): StackPanel;
  85151. }
  85152. }
  85153. declare module BABYLON.GUI {
  85154. /**
  85155. * Class used to create slider controls
  85156. */
  85157. export class BaseSlider extends Control {
  85158. name?: string | undefined;
  85159. protected _thumbWidth: ValueAndUnit;
  85160. private _minimum;
  85161. private _maximum;
  85162. private _value;
  85163. private _isVertical;
  85164. protected _barOffset: ValueAndUnit;
  85165. private _isThumbClamped;
  85166. protected _displayThumb: boolean;
  85167. private _step;
  85168. private _lastPointerDownID;
  85169. protected _effectiveBarOffset: number;
  85170. protected _renderLeft: number;
  85171. protected _renderTop: number;
  85172. protected _renderWidth: number;
  85173. protected _renderHeight: number;
  85174. protected _backgroundBoxLength: number;
  85175. protected _backgroundBoxThickness: number;
  85176. protected _effectiveThumbThickness: number;
  85177. /** BABYLON.Observable raised when the sldier value changes */
  85178. onValueChangedObservable: BABYLON.Observable<number>;
  85179. /** Gets or sets a boolean indicating if the thumb must be rendered */
  85180. get displayThumb(): boolean;
  85181. set displayThumb(value: boolean);
  85182. /** Gets or sets a step to apply to values (0 by default) */
  85183. get step(): number;
  85184. set step(value: number);
  85185. /** Gets or sets main bar offset (ie. the margin applied to the value bar) */
  85186. get barOffset(): string | number;
  85187. /** Gets main bar offset in pixels*/
  85188. get barOffsetInPixels(): number;
  85189. set barOffset(value: string | number);
  85190. /** Gets or sets thumb width */
  85191. get thumbWidth(): string | number;
  85192. /** Gets thumb width in pixels */
  85193. get thumbWidthInPixels(): number;
  85194. set thumbWidth(value: string | number);
  85195. /** Gets or sets minimum value */
  85196. get minimum(): number;
  85197. set minimum(value: number);
  85198. /** Gets or sets maximum value */
  85199. get maximum(): number;
  85200. set maximum(value: number);
  85201. /** Gets or sets current value */
  85202. get value(): number;
  85203. set value(value: number);
  85204. /**Gets or sets a boolean indicating if the slider should be vertical or horizontal */
  85205. get isVertical(): boolean;
  85206. set isVertical(value: boolean);
  85207. /** Gets or sets a value indicating if the thumb can go over main bar extends */
  85208. get isThumbClamped(): boolean;
  85209. set isThumbClamped(value: boolean);
  85210. /**
  85211. * Creates a new BaseSlider
  85212. * @param name defines the control name
  85213. */
  85214. constructor(name?: string | undefined);
  85215. protected _getTypeName(): string;
  85216. protected _getThumbPosition(): number;
  85217. protected _getThumbThickness(type: string): number;
  85218. protected _prepareRenderingData(type: string): void;
  85219. private _pointerIsDown;
  85220. /** @hidden */
  85221. protected _updateValueFromPointer(x: number, y: number): void;
  85222. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, pi: BABYLON.PointerInfoBase): boolean;
  85223. _onPointerMove(target: Control, coordinates: BABYLON.Vector2, pointerId: number, pi: BABYLON.PointerInfoBase): void;
  85224. _onPointerUp(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, notifyClick: boolean): void;
  85225. _onCanvasBlur(): void;
  85226. }
  85227. }
  85228. declare module BABYLON.GUI {
  85229. /**
  85230. * Class used to create slider controls
  85231. */
  85232. export class Slider extends BaseSlider {
  85233. name?: string | undefined;
  85234. private _background;
  85235. private _borderColor;
  85236. private _thumbColor;
  85237. private _isThumbCircle;
  85238. protected _displayValueBar: boolean;
  85239. /** Gets or sets a boolean indicating if the value bar must be rendered */
  85240. get displayValueBar(): boolean;
  85241. set displayValueBar(value: boolean);
  85242. /** Gets or sets border color */
  85243. get borderColor(): string;
  85244. set borderColor(value: string);
  85245. /** Gets or sets background color */
  85246. get background(): string;
  85247. set background(value: string);
  85248. /** Gets or sets thumb's color */
  85249. get thumbColor(): string;
  85250. set thumbColor(value: string);
  85251. /** Gets or sets a boolean indicating if the thumb should be round or square */
  85252. get isThumbCircle(): boolean;
  85253. set isThumbCircle(value: boolean);
  85254. /**
  85255. * Creates a new Slider
  85256. * @param name defines the control name
  85257. */
  85258. constructor(name?: string | undefined);
  85259. protected _getTypeName(): string;
  85260. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): void;
  85261. }
  85262. }
  85263. declare module BABYLON.GUI {
  85264. /** Class used to create a RadioGroup
  85265. * which contains groups of radio buttons
  85266. */
  85267. export class SelectorGroup {
  85268. /** name of SelectorGroup */
  85269. name: string;
  85270. private _groupPanel;
  85271. private _selectors;
  85272. private _groupHeader;
  85273. /**
  85274. * Creates a new SelectorGroup
  85275. * @param name of group, used as a group heading
  85276. */
  85277. constructor(
  85278. /** name of SelectorGroup */
  85279. name: string);
  85280. /** Gets the groupPanel of the SelectorGroup */
  85281. get groupPanel(): StackPanel;
  85282. /** Gets the selectors array */
  85283. get selectors(): StackPanel[];
  85284. /** Gets and sets the group header */
  85285. get header(): string;
  85286. set header(label: string);
  85287. /** @hidden */
  85288. private _addGroupHeader;
  85289. /** @hidden*/
  85290. _getSelector(selectorNb: number): StackPanel | undefined;
  85291. /** Removes the selector at the given position
  85292. * @param selectorNb the position of the selector within the group
  85293. */
  85294. removeSelector(selectorNb: number): void;
  85295. }
  85296. /** Class used to create a CheckboxGroup
  85297. * which contains groups of checkbox buttons
  85298. */
  85299. export class CheckboxGroup extends SelectorGroup {
  85300. /** Adds a checkbox as a control
  85301. * @param text is the label for the selector
  85302. * @param func is the function called when the Selector is checked
  85303. * @param checked is true when Selector is checked
  85304. */
  85305. addCheckbox(text: string, func?: (s: boolean) => void, checked?: boolean): void;
  85306. /** @hidden */
  85307. _setSelectorLabel(selectorNb: number, label: string): void;
  85308. /** @hidden */
  85309. _setSelectorLabelColor(selectorNb: number, color: string): void;
  85310. /** @hidden */
  85311. _setSelectorButtonColor(selectorNb: number, color: string): void;
  85312. /** @hidden */
  85313. _setSelectorButtonBackground(selectorNb: number, color: string): void;
  85314. }
  85315. /** Class used to create a RadioGroup
  85316. * which contains groups of radio buttons
  85317. */
  85318. export class RadioGroup extends SelectorGroup {
  85319. private _selectNb;
  85320. /** Adds a radio button as a control
  85321. * @param label is the label for the selector
  85322. * @param func is the function called when the Selector is checked
  85323. * @param checked is true when Selector is checked
  85324. */
  85325. addRadio(label: string, func?: (n: number) => void, checked?: boolean): void;
  85326. /** @hidden */
  85327. _setSelectorLabel(selectorNb: number, label: string): void;
  85328. /** @hidden */
  85329. _setSelectorLabelColor(selectorNb: number, color: string): void;
  85330. /** @hidden */
  85331. _setSelectorButtonColor(selectorNb: number, color: string): void;
  85332. /** @hidden */
  85333. _setSelectorButtonBackground(selectorNb: number, color: string): void;
  85334. }
  85335. /** Class used to create a SliderGroup
  85336. * which contains groups of slider buttons
  85337. */
  85338. export class SliderGroup extends SelectorGroup {
  85339. /**
  85340. * Adds a slider to the SelectorGroup
  85341. * @param label is the label for the SliderBar
  85342. * @param func is the function called when the Slider moves
  85343. * @param unit is a string describing the units used, eg degrees or metres
  85344. * @param min is the minimum value for the Slider
  85345. * @param max is the maximum value for the Slider
  85346. * @param value is the start value for the Slider between min and max
  85347. * @param onValueChange is the function used to format the value displayed, eg radians to degrees
  85348. */
  85349. addSlider(label: string, func?: (v: number) => void, unit?: string, min?: number, max?: number, value?: number, onValueChange?: (v: number) => number): void;
  85350. /** @hidden */
  85351. _setSelectorLabel(selectorNb: number, label: string): void;
  85352. /** @hidden */
  85353. _setSelectorLabelColor(selectorNb: number, color: string): void;
  85354. /** @hidden */
  85355. _setSelectorButtonColor(selectorNb: number, color: string): void;
  85356. /** @hidden */
  85357. _setSelectorButtonBackground(selectorNb: number, color: string): void;
  85358. }
  85359. /** Class used to hold the controls for the checkboxes, radio buttons and sliders
  85360. * @see https://doc.babylonjs.com/how_to/selector
  85361. */
  85362. export class SelectionPanel extends Rectangle {
  85363. /** name of SelectionPanel */
  85364. name: string;
  85365. /** an array of SelectionGroups */
  85366. groups: SelectorGroup[];
  85367. private _panel;
  85368. private _buttonColor;
  85369. private _buttonBackground;
  85370. private _headerColor;
  85371. private _barColor;
  85372. private _barHeight;
  85373. private _spacerHeight;
  85374. private _labelColor;
  85375. private _groups;
  85376. private _bars;
  85377. /**
  85378. * Creates a new SelectionPanel
  85379. * @param name of SelectionPanel
  85380. * @param groups is an array of SelectionGroups
  85381. */
  85382. constructor(
  85383. /** name of SelectionPanel */
  85384. name: string,
  85385. /** an array of SelectionGroups */
  85386. groups?: SelectorGroup[]);
  85387. protected _getTypeName(): string;
  85388. /** Gets the (stack) panel of the SelectionPanel */
  85389. get panel(): StackPanel;
  85390. /** Gets or sets the headerColor */
  85391. get headerColor(): string;
  85392. set headerColor(color: string);
  85393. private _setHeaderColor;
  85394. /** Gets or sets the button color */
  85395. get buttonColor(): string;
  85396. set buttonColor(color: string);
  85397. private _setbuttonColor;
  85398. /** Gets or sets the label color */
  85399. get labelColor(): string;
  85400. set labelColor(color: string);
  85401. private _setLabelColor;
  85402. /** Gets or sets the button background */
  85403. get buttonBackground(): string;
  85404. set buttonBackground(color: string);
  85405. private _setButtonBackground;
  85406. /** Gets or sets the color of separator bar */
  85407. get barColor(): string;
  85408. set barColor(color: string);
  85409. private _setBarColor;
  85410. /** Gets or sets the height of separator bar */
  85411. get barHeight(): string;
  85412. set barHeight(value: string);
  85413. private _setBarHeight;
  85414. /** Gets or sets the height of spacers*/
  85415. get spacerHeight(): string;
  85416. set spacerHeight(value: string);
  85417. private _setSpacerHeight;
  85418. /** Adds a bar between groups */
  85419. private _addSpacer;
  85420. /** Add a group to the selection panel
  85421. * @param group is the selector group to add
  85422. */
  85423. addGroup(group: SelectorGroup): void;
  85424. /** Remove the group from the given position
  85425. * @param groupNb is the position of the group in the list
  85426. */
  85427. removeGroup(groupNb: number): void;
  85428. /** Change a group header label
  85429. * @param label is the new group header label
  85430. * @param groupNb is the number of the group to relabel
  85431. * */
  85432. setHeaderName(label: string, groupNb: number): void;
  85433. /** Change selector label to the one given
  85434. * @param label is the new selector label
  85435. * @param groupNb is the number of the groupcontaining the selector
  85436. * @param selectorNb is the number of the selector within a group to relabel
  85437. * */
  85438. relabel(label: string, groupNb: number, selectorNb: number): void;
  85439. /** For a given group position remove the selector at the given position
  85440. * @param groupNb is the number of the group to remove the selector from
  85441. * @param selectorNb is the number of the selector within the group
  85442. */
  85443. removeFromGroupSelector(groupNb: number, selectorNb: number): void;
  85444. /** For a given group position of correct type add a checkbox button
  85445. * @param groupNb is the number of the group to remove the selector from
  85446. * @param label is the label for the selector
  85447. * @param func is the function called when the Selector is checked
  85448. * @param checked is true when Selector is checked
  85449. */
  85450. addToGroupCheckbox(groupNb: number, label: string, func?: () => void, checked?: boolean): void;
  85451. /** For a given group position of correct type add a radio button
  85452. * @param groupNb is the number of the group to remove the selector from
  85453. * @param label is the label for the selector
  85454. * @param func is the function called when the Selector is checked
  85455. * @param checked is true when Selector is checked
  85456. */
  85457. addToGroupRadio(groupNb: number, label: string, func?: () => void, checked?: boolean): void;
  85458. /**
  85459. * For a given slider group add a slider
  85460. * @param groupNb is the number of the group to add the slider to
  85461. * @param label is the label for the Slider
  85462. * @param func is the function called when the Slider moves
  85463. * @param unit is a string describing the units used, eg degrees or metres
  85464. * @param min is the minimum value for the Slider
  85465. * @param max is the maximum value for the Slider
  85466. * @param value is the start value for the Slider between min and max
  85467. * @param onVal is the function used to format the value displayed, eg radians to degrees
  85468. */
  85469. addToGroupSlider(groupNb: number, label: string, func?: () => void, unit?: string, min?: number, max?: number, value?: number, onVal?: (v: number) => number): void;
  85470. }
  85471. }
  85472. declare module BABYLON.GUI {
  85473. /**
  85474. * Class used to hold a the container for ScrollViewer
  85475. * @hidden
  85476. */
  85477. export class _ScrollViewerWindow extends Container {
  85478. parentClientWidth: number;
  85479. parentClientHeight: number;
  85480. private _freezeControls;
  85481. private _parentMeasure;
  85482. private _oldLeft;
  85483. private _oldTop;
  85484. get freezeControls(): boolean;
  85485. set freezeControls(value: boolean);
  85486. private _bucketWidth;
  85487. private _bucketHeight;
  85488. private _buckets;
  85489. private _bucketLen;
  85490. get bucketWidth(): number;
  85491. get bucketHeight(): number;
  85492. setBucketSizes(width: number, height: number): void;
  85493. private _useBuckets;
  85494. private _makeBuckets;
  85495. private _dispatchInBuckets;
  85496. private _updateMeasures;
  85497. private _updateChildrenMeasures;
  85498. private _restoreMeasures;
  85499. /**
  85500. * Creates a new ScrollViewerWindow
  85501. * @param name of ScrollViewerWindow
  85502. */
  85503. constructor(name?: string);
  85504. protected _getTypeName(): string;
  85505. /** @hidden */
  85506. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  85507. /** @hidden */
  85508. _layout(parentMeasure: Measure, context: CanvasRenderingContext2D): boolean;
  85509. private _scrollChildren;
  85510. private _scrollChildrenWithBuckets;
  85511. /** @hidden */
  85512. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: Measure): void;
  85513. protected _postMeasure(): void;
  85514. }
  85515. }
  85516. declare module BABYLON.GUI {
  85517. /**
  85518. * Class used to create slider controls
  85519. */
  85520. export class ScrollBar extends BaseSlider {
  85521. name?: string | undefined;
  85522. private _background;
  85523. private _borderColor;
  85524. private _tempMeasure;
  85525. /** Gets or sets border color */
  85526. get borderColor(): string;
  85527. set borderColor(value: string);
  85528. /** Gets or sets background color */
  85529. get background(): string;
  85530. set background(value: string);
  85531. /**
  85532. * Creates a new Slider
  85533. * @param name defines the control name
  85534. */
  85535. constructor(name?: string | undefined);
  85536. protected _getTypeName(): string;
  85537. protected _getThumbThickness(): number;
  85538. _draw(context: CanvasRenderingContext2D): void;
  85539. private _first;
  85540. private _originX;
  85541. private _originY;
  85542. /** @hidden */
  85543. protected _updateValueFromPointer(x: number, y: number): void;
  85544. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, pi: BABYLON.PointerInfoBase): boolean;
  85545. }
  85546. }
  85547. declare module BABYLON.GUI {
  85548. /**
  85549. * Class used to create slider controls
  85550. */
  85551. export class ImageScrollBar extends BaseSlider {
  85552. name?: string | undefined;
  85553. private _backgroundBaseImage;
  85554. private _backgroundImage;
  85555. private _thumbImage;
  85556. private _thumbBaseImage;
  85557. private _thumbLength;
  85558. private _thumbHeight;
  85559. private _barImageHeight;
  85560. private _tempMeasure;
  85561. /** Number of 90° rotation to apply on the images when in vertical mode */
  85562. num90RotationInVerticalMode: number;
  85563. /**
  85564. * Gets or sets the image used to render the background for horizontal bar
  85565. */
  85566. get backgroundImage(): Image;
  85567. set backgroundImage(value: Image);
  85568. /**
  85569. * Gets or sets the image used to render the thumb
  85570. */
  85571. get thumbImage(): Image;
  85572. set thumbImage(value: Image);
  85573. /**
  85574. * Gets or sets the length of the thumb
  85575. */
  85576. get thumbLength(): number;
  85577. set thumbLength(value: number);
  85578. /**
  85579. * Gets or sets the height of the thumb
  85580. */
  85581. get thumbHeight(): number;
  85582. set thumbHeight(value: number);
  85583. /**
  85584. * Gets or sets the height of the bar image
  85585. */
  85586. get barImageHeight(): number;
  85587. set barImageHeight(value: number);
  85588. /**
  85589. * Creates a new ImageScrollBar
  85590. * @param name defines the control name
  85591. */
  85592. constructor(name?: string | undefined);
  85593. protected _getTypeName(): string;
  85594. protected _getThumbThickness(): number;
  85595. _draw(context: CanvasRenderingContext2D): void;
  85596. private _first;
  85597. private _originX;
  85598. private _originY;
  85599. /** @hidden */
  85600. protected _updateValueFromPointer(x: number, y: number): void;
  85601. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, pi: BABYLON.PointerInfoBase): boolean;
  85602. }
  85603. }
  85604. declare module BABYLON.GUI {
  85605. /**
  85606. * Class used to hold a viewer window and sliders in a grid
  85607. */
  85608. export class ScrollViewer extends Rectangle {
  85609. private _grid;
  85610. private _horizontalBarSpace;
  85611. private _verticalBarSpace;
  85612. private _dragSpace;
  85613. private _horizontalBar;
  85614. private _verticalBar;
  85615. private _barColor;
  85616. private _barBackground;
  85617. private _barImage;
  85618. private _horizontalBarImage;
  85619. private _verticalBarImage;
  85620. private _barBackgroundImage;
  85621. private _horizontalBarBackgroundImage;
  85622. private _verticalBarBackgroundImage;
  85623. private _barSize;
  85624. private _window;
  85625. private _pointerIsOver;
  85626. private _wheelPrecision;
  85627. private _onWheelObserver;
  85628. private _clientWidth;
  85629. private _clientHeight;
  85630. private _useImageBar;
  85631. private _thumbLength;
  85632. private _thumbHeight;
  85633. private _barImageHeight;
  85634. private _horizontalBarImageHeight;
  85635. private _verticalBarImageHeight;
  85636. private _oldWindowContentsWidth;
  85637. private _oldWindowContentsHeight;
  85638. /**
  85639. * Gets the horizontal scrollbar
  85640. */
  85641. get horizontalBar(): ScrollBar | ImageScrollBar;
  85642. /**
  85643. * Gets the vertical scrollbar
  85644. */
  85645. get verticalBar(): ScrollBar | ImageScrollBar;
  85646. /**
  85647. * Adds a new control to the current container
  85648. * @param control defines the control to add
  85649. * @returns the current container
  85650. */
  85651. addControl(control: BABYLON.Nullable<Control>): Container;
  85652. /**
  85653. * Removes a control from the current container
  85654. * @param control defines the control to remove
  85655. * @returns the current container
  85656. */
  85657. removeControl(control: Control): Container;
  85658. /** Gets the list of children */
  85659. get children(): Control[];
  85660. _flagDescendantsAsMatrixDirty(): void;
  85661. /**
  85662. * Freezes or unfreezes the controls in the window.
  85663. * When controls are frozen, the scroll viewer can render a lot more quickly but updates to positions/sizes of controls
  85664. * are not taken into account. If you want to change positions/sizes, unfreeze, perform the changes then freeze again
  85665. */
  85666. get freezeControls(): boolean;
  85667. set freezeControls(value: boolean);
  85668. /** Gets the bucket width */
  85669. get bucketWidth(): number;
  85670. /** Gets the bucket height */
  85671. get bucketHeight(): number;
  85672. /**
  85673. * Sets the bucket sizes.
  85674. * When freezeControls is true, setting a non-zero bucket size will improve performances by updating only
  85675. * controls that are visible. The bucket sizes is used to subdivide (internally) the window area to smaller areas into which
  85676. * controls are dispatched. So, the size should be roughly equals to the mean size of all the controls of
  85677. * the window. To disable the usage of buckets, sets either width or height (or both) to 0.
  85678. * Please note that using this option will raise the memory usage (the higher the bucket sizes, the less memory
  85679. * used), that's why it is not enabled by default.
  85680. * @param width width of the bucket
  85681. * @param height height of the bucket
  85682. */
  85683. setBucketSizes(width: number, height: number): void;
  85684. private _forceHorizontalBar;
  85685. private _forceVerticalBar;
  85686. /**
  85687. * Forces the horizontal scroll bar to be displayed
  85688. */
  85689. get forceHorizontalBar(): boolean;
  85690. set forceHorizontalBar(value: boolean);
  85691. /**
  85692. * Forces the vertical scroll bar to be displayed
  85693. */
  85694. get forceVerticalBar(): boolean;
  85695. set forceVerticalBar(value: boolean);
  85696. /**
  85697. * Creates a new ScrollViewer
  85698. * @param name of ScrollViewer
  85699. */
  85700. constructor(name?: string, isImageBased?: boolean);
  85701. /** Reset the scroll viewer window to initial size */
  85702. resetWindow(): void;
  85703. protected _getTypeName(): string;
  85704. private _buildClientSizes;
  85705. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  85706. protected _postMeasure(): void;
  85707. /**
  85708. * Gets or sets the mouse wheel precision
  85709. * from 0 to 1 with a default value of 0.05
  85710. * */
  85711. get wheelPrecision(): number;
  85712. set wheelPrecision(value: number);
  85713. /** Gets or sets the scroll bar container background color */
  85714. get scrollBackground(): string;
  85715. set scrollBackground(color: string);
  85716. /** Gets or sets the bar color */
  85717. get barColor(): string;
  85718. set barColor(color: string);
  85719. /** Gets or sets the bar image */
  85720. get thumbImage(): Image;
  85721. set thumbImage(value: Image);
  85722. /** Gets or sets the horizontal bar image */
  85723. get horizontalThumbImage(): Image;
  85724. set horizontalThumbImage(value: Image);
  85725. /** Gets or sets the vertical bar image */
  85726. get verticalThumbImage(): Image;
  85727. set verticalThumbImage(value: Image);
  85728. /** Gets or sets the size of the bar */
  85729. get barSize(): number;
  85730. set barSize(value: number);
  85731. /** Gets or sets the length of the thumb */
  85732. get thumbLength(): number;
  85733. set thumbLength(value: number);
  85734. /** Gets or sets the height of the thumb */
  85735. get thumbHeight(): number;
  85736. set thumbHeight(value: number);
  85737. /** Gets or sets the height of the bar image */
  85738. get barImageHeight(): number;
  85739. set barImageHeight(value: number);
  85740. /** Gets or sets the height of the horizontal bar image */
  85741. get horizontalBarImageHeight(): number;
  85742. set horizontalBarImageHeight(value: number);
  85743. /** Gets or sets the height of the vertical bar image */
  85744. get verticalBarImageHeight(): number;
  85745. set verticalBarImageHeight(value: number);
  85746. /** Gets or sets the bar background */
  85747. get barBackground(): string;
  85748. set barBackground(color: string);
  85749. /** Gets or sets the bar background image */
  85750. get barImage(): Image;
  85751. set barImage(value: Image);
  85752. /** Gets or sets the horizontal bar background image */
  85753. get horizontalBarImage(): Image;
  85754. set horizontalBarImage(value: Image);
  85755. /** Gets or sets the vertical bar background image */
  85756. get verticalBarImage(): Image;
  85757. set verticalBarImage(value: Image);
  85758. private _setWindowPosition;
  85759. /** @hidden */
  85760. private _updateScroller;
  85761. _link(host: AdvancedDynamicTexture): void;
  85762. /** @hidden */
  85763. private _addBar;
  85764. /** @hidden */
  85765. private _attachWheel;
  85766. _renderHighlightSpecific(context: CanvasRenderingContext2D): void;
  85767. /** Releases associated resources */
  85768. dispose(): void;
  85769. }
  85770. }
  85771. declare module BABYLON.GUI {
  85772. /**
  85773. * Class used to create toggle buttons
  85774. */
  85775. export class ToggleButton extends Rectangle {
  85776. name?: string | undefined;
  85777. /**
  85778. * Function called to generate the toActive animation
  85779. */
  85780. toActiveAnimation: () => void;
  85781. /**
  85782. * Function called to generate the toInactive animation
  85783. */
  85784. toInactiveAnimation: () => void;
  85785. /**
  85786. * Function called to generate a pointer enter animation when the toggle button is active.
  85787. */
  85788. pointerEnterActiveAnimation: () => void;
  85789. /**
  85790. * Function called to generate a pointer out animation when the toggle button is active.
  85791. */
  85792. pointerOutActiveAnimation: () => void;
  85793. /**
  85794. * Function called to generate a pointer down animation when the toggle button is active.
  85795. */
  85796. pointerDownActiveAnimation: () => void;
  85797. /**
  85798. * Function called to generate a pointer up animation when the toggle button is active.
  85799. */
  85800. pointerUpActiveAnimation: () => void;
  85801. /**
  85802. * Function called to generate a pointer enter animation when the toggle button is inactive.
  85803. */
  85804. pointerEnterInactiveAnimation: () => void;
  85805. /**
  85806. * Function called to generate a pointer out animation when the toggle button is inactive.
  85807. */
  85808. pointerOutInactiveAnimation: () => void;
  85809. /**
  85810. * Function called to generate a pointer down animation when the toggle button is inactive.
  85811. */
  85812. pointerDownInactiveAnimation: () => void;
  85813. /**
  85814. * Function called to generate a pointer up animation when the toggle button is inactive.
  85815. */
  85816. pointerUpInactiveAnimation: () => void;
  85817. /** BABYLON.Observable raised when isActive is changed */
  85818. onIsActiveChangedObservable: BABYLON.Observable<boolean>;
  85819. /**
  85820. * 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
  85821. */
  85822. delegatePickingToChildren: boolean;
  85823. private _image;
  85824. /**
  85825. * Returns the ToggleButton's image control if it exists
  85826. */
  85827. get image(): BABYLON.Nullable<Image>;
  85828. private _textBlock;
  85829. /**
  85830. * Returns the ToggleButton's child TextBlock control if it exists
  85831. */
  85832. get textBlock(): BABYLON.Nullable<TextBlock>;
  85833. private _group;
  85834. /** Gets or sets group name this toggle button belongs to */
  85835. get group(): string;
  85836. set group(value: string);
  85837. private _isActive;
  85838. /** Gets or sets a boolean indicating if the toogle button is active or not */
  85839. get isActive(): boolean;
  85840. set isActive(value: boolean);
  85841. /**
  85842. * Creates a new ToggleButton
  85843. * @param name defines the control name
  85844. * @param group defines the toggle group this toggle belongs to
  85845. */
  85846. constructor(name?: string | undefined, group?: string);
  85847. protected _getTypeName(): string;
  85848. /** @hidden */
  85849. _processPicking(x: number, y: number, pi: BABYLON.PointerInfoBase, type: number, pointerId: number, buttonIndex: number, deltaX?: number, deltaY?: number): boolean;
  85850. /** @hidden */
  85851. _onPointerEnter(target: Control, pi: BABYLON.PointerInfoBase): boolean;
  85852. /** @hidden */
  85853. _onPointerOut(target: Control, pi: BABYLON.PointerInfoBase, force?: boolean): void;
  85854. /** @hidden */
  85855. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, pi: BABYLON.PointerInfoBase): boolean;
  85856. /** @hidden */
  85857. _onPointerUp(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, notifyClick: boolean, pi: BABYLON.PointerInfoBase): void;
  85858. }
  85859. }
  85860. declare module BABYLON.GUI {
  85861. /** Class used to render a grid */
  85862. export class DisplayGrid extends Control {
  85863. name?: string | undefined;
  85864. private _cellWidth;
  85865. private _cellHeight;
  85866. private _minorLineTickness;
  85867. private _minorLineColor;
  85868. private _majorLineTickness;
  85869. private _majorLineColor;
  85870. private _majorLineFrequency;
  85871. private _background;
  85872. private _displayMajorLines;
  85873. private _displayMinorLines;
  85874. /** Gets or sets a boolean indicating if minor lines must be rendered (true by default)) */
  85875. get displayMinorLines(): boolean;
  85876. set displayMinorLines(value: boolean);
  85877. /** Gets or sets a boolean indicating if major lines must be rendered (true by default)) */
  85878. get displayMajorLines(): boolean;
  85879. set displayMajorLines(value: boolean);
  85880. /** Gets or sets background color (Black by default) */
  85881. get background(): string;
  85882. set background(value: string);
  85883. /** Gets or sets the width of each cell (20 by default) */
  85884. get cellWidth(): number;
  85885. set cellWidth(value: number);
  85886. /** Gets or sets the height of each cell (20 by default) */
  85887. get cellHeight(): number;
  85888. set cellHeight(value: number);
  85889. /** Gets or sets the tickness of minor lines (1 by default) */
  85890. get minorLineTickness(): number;
  85891. set minorLineTickness(value: number);
  85892. /** Gets or sets the color of minor lines (DarkGray by default) */
  85893. get minorLineColor(): string;
  85894. set minorLineColor(value: string);
  85895. /** Gets or sets the tickness of major lines (2 by default) */
  85896. get majorLineTickness(): number;
  85897. set majorLineTickness(value: number);
  85898. /** Gets or sets the color of major lines (White by default) */
  85899. get majorLineColor(): string;
  85900. set majorLineColor(value: string);
  85901. /** Gets or sets the frequency of major lines (default is 1 every 5 minor lines)*/
  85902. get majorLineFrequency(): number;
  85903. set majorLineFrequency(value: number);
  85904. /**
  85905. * Creates a new GridDisplayRectangle
  85906. * @param name defines the control name
  85907. */
  85908. constructor(name?: string | undefined);
  85909. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): void;
  85910. protected _getTypeName(): string;
  85911. }
  85912. }
  85913. declare module BABYLON.GUI {
  85914. /**
  85915. * Class used to create slider controls based on images
  85916. */
  85917. export class ImageBasedSlider extends BaseSlider {
  85918. name?: string | undefined;
  85919. private _backgroundImage;
  85920. private _thumbImage;
  85921. private _valueBarImage;
  85922. private _tempMeasure;
  85923. get displayThumb(): boolean;
  85924. set displayThumb(value: boolean);
  85925. /**
  85926. * Gets or sets the image used to render the background
  85927. */
  85928. get backgroundImage(): Image;
  85929. set backgroundImage(value: Image);
  85930. /**
  85931. * Gets or sets the image used to render the value bar
  85932. */
  85933. get valueBarImage(): Image;
  85934. set valueBarImage(value: Image);
  85935. /**
  85936. * Gets or sets the image used to render the thumb
  85937. */
  85938. get thumbImage(): Image;
  85939. set thumbImage(value: Image);
  85940. /**
  85941. * Creates a new ImageBasedSlider
  85942. * @param name defines the control name
  85943. */
  85944. constructor(name?: string | undefined);
  85945. protected _getTypeName(): string;
  85946. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): void;
  85947. }
  85948. }
  85949. declare module BABYLON.GUI {
  85950. /**
  85951. * Forcing an export so that this code will execute
  85952. * @hidden
  85953. */
  85954. const name = "Statics";
  85955. }
  85956. declare module BABYLON.GUI {
  85957. /**
  85958. * This class can be used to get instrumentation data from a AdvancedDynamicTexture object
  85959. */
  85960. export class AdvancedDynamicTextureInstrumentation implements BABYLON.IDisposable {
  85961. /**
  85962. * Define the instrumented AdvancedDynamicTexture.
  85963. */
  85964. texture: AdvancedDynamicTexture;
  85965. private _captureRenderTime;
  85966. private _renderTime;
  85967. private _captureLayoutTime;
  85968. private _layoutTime;
  85969. private _onBeginRenderObserver;
  85970. private _onEndRenderObserver;
  85971. private _onBeginLayoutObserver;
  85972. private _onEndLayoutObserver;
  85973. /**
  85974. * Gets the perf counter used to capture render time
  85975. */
  85976. get renderTimeCounter(): BABYLON.PerfCounter;
  85977. /**
  85978. * Gets the perf counter used to capture layout time
  85979. */
  85980. get layoutTimeCounter(): BABYLON.PerfCounter;
  85981. /**
  85982. * Enable or disable the render time capture
  85983. */
  85984. get captureRenderTime(): boolean;
  85985. set captureRenderTime(value: boolean);
  85986. /**
  85987. * Enable or disable the layout time capture
  85988. */
  85989. get captureLayoutTime(): boolean;
  85990. set captureLayoutTime(value: boolean);
  85991. /**
  85992. * Instantiates a new advanced dynamic texture instrumentation.
  85993. * This class can be used to get instrumentation data from an AdvancedDynamicTexture object
  85994. * @param texture Defines the AdvancedDynamicTexture to instrument
  85995. */
  85996. constructor(
  85997. /**
  85998. * Define the instrumented AdvancedDynamicTexture.
  85999. */
  86000. texture: AdvancedDynamicTexture);
  86001. /**
  86002. * Dispose and release associated resources.
  86003. */
  86004. dispose(): void;
  86005. }
  86006. }
  86007. declare module BABYLON.GUI {
  86008. /**
  86009. * Class used to load GUI via XML.
  86010. */
  86011. export class XmlLoader {
  86012. private _nodes;
  86013. private _nodeTypes;
  86014. private _isLoaded;
  86015. private _objectAttributes;
  86016. private _parentClass;
  86017. /**
  86018. * Create a new xml loader
  86019. * @param parentClass Sets the class context. Used when the loader is instanced inside a class and not in a global context
  86020. */
  86021. constructor(parentClass?: null);
  86022. private _getChainElement;
  86023. private _getClassAttribute;
  86024. private _createGuiElement;
  86025. private _parseGrid;
  86026. private _parseElement;
  86027. private _prepareSourceElement;
  86028. private _parseElementsFromSource;
  86029. private _parseXml;
  86030. /**
  86031. * Gets if the loading has finished.
  86032. * @returns whether the loading has finished or not
  86033. */
  86034. isLoaded(): boolean;
  86035. /**
  86036. * Gets a loaded node / control by id.
  86037. * @param id the Controls id set in the xml
  86038. * @returns element of type Control
  86039. */
  86040. getNodeById(id: string): any;
  86041. /**
  86042. * Gets all loaded nodes / controls
  86043. * @returns Array of controls
  86044. */
  86045. getNodes(): any;
  86046. /**
  86047. * Initiates the xml layout loading
  86048. * @param xmlFile defines the xml layout to load
  86049. * @param rootNode defines the node / control to use as a parent for the loaded layout controls.
  86050. * @param callback defines the callback called on layout load.
  86051. */
  86052. loadLayout(xmlFile: any, rootNode: any, callback: any): void;
  86053. }
  86054. }
  86055. declare module BABYLON.GUI {
  86056. /**
  86057. * Class used to create containers for controls
  86058. */
  86059. export class Container3D extends Control3D {
  86060. private _blockLayout;
  86061. /**
  86062. * Gets the list of child controls
  86063. */
  86064. protected _children: Control3D[];
  86065. /**
  86066. * Gets the list of child controls
  86067. */
  86068. get children(): Array<Control3D>;
  86069. /**
  86070. * Gets or sets a boolean indicating if the layout must be blocked (default is false).
  86071. * This is helpful to optimize layout operation when adding multiple children in a row
  86072. */
  86073. get blockLayout(): boolean;
  86074. set blockLayout(value: boolean);
  86075. /**
  86076. * Creates a new container
  86077. * @param name defines the container name
  86078. */
  86079. constructor(name?: string);
  86080. /**
  86081. * Force the container to update the layout. Please note that it will not take blockLayout property in account
  86082. * @returns the current container
  86083. */
  86084. updateLayout(): Container3D;
  86085. /**
  86086. * Gets a boolean indicating if the given control is in the children of this control
  86087. * @param control defines the control to check
  86088. * @returns true if the control is in the child list
  86089. */
  86090. containsControl(control: Control3D): boolean;
  86091. /**
  86092. * Adds a control to the children of this control
  86093. * @param control defines the control to add
  86094. * @returns the current container
  86095. */
  86096. addControl(control: Control3D): Container3D;
  86097. /**
  86098. * This function will be called everytime a new control is added
  86099. */
  86100. protected _arrangeChildren(): void;
  86101. protected _createNode(scene: BABYLON.Scene): BABYLON.Nullable<BABYLON.TransformNode>;
  86102. /**
  86103. * Removes a control from the children of this control
  86104. * @param control defines the control to remove
  86105. * @returns the current container
  86106. */
  86107. removeControl(control: Control3D): Container3D;
  86108. protected _getTypeName(): string;
  86109. /**
  86110. * Releases all associated resources
  86111. */
  86112. dispose(): void;
  86113. /** Control rotation will remain unchanged */
  86114. static readonly UNSET_ORIENTATION: number;
  86115. /** Control will rotate to make it look at sphere central axis */
  86116. static readonly FACEORIGIN_ORIENTATION: number;
  86117. /** Control will rotate to make it look back at sphere central axis */
  86118. static readonly FACEORIGINREVERSED_ORIENTATION: number;
  86119. /** Control will rotate to look at z axis (0, 0, 1) */
  86120. static readonly FACEFORWARD_ORIENTATION: number;
  86121. /** Control will rotate to look at negative z axis (0, 0, -1) */
  86122. static readonly FACEFORWARDREVERSED_ORIENTATION: number;
  86123. }
  86124. }
  86125. declare module BABYLON.GUI {
  86126. /**
  86127. * Class used to manage 3D user interface
  86128. * @see https://doc.babylonjs.com/how_to/gui3d
  86129. */
  86130. export class GUI3DManager implements BABYLON.IDisposable {
  86131. private _scene;
  86132. private _sceneDisposeObserver;
  86133. private _utilityLayer;
  86134. private _rootContainer;
  86135. private _pointerObserver;
  86136. private _pointerOutObserver;
  86137. /** @hidden */
  86138. _lastPickedControl: Control3D;
  86139. /** @hidden */
  86140. _lastControlOver: {
  86141. [pointerId: number]: Control3D;
  86142. };
  86143. /** @hidden */
  86144. _lastControlDown: {
  86145. [pointerId: number]: Control3D;
  86146. };
  86147. /**
  86148. * BABYLON.Observable raised when the point picked by the pointer events changed
  86149. */
  86150. onPickedPointChangedObservable: BABYLON.Observable<BABYLON.Nullable<BABYLON.Vector3>>;
  86151. /** @hidden */
  86152. _sharedMaterials: {
  86153. [key: string]: BABYLON.Material;
  86154. };
  86155. /** Gets the hosting scene */
  86156. get scene(): BABYLON.Scene;
  86157. /** Gets associated utility layer */
  86158. get utilityLayer(): BABYLON.Nullable<BABYLON.UtilityLayerRenderer>;
  86159. /**
  86160. * Creates a new GUI3DManager
  86161. * @param scene
  86162. */
  86163. constructor(scene?: BABYLON.Scene);
  86164. private _handlePointerOut;
  86165. private _doPicking;
  86166. /**
  86167. * Gets the root container
  86168. */
  86169. get rootContainer(): Container3D;
  86170. /**
  86171. * Gets a boolean indicating if the given control is in the root child list
  86172. * @param control defines the control to check
  86173. * @returns true if the control is in the root child list
  86174. */
  86175. containsControl(control: Control3D): boolean;
  86176. /**
  86177. * Adds a control to the root child list
  86178. * @param control defines the control to add
  86179. * @returns the current manager
  86180. */
  86181. addControl(control: Control3D): GUI3DManager;
  86182. /**
  86183. * Removes a control from the root child list
  86184. * @param control defines the control to remove
  86185. * @returns the current container
  86186. */
  86187. removeControl(control: Control3D): GUI3DManager;
  86188. /**
  86189. * Releases all associated resources
  86190. */
  86191. dispose(): void;
  86192. }
  86193. }
  86194. declare module BABYLON.GUI {
  86195. /**
  86196. * Class used to transport BABYLON.Vector3 information for pointer events
  86197. */
  86198. export class Vector3WithInfo extends BABYLON.Vector3 {
  86199. /** defines the current mouse button index */
  86200. buttonIndex: number;
  86201. /**
  86202. * Creates a new Vector3WithInfo
  86203. * @param source defines the vector3 data to transport
  86204. * @param buttonIndex defines the current mouse button index
  86205. */
  86206. constructor(source: BABYLON.Vector3,
  86207. /** defines the current mouse button index */
  86208. buttonIndex?: number);
  86209. }
  86210. }
  86211. declare module BABYLON.GUI {
  86212. /**
  86213. * Class used as base class for controls
  86214. */
  86215. export class Control3D implements BABYLON.IDisposable, BABYLON.IBehaviorAware<Control3D> {
  86216. /** Defines the control name */
  86217. name?: string | undefined;
  86218. /** @hidden */
  86219. _host: GUI3DManager;
  86220. private _node;
  86221. private _downCount;
  86222. private _enterCount;
  86223. private _downPointerIds;
  86224. private _isVisible;
  86225. /** Gets or sets the control position in world space */
  86226. get position(): BABYLON.Vector3;
  86227. set position(value: BABYLON.Vector3);
  86228. /** Gets or sets the control scaling in world space */
  86229. get scaling(): BABYLON.Vector3;
  86230. set scaling(value: BABYLON.Vector3);
  86231. /** Callback used to start pointer enter animation */
  86232. pointerEnterAnimation: () => void;
  86233. /** Callback used to start pointer out animation */
  86234. pointerOutAnimation: () => void;
  86235. /** Callback used to start pointer down animation */
  86236. pointerDownAnimation: () => void;
  86237. /** Callback used to start pointer up animation */
  86238. pointerUpAnimation: () => void;
  86239. /**
  86240. * An event triggered when the pointer move over the control
  86241. */
  86242. onPointerMoveObservable: BABYLON.Observable<BABYLON.Vector3>;
  86243. /**
  86244. * An event triggered when the pointer move out of the control
  86245. */
  86246. onPointerOutObservable: BABYLON.Observable<Control3D>;
  86247. /**
  86248. * An event triggered when the pointer taps the control
  86249. */
  86250. onPointerDownObservable: BABYLON.Observable<Vector3WithInfo>;
  86251. /**
  86252. * An event triggered when pointer is up
  86253. */
  86254. onPointerUpObservable: BABYLON.Observable<Vector3WithInfo>;
  86255. /**
  86256. * An event triggered when a control is clicked on (with a mouse)
  86257. */
  86258. onPointerClickObservable: BABYLON.Observable<Vector3WithInfo>;
  86259. /**
  86260. * An event triggered when pointer enters the control
  86261. */
  86262. onPointerEnterObservable: BABYLON.Observable<Control3D>;
  86263. /**
  86264. * Gets or sets the parent container
  86265. */
  86266. parent: BABYLON.Nullable<Container3D>;
  86267. private _behaviors;
  86268. /**
  86269. * Gets the list of attached behaviors
  86270. * @see https://doc.babylonjs.com/features/behaviour
  86271. */
  86272. get behaviors(): BABYLON.Behavior<Control3D>[];
  86273. /**
  86274. * Attach a behavior to the control
  86275. * @see https://doc.babylonjs.com/features/behaviour
  86276. * @param behavior defines the behavior to attach
  86277. * @returns the current control
  86278. */
  86279. addBehavior(behavior: BABYLON.Behavior<Control3D>): Control3D;
  86280. /**
  86281. * Remove an attached behavior
  86282. * @see https://doc.babylonjs.com/features/behaviour
  86283. * @param behavior defines the behavior to attach
  86284. * @returns the current control
  86285. */
  86286. removeBehavior(behavior: BABYLON.Behavior<Control3D>): Control3D;
  86287. /**
  86288. * Gets an attached behavior by name
  86289. * @param name defines the name of the behavior to look for
  86290. * @see https://doc.babylonjs.com/features/behaviour
  86291. * @returns null if behavior was not found else the requested behavior
  86292. */
  86293. getBehaviorByName(name: string): BABYLON.Nullable<BABYLON.Behavior<Control3D>>;
  86294. /** Gets or sets a boolean indicating if the control is visible */
  86295. get isVisible(): boolean;
  86296. set isVisible(value: boolean);
  86297. /**
  86298. * Creates a new control
  86299. * @param name defines the control name
  86300. */
  86301. constructor(
  86302. /** Defines the control name */
  86303. name?: string | undefined);
  86304. /**
  86305. * Gets a string representing the class name
  86306. */
  86307. get typeName(): string;
  86308. /**
  86309. * Get the current class name of the control.
  86310. * @returns current class name
  86311. */
  86312. getClassName(): string;
  86313. protected _getTypeName(): string;
  86314. /**
  86315. * Gets the transform node used by this control
  86316. */
  86317. get node(): BABYLON.Nullable<BABYLON.TransformNode>;
  86318. /**
  86319. * Gets the mesh used to render this control
  86320. */
  86321. get mesh(): BABYLON.Nullable<BABYLON.AbstractMesh>;
  86322. /**
  86323. * Link the control as child of the given node
  86324. * @param node defines the node to link to. Use null to unlink the control
  86325. * @returns the current control
  86326. */
  86327. linkToTransformNode(node: BABYLON.Nullable<BABYLON.TransformNode>): Control3D;
  86328. /** @hidden **/
  86329. _prepareNode(scene: BABYLON.Scene): void;
  86330. protected _injectGUI3DMetadata(node: BABYLON.TransformNode): any;
  86331. /**
  86332. * Node creation.
  86333. * Can be overriden by children
  86334. * @param scene defines the scene where the node must be attached
  86335. * @returns the attached node or null if none. Must return a BABYLON.Mesh or BABYLON.AbstractMesh if there is an atttached visible object
  86336. */
  86337. protected _createNode(scene: BABYLON.Scene): BABYLON.Nullable<BABYLON.TransformNode>;
  86338. /**
  86339. * Affect a material to the given mesh
  86340. * @param mesh defines the mesh which will represent the control
  86341. */
  86342. protected _affectMaterial(mesh: BABYLON.AbstractMesh): void;
  86343. /** @hidden */
  86344. _onPointerMove(target: Control3D, coordinates: BABYLON.Vector3): void;
  86345. /** @hidden */
  86346. _onPointerEnter(target: Control3D): boolean;
  86347. /** @hidden */
  86348. _onPointerOut(target: Control3D): void;
  86349. /** @hidden */
  86350. _onPointerDown(target: Control3D, coordinates: BABYLON.Vector3, pointerId: number, buttonIndex: number): boolean;
  86351. /** @hidden */
  86352. _onPointerUp(target: Control3D, coordinates: BABYLON.Vector3, pointerId: number, buttonIndex: number, notifyClick: boolean): void;
  86353. /** @hidden */
  86354. forcePointerUp(pointerId?: BABYLON.Nullable<number>): void;
  86355. /** @hidden */
  86356. _processObservables(type: number, pickedPoint: BABYLON.Vector3, pointerId: number, buttonIndex: number): boolean;
  86357. /** @hidden */
  86358. _disposeNode(): void;
  86359. /**
  86360. * Releases all associated resources
  86361. */
  86362. dispose(): void;
  86363. }
  86364. }
  86365. declare module BABYLON.GUI {
  86366. /**
  86367. * Class used as a root to all buttons
  86368. */
  86369. export class AbstractButton3D extends Control3D {
  86370. /**
  86371. * Creates a new button
  86372. * @param name defines the control name
  86373. */
  86374. constructor(name?: string);
  86375. protected _getTypeName(): string;
  86376. protected _createNode(scene: BABYLON.Scene): BABYLON.TransformNode;
  86377. }
  86378. }
  86379. declare module BABYLON.GUI {
  86380. /**
  86381. * Class used to create a button in 3D
  86382. */
  86383. export class Button3D extends AbstractButton3D {
  86384. /** @hidden */
  86385. protected _currentMaterial: BABYLON.Material;
  86386. private _facadeTexture;
  86387. private _content;
  86388. private _contentResolution;
  86389. private _contentScaleRatio;
  86390. /**
  86391. * Gets or sets the texture resolution used to render content (512 by default)
  86392. */
  86393. get contentResolution(): BABYLON.int;
  86394. set contentResolution(value: BABYLON.int);
  86395. /**
  86396. * Gets or sets the texture scale ratio used to render content (2 by default)
  86397. */
  86398. get contentScaleRatio(): number;
  86399. set contentScaleRatio(value: number);
  86400. protected _disposeFacadeTexture(): void;
  86401. protected _resetContent(): void;
  86402. /**
  86403. * Creates a new button
  86404. * @param name defines the control name
  86405. */
  86406. constructor(name?: string);
  86407. /**
  86408. * Gets or sets the GUI 2D content used to display the button's facade
  86409. */
  86410. get content(): Control;
  86411. set content(value: Control);
  86412. /**
  86413. * Apply the facade texture (created from the content property).
  86414. * This function can be overloaded by child classes
  86415. * @param facadeTexture defines the AdvancedDynamicTexture to use
  86416. */
  86417. protected _applyFacade(facadeTexture: AdvancedDynamicTexture): void;
  86418. protected _getTypeName(): string;
  86419. protected _createNode(scene: BABYLON.Scene): BABYLON.TransformNode;
  86420. protected _affectMaterial(mesh: BABYLON.AbstractMesh): void;
  86421. /**
  86422. * Releases all associated resources
  86423. */
  86424. dispose(): void;
  86425. }
  86426. }
  86427. declare module BABYLON.GUI {
  86428. /**
  86429. * Abstract class used to create a container panel deployed on the surface of a volume
  86430. */
  86431. export abstract class VolumeBasedPanel extends Container3D {
  86432. private _columns;
  86433. private _rows;
  86434. private _rowThenColum;
  86435. private _orientation;
  86436. protected _cellWidth: number;
  86437. protected _cellHeight: number;
  86438. /**
  86439. * Gets or sets the distance between elements
  86440. */
  86441. margin: number;
  86442. /**
  86443. * Gets or sets the orientation to apply to all controls (BABYLON.Container3D.FaceOriginReversedOrientation by default)
  86444. * | Value | Type | Description |
  86445. * | ----- | ----------------------------------- | ----------- |
  86446. * | 0 | UNSET_ORIENTATION | Control rotation will remain unchanged |
  86447. * | 1 | FACEORIGIN_ORIENTATION | Control will rotate to make it look at sphere central axis |
  86448. * | 2 | FACEORIGINREVERSED_ORIENTATION | Control will rotate to make it look back at sphere central axis |
  86449. * | 3 | FACEFORWARD_ORIENTATION | Control will rotate to look at z axis (0, 0, 1) |
  86450. * | 4 | FACEFORWARDREVERSED_ORIENTATION | Control will rotate to look at negative z axis (0, 0, -1) |
  86451. */
  86452. get orientation(): number;
  86453. set orientation(value: number);
  86454. /**
  86455. * Gets or sets the number of columns requested (10 by default).
  86456. * The panel will automatically compute the number of rows based on number of child controls.
  86457. */
  86458. get columns(): BABYLON.int;
  86459. set columns(value: BABYLON.int);
  86460. /**
  86461. * Gets or sets a the number of rows requested.
  86462. * The panel will automatically compute the number of columns based on number of child controls.
  86463. */
  86464. get rows(): BABYLON.int;
  86465. set rows(value: BABYLON.int);
  86466. /**
  86467. * Creates new VolumeBasedPanel
  86468. */
  86469. constructor();
  86470. protected _arrangeChildren(): void;
  86471. /** Child classes must implement this function to provide correct control positioning */
  86472. protected abstract _mapGridNode(control: Control3D, nodePosition: BABYLON.Vector3): void;
  86473. /** Child classes can implement this function to provide additional processing */
  86474. protected _finalProcessing(): void;
  86475. }
  86476. }
  86477. declare module BABYLON.GUI {
  86478. /**
  86479. * Class used to create a container panel deployed on the surface of a cylinder
  86480. */
  86481. export class CylinderPanel extends VolumeBasedPanel {
  86482. private _radius;
  86483. /**
  86484. * Gets or sets the radius of the cylinder where to project controls (5 by default)
  86485. */
  86486. get radius(): BABYLON.float;
  86487. set radius(value: BABYLON.float);
  86488. protected _mapGridNode(control: Control3D, nodePosition: BABYLON.Vector3): void;
  86489. private _cylindricalMapping;
  86490. }
  86491. }
  86492. declare module BABYLON.GUI {
  86493. /** @hidden */
  86494. export var fluentVertexShader: {
  86495. name: string;
  86496. shader: string;
  86497. };
  86498. }
  86499. declare module BABYLON.GUI {
  86500. /** @hidden */
  86501. export var fluentPixelShader: {
  86502. name: string;
  86503. shader: string;
  86504. };
  86505. }
  86506. declare module BABYLON.GUI {
  86507. /** @hidden */
  86508. export class FluentMaterialDefines extends BABYLON.MaterialDefines {
  86509. INNERGLOW: boolean;
  86510. BORDER: boolean;
  86511. HOVERLIGHT: boolean;
  86512. TEXTURE: boolean;
  86513. constructor();
  86514. }
  86515. /**
  86516. * Class used to render controls with fluent desgin
  86517. */
  86518. export class FluentMaterial extends BABYLON.PushMaterial {
  86519. /**
  86520. * Gets or sets inner glow intensity. A value of 0 means no glow (default is 0.5)
  86521. */
  86522. innerGlowColorIntensity: number;
  86523. /**
  86524. * Gets or sets the inner glow color (white by default)
  86525. */
  86526. innerGlowColor: BABYLON.Color3;
  86527. /**
  86528. * Gets or sets the albedo color (Default is BABYLON.Color3(0.3, 0.35, 0.4))
  86529. */
  86530. albedoColor: BABYLON.Color3;
  86531. /**
  86532. * Gets or sets a boolean indicating if borders must be rendered (default is false)
  86533. */
  86534. renderBorders: boolean;
  86535. /**
  86536. * Gets or sets border width (default is 0.5)
  86537. */
  86538. borderWidth: number;
  86539. /**
  86540. * Gets or sets a value indicating the smoothing value applied to border edges (0.02 by default)
  86541. */
  86542. edgeSmoothingValue: number;
  86543. /**
  86544. * Gets or sets the minimum value that can be applied to border width (default is 0.1)
  86545. */
  86546. borderMinValue: number;
  86547. /**
  86548. * Gets or sets a boolean indicating if hover light must be rendered (default is false)
  86549. */
  86550. renderHoverLight: boolean;
  86551. /**
  86552. * Gets or sets the radius used to render the hover light (default is 1.0)
  86553. */
  86554. hoverRadius: number;
  86555. /**
  86556. * Gets or sets the color used to render the hover light (default is BABYLON.Color4(0.3, 0.3, 0.3, 1.0))
  86557. */
  86558. hoverColor: BABYLON.Color4;
  86559. /**
  86560. * Gets or sets the hover light position in world space (default is BABYLON.Vector3.Zero())
  86561. */
  86562. hoverPosition: BABYLON.Vector3;
  86563. private _albedoTexture;
  86564. /** Gets or sets the texture to use for albedo color */
  86565. albedoTexture: BABYLON.Nullable<BABYLON.BaseTexture>;
  86566. /**
  86567. * Creates a new Fluent material
  86568. * @param name defines the name of the material
  86569. * @param scene defines the hosting scene
  86570. */
  86571. constructor(name: string, scene: BABYLON.Scene);
  86572. needAlphaBlending(): boolean;
  86573. needAlphaTesting(): boolean;
  86574. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  86575. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  86576. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  86577. getActiveTextures(): BABYLON.BaseTexture[];
  86578. hasTexture(texture: BABYLON.BaseTexture): boolean;
  86579. dispose(forceDisposeEffect?: boolean): void;
  86580. clone(name: string): FluentMaterial;
  86581. serialize(): any;
  86582. getClassName(): string;
  86583. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): FluentMaterial;
  86584. }
  86585. }
  86586. declare module BABYLON.GUI {
  86587. /**
  86588. * Class used to create a holographic button in 3D
  86589. */
  86590. export class HolographicButton extends Button3D {
  86591. private _backPlate;
  86592. private _textPlate;
  86593. private _frontPlate;
  86594. private _text;
  86595. private _imageUrl;
  86596. private _shareMaterials;
  86597. private _frontMaterial;
  86598. private _backMaterial;
  86599. private _plateMaterial;
  86600. private _pickedPointObserver;
  86601. private _tooltipFade;
  86602. private _tooltipTextBlock;
  86603. private _tooltipTexture;
  86604. private _tooltipMesh;
  86605. private _tooltipHoverObserver;
  86606. private _tooltipOutObserver;
  86607. private _disposeTooltip;
  86608. /**
  86609. * Rendering ground id of all the mesh in the button
  86610. */
  86611. set renderingGroupId(id: number);
  86612. get renderingGroupId(): number;
  86613. /**
  86614. * Text to be displayed on the tooltip shown when hovering on the button. When set to null tooltip is disabled. (Default: null)
  86615. */
  86616. set tooltipText(text: BABYLON.Nullable<string>);
  86617. get tooltipText(): BABYLON.Nullable<string>;
  86618. /**
  86619. * Gets or sets text for the button
  86620. */
  86621. get text(): string;
  86622. set text(value: string);
  86623. /**
  86624. * Gets or sets the image url for the button
  86625. */
  86626. get imageUrl(): string;
  86627. set imageUrl(value: string);
  86628. /**
  86629. * Gets the back material used by this button
  86630. */
  86631. get backMaterial(): FluentMaterial;
  86632. /**
  86633. * Gets the front material used by this button
  86634. */
  86635. get frontMaterial(): FluentMaterial;
  86636. /**
  86637. * Gets the plate material used by this button
  86638. */
  86639. get plateMaterial(): BABYLON.StandardMaterial;
  86640. /**
  86641. * Gets a boolean indicating if this button shares its material with other HolographicButtons
  86642. */
  86643. get shareMaterials(): boolean;
  86644. /**
  86645. * Creates a new button
  86646. * @param name defines the control name
  86647. */
  86648. constructor(name?: string, shareMaterials?: boolean);
  86649. protected _getTypeName(): string;
  86650. private _rebuildContent;
  86651. protected _createNode(scene: BABYLON.Scene): BABYLON.TransformNode;
  86652. protected _applyFacade(facadeTexture: AdvancedDynamicTexture): void;
  86653. private _createBackMaterial;
  86654. private _createFrontMaterial;
  86655. private _createPlateMaterial;
  86656. protected _affectMaterial(mesh: BABYLON.Mesh): void;
  86657. /**
  86658. * Releases all associated resources
  86659. */
  86660. dispose(): void;
  86661. }
  86662. }
  86663. declare module BABYLON.GUI {
  86664. /**
  86665. * Class used to create an interactable object. It's a 3D button using a mesh coming from the current scene
  86666. */
  86667. export class MeshButton3D extends Button3D {
  86668. /** @hidden */
  86669. protected _currentMesh: BABYLON.Mesh;
  86670. /**
  86671. * Creates a new 3D button based on a mesh
  86672. * @param mesh mesh to become a 3D button
  86673. * @param name defines the control name
  86674. */
  86675. constructor(mesh: BABYLON.Mesh, name?: string);
  86676. protected _getTypeName(): string;
  86677. protected _createNode(scene: BABYLON.Scene): BABYLON.TransformNode;
  86678. protected _affectMaterial(mesh: BABYLON.AbstractMesh): void;
  86679. }
  86680. }
  86681. declare module BABYLON.GUI {
  86682. /**
  86683. * Class used to create a container panel deployed on the surface of a plane
  86684. */
  86685. export class PlanePanel extends VolumeBasedPanel {
  86686. protected _mapGridNode(control: Control3D, nodePosition: BABYLON.Vector3): void;
  86687. }
  86688. }
  86689. declare module BABYLON.GUI {
  86690. /**
  86691. * Class used to create a container panel where items get randomized planar mapping
  86692. */
  86693. export class ScatterPanel extends VolumeBasedPanel {
  86694. private _iteration;
  86695. /**
  86696. * Gets or sets the number of iteration to use to scatter the controls (100 by default)
  86697. */
  86698. get iteration(): BABYLON.float;
  86699. set iteration(value: BABYLON.float);
  86700. protected _mapGridNode(control: Control3D, nodePosition: BABYLON.Vector3): void;
  86701. private _scatterMapping;
  86702. protected _finalProcessing(): void;
  86703. }
  86704. }
  86705. declare module BABYLON.GUI {
  86706. /**
  86707. * Class used to create a container panel deployed on the surface of a sphere
  86708. */
  86709. export class SpherePanel extends VolumeBasedPanel {
  86710. private _radius;
  86711. /**
  86712. * Gets or sets the radius of the sphere where to project controls (5 by default)
  86713. */
  86714. get radius(): BABYLON.float;
  86715. set radius(value: BABYLON.float);
  86716. protected _mapGridNode(control: Control3D, nodePosition: BABYLON.Vector3): void;
  86717. private _sphericalMapping;
  86718. }
  86719. }
  86720. declare module BABYLON.GUI {
  86721. /**
  86722. * Class used to create a stack panel in 3D on XY plane
  86723. */
  86724. export class StackPanel3D extends Container3D {
  86725. private _isVertical;
  86726. /**
  86727. * Gets or sets a boolean indicating if the stack panel is vertical or horizontal (horizontal by default)
  86728. */
  86729. get isVertical(): boolean;
  86730. set isVertical(value: boolean);
  86731. /**
  86732. * Gets or sets the distance between elements
  86733. */
  86734. margin: number;
  86735. /**
  86736. * Creates new StackPanel
  86737. * @param isVertical
  86738. */
  86739. constructor(isVertical?: boolean);
  86740. protected _arrangeChildren(): void;
  86741. }
  86742. }
  86743. declare module BABYLON {
  86744. /**
  86745. * Configuration for glTF validation
  86746. */
  86747. export interface IGLTFValidationConfiguration {
  86748. /**
  86749. * The url of the glTF validator.
  86750. */
  86751. url: string;
  86752. }
  86753. /**
  86754. * glTF validation
  86755. */
  86756. export class GLTFValidation {
  86757. /**
  86758. * The configuration. Defaults to `{ url: "https://preview.babylonjs.com/gltf_validator.js" }`.
  86759. */
  86760. static Configuration: IGLTFValidationConfiguration;
  86761. private static _LoadScriptPromise;
  86762. /**
  86763. * Validate a glTF asset using the glTF-Validator.
  86764. * @param data The JSON of a glTF or the array buffer of a binary glTF
  86765. * @param rootUrl The root url for the glTF
  86766. * @param fileName The file name for the glTF
  86767. * @param getExternalResource The callback to get external resources for the glTF validator
  86768. * @returns A promise that resolves with the glTF validation results once complete
  86769. */
  86770. static ValidateAsync(data: string | ArrayBuffer, rootUrl: string, fileName: string, getExternalResource: (uri: string) => Promise<ArrayBuffer>): Promise<BABYLON.GLTF2.IGLTFValidationResults>;
  86771. }
  86772. }
  86773. declare module BABYLON {
  86774. /**
  86775. * Mode that determines the coordinate system to use.
  86776. */
  86777. export enum GLTFLoaderCoordinateSystemMode {
  86778. /**
  86779. * Automatically convert the glTF right-handed data to the appropriate system based on the current coordinate system mode of the scene.
  86780. */
  86781. AUTO = 0,
  86782. /**
  86783. * Sets the useRightHandedSystem flag on the scene.
  86784. */
  86785. FORCE_RIGHT_HANDED = 1
  86786. }
  86787. /**
  86788. * Mode that determines what animations will start.
  86789. */
  86790. export enum GLTFLoaderAnimationStartMode {
  86791. /**
  86792. * No animation will start.
  86793. */
  86794. NONE = 0,
  86795. /**
  86796. * The first animation will start.
  86797. */
  86798. FIRST = 1,
  86799. /**
  86800. * All animations will start.
  86801. */
  86802. ALL = 2
  86803. }
  86804. /**
  86805. * Interface that contains the data for the glTF asset.
  86806. */
  86807. export interface IGLTFLoaderData {
  86808. /**
  86809. * The object that represents the glTF JSON.
  86810. */
  86811. json: Object;
  86812. /**
  86813. * The BIN chunk of a binary glTF.
  86814. */
  86815. bin: Nullable<IDataBuffer>;
  86816. }
  86817. /**
  86818. * Interface for extending the loader.
  86819. */
  86820. export interface IGLTFLoaderExtension {
  86821. /**
  86822. * The name of this extension.
  86823. */
  86824. readonly name: string;
  86825. /**
  86826. * Defines whether this extension is enabled.
  86827. */
  86828. enabled: boolean;
  86829. /**
  86830. * Defines the order of this extension.
  86831. * The loader sorts the extensions using these values when loading.
  86832. */
  86833. order?: number;
  86834. }
  86835. /**
  86836. * Loader state.
  86837. */
  86838. export enum GLTFLoaderState {
  86839. /**
  86840. * The asset is loading.
  86841. */
  86842. LOADING = 0,
  86843. /**
  86844. * The asset is ready for rendering.
  86845. */
  86846. READY = 1,
  86847. /**
  86848. * The asset is completely loaded.
  86849. */
  86850. COMPLETE = 2
  86851. }
  86852. /** @hidden */
  86853. export interface IGLTFLoader extends IDisposable {
  86854. readonly state: Nullable<GLTFLoaderState>;
  86855. importMeshAsync: (meshesNames: any, scene: Scene, forAssetContainer: boolean, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string) => Promise<ISceneLoaderAsyncResult>;
  86856. loadAsync: (scene: Scene, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string) => Promise<void>;
  86857. }
  86858. /**
  86859. * File loader for loading glTF files into a scene.
  86860. */
  86861. export class GLTFFileLoader implements IDisposable, ISceneLoaderPluginAsync, ISceneLoaderPluginFactory {
  86862. /** @hidden */
  86863. static _CreateGLTF1Loader: (parent: GLTFFileLoader) => IGLTFLoader;
  86864. /** @hidden */
  86865. static _CreateGLTF2Loader: (parent: GLTFFileLoader) => IGLTFLoader;
  86866. /**
  86867. * Raised when the asset has been parsed
  86868. */
  86869. onParsedObservable: Observable<IGLTFLoaderData>;
  86870. private _onParsedObserver;
  86871. /**
  86872. * Raised when the asset has been parsed
  86873. */
  86874. set onParsed(callback: (loaderData: IGLTFLoaderData) => void);
  86875. /**
  86876. * 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.
  86877. * Textures always loads asynchronously. For example, the success callback can compute the bounding information of the loaded meshes when incremental loading is disabled.
  86878. * Defaults to true.
  86879. * @hidden
  86880. */
  86881. static IncrementalLoading: boolean;
  86882. /**
  86883. * Set this property to true in order to work with homogeneous coordinates, available with some converters and exporters.
  86884. * Defaults to false. See https://en.wikipedia.org/wiki/Homogeneous_coordinates.
  86885. * @hidden
  86886. */
  86887. static HomogeneousCoordinates: boolean;
  86888. /**
  86889. * The coordinate system mode. Defaults to AUTO.
  86890. */
  86891. coordinateSystemMode: GLTFLoaderCoordinateSystemMode;
  86892. /**
  86893. * The animation start mode. Defaults to FIRST.
  86894. */
  86895. animationStartMode: GLTFLoaderAnimationStartMode;
  86896. /**
  86897. * Defines if the loader should compile materials before raising the success callback. Defaults to false.
  86898. */
  86899. compileMaterials: boolean;
  86900. /**
  86901. * Defines if the loader should also compile materials with clip planes. Defaults to false.
  86902. */
  86903. useClipPlane: boolean;
  86904. /**
  86905. * Defines if the loader should compile shadow generators before raising the success callback. Defaults to false.
  86906. */
  86907. compileShadowGenerators: boolean;
  86908. /**
  86909. * Defines if the Alpha blended materials are only applied as coverage.
  86910. * If false, (default) The luminance of each pixel will reduce its opacity to simulate the behaviour of most physical materials.
  86911. * If true, no extra effects are applied to transparent pixels.
  86912. */
  86913. transparencyAsCoverage: boolean;
  86914. /**
  86915. * Defines if the loader should use range requests when load binary glTF files from HTTP.
  86916. * Enabling will disable offline support and glTF validator.
  86917. * Defaults to false.
  86918. */
  86919. useRangeRequests: boolean;
  86920. /**
  86921. * Defines if the loader should create instances when multiple glTF nodes point to the same glTF mesh. Defaults to true.
  86922. */
  86923. createInstances: boolean;
  86924. /**
  86925. * 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.
  86926. */
  86927. alwaysComputeBoundingBox: boolean;
  86928. /**
  86929. * If true, load all materials defined in the file, even if not used by any mesh. Defaults to false.
  86930. */
  86931. loadAllMaterials: boolean;
  86932. /**
  86933. * Function called before loading a url referenced by the asset.
  86934. */
  86935. preprocessUrlAsync: (url: string) => Promise<string>;
  86936. /**
  86937. * Observable raised when the loader creates a mesh after parsing the glTF properties of the mesh.
  86938. * 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, ...)
  86939. */
  86940. readonly onMeshLoadedObservable: Observable<AbstractMesh>;
  86941. private _onMeshLoadedObserver;
  86942. /**
  86943. * Callback raised when the loader creates a mesh after parsing the glTF properties of the mesh.
  86944. * 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, ...)
  86945. */
  86946. set onMeshLoaded(callback: (mesh: AbstractMesh) => void);
  86947. /**
  86948. * Observable raised when the loader creates a texture after parsing the glTF properties of the texture.
  86949. */
  86950. readonly onTextureLoadedObservable: Observable<BaseTexture>;
  86951. private _onTextureLoadedObserver;
  86952. /**
  86953. * Callback raised when the loader creates a texture after parsing the glTF properties of the texture.
  86954. */
  86955. set onTextureLoaded(callback: (texture: BaseTexture) => void);
  86956. /**
  86957. * Observable raised when the loader creates a material after parsing the glTF properties of the material.
  86958. */
  86959. readonly onMaterialLoadedObservable: Observable<Material>;
  86960. private _onMaterialLoadedObserver;
  86961. /**
  86962. * Callback raised when the loader creates a material after parsing the glTF properties of the material.
  86963. */
  86964. set onMaterialLoaded(callback: (material: Material) => void);
  86965. /**
  86966. * Observable raised when the loader creates a camera after parsing the glTF properties of the camera.
  86967. */
  86968. readonly onCameraLoadedObservable: Observable<Camera>;
  86969. private _onCameraLoadedObserver;
  86970. /**
  86971. * Callback raised when the loader creates a camera after parsing the glTF properties of the camera.
  86972. */
  86973. set onCameraLoaded(callback: (camera: Camera) => void);
  86974. /**
  86975. * Observable raised when the asset is completely loaded, immediately before the loader is disposed.
  86976. * For assets with LODs, raised when all of the LODs are complete.
  86977. * For assets without LODs, raised when the model is complete, immediately after the loader resolves the returned promise.
  86978. */
  86979. readonly onCompleteObservable: Observable<void>;
  86980. private _onCompleteObserver;
  86981. /**
  86982. * Callback raised when the asset is completely loaded, immediately before the loader is disposed.
  86983. * For assets with LODs, raised when all of the LODs are complete.
  86984. * For assets without LODs, raised when the model is complete, immediately after the loader resolves the returned promise.
  86985. */
  86986. set onComplete(callback: () => void);
  86987. /**
  86988. * Observable raised when an error occurs.
  86989. */
  86990. readonly onErrorObservable: Observable<any>;
  86991. private _onErrorObserver;
  86992. /**
  86993. * Callback raised when an error occurs.
  86994. */
  86995. set onError(callback: (reason: any) => void);
  86996. /**
  86997. * Observable raised after the loader is disposed.
  86998. */
  86999. readonly onDisposeObservable: Observable<void>;
  87000. private _onDisposeObserver;
  87001. /**
  87002. * Callback raised after the loader is disposed.
  87003. */
  87004. set onDispose(callback: () => void);
  87005. /**
  87006. * Observable raised after a loader extension is created.
  87007. * Set additional options for a loader extension in this event.
  87008. */
  87009. readonly onExtensionLoadedObservable: Observable<IGLTFLoaderExtension>;
  87010. private _onExtensionLoadedObserver;
  87011. /**
  87012. * Callback raised after a loader extension is created.
  87013. */
  87014. set onExtensionLoaded(callback: (extension: IGLTFLoaderExtension) => void);
  87015. /**
  87016. * Defines if the loader logging is enabled.
  87017. */
  87018. get loggingEnabled(): boolean;
  87019. set loggingEnabled(value: boolean);
  87020. /**
  87021. * Defines if the loader should capture performance counters.
  87022. */
  87023. get capturePerformanceCounters(): boolean;
  87024. set capturePerformanceCounters(value: boolean);
  87025. /**
  87026. * Defines if the loader should validate the asset.
  87027. */
  87028. validate: boolean;
  87029. /**
  87030. * Observable raised after validation when validate is set to true. The event data is the result of the validation.
  87031. */
  87032. readonly onValidatedObservable: Observable<BABYLON.GLTF2.IGLTFValidationResults>;
  87033. private _onValidatedObserver;
  87034. /**
  87035. * Callback raised after a loader extension is created.
  87036. */
  87037. set onValidated(callback: (results: BABYLON.GLTF2.IGLTFValidationResults) => void);
  87038. private _loader;
  87039. private _progressCallback?;
  87040. private _requests;
  87041. private static magicBase64Encoded;
  87042. /**
  87043. * Name of the loader ("gltf")
  87044. */
  87045. name: string;
  87046. /** @hidden */
  87047. extensions: ISceneLoaderPluginExtensions;
  87048. /**
  87049. * Disposes the loader, releases resources during load, and cancels any outstanding requests.
  87050. */
  87051. dispose(): void;
  87052. /** @hidden */
  87053. requestFile(scene: Scene, url: string, onSuccess: (data: any, request?: WebRequest) => void, onProgress?: (ev: ISceneLoaderProgressEvent) => void, useArrayBuffer?: boolean, onError?: (error: any) => void): IFileRequest;
  87054. /** @hidden */
  87055. readFile(scene: Scene, file: File, onSuccess: (data: any) => void, onProgress?: (ev: ISceneLoaderProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: any) => void): IFileRequest;
  87056. /** @hidden */
  87057. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string): Promise<ISceneLoaderAsyncResult>;
  87058. /** @hidden */
  87059. loadAsync(scene: Scene, data: any, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  87060. /** @hidden */
  87061. loadAssetContainerAsync(scene: Scene, data: any, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  87062. /** @hidden */
  87063. canDirectLoad(data: string): boolean;
  87064. /** @hidden */
  87065. directLoad(scene: Scene, data: string): Promise<any>;
  87066. /**
  87067. * The callback that allows custom handling of the root url based on the response url.
  87068. * @param rootUrl the original root url
  87069. * @param responseURL the response url if available
  87070. * @returns the new root url
  87071. */
  87072. rewriteRootURL?(rootUrl: string, responseURL?: string): string;
  87073. /** @hidden */
  87074. createPlugin(): ISceneLoaderPlugin | ISceneLoaderPluginAsync;
  87075. /**
  87076. * The loader state or null if the loader is not active.
  87077. */
  87078. get loaderState(): Nullable<GLTFLoaderState>;
  87079. /**
  87080. * Returns a promise that resolves when the asset is completely loaded.
  87081. * @returns a promise that resolves when the asset is completely loaded.
  87082. */
  87083. whenCompleteAsync(): Promise<void>;
  87084. /** @hidden */
  87085. _loadFile(url: string, scene: Scene, onSuccess: (data: string | ArrayBuffer) => void, useArrayBuffer?: boolean, onError?: (request?: WebRequest) => void): IFileRequest;
  87086. /** @hidden */
  87087. _requestFile(url: string, scene: Scene, onSuccess: (data: string | ArrayBuffer, request?: WebRequest) => void, useArrayBuffer?: boolean, onError?: (error: RequestFileError) => void, onOpened?: (request: WebRequest) => void): IFileRequest;
  87088. private _onProgress;
  87089. private _validate;
  87090. private _getLoader;
  87091. private _parseJson;
  87092. private _unpackBinaryAsync;
  87093. private _unpackBinaryV1Async;
  87094. private _unpackBinaryV2Async;
  87095. private static _parseVersion;
  87096. private static _compareVersion;
  87097. private static readonly _logSpaces;
  87098. private _logIndentLevel;
  87099. private _loggingEnabled;
  87100. /** @hidden */
  87101. _log: (message: string) => void;
  87102. /** @hidden */
  87103. _logOpen(message: string): void;
  87104. /** @hidden */
  87105. _logClose(): void;
  87106. private _logEnabled;
  87107. private _logDisabled;
  87108. private _capturePerformanceCounters;
  87109. /** @hidden */
  87110. _startPerformanceCounter: (counterName: string) => void;
  87111. /** @hidden */
  87112. _endPerformanceCounter: (counterName: string) => void;
  87113. private _startPerformanceCounterEnabled;
  87114. private _startPerformanceCounterDisabled;
  87115. private _endPerformanceCounterEnabled;
  87116. private _endPerformanceCounterDisabled;
  87117. }
  87118. }
  87119. declare module BABYLON.GLTF1 {
  87120. /**
  87121. * Enums
  87122. * @hidden
  87123. */
  87124. export enum EComponentType {
  87125. BYTE = 5120,
  87126. UNSIGNED_BYTE = 5121,
  87127. SHORT = 5122,
  87128. UNSIGNED_SHORT = 5123,
  87129. FLOAT = 5126
  87130. }
  87131. /** @hidden */
  87132. export enum EShaderType {
  87133. FRAGMENT = 35632,
  87134. VERTEX = 35633
  87135. }
  87136. /** @hidden */
  87137. export enum EParameterType {
  87138. BYTE = 5120,
  87139. UNSIGNED_BYTE = 5121,
  87140. SHORT = 5122,
  87141. UNSIGNED_SHORT = 5123,
  87142. INT = 5124,
  87143. UNSIGNED_INT = 5125,
  87144. FLOAT = 5126,
  87145. FLOAT_VEC2 = 35664,
  87146. FLOAT_VEC3 = 35665,
  87147. FLOAT_VEC4 = 35666,
  87148. INT_VEC2 = 35667,
  87149. INT_VEC3 = 35668,
  87150. INT_VEC4 = 35669,
  87151. BOOL = 35670,
  87152. BOOL_VEC2 = 35671,
  87153. BOOL_VEC3 = 35672,
  87154. BOOL_VEC4 = 35673,
  87155. FLOAT_MAT2 = 35674,
  87156. FLOAT_MAT3 = 35675,
  87157. FLOAT_MAT4 = 35676,
  87158. SAMPLER_2D = 35678
  87159. }
  87160. /** @hidden */
  87161. export enum ETextureWrapMode {
  87162. CLAMP_TO_EDGE = 33071,
  87163. MIRRORED_REPEAT = 33648,
  87164. REPEAT = 10497
  87165. }
  87166. /** @hidden */
  87167. export enum ETextureFilterType {
  87168. NEAREST = 9728,
  87169. LINEAR = 9728,
  87170. NEAREST_MIPMAP_NEAREST = 9984,
  87171. LINEAR_MIPMAP_NEAREST = 9985,
  87172. NEAREST_MIPMAP_LINEAR = 9986,
  87173. LINEAR_MIPMAP_LINEAR = 9987
  87174. }
  87175. /** @hidden */
  87176. export enum ETextureFormat {
  87177. ALPHA = 6406,
  87178. RGB = 6407,
  87179. RGBA = 6408,
  87180. LUMINANCE = 6409,
  87181. LUMINANCE_ALPHA = 6410
  87182. }
  87183. /** @hidden */
  87184. export enum ECullingType {
  87185. FRONT = 1028,
  87186. BACK = 1029,
  87187. FRONT_AND_BACK = 1032
  87188. }
  87189. /** @hidden */
  87190. export enum EBlendingFunction {
  87191. ZERO = 0,
  87192. ONE = 1,
  87193. SRC_COLOR = 768,
  87194. ONE_MINUS_SRC_COLOR = 769,
  87195. DST_COLOR = 774,
  87196. ONE_MINUS_DST_COLOR = 775,
  87197. SRC_ALPHA = 770,
  87198. ONE_MINUS_SRC_ALPHA = 771,
  87199. DST_ALPHA = 772,
  87200. ONE_MINUS_DST_ALPHA = 773,
  87201. CONSTANT_COLOR = 32769,
  87202. ONE_MINUS_CONSTANT_COLOR = 32770,
  87203. CONSTANT_ALPHA = 32771,
  87204. ONE_MINUS_CONSTANT_ALPHA = 32772,
  87205. SRC_ALPHA_SATURATE = 776
  87206. }
  87207. /** @hidden */
  87208. export interface IGLTFProperty {
  87209. extensions?: {
  87210. [key: string]: any;
  87211. };
  87212. extras?: Object;
  87213. }
  87214. /** @hidden */
  87215. export interface IGLTFChildRootProperty extends IGLTFProperty {
  87216. name?: string;
  87217. }
  87218. /** @hidden */
  87219. export interface IGLTFAccessor extends IGLTFChildRootProperty {
  87220. bufferView: string;
  87221. byteOffset: number;
  87222. byteStride: number;
  87223. count: number;
  87224. type: string;
  87225. componentType: EComponentType;
  87226. max?: number[];
  87227. min?: number[];
  87228. name?: string;
  87229. }
  87230. /** @hidden */
  87231. export interface IGLTFBufferView extends IGLTFChildRootProperty {
  87232. buffer: string;
  87233. byteOffset: number;
  87234. byteLength: number;
  87235. byteStride: number;
  87236. target?: number;
  87237. }
  87238. /** @hidden */
  87239. export interface IGLTFBuffer extends IGLTFChildRootProperty {
  87240. uri: string;
  87241. byteLength?: number;
  87242. type?: string;
  87243. }
  87244. /** @hidden */
  87245. export interface IGLTFShader extends IGLTFChildRootProperty {
  87246. uri: string;
  87247. type: EShaderType;
  87248. }
  87249. /** @hidden */
  87250. export interface IGLTFProgram extends IGLTFChildRootProperty {
  87251. attributes: string[];
  87252. fragmentShader: string;
  87253. vertexShader: string;
  87254. }
  87255. /** @hidden */
  87256. export interface IGLTFTechniqueParameter {
  87257. type: number;
  87258. count?: number;
  87259. semantic?: string;
  87260. node?: string;
  87261. value?: number | boolean | string | Array<any>;
  87262. source?: string;
  87263. babylonValue?: any;
  87264. }
  87265. /** @hidden */
  87266. export interface IGLTFTechniqueCommonProfile {
  87267. lightingModel: string;
  87268. texcoordBindings: Object;
  87269. parameters?: Array<any>;
  87270. }
  87271. /** @hidden */
  87272. export interface IGLTFTechniqueStatesFunctions {
  87273. blendColor?: number[];
  87274. blendEquationSeparate?: number[];
  87275. blendFuncSeparate?: number[];
  87276. colorMask: boolean[];
  87277. cullFace: number[];
  87278. }
  87279. /** @hidden */
  87280. export interface IGLTFTechniqueStates {
  87281. enable: number[];
  87282. functions: IGLTFTechniqueStatesFunctions;
  87283. }
  87284. /** @hidden */
  87285. export interface IGLTFTechnique extends IGLTFChildRootProperty {
  87286. parameters: {
  87287. [key: string]: IGLTFTechniqueParameter;
  87288. };
  87289. program: string;
  87290. attributes: {
  87291. [key: string]: string;
  87292. };
  87293. uniforms: {
  87294. [key: string]: string;
  87295. };
  87296. states: IGLTFTechniqueStates;
  87297. }
  87298. /** @hidden */
  87299. export interface IGLTFMaterial extends IGLTFChildRootProperty {
  87300. technique?: string;
  87301. values: string[];
  87302. }
  87303. /** @hidden */
  87304. export interface IGLTFMeshPrimitive extends IGLTFProperty {
  87305. attributes: {
  87306. [key: string]: string;
  87307. };
  87308. indices: string;
  87309. material: string;
  87310. mode?: number;
  87311. }
  87312. /** @hidden */
  87313. export interface IGLTFMesh extends IGLTFChildRootProperty {
  87314. primitives: IGLTFMeshPrimitive[];
  87315. }
  87316. /** @hidden */
  87317. export interface IGLTFImage extends IGLTFChildRootProperty {
  87318. uri: string;
  87319. }
  87320. /** @hidden */
  87321. export interface IGLTFSampler extends IGLTFChildRootProperty {
  87322. magFilter?: number;
  87323. minFilter?: number;
  87324. wrapS?: number;
  87325. wrapT?: number;
  87326. }
  87327. /** @hidden */
  87328. export interface IGLTFTexture extends IGLTFChildRootProperty {
  87329. sampler: string;
  87330. source: string;
  87331. format?: ETextureFormat;
  87332. internalFormat?: ETextureFormat;
  87333. target?: number;
  87334. type?: number;
  87335. babylonTexture?: Texture;
  87336. }
  87337. /** @hidden */
  87338. export interface IGLTFAmbienLight {
  87339. color?: number[];
  87340. }
  87341. /** @hidden */
  87342. export interface IGLTFDirectionalLight {
  87343. color?: number[];
  87344. }
  87345. /** @hidden */
  87346. export interface IGLTFPointLight {
  87347. color?: number[];
  87348. constantAttenuation?: number;
  87349. linearAttenuation?: number;
  87350. quadraticAttenuation?: number;
  87351. }
  87352. /** @hidden */
  87353. export interface IGLTFSpotLight {
  87354. color?: number[];
  87355. constantAttenuation?: number;
  87356. fallOfAngle?: number;
  87357. fallOffExponent?: number;
  87358. linearAttenuation?: number;
  87359. quadraticAttenuation?: number;
  87360. }
  87361. /** @hidden */
  87362. export interface IGLTFLight extends IGLTFChildRootProperty {
  87363. type: string;
  87364. }
  87365. /** @hidden */
  87366. export interface IGLTFCameraOrthographic {
  87367. xmag: number;
  87368. ymag: number;
  87369. zfar: number;
  87370. znear: number;
  87371. }
  87372. /** @hidden */
  87373. export interface IGLTFCameraPerspective {
  87374. aspectRatio: number;
  87375. yfov: number;
  87376. zfar: number;
  87377. znear: number;
  87378. }
  87379. /** @hidden */
  87380. export interface IGLTFCamera extends IGLTFChildRootProperty {
  87381. type: string;
  87382. }
  87383. /** @hidden */
  87384. export interface IGLTFAnimationChannelTarget {
  87385. id: string;
  87386. path: string;
  87387. }
  87388. /** @hidden */
  87389. export interface IGLTFAnimationChannel {
  87390. sampler: string;
  87391. target: IGLTFAnimationChannelTarget;
  87392. }
  87393. /** @hidden */
  87394. export interface IGLTFAnimationSampler {
  87395. input: string;
  87396. output: string;
  87397. interpolation?: string;
  87398. }
  87399. /** @hidden */
  87400. export interface IGLTFAnimation extends IGLTFChildRootProperty {
  87401. channels?: IGLTFAnimationChannel[];
  87402. parameters?: {
  87403. [key: string]: string;
  87404. };
  87405. samplers?: {
  87406. [key: string]: IGLTFAnimationSampler;
  87407. };
  87408. }
  87409. /** @hidden */
  87410. export interface IGLTFNodeInstanceSkin {
  87411. skeletons: string[];
  87412. skin: string;
  87413. meshes: string[];
  87414. }
  87415. /** @hidden */
  87416. export interface IGLTFSkins extends IGLTFChildRootProperty {
  87417. bindShapeMatrix: number[];
  87418. inverseBindMatrices: string;
  87419. jointNames: string[];
  87420. babylonSkeleton?: Skeleton;
  87421. }
  87422. /** @hidden */
  87423. export interface IGLTFNode extends IGLTFChildRootProperty {
  87424. camera?: string;
  87425. children: string[];
  87426. skin?: string;
  87427. jointName?: string;
  87428. light?: string;
  87429. matrix: number[];
  87430. mesh?: string;
  87431. meshes?: string[];
  87432. rotation?: number[];
  87433. scale?: number[];
  87434. translation?: number[];
  87435. babylonNode?: Node;
  87436. }
  87437. /** @hidden */
  87438. export interface IGLTFScene extends IGLTFChildRootProperty {
  87439. nodes: string[];
  87440. }
  87441. /** @hidden */
  87442. export interface IGLTFRuntime {
  87443. extensions: {
  87444. [key: string]: any;
  87445. };
  87446. accessors: {
  87447. [key: string]: IGLTFAccessor;
  87448. };
  87449. buffers: {
  87450. [key: string]: IGLTFBuffer;
  87451. };
  87452. bufferViews: {
  87453. [key: string]: IGLTFBufferView;
  87454. };
  87455. meshes: {
  87456. [key: string]: IGLTFMesh;
  87457. };
  87458. lights: {
  87459. [key: string]: IGLTFLight;
  87460. };
  87461. cameras: {
  87462. [key: string]: IGLTFCamera;
  87463. };
  87464. nodes: {
  87465. [key: string]: IGLTFNode;
  87466. };
  87467. images: {
  87468. [key: string]: IGLTFImage;
  87469. };
  87470. textures: {
  87471. [key: string]: IGLTFTexture;
  87472. };
  87473. shaders: {
  87474. [key: string]: IGLTFShader;
  87475. };
  87476. programs: {
  87477. [key: string]: IGLTFProgram;
  87478. };
  87479. samplers: {
  87480. [key: string]: IGLTFSampler;
  87481. };
  87482. techniques: {
  87483. [key: string]: IGLTFTechnique;
  87484. };
  87485. materials: {
  87486. [key: string]: IGLTFMaterial;
  87487. };
  87488. animations: {
  87489. [key: string]: IGLTFAnimation;
  87490. };
  87491. skins: {
  87492. [key: string]: IGLTFSkins;
  87493. };
  87494. currentScene?: Object;
  87495. scenes: {
  87496. [key: string]: IGLTFScene;
  87497. };
  87498. extensionsUsed: string[];
  87499. extensionsRequired?: string[];
  87500. buffersCount: number;
  87501. shaderscount: number;
  87502. scene: Scene;
  87503. rootUrl: string;
  87504. loadedBufferCount: number;
  87505. loadedBufferViews: {
  87506. [name: string]: ArrayBufferView;
  87507. };
  87508. loadedShaderCount: number;
  87509. importOnlyMeshes: boolean;
  87510. importMeshesNames?: string[];
  87511. dummyNodes: Node[];
  87512. forAssetContainer: boolean;
  87513. }
  87514. /** @hidden */
  87515. export interface INodeToRoot {
  87516. bone: Bone;
  87517. node: IGLTFNode;
  87518. id: string;
  87519. }
  87520. /** @hidden */
  87521. export interface IJointNode {
  87522. node: IGLTFNode;
  87523. id: string;
  87524. }
  87525. }
  87526. declare module BABYLON.GLTF1 {
  87527. /**
  87528. * Utils functions for GLTF
  87529. * @hidden
  87530. */
  87531. export class GLTFUtils {
  87532. /**
  87533. * Sets the given "parameter" matrix
  87534. * @param scene: the Scene object
  87535. * @param source: the source node where to pick the matrix
  87536. * @param parameter: the GLTF technique parameter
  87537. * @param uniformName: the name of the shader's uniform
  87538. * @param shaderMaterial: the shader material
  87539. */
  87540. static SetMatrix(scene: Scene, source: Node, parameter: IGLTFTechniqueParameter, uniformName: string, shaderMaterial: ShaderMaterial | Effect): void;
  87541. /**
  87542. * Sets the given "parameter" matrix
  87543. * @param shaderMaterial: the shader material
  87544. * @param uniform: the name of the shader's uniform
  87545. * @param value: the value of the uniform
  87546. * @param type: the uniform's type (EParameterType FLOAT, VEC2, VEC3 or VEC4)
  87547. */
  87548. static SetUniform(shaderMaterial: ShaderMaterial | Effect, uniform: string, value: any, type: number): boolean;
  87549. /**
  87550. * Returns the wrap mode of the texture
  87551. * @param mode: the mode value
  87552. */
  87553. static GetWrapMode(mode: number): number;
  87554. /**
  87555. * Returns the byte stride giving an accessor
  87556. * @param accessor: the GLTF accessor objet
  87557. */
  87558. static GetByteStrideFromType(accessor: IGLTFAccessor): number;
  87559. /**
  87560. * Returns the texture filter mode giving a mode value
  87561. * @param mode: the filter mode value
  87562. */
  87563. static GetTextureFilterMode(mode: number): ETextureFilterType;
  87564. static GetBufferFromBufferView(gltfRuntime: IGLTFRuntime, bufferView: IGLTFBufferView, byteOffset: number, byteLength: number, componentType: EComponentType): ArrayBufferView;
  87565. /**
  87566. * Returns a buffer from its accessor
  87567. * @param gltfRuntime: the GLTF runtime
  87568. * @param accessor: the GLTF accessor
  87569. */
  87570. static GetBufferFromAccessor(gltfRuntime: IGLTFRuntime, accessor: IGLTFAccessor): any;
  87571. /**
  87572. * Decodes a buffer view into a string
  87573. * @param view: the buffer view
  87574. */
  87575. static DecodeBufferToText(view: ArrayBufferView): string;
  87576. /**
  87577. * Returns the default material of gltf. Related to
  87578. * https://github.com/KhronosGroup/glTF/tree/master/specification/1.0#appendix-a-default-material
  87579. * @param scene: the Babylon.js scene
  87580. */
  87581. static GetDefaultMaterial(scene: Scene): ShaderMaterial;
  87582. private static _DefaultMaterial;
  87583. }
  87584. }
  87585. declare module BABYLON.GLTF1 {
  87586. /**
  87587. * Implementation of the base glTF spec
  87588. * @hidden
  87589. */
  87590. export class GLTFLoaderBase {
  87591. static CreateRuntime(parsedData: any, scene: Scene, rootUrl: string): IGLTFRuntime;
  87592. static LoadBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: ArrayBufferView) => void, onError: (message: string) => void, onProgress?: () => void): void;
  87593. static LoadTextureBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: Nullable<ArrayBufferView>) => void, onError: (message: string) => void): void;
  87594. static CreateTextureAsync(gltfRuntime: IGLTFRuntime, id: string, buffer: Nullable<ArrayBufferView>, onSuccess: (texture: Texture) => void, onError: (message: string) => void): void;
  87595. static LoadShaderStringAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (shaderString: string | ArrayBuffer) => void, onError?: (message: string) => void): void;
  87596. static LoadMaterialAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (material: Material) => void, onError: (message: string) => void): void;
  87597. }
  87598. /**
  87599. * glTF V1 Loader
  87600. * @hidden
  87601. */
  87602. export class GLTFLoader implements IGLTFLoader {
  87603. static Extensions: {
  87604. [name: string]: GLTFLoaderExtension;
  87605. };
  87606. static RegisterExtension(extension: GLTFLoaderExtension): void;
  87607. state: Nullable<GLTFLoaderState>;
  87608. dispose(): void;
  87609. private _importMeshAsync;
  87610. /**
  87611. * Imports one or more meshes from a loaded gltf file and adds them to the scene
  87612. * @param meshesNames a string or array of strings of the mesh names that should be loaded from the file
  87613. * @param scene the scene the meshes should be added to
  87614. * @param forAssetContainer defines if the entities must be stored in the scene
  87615. * @param data gltf data containing information of the meshes in a loaded file
  87616. * @param rootUrl root url to load from
  87617. * @param onProgress event that fires when loading progress has occured
  87618. * @returns a promise containg the loaded meshes, particles, skeletons and animations
  87619. */
  87620. importMeshAsync(meshesNames: any, scene: Scene, forAssetContainer: boolean, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void): Promise<ISceneLoaderAsyncResult>;
  87621. private _loadAsync;
  87622. /**
  87623. * Imports all objects from a loaded gltf file and adds them to the scene
  87624. * @param scene the scene the objects should be added to
  87625. * @param data gltf data containing information of the meshes in a loaded file
  87626. * @param rootUrl root url to load from
  87627. * @param onProgress event that fires when loading progress has occured
  87628. * @returns a promise which completes when objects have been loaded to the scene
  87629. */
  87630. loadAsync(scene: Scene, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void): Promise<void>;
  87631. private _loadShadersAsync;
  87632. private _loadBuffersAsync;
  87633. private _createNodes;
  87634. }
  87635. /** @hidden */
  87636. export abstract class GLTFLoaderExtension {
  87637. private _name;
  87638. constructor(name: string);
  87639. get name(): string;
  87640. /**
  87641. * Defines an override for loading the runtime
  87642. * Return true to stop further extensions from loading the runtime
  87643. */
  87644. loadRuntimeAsync(scene: Scene, data: IGLTFLoaderData, rootUrl: string, onSuccess?: (gltfRuntime: IGLTFRuntime) => void, onError?: (message: string) => void): boolean;
  87645. /**
  87646. * Defines an onverride for creating gltf runtime
  87647. * Return true to stop further extensions from creating the runtime
  87648. */
  87649. loadRuntimeExtensionsAsync(gltfRuntime: IGLTFRuntime, onSuccess: () => void, onError?: (message: string) => void): boolean;
  87650. /**
  87651. * Defines an override for loading buffers
  87652. * Return true to stop further extensions from loading this buffer
  87653. */
  87654. loadBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: ArrayBufferView) => void, onError: (message: string) => void, onProgress?: () => void): boolean;
  87655. /**
  87656. * Defines an override for loading texture buffers
  87657. * Return true to stop further extensions from loading this texture data
  87658. */
  87659. loadTextureBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: ArrayBufferView) => void, onError: (message: string) => void): boolean;
  87660. /**
  87661. * Defines an override for creating textures
  87662. * Return true to stop further extensions from loading this texture
  87663. */
  87664. createTextureAsync(gltfRuntime: IGLTFRuntime, id: string, buffer: ArrayBufferView, onSuccess: (texture: Texture) => void, onError: (message: string) => void): boolean;
  87665. /**
  87666. * Defines an override for loading shader strings
  87667. * Return true to stop further extensions from loading this shader data
  87668. */
  87669. loadShaderStringAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (shaderString: string) => void, onError: (message: string) => void): boolean;
  87670. /**
  87671. * Defines an override for loading materials
  87672. * Return true to stop further extensions from loading this material
  87673. */
  87674. loadMaterialAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (material: Material) => void, onError: (message: string) => void): boolean;
  87675. static LoadRuntimeAsync(scene: Scene, data: IGLTFLoaderData, rootUrl: string, onSuccess?: (gltfRuntime: IGLTFRuntime) => void, onError?: (message: string) => void): void;
  87676. static LoadRuntimeExtensionsAsync(gltfRuntime: IGLTFRuntime, onSuccess: () => void, onError?: (message: string) => void): void;
  87677. static LoadBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (bufferView: ArrayBufferView) => void, onError: (message: string) => void, onProgress?: () => void): void;
  87678. static LoadTextureAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (texture: Texture) => void, onError: (message: string) => void): void;
  87679. static LoadShaderStringAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (shaderData: string | ArrayBuffer) => void, onError: (message: string) => void): void;
  87680. static LoadMaterialAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (material: Material) => void, onError: (message: string) => void): void;
  87681. private static LoadTextureBufferAsync;
  87682. private static CreateTextureAsync;
  87683. private static ApplyExtensions;
  87684. }
  87685. }
  87686. declare module BABYLON.GLTF1 {
  87687. /** @hidden */
  87688. export class GLTFBinaryExtension extends GLTFLoaderExtension {
  87689. private _bin;
  87690. constructor();
  87691. loadRuntimeAsync(scene: Scene, data: IGLTFLoaderData, rootUrl: string, onSuccess: (gltfRuntime: IGLTFRuntime) => void, onError: (message: string) => void): boolean;
  87692. loadBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: ArrayBufferView) => void, onError: (message: string) => void): boolean;
  87693. loadTextureBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: ArrayBufferView) => void, onError: (message: string) => void): boolean;
  87694. loadShaderStringAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (shaderString: string) => void, onError: (message: string) => void): boolean;
  87695. }
  87696. }
  87697. declare module BABYLON.GLTF1 {
  87698. /** @hidden */
  87699. export class GLTFMaterialsCommonExtension extends GLTFLoaderExtension {
  87700. constructor();
  87701. loadRuntimeExtensionsAsync(gltfRuntime: IGLTFRuntime, onSuccess: () => void, onError: (message: string) => void): boolean;
  87702. loadMaterialAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (material: Material) => void, onError: (message: string) => void): boolean;
  87703. private _loadTexture;
  87704. }
  87705. }
  87706. declare module BABYLON.GLTF2.Loader {
  87707. /**
  87708. * Loader interface with an index field.
  87709. */
  87710. export interface IArrayItem {
  87711. /**
  87712. * The index of this item in the array.
  87713. */
  87714. index: number;
  87715. }
  87716. /**
  87717. * Loader interface with additional members.
  87718. */
  87719. export interface IAccessor extends BABYLON.GLTF2.IAccessor, IArrayItem {
  87720. /** @hidden */
  87721. _data?: Promise<ArrayBufferView>;
  87722. /** @hidden */
  87723. _babylonVertexBuffer?: Promise<VertexBuffer>;
  87724. }
  87725. /**
  87726. * Loader interface with additional members.
  87727. */
  87728. export interface IAnimationChannel extends BABYLON.GLTF2.IAnimationChannel, IArrayItem {
  87729. }
  87730. /** @hidden */
  87731. export interface _IAnimationSamplerData {
  87732. input: Float32Array;
  87733. interpolation: BABYLON.GLTF2.AnimationSamplerInterpolation;
  87734. output: Float32Array;
  87735. }
  87736. /**
  87737. * Loader interface with additional members.
  87738. */
  87739. export interface IAnimationSampler extends BABYLON.GLTF2.IAnimationSampler, IArrayItem {
  87740. /** @hidden */
  87741. _data?: Promise<_IAnimationSamplerData>;
  87742. }
  87743. /**
  87744. * Loader interface with additional members.
  87745. */
  87746. export interface IAnimation extends BABYLON.GLTF2.IAnimation, IArrayItem {
  87747. channels: IAnimationChannel[];
  87748. samplers: IAnimationSampler[];
  87749. /** @hidden */
  87750. _babylonAnimationGroup?: AnimationGroup;
  87751. }
  87752. /**
  87753. * Loader interface with additional members.
  87754. */
  87755. export interface IBuffer extends BABYLON.GLTF2.IBuffer, IArrayItem {
  87756. /** @hidden */
  87757. _data?: Promise<ArrayBufferView>;
  87758. }
  87759. /**
  87760. * Loader interface with additional members.
  87761. */
  87762. export interface IBufferView extends BABYLON.GLTF2.IBufferView, IArrayItem {
  87763. /** @hidden */
  87764. _data?: Promise<ArrayBufferView>;
  87765. /** @hidden */
  87766. _babylonBuffer?: Promise<Buffer>;
  87767. }
  87768. /**
  87769. * Loader interface with additional members.
  87770. */
  87771. export interface ICamera extends BABYLON.GLTF2.ICamera, IArrayItem {
  87772. }
  87773. /**
  87774. * Loader interface with additional members.
  87775. */
  87776. export interface IImage extends BABYLON.GLTF2.IImage, IArrayItem {
  87777. /** @hidden */
  87778. _data?: Promise<ArrayBufferView>;
  87779. }
  87780. /**
  87781. * Loader interface with additional members.
  87782. */
  87783. export interface IMaterialNormalTextureInfo extends BABYLON.GLTF2.IMaterialNormalTextureInfo, ITextureInfo {
  87784. }
  87785. /**
  87786. * Loader interface with additional members.
  87787. */
  87788. export interface IMaterialOcclusionTextureInfo extends BABYLON.GLTF2.IMaterialOcclusionTextureInfo, ITextureInfo {
  87789. }
  87790. /**
  87791. * Loader interface with additional members.
  87792. */
  87793. export interface IMaterialPbrMetallicRoughness extends BABYLON.GLTF2.IMaterialPbrMetallicRoughness {
  87794. baseColorTexture?: ITextureInfo;
  87795. metallicRoughnessTexture?: ITextureInfo;
  87796. }
  87797. /**
  87798. * Loader interface with additional members.
  87799. */
  87800. export interface IMaterial extends BABYLON.GLTF2.IMaterial, IArrayItem {
  87801. pbrMetallicRoughness?: IMaterialPbrMetallicRoughness;
  87802. normalTexture?: IMaterialNormalTextureInfo;
  87803. occlusionTexture?: IMaterialOcclusionTextureInfo;
  87804. emissiveTexture?: ITextureInfo;
  87805. /** @hidden */
  87806. _data?: {
  87807. [babylonDrawMode: number]: {
  87808. babylonMaterial: Material;
  87809. babylonMeshes: AbstractMesh[];
  87810. promise: Promise<void>;
  87811. };
  87812. };
  87813. }
  87814. /**
  87815. * Loader interface with additional members.
  87816. */
  87817. export interface IMesh extends BABYLON.GLTF2.IMesh, IArrayItem {
  87818. primitives: IMeshPrimitive[];
  87819. }
  87820. /**
  87821. * Loader interface with additional members.
  87822. */
  87823. export interface IMeshPrimitive extends BABYLON.GLTF2.IMeshPrimitive, IArrayItem {
  87824. /** @hidden */
  87825. _instanceData?: {
  87826. babylonSourceMesh: Mesh;
  87827. promise: Promise<any>;
  87828. };
  87829. }
  87830. /**
  87831. * Loader interface with additional members.
  87832. */
  87833. export interface INode extends BABYLON.GLTF2.INode, IArrayItem {
  87834. /**
  87835. * The parent glTF node.
  87836. */
  87837. parent?: INode;
  87838. /** @hidden */
  87839. _babylonTransformNode?: TransformNode;
  87840. /** @hidden */
  87841. _primitiveBabylonMeshes?: AbstractMesh[];
  87842. /** @hidden */
  87843. _babylonBones?: Bone[];
  87844. /** @hidden */
  87845. _numMorphTargets?: number;
  87846. }
  87847. /** @hidden */
  87848. export interface _ISamplerData {
  87849. noMipMaps: boolean;
  87850. samplingMode: number;
  87851. wrapU: number;
  87852. wrapV: number;
  87853. }
  87854. /**
  87855. * Loader interface with additional members.
  87856. */
  87857. export interface ISampler extends BABYLON.GLTF2.ISampler, IArrayItem {
  87858. /** @hidden */
  87859. _data?: _ISamplerData;
  87860. }
  87861. /**
  87862. * Loader interface with additional members.
  87863. */
  87864. export interface IScene extends BABYLON.GLTF2.IScene, IArrayItem {
  87865. }
  87866. /**
  87867. * Loader interface with additional members.
  87868. */
  87869. export interface ISkin extends BABYLON.GLTF2.ISkin, IArrayItem {
  87870. /** @hidden */
  87871. _data?: {
  87872. babylonSkeleton: Skeleton;
  87873. promise: Promise<void>;
  87874. };
  87875. }
  87876. /**
  87877. * Loader interface with additional members.
  87878. */
  87879. export interface ITexture extends BABYLON.GLTF2.ITexture, IArrayItem {
  87880. /** @hidden */
  87881. _textureInfo: ITextureInfo;
  87882. }
  87883. /**
  87884. * Loader interface with additional members.
  87885. */
  87886. export interface ITextureInfo extends BABYLON.GLTF2.ITextureInfo {
  87887. /** false or undefined if the texture holds color data (true if data are roughness, normal, ...) */
  87888. nonColorData?: boolean;
  87889. }
  87890. /**
  87891. * Loader interface with additional members.
  87892. */
  87893. export interface IGLTF extends BABYLON.GLTF2.IGLTF {
  87894. accessors?: IAccessor[];
  87895. animations?: IAnimation[];
  87896. buffers?: IBuffer[];
  87897. bufferViews?: IBufferView[];
  87898. cameras?: ICamera[];
  87899. images?: IImage[];
  87900. materials?: IMaterial[];
  87901. meshes?: IMesh[];
  87902. nodes?: INode[];
  87903. samplers?: ISampler[];
  87904. scenes?: IScene[];
  87905. skins?: ISkin[];
  87906. textures?: ITexture[];
  87907. }
  87908. }
  87909. declare module BABYLON.GLTF2 {
  87910. /**
  87911. * Interface for a glTF loader extension.
  87912. */
  87913. export interface IGLTFLoaderExtension extends BABYLON.IGLTFLoaderExtension, IDisposable {
  87914. /**
  87915. * Called after the loader state changes to LOADING.
  87916. */
  87917. onLoading?(): void;
  87918. /**
  87919. * Called after the loader state changes to READY.
  87920. */
  87921. onReady?(): void;
  87922. /**
  87923. * Define this method to modify the default behavior when loading scenes.
  87924. * @param context The context when loading the asset
  87925. * @param scene The glTF scene property
  87926. * @returns A promise that resolves when the load is complete or null if not handled
  87927. */
  87928. loadSceneAsync?(context: string, scene: IScene): Nullable<Promise<void>>;
  87929. /**
  87930. * Define this method to modify the default behavior when loading nodes.
  87931. * @param context The context when loading the asset
  87932. * @param node The glTF node property
  87933. * @param assign A function called synchronously after parsing the glTF properties
  87934. * @returns A promise that resolves with the loaded Babylon transform node when the load is complete or null if not handled
  87935. */
  87936. loadNodeAsync?(context: string, node: INode, assign: (babylonMesh: TransformNode) => void): Nullable<Promise<TransformNode>>;
  87937. /**
  87938. * Define this method to modify the default behavior when loading cameras.
  87939. * @param context The context when loading the asset
  87940. * @param camera The glTF camera property
  87941. * @param assign A function called synchronously after parsing the glTF properties
  87942. * @returns A promise that resolves with the loaded Babylon camera when the load is complete or null if not handled
  87943. */
  87944. loadCameraAsync?(context: string, camera: ICamera, assign: (babylonCamera: Camera) => void): Nullable<Promise<Camera>>;
  87945. /**
  87946. * @hidden
  87947. * Define this method to modify the default behavior when loading vertex data for mesh primitives.
  87948. * @param context The context when loading the asset
  87949. * @param primitive The glTF mesh primitive property
  87950. * @returns A promise that resolves with the loaded geometry when the load is complete or null if not handled
  87951. */
  87952. _loadVertexDataAsync?(context: string, primitive: IMeshPrimitive, babylonMesh: Mesh): Nullable<Promise<Geometry>>;
  87953. /**
  87954. * @hidden
  87955. * Define this method to modify the default behavior when loading data for mesh primitives.
  87956. * @param context The context when loading the asset
  87957. * @param name The mesh name when loading the asset
  87958. * @param node The glTF node when loading the asset
  87959. * @param mesh The glTF mesh when loading the asset
  87960. * @param primitive The glTF mesh primitive property
  87961. * @param assign A function called synchronously after parsing the glTF properties
  87962. * @returns A promise that resolves with the loaded mesh when the load is complete or null if not handled
  87963. */
  87964. _loadMeshPrimitiveAsync?(context: string, name: string, node: INode, mesh: IMesh, primitive: IMeshPrimitive, assign: (babylonMesh: AbstractMesh) => void): Nullable<Promise<AbstractMesh>>;
  87965. /**
  87966. * @hidden
  87967. * Define this method to modify the default behavior when loading materials. Load material creates the material and then loads material properties.
  87968. * @param context The context when loading the asset
  87969. * @param material The glTF material property
  87970. * @param assign A function called synchronously after parsing the glTF properties
  87971. * @returns A promise that resolves with the loaded Babylon material when the load is complete or null if not handled
  87972. */
  87973. _loadMaterialAsync?(context: string, material: IMaterial, babylonMesh: Nullable<Mesh>, babylonDrawMode: number, assign: (babylonMaterial: Material) => void): Nullable<Promise<Material>>;
  87974. /**
  87975. * Define this method to modify the default behavior when creating materials.
  87976. * @param context The context when loading the asset
  87977. * @param material The glTF material property
  87978. * @param babylonDrawMode The draw mode for the Babylon material
  87979. * @returns The Babylon material or null if not handled
  87980. */
  87981. createMaterial?(context: string, material: IMaterial, babylonDrawMode: number): Nullable<Material>;
  87982. /**
  87983. * Define this method to modify the default behavior when loading material properties.
  87984. * @param context The context when loading the asset
  87985. * @param material The glTF material property
  87986. * @param babylonMaterial The Babylon material
  87987. * @returns A promise that resolves when the load is complete or null if not handled
  87988. */
  87989. loadMaterialPropertiesAsync?(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  87990. /**
  87991. * Define this method to modify the default behavior when loading texture infos.
  87992. * @param context The context when loading the asset
  87993. * @param textureInfo The glTF texture info property
  87994. * @param assign A function called synchronously after parsing the glTF properties
  87995. * @returns A promise that resolves with the loaded Babylon texture when the load is complete or null if not handled
  87996. */
  87997. loadTextureInfoAsync?(context: string, textureInfo: ITextureInfo, assign: (babylonTexture: BaseTexture) => void): Nullable<Promise<BaseTexture>>;
  87998. /**
  87999. * @hidden
  88000. * Define this method to modify the default behavior when loading textures.
  88001. * @param context The context when loading the asset
  88002. * @param texture The glTF texture property
  88003. * @param assign A function called synchronously after parsing the glTF properties
  88004. * @returns A promise that resolves with the loaded Babylon texture when the load is complete or null if not handled
  88005. */
  88006. _loadTextureAsync?(context: string, texture: ITexture, assign: (babylonTexture: BaseTexture) => void): Nullable<Promise<BaseTexture>>;
  88007. /**
  88008. * Define this method to modify the default behavior when loading animations.
  88009. * @param context The context when loading the asset
  88010. * @param animation The glTF animation property
  88011. * @returns A promise that resolves with the loaded Babylon animation group when the load is complete or null if not handled
  88012. */
  88013. loadAnimationAsync?(context: string, animation: IAnimation): Nullable<Promise<AnimationGroup>>;
  88014. /**
  88015. * @hidden
  88016. * Define this method to modify the default behavior when loading skins.
  88017. * @param context The context when loading the asset
  88018. * @param node The glTF node property
  88019. * @param skin The glTF skin property
  88020. * @returns A promise that resolves when the load is complete or null if not handled
  88021. */
  88022. _loadSkinAsync?(context: string, node: INode, skin: ISkin): Nullable<Promise<void>>;
  88023. /**
  88024. * @hidden
  88025. * Define this method to modify the default behavior when loading uris.
  88026. * @param context The context when loading the asset
  88027. * @param property The glTF property associated with the uri
  88028. * @param uri The uri to load
  88029. * @returns A promise that resolves with the loaded data when the load is complete or null if not handled
  88030. */
  88031. _loadUriAsync?(context: string, property: IProperty, uri: string): Nullable<Promise<ArrayBufferView>>;
  88032. /**
  88033. * Define this method to modify the default behavior when loading buffer views.
  88034. * @param context The context when loading the asset
  88035. * @param bufferView The glTF buffer view property
  88036. * @returns A promise that resolves with the loaded data when the load is complete or null if not handled
  88037. */
  88038. loadBufferViewAsync?(context: string, bufferView: IBufferView): Nullable<Promise<ArrayBufferView>>;
  88039. /**
  88040. * Define this method to modify the default behavior when loading buffers.
  88041. * @param context The context when loading the asset
  88042. * @param buffer The glTF buffer property
  88043. * @param byteOffset The byte offset to load
  88044. * @param byteLength The byte length to load
  88045. * @returns A promise that resolves with the loaded data when the load is complete or null if not handled
  88046. */
  88047. loadBufferAsync?(context: string, buffer: IBuffer, byteOffset: number, byteLength: number): Nullable<Promise<ArrayBufferView>>;
  88048. }
  88049. }
  88050. declare module BABYLON.GLTF2 {
  88051. /**
  88052. * Helper class for working with arrays when loading the glTF asset
  88053. */
  88054. export class ArrayItem {
  88055. /**
  88056. * Gets an item from the given array.
  88057. * @param context The context when loading the asset
  88058. * @param array The array to get the item from
  88059. * @param index The index to the array
  88060. * @returns The array item
  88061. */
  88062. static Get<T>(context: string, array: ArrayLike<T> | undefined, index: number | undefined): T;
  88063. /**
  88064. * Assign an `index` field to each item of the given array.
  88065. * @param array The array of items
  88066. */
  88067. static Assign(array?: BABYLON.GLTF2.Loader.IArrayItem[]): void;
  88068. }
  88069. /**
  88070. * The glTF 2.0 loader
  88071. */
  88072. export class GLTFLoader implements IGLTFLoader {
  88073. /** @hidden */
  88074. _completePromises: Promise<any>[];
  88075. /** @hidden */
  88076. _forAssetContainer: boolean;
  88077. /** Storage */
  88078. _babylonLights: Light[];
  88079. /** @hidden */
  88080. _disableInstancedMesh: number;
  88081. private _disposed;
  88082. private _parent;
  88083. private _state;
  88084. private _extensions;
  88085. private _rootUrl;
  88086. private _fileName;
  88087. private _uniqueRootUrl;
  88088. private _gltf;
  88089. private _bin;
  88090. private _babylonScene;
  88091. private _rootBabylonMesh;
  88092. private _defaultBabylonMaterialData;
  88093. private static _RegisteredExtensions;
  88094. /**
  88095. * The default glTF sampler.
  88096. */
  88097. static readonly DefaultSampler: ISampler;
  88098. /**
  88099. * Registers a loader extension.
  88100. * @param name The name of the loader extension.
  88101. * @param factory The factory function that creates the loader extension.
  88102. */
  88103. static RegisterExtension(name: string, factory: (loader: GLTFLoader) => IGLTFLoaderExtension): void;
  88104. /**
  88105. * Unregisters a loader extension.
  88106. * @param name The name of the loader extension.
  88107. * @returns A boolean indicating whether the extension has been unregistered
  88108. */
  88109. static UnregisterExtension(name: string): boolean;
  88110. /**
  88111. * The loader state.
  88112. */
  88113. get state(): Nullable<GLTFLoaderState>;
  88114. /**
  88115. * The object that represents the glTF JSON.
  88116. */
  88117. get gltf(): IGLTF;
  88118. /**
  88119. * The BIN chunk of a binary glTF.
  88120. */
  88121. get bin(): Nullable<IDataBuffer>;
  88122. /**
  88123. * The parent file loader.
  88124. */
  88125. get parent(): GLTFFileLoader;
  88126. /**
  88127. * The Babylon scene when loading the asset.
  88128. */
  88129. get babylonScene(): Scene;
  88130. /**
  88131. * The root Babylon mesh when loading the asset.
  88132. */
  88133. get rootBabylonMesh(): Mesh;
  88134. /** @hidden */
  88135. constructor(parent: GLTFFileLoader);
  88136. /** @hidden */
  88137. dispose(): void;
  88138. /** @hidden */
  88139. importMeshAsync(meshesNames: any, scene: Scene, forAssetContainer: boolean, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string): Promise<ISceneLoaderAsyncResult>;
  88140. /** @hidden */
  88141. loadAsync(scene: Scene, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  88142. private _loadAsync;
  88143. private _loadData;
  88144. private _setupData;
  88145. private _loadExtensions;
  88146. private _checkExtensions;
  88147. private _setState;
  88148. private _createRootNode;
  88149. /**
  88150. * Loads a glTF scene.
  88151. * @param context The context when loading the asset
  88152. * @param scene The glTF scene property
  88153. * @returns A promise that resolves when the load is complete
  88154. */
  88155. loadSceneAsync(context: string, scene: IScene): Promise<void>;
  88156. private _forEachPrimitive;
  88157. private _getGeometries;
  88158. private _getMeshes;
  88159. private _getTransformNodes;
  88160. private _getSkeletons;
  88161. private _getAnimationGroups;
  88162. private _startAnimations;
  88163. /**
  88164. * Loads a glTF node.
  88165. * @param context The context when loading the asset
  88166. * @param node The glTF node property
  88167. * @param assign A function called synchronously after parsing the glTF properties
  88168. * @returns A promise that resolves with the loaded Babylon mesh when the load is complete
  88169. */
  88170. loadNodeAsync(context: string, node: INode, assign?: (babylonTransformNode: TransformNode) => void): Promise<TransformNode>;
  88171. private _loadMeshAsync;
  88172. /**
  88173. * @hidden Define this method to modify the default behavior when loading data for mesh primitives.
  88174. * @param context The context when loading the asset
  88175. * @param name The mesh name when loading the asset
  88176. * @param node The glTF node when loading the asset
  88177. * @param mesh The glTF mesh when loading the asset
  88178. * @param primitive The glTF mesh primitive property
  88179. * @param assign A function called synchronously after parsing the glTF properties
  88180. * @returns A promise that resolves with the loaded mesh when the load is complete or null if not handled
  88181. */
  88182. _loadMeshPrimitiveAsync(context: string, name: string, node: INode, mesh: IMesh, primitive: IMeshPrimitive, assign: (babylonMesh: AbstractMesh) => void): Promise<AbstractMesh>;
  88183. private _loadVertexDataAsync;
  88184. private _createMorphTargets;
  88185. private _loadMorphTargetsAsync;
  88186. private _loadMorphTargetVertexDataAsync;
  88187. private static _LoadTransform;
  88188. private _loadSkinAsync;
  88189. private _loadBones;
  88190. private _loadBone;
  88191. private _loadSkinInverseBindMatricesDataAsync;
  88192. private _updateBoneMatrices;
  88193. private _getNodeMatrix;
  88194. /**
  88195. * Loads a glTF camera.
  88196. * @param context The context when loading the asset
  88197. * @param camera The glTF camera property
  88198. * @param assign A function called synchronously after parsing the glTF properties
  88199. * @returns A promise that resolves with the loaded Babylon camera when the load is complete
  88200. */
  88201. loadCameraAsync(context: string, camera: ICamera, assign?: (babylonCamera: Camera) => void): Promise<Camera>;
  88202. private _loadAnimationsAsync;
  88203. /**
  88204. * Loads a glTF animation.
  88205. * @param context The context when loading the asset
  88206. * @param animation The glTF animation property
  88207. * @returns A promise that resolves with the loaded Babylon animation group when the load is complete
  88208. */
  88209. loadAnimationAsync(context: string, animation: IAnimation): Promise<AnimationGroup>;
  88210. /**
  88211. * @hidden Loads a glTF animation channel.
  88212. * @param context The context when loading the asset
  88213. * @param animationContext The context of the animation when loading the asset
  88214. * @param animation The glTF animation property
  88215. * @param channel The glTF animation channel property
  88216. * @param babylonAnimationGroup The babylon animation group property
  88217. * @param animationTargetOverride The babylon animation channel target override property. My be null.
  88218. * @returns A void promise when the channel load is complete
  88219. */
  88220. _loadAnimationChannelAsync(context: string, animationContext: string, animation: IAnimation, channel: IAnimationChannel, babylonAnimationGroup: AnimationGroup, animationTargetOverride?: Nullable<IAnimatable>): Promise<void>;
  88221. private _loadAnimationSamplerAsync;
  88222. /**
  88223. * Loads a glTF buffer.
  88224. * @param context The context when loading the asset
  88225. * @param buffer The glTF buffer property
  88226. * @param byteOffset The byte offset to use
  88227. * @param byteLength The byte length to use
  88228. * @returns A promise that resolves with the loaded data when the load is complete
  88229. */
  88230. loadBufferAsync(context: string, buffer: IBuffer, byteOffset: number, byteLength: number): Promise<ArrayBufferView>;
  88231. /**
  88232. * Loads a glTF buffer view.
  88233. * @param context The context when loading the asset
  88234. * @param bufferView The glTF buffer view property
  88235. * @returns A promise that resolves with the loaded data when the load is complete
  88236. */
  88237. loadBufferViewAsync(context: string, bufferView: IBufferView): Promise<ArrayBufferView>;
  88238. private _loadAccessorAsync;
  88239. /** @hidden */
  88240. _loadFloatAccessorAsync(context: string, accessor: IAccessor): Promise<Float32Array>;
  88241. private _loadIndicesAccessorAsync;
  88242. private _loadVertexBufferViewAsync;
  88243. private _loadVertexAccessorAsync;
  88244. private _loadMaterialMetallicRoughnessPropertiesAsync;
  88245. /** @hidden */
  88246. _loadMaterialAsync(context: string, material: IMaterial, babylonMesh: Nullable<Mesh>, babylonDrawMode: number, assign?: (babylonMaterial: Material) => void): Promise<Material>;
  88247. private _createDefaultMaterial;
  88248. /**
  88249. * Creates a Babylon material from a glTF material.
  88250. * @param context The context when loading the asset
  88251. * @param material The glTF material property
  88252. * @param babylonDrawMode The draw mode for the Babylon material
  88253. * @returns The Babylon material
  88254. */
  88255. createMaterial(context: string, material: IMaterial, babylonDrawMode: number): Material;
  88256. /**
  88257. * Loads properties from a glTF material into a Babylon material.
  88258. * @param context The context when loading the asset
  88259. * @param material The glTF material property
  88260. * @param babylonMaterial The Babylon material
  88261. * @returns A promise that resolves when the load is complete
  88262. */
  88263. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Promise<void>;
  88264. /**
  88265. * Loads the normal, occlusion, and emissive properties from a glTF material into a Babylon material.
  88266. * @param context The context when loading the asset
  88267. * @param material The glTF material property
  88268. * @param babylonMaterial The Babylon material
  88269. * @returns A promise that resolves when the load is complete
  88270. */
  88271. loadMaterialBasePropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Promise<void>;
  88272. /**
  88273. * Loads the alpha properties from a glTF material into a Babylon material.
  88274. * Must be called after the setting the albedo texture of the Babylon material when the material has an albedo texture.
  88275. * @param context The context when loading the asset
  88276. * @param material The glTF material property
  88277. * @param babylonMaterial The Babylon material
  88278. */
  88279. loadMaterialAlphaProperties(context: string, material: IMaterial, babylonMaterial: Material): void;
  88280. /**
  88281. * Loads a glTF texture info.
  88282. * @param context The context when loading the asset
  88283. * @param textureInfo The glTF texture info property
  88284. * @param assign A function called synchronously after parsing the glTF properties
  88285. * @returns A promise that resolves with the loaded Babylon texture when the load is complete
  88286. */
  88287. loadTextureInfoAsync(context: string, textureInfo: ITextureInfo, assign?: (babylonTexture: BaseTexture) => void): Promise<BaseTexture>;
  88288. /** @hidden */
  88289. _loadTextureAsync(context: string, texture: ITexture, assign?: (babylonTexture: BaseTexture) => void): Promise<BaseTexture>;
  88290. /** @hidden */
  88291. _createTextureAsync(context: string, sampler: ISampler, image: IImage, assign?: (babylonTexture: BaseTexture) => void, textureLoaderOptions?: any): Promise<BaseTexture>;
  88292. private _loadSampler;
  88293. /**
  88294. * Loads a glTF image.
  88295. * @param context The context when loading the asset
  88296. * @param image The glTF image property
  88297. * @returns A promise that resolves with the loaded data when the load is complete
  88298. */
  88299. loadImageAsync(context: string, image: IImage): Promise<ArrayBufferView>;
  88300. /**
  88301. * Loads a glTF uri.
  88302. * @param context The context when loading the asset
  88303. * @param property The glTF property associated with the uri
  88304. * @param uri The base64 or relative uri
  88305. * @returns A promise that resolves with the loaded data when the load is complete
  88306. */
  88307. loadUriAsync(context: string, property: IProperty, uri: string): Promise<ArrayBufferView>;
  88308. /**
  88309. * Adds a JSON pointer to the metadata of the Babylon object at `<object>.metadata.gltf.pointers`.
  88310. * @param babylonObject the Babylon object with metadata
  88311. * @param pointer the JSON pointer
  88312. */
  88313. static AddPointerMetadata(babylonObject: {
  88314. metadata: any;
  88315. }, pointer: string): void;
  88316. private static _GetTextureWrapMode;
  88317. private static _GetTextureSamplingMode;
  88318. private static _GetTypedArrayConstructor;
  88319. private static _GetTypedArray;
  88320. private static _GetNumComponents;
  88321. private static _ValidateUri;
  88322. /** @hidden */
  88323. static _GetDrawMode(context: string, mode: number | undefined): number;
  88324. private _compileMaterialsAsync;
  88325. private _compileShadowGeneratorsAsync;
  88326. private _forEachExtensions;
  88327. private _applyExtensions;
  88328. private _extensionsOnLoading;
  88329. private _extensionsOnReady;
  88330. private _extensionsLoadSceneAsync;
  88331. private _extensionsLoadNodeAsync;
  88332. private _extensionsLoadCameraAsync;
  88333. private _extensionsLoadVertexDataAsync;
  88334. private _extensionsLoadMeshPrimitiveAsync;
  88335. private _extensionsLoadMaterialAsync;
  88336. private _extensionsCreateMaterial;
  88337. private _extensionsLoadMaterialPropertiesAsync;
  88338. private _extensionsLoadTextureInfoAsync;
  88339. private _extensionsLoadTextureAsync;
  88340. private _extensionsLoadAnimationAsync;
  88341. private _extensionsLoadSkinAsync;
  88342. private _extensionsLoadUriAsync;
  88343. private _extensionsLoadBufferViewAsync;
  88344. private _extensionsLoadBufferAsync;
  88345. /**
  88346. * Helper method called by a loader extension to load an glTF extension.
  88347. * @param context The context when loading the asset
  88348. * @param property The glTF property to load the extension from
  88349. * @param extensionName The name of the extension to load
  88350. * @param actionAsync The action to run
  88351. * @returns The promise returned by actionAsync or null if the extension does not exist
  88352. */
  88353. static LoadExtensionAsync<TExtension = any, TResult = void>(context: string, property: IProperty, extensionName: string, actionAsync: (extensionContext: string, extension: TExtension) => Nullable<Promise<TResult>>): Nullable<Promise<TResult>>;
  88354. /**
  88355. * Helper method called by a loader extension to load a glTF extra.
  88356. * @param context The context when loading the asset
  88357. * @param property The glTF property to load the extra from
  88358. * @param extensionName The name of the extension to load
  88359. * @param actionAsync The action to run
  88360. * @returns The promise returned by actionAsync or null if the extra does not exist
  88361. */
  88362. static LoadExtraAsync<TExtra = any, TResult = void>(context: string, property: IProperty, extensionName: string, actionAsync: (extraContext: string, extra: TExtra) => Nullable<Promise<TResult>>): Nullable<Promise<TResult>>;
  88363. /**
  88364. * Checks for presence of an extension.
  88365. * @param name The name of the extension to check
  88366. * @returns A boolean indicating the presence of the given extension name in `extensionsUsed`
  88367. */
  88368. isExtensionUsed(name: string): boolean;
  88369. /**
  88370. * Increments the indentation level and logs a message.
  88371. * @param message The message to log
  88372. */
  88373. logOpen(message: string): void;
  88374. /**
  88375. * Decrements the indentation level.
  88376. */
  88377. logClose(): void;
  88378. /**
  88379. * Logs a message
  88380. * @param message The message to log
  88381. */
  88382. log(message: string): void;
  88383. /**
  88384. * Starts a performance counter.
  88385. * @param counterName The name of the performance counter
  88386. */
  88387. startPerformanceCounter(counterName: string): void;
  88388. /**
  88389. * Ends a performance counter.
  88390. * @param counterName The name of the performance counter
  88391. */
  88392. endPerformanceCounter(counterName: string): void;
  88393. }
  88394. }
  88395. declare module BABYLON.GLTF2.Loader.Extensions {
  88396. /** @hidden */
  88397. interface IEXTLightsImageBased_LightImageBased {
  88398. _babylonTexture?: BaseTexture;
  88399. _loaded?: Promise<void>;
  88400. }
  88401. /**
  88402. * [Specification](https://github.com/KhronosGroup/glTF/blob/master/extensions/2.0/Vendor/EXT_lights_image_based/README.md)
  88403. */
  88404. export class EXT_lights_image_based implements IGLTFLoaderExtension {
  88405. /**
  88406. * The name of this extension.
  88407. */
  88408. readonly name: string;
  88409. /**
  88410. * Defines whether this extension is enabled.
  88411. */
  88412. enabled: boolean;
  88413. private _loader;
  88414. private _lights?;
  88415. /** @hidden */
  88416. constructor(loader: GLTFLoader);
  88417. /** @hidden */
  88418. dispose(): void;
  88419. /** @hidden */
  88420. onLoading(): void;
  88421. /** @hidden */
  88422. loadSceneAsync(context: string, scene: IScene): Nullable<Promise<void>>;
  88423. private _loadLightAsync;
  88424. }
  88425. }
  88426. declare module BABYLON.GLTF2.Loader.Extensions {
  88427. /**
  88428. * [Proposed Specification](https://github.com/KhronosGroup/glTF/pull/1691)
  88429. * [Playground Sample](https://playground.babylonjs.com/#QFIGLW#9)
  88430. * !!! Experimental Extension Subject to Changes !!!
  88431. */
  88432. export class EXT_mesh_gpu_instancing implements IGLTFLoaderExtension {
  88433. /**
  88434. * The name of this extension.
  88435. */
  88436. readonly name: string;
  88437. /**
  88438. * Defines whether this extension is enabled.
  88439. */
  88440. enabled: boolean;
  88441. private _loader;
  88442. /** @hidden */
  88443. constructor(loader: GLTFLoader);
  88444. /** @hidden */
  88445. dispose(): void;
  88446. /** @hidden */
  88447. loadNodeAsync(context: string, node: INode, assign: (babylonTransformNode: TransformNode) => void): Nullable<Promise<TransformNode>>;
  88448. }
  88449. }
  88450. declare module BABYLON.GLTF2.Loader.Extensions {
  88451. /**
  88452. * [Specification](https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Vendor/EXT_meshopt_compression)
  88453. *
  88454. * This extension uses a WebAssembly decoder module from https://github.com/zeux/meshoptimizer/tree/master/js
  88455. */
  88456. export class EXT_meshopt_compression implements IGLTFLoaderExtension {
  88457. /**
  88458. * The name of this extension.
  88459. */
  88460. readonly name: string;
  88461. /**
  88462. * Defines whether this extension is enabled.
  88463. */
  88464. enabled: boolean;
  88465. /**
  88466. * Path to decoder module; defaults to https://preview.babylonjs.com/meshopt_decoder.js
  88467. */
  88468. static DecoderPath: string;
  88469. private _loader;
  88470. private _decoderPromise?;
  88471. /** @hidden */
  88472. constructor(loader: GLTFLoader);
  88473. /** @hidden */
  88474. dispose(): void;
  88475. /** @hidden */
  88476. loadBufferViewAsync(context: string, bufferView: IBufferView): Nullable<Promise<ArrayBufferView>>;
  88477. }
  88478. }
  88479. declare module BABYLON.GLTF2.Loader.Extensions {
  88480. /**
  88481. * [Specification](https://github.com/KhronosGroup/glTF/blob/master/extensions/2.0/Vendor/EXT_texture_webp/)
  88482. */
  88483. export class EXT_texture_webp implements IGLTFLoaderExtension {
  88484. /** The name of this extension. */
  88485. readonly name: string;
  88486. /** Defines whether this extension is enabled. */
  88487. enabled: boolean;
  88488. private _loader;
  88489. /** @hidden */
  88490. constructor(loader: GLTFLoader);
  88491. /** @hidden */
  88492. dispose(): void;
  88493. /** @hidden */
  88494. _loadTextureAsync(context: string, texture: ITexture, assign: (babylonTexture: BaseTexture) => void): Nullable<Promise<BaseTexture>>;
  88495. }
  88496. }
  88497. declare module BABYLON.GLTF2.Loader.Extensions {
  88498. /**
  88499. * [Specification](https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Khronos/KHR_draco_mesh_compression)
  88500. */
  88501. export class KHR_draco_mesh_compression implements IGLTFLoaderExtension {
  88502. /**
  88503. * The name of this extension.
  88504. */
  88505. readonly name: string;
  88506. /**
  88507. * The draco compression used to decode vertex data or DracoCompression.Default if not defined
  88508. */
  88509. dracoCompression?: DracoCompression;
  88510. /**
  88511. * Defines whether this extension is enabled.
  88512. */
  88513. enabled: boolean;
  88514. private _loader;
  88515. /** @hidden */
  88516. constructor(loader: GLTFLoader);
  88517. /** @hidden */
  88518. dispose(): void;
  88519. /** @hidden */
  88520. _loadVertexDataAsync(context: string, primitive: IMeshPrimitive, babylonMesh: Mesh): Nullable<Promise<Geometry>>;
  88521. }
  88522. }
  88523. declare module BABYLON.GLTF2.Loader.Extensions {
  88524. /**
  88525. * [Specification](https://github.com/KhronosGroup/glTF/blob/master/extensions/2.0/Khronos/KHR_lights_punctual)
  88526. */
  88527. export class KHR_lights implements IGLTFLoaderExtension {
  88528. /**
  88529. * The name of this extension.
  88530. */
  88531. readonly name: string;
  88532. /**
  88533. * Defines whether this extension is enabled.
  88534. */
  88535. enabled: boolean;
  88536. private _loader;
  88537. private _lights?;
  88538. /** @hidden */
  88539. constructor(loader: GLTFLoader);
  88540. /** @hidden */
  88541. dispose(): void;
  88542. /** @hidden */
  88543. onLoading(): void;
  88544. /** @hidden */
  88545. loadNodeAsync(context: string, node: INode, assign: (babylonTransformNode: TransformNode) => void): Nullable<Promise<TransformNode>>;
  88546. }
  88547. }
  88548. declare module BABYLON.GLTF2.Loader.Extensions {
  88549. /**
  88550. * [Specification](https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Khronos/KHR_materials_pbrSpecularGlossiness)
  88551. */
  88552. export class KHR_materials_pbrSpecularGlossiness implements IGLTFLoaderExtension {
  88553. /**
  88554. * The name of this extension.
  88555. */
  88556. readonly name: string;
  88557. /**
  88558. * Defines whether this extension is enabled.
  88559. */
  88560. enabled: boolean;
  88561. /**
  88562. * Defines a number that determines the order the extensions are applied.
  88563. */
  88564. order: number;
  88565. private _loader;
  88566. /** @hidden */
  88567. constructor(loader: GLTFLoader);
  88568. /** @hidden */
  88569. dispose(): void;
  88570. /** @hidden */
  88571. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  88572. private _loadSpecularGlossinessPropertiesAsync;
  88573. }
  88574. }
  88575. declare module BABYLON.GLTF2.Loader.Extensions {
  88576. /**
  88577. * [Specification](https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Khronos/KHR_materials_unlit)
  88578. */
  88579. export class KHR_materials_unlit implements IGLTFLoaderExtension {
  88580. /**
  88581. * The name of this extension.
  88582. */
  88583. readonly name: string;
  88584. /**
  88585. * Defines whether this extension is enabled.
  88586. */
  88587. enabled: boolean;
  88588. /**
  88589. * Defines a number that determines the order the extensions are applied.
  88590. */
  88591. order: number;
  88592. private _loader;
  88593. /** @hidden */
  88594. constructor(loader: GLTFLoader);
  88595. /** @hidden */
  88596. dispose(): void;
  88597. /** @hidden */
  88598. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  88599. private _loadUnlitPropertiesAsync;
  88600. }
  88601. }
  88602. declare module BABYLON.GLTF2.Loader.Extensions {
  88603. /**
  88604. * [Specification](https://github.com/KhronosGroup/glTF/blob/master/extensions/2.0/Khronos/KHR_materials_clearcoat/README.md)
  88605. * [Playground Sample](https://www.babylonjs-playground.com/frame.html#7F7PN6#8)
  88606. */
  88607. export class KHR_materials_clearcoat implements IGLTFLoaderExtension {
  88608. /**
  88609. * The name of this extension.
  88610. */
  88611. readonly name: string;
  88612. /**
  88613. * Defines whether this extension is enabled.
  88614. */
  88615. enabled: boolean;
  88616. /**
  88617. * Defines a number that determines the order the extensions are applied.
  88618. */
  88619. order: number;
  88620. private _loader;
  88621. /** @hidden */
  88622. constructor(loader: GLTFLoader);
  88623. /** @hidden */
  88624. dispose(): void;
  88625. /** @hidden */
  88626. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  88627. private _loadClearCoatPropertiesAsync;
  88628. }
  88629. }
  88630. declare module BABYLON.GLTF2.Loader.Extensions {
  88631. /**
  88632. * [Specification](https://github.com/KhronosGroup/glTF/blob/master/extensions/2.0/Khronos/KHR_materials_sheen/README.md)
  88633. * [Playground Sample](https://www.babylonjs-playground.com/frame.html#BNIZX6#4)
  88634. * !!! Experimental Extension Subject to Changes !!!
  88635. */
  88636. export class KHR_materials_sheen implements IGLTFLoaderExtension {
  88637. /**
  88638. * The name of this extension.
  88639. */
  88640. readonly name: string;
  88641. /**
  88642. * Defines whether this extension is enabled.
  88643. */
  88644. enabled: boolean;
  88645. /**
  88646. * Defines a number that determines the order the extensions are applied.
  88647. */
  88648. order: number;
  88649. private _loader;
  88650. /** @hidden */
  88651. constructor(loader: GLTFLoader);
  88652. /** @hidden */
  88653. dispose(): void;
  88654. /** @hidden */
  88655. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  88656. private _loadSheenPropertiesAsync;
  88657. }
  88658. }
  88659. declare module BABYLON.GLTF2.Loader.Extensions {
  88660. /**
  88661. * [Proposed Specification](https://github.com/KhronosGroup/glTF/pull/1719)
  88662. * !!! Experimental Extension Subject to Changes !!!
  88663. */
  88664. export class KHR_materials_specular implements IGLTFLoaderExtension {
  88665. /**
  88666. * The name of this extension.
  88667. */
  88668. readonly name: string;
  88669. /**
  88670. * Defines whether this extension is enabled.
  88671. */
  88672. enabled: boolean;
  88673. /**
  88674. * Defines a number that determines the order the extensions are applied.
  88675. */
  88676. order: number;
  88677. private _loader;
  88678. /** @hidden */
  88679. constructor(loader: GLTFLoader);
  88680. /** @hidden */
  88681. dispose(): void;
  88682. /** @hidden */
  88683. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  88684. private _loadSpecularPropertiesAsync;
  88685. }
  88686. }
  88687. declare module BABYLON.GLTF2.Loader.Extensions {
  88688. /**
  88689. * [Proposed Specification](https://github.com/KhronosGroup/glTF/pull/1718)
  88690. * !!! Experimental Extension Subject to Changes !!!
  88691. */
  88692. export class KHR_materials_ior implements IGLTFLoaderExtension {
  88693. /**
  88694. * Default ior Value from the spec.
  88695. */
  88696. private static readonly _DEFAULT_IOR;
  88697. /**
  88698. * The name of this extension.
  88699. */
  88700. readonly name: string;
  88701. /**
  88702. * Defines whether this extension is enabled.
  88703. */
  88704. enabled: boolean;
  88705. /**
  88706. * Defines a number that determines the order the extensions are applied.
  88707. */
  88708. order: number;
  88709. private _loader;
  88710. /** @hidden */
  88711. constructor(loader: GLTFLoader);
  88712. /** @hidden */
  88713. dispose(): void;
  88714. /** @hidden */
  88715. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  88716. private _loadIorPropertiesAsync;
  88717. }
  88718. }
  88719. declare module BABYLON.GLTF2.Loader.Extensions {
  88720. /**
  88721. * [Specification](https://github.com/KhronosGroup/glTF/blob/master/extensions/2.0/Khronos/KHR_materials_variants/README.md)
  88722. */
  88723. export class KHR_materials_variants implements IGLTFLoaderExtension {
  88724. /**
  88725. * The name of this extension.
  88726. */
  88727. readonly name: string;
  88728. /**
  88729. * Defines whether this extension is enabled.
  88730. */
  88731. enabled: boolean;
  88732. private _loader;
  88733. private _variants?;
  88734. /** @hidden */
  88735. constructor(loader: GLTFLoader);
  88736. /** @hidden */
  88737. dispose(): void;
  88738. /**
  88739. * Gets the list of available variant names for this asset.
  88740. * @param rootMesh The glTF root mesh
  88741. * @returns the list of all the variant names for this model
  88742. */
  88743. static GetAvailableVariants(rootMesh: Mesh): string[];
  88744. /**
  88745. * Gets the list of available variant names for this asset.
  88746. * @param rootMesh The glTF root mesh
  88747. * @returns the list of all the variant names for this model
  88748. */
  88749. getAvailableVariants(rootMesh: Mesh): string[];
  88750. /**
  88751. * Select a variant given a variant name or a list of variant names.
  88752. * @param rootMesh The glTF root mesh
  88753. * @param variantName The variant name(s) to select.
  88754. */
  88755. static SelectVariant(rootMesh: Mesh, variantName: string | string[]): void;
  88756. /**
  88757. * Select a variant given a variant name or a list of variant names.
  88758. * @param rootMesh The glTF root mesh
  88759. * @param variantName The variant name(s) to select.
  88760. */
  88761. selectVariant(rootMesh: Mesh, variantName: string | string[]): void;
  88762. /**
  88763. * Reset back to the original before selecting a variant.
  88764. * @param rootMesh The glTF root mesh
  88765. */
  88766. static Reset(rootMesh: Mesh): void;
  88767. /**
  88768. * Reset back to the original before selecting a variant.
  88769. * @param rootMesh The glTF root mesh
  88770. */
  88771. reset(rootMesh: Mesh): void;
  88772. /**
  88773. * Gets the last selected variant name(s) or null if original.
  88774. * @param rootMesh The glTF root mesh
  88775. * @returns The selected variant name(s).
  88776. */
  88777. static GetLastSelectedVariant(rootMesh: Mesh): Nullable<string | string[]>;
  88778. /**
  88779. * Gets the last selected variant name(s) or null if original.
  88780. * @param rootMesh The glTF root mesh
  88781. * @returns The selected variant name(s).
  88782. */
  88783. getLastSelectedVariant(rootMesh: Mesh): Nullable<string | string[]>;
  88784. private static _GetExtensionMetadata;
  88785. /** @hidden */
  88786. onLoading(): void;
  88787. /** @hidden */
  88788. _loadMeshPrimitiveAsync(context: string, name: string, node: INode, mesh: IMesh, primitive: IMeshPrimitive, assign: (babylonMesh: AbstractMesh) => void): Nullable<Promise<AbstractMesh>>;
  88789. }
  88790. }
  88791. declare module BABYLON.GLTF2.Loader.Extensions {
  88792. /**
  88793. * [Specification](https://github.com/KhronosGroup/glTF/blob/master/extensions/2.0/Khronos/KHR_materials_transmission/README.md)
  88794. */
  88795. export class KHR_materials_transmission implements IGLTFLoaderExtension {
  88796. /**
  88797. * The name of this extension.
  88798. */
  88799. readonly name: string;
  88800. /**
  88801. * Defines whether this extension is enabled.
  88802. */
  88803. enabled: boolean;
  88804. /**
  88805. * Defines a number that determines the order the extensions are applied.
  88806. */
  88807. order: number;
  88808. private _loader;
  88809. /** @hidden */
  88810. constructor(loader: GLTFLoader);
  88811. /** @hidden */
  88812. dispose(): void;
  88813. /** @hidden */
  88814. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  88815. private _loadTransparentPropertiesAsync;
  88816. }
  88817. }
  88818. declare module BABYLON.GLTF2.Loader.Extensions {
  88819. /**
  88820. * [Proposed Specification](https://github.com/KhronosGroup/glTF/pull/1825)
  88821. * !!! Experimental Extension Subject to Changes !!!
  88822. */
  88823. export class KHR_materials_translucency implements IGLTFLoaderExtension {
  88824. /**
  88825. * The name of this extension.
  88826. */
  88827. readonly name: string;
  88828. /**
  88829. * Defines whether this extension is enabled.
  88830. */
  88831. enabled: boolean;
  88832. /**
  88833. * Defines a number that determines the order the extensions are applied.
  88834. */
  88835. order: number;
  88836. private _loader;
  88837. /** @hidden */
  88838. constructor(loader: GLTFLoader);
  88839. /** @hidden */
  88840. dispose(): void;
  88841. /** @hidden */
  88842. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  88843. private _loadTranslucentPropertiesAsync;
  88844. }
  88845. }
  88846. declare module BABYLON.GLTF2.Loader.Extensions {
  88847. /**
  88848. * [Specification](https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Khronos/KHR_mesh_quantization)
  88849. */
  88850. export class KHR_mesh_quantization implements IGLTFLoaderExtension {
  88851. /**
  88852. * The name of this extension.
  88853. */
  88854. readonly name: string;
  88855. /**
  88856. * Defines whether this extension is enabled.
  88857. */
  88858. enabled: boolean;
  88859. /** @hidden */
  88860. constructor(loader: GLTFLoader);
  88861. /** @hidden */
  88862. dispose(): void;
  88863. }
  88864. }
  88865. declare module BABYLON.GLTF2.Loader.Extensions {
  88866. /**
  88867. * [Proposed Specification](https://github.com/KhronosGroup/glTF/pull/1751)
  88868. * !!! Experimental Extension Subject to Changes !!!
  88869. */
  88870. export class KHR_texture_basisu implements IGLTFLoaderExtension {
  88871. /** The name of this extension. */
  88872. readonly name: string;
  88873. /** Defines whether this extension is enabled. */
  88874. enabled: boolean;
  88875. private _loader;
  88876. /** @hidden */
  88877. constructor(loader: GLTFLoader);
  88878. /** @hidden */
  88879. dispose(): void;
  88880. /** @hidden */
  88881. _loadTextureAsync(context: string, texture: ITexture, assign: (babylonTexture: BaseTexture) => void): Nullable<Promise<BaseTexture>>;
  88882. }
  88883. }
  88884. declare module BABYLON.GLTF2.Loader.Extensions {
  88885. /**
  88886. * [Specification](https://github.com/KhronosGroup/glTF/blob/master/extensions/2.0/Khronos/KHR_texture_transform)
  88887. */
  88888. export class KHR_texture_transform implements IGLTFLoaderExtension {
  88889. /**
  88890. * The name of this extension.
  88891. */
  88892. readonly name: string;
  88893. /**
  88894. * Defines whether this extension is enabled.
  88895. */
  88896. enabled: boolean;
  88897. private _loader;
  88898. /** @hidden */
  88899. constructor(loader: GLTFLoader);
  88900. /** @hidden */
  88901. dispose(): void;
  88902. /** @hidden */
  88903. loadTextureInfoAsync(context: string, textureInfo: ITextureInfo, assign: (babylonTexture: BaseTexture) => void): Nullable<Promise<BaseTexture>>;
  88904. }
  88905. }
  88906. declare module BABYLON.GLTF2.Loader.Extensions {
  88907. /**
  88908. * [Proposed Specification](https://github.com/KhronosGroup/glTF/pull/1893)
  88909. * !!! Experimental Extension Subject to Changes !!!
  88910. */
  88911. export class KHR_xmp_json_ld implements IGLTFLoaderExtension {
  88912. /**
  88913. * The name of this extension.
  88914. */
  88915. readonly name: string;
  88916. /**
  88917. * Defines whether this extension is enabled.
  88918. */
  88919. enabled: boolean;
  88920. /**
  88921. * Defines a number that determines the order the extensions are applied.
  88922. */
  88923. order: number;
  88924. private _loader;
  88925. /** @hidden */
  88926. constructor(loader: GLTFLoader);
  88927. /** @hidden */
  88928. dispose(): void;
  88929. /**
  88930. * Called after the loader state changes to LOADING.
  88931. */
  88932. onLoading(): void;
  88933. }
  88934. }
  88935. declare module BABYLON.GLTF2.Loader.Extensions {
  88936. /**
  88937. * [Specification](https://github.com/najadojo/glTF/tree/MSFT_audio_emitter/extensions/2.0/Vendor/MSFT_audio_emitter)
  88938. */
  88939. export class MSFT_audio_emitter implements IGLTFLoaderExtension {
  88940. /**
  88941. * The name of this extension.
  88942. */
  88943. readonly name: string;
  88944. /**
  88945. * Defines whether this extension is enabled.
  88946. */
  88947. enabled: boolean;
  88948. private _loader;
  88949. private _clips;
  88950. private _emitters;
  88951. /** @hidden */
  88952. constructor(loader: GLTFLoader);
  88953. /** @hidden */
  88954. dispose(): void;
  88955. /** @hidden */
  88956. onLoading(): void;
  88957. /** @hidden */
  88958. loadSceneAsync(context: string, scene: IScene): Nullable<Promise<void>>;
  88959. /** @hidden */
  88960. loadNodeAsync(context: string, node: INode, assign: (babylonTransformNode: TransformNode) => void): Nullable<Promise<TransformNode>>;
  88961. /** @hidden */
  88962. loadAnimationAsync(context: string, animation: IAnimation): Nullable<Promise<AnimationGroup>>;
  88963. private _loadClipAsync;
  88964. private _loadEmitterAsync;
  88965. private _getEventAction;
  88966. private _loadAnimationEventAsync;
  88967. }
  88968. }
  88969. declare module BABYLON.GLTF2.Loader.Extensions {
  88970. /**
  88971. * [Specification](https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Vendor/MSFT_lod)
  88972. */
  88973. export class MSFT_lod implements IGLTFLoaderExtension {
  88974. /**
  88975. * The name of this extension.
  88976. */
  88977. readonly name: string;
  88978. /**
  88979. * Defines whether this extension is enabled.
  88980. */
  88981. enabled: boolean;
  88982. /**
  88983. * Defines a number that determines the order the extensions are applied.
  88984. */
  88985. order: number;
  88986. /**
  88987. * Maximum number of LODs to load, starting from the lowest LOD.
  88988. */
  88989. maxLODsToLoad: number;
  88990. /**
  88991. * Observable raised when all node LODs of one level are loaded.
  88992. * The event data is the index of the loaded LOD starting from zero.
  88993. * Dispose the loader to cancel the loading of the next level of LODs.
  88994. */
  88995. onNodeLODsLoadedObservable: Observable<number>;
  88996. /**
  88997. * Observable raised when all material LODs of one level are loaded.
  88998. * The event data is the index of the loaded LOD starting from zero.
  88999. * Dispose the loader to cancel the loading of the next level of LODs.
  89000. */
  89001. onMaterialLODsLoadedObservable: Observable<number>;
  89002. private _loader;
  89003. private _bufferLODs;
  89004. private _nodeIndexLOD;
  89005. private _nodeSignalLODs;
  89006. private _nodePromiseLODs;
  89007. private _nodeBufferLODs;
  89008. private _materialIndexLOD;
  89009. private _materialSignalLODs;
  89010. private _materialPromiseLODs;
  89011. private _materialBufferLODs;
  89012. /** @hidden */
  89013. constructor(loader: GLTFLoader);
  89014. /** @hidden */
  89015. dispose(): void;
  89016. /** @hidden */
  89017. onReady(): void;
  89018. /** @hidden */
  89019. loadSceneAsync(context: string, scene: IScene): Nullable<Promise<void>>;
  89020. /** @hidden */
  89021. loadNodeAsync(context: string, node: INode, assign: (babylonTransformNode: TransformNode) => void): Nullable<Promise<TransformNode>>;
  89022. /** @hidden */
  89023. _loadMaterialAsync(context: string, material: IMaterial, babylonMesh: Nullable<Mesh>, babylonDrawMode: number, assign: (babylonMaterial: Material) => void): Nullable<Promise<Material>>;
  89024. /** @hidden */
  89025. _loadUriAsync(context: string, property: IProperty, uri: string): Nullable<Promise<ArrayBufferView>>;
  89026. /** @hidden */
  89027. loadBufferAsync(context: string, buffer: IBuffer, byteOffset: number, byteLength: number): Nullable<Promise<ArrayBufferView>>;
  89028. private _loadBufferLOD;
  89029. /**
  89030. * Gets an array of LOD properties from lowest to highest.
  89031. */
  89032. private _getLODs;
  89033. private _disposeTransformNode;
  89034. private _disposeMaterials;
  89035. }
  89036. }
  89037. declare module BABYLON.GLTF2.Loader.Extensions {
  89038. /** @hidden */
  89039. export class MSFT_minecraftMesh implements IGLTFLoaderExtension {
  89040. readonly name: string;
  89041. enabled: boolean;
  89042. private _loader;
  89043. constructor(loader: GLTFLoader);
  89044. dispose(): void;
  89045. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  89046. }
  89047. }
  89048. declare module BABYLON.GLTF2.Loader.Extensions {
  89049. /** @hidden */
  89050. export class MSFT_sRGBFactors implements IGLTFLoaderExtension {
  89051. readonly name: string;
  89052. enabled: boolean;
  89053. private _loader;
  89054. constructor(loader: GLTFLoader);
  89055. dispose(): void;
  89056. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  89057. }
  89058. }
  89059. declare module BABYLON.GLTF2.Loader.Extensions {
  89060. /**
  89061. * Store glTF extras (if present) in BJS objects' metadata
  89062. */
  89063. export class ExtrasAsMetadata implements IGLTFLoaderExtension {
  89064. /**
  89065. * The name of this extension.
  89066. */
  89067. readonly name: string;
  89068. /**
  89069. * Defines whether this extension is enabled.
  89070. */
  89071. enabled: boolean;
  89072. private _loader;
  89073. private _assignExtras;
  89074. /** @hidden */
  89075. constructor(loader: GLTFLoader);
  89076. /** @hidden */
  89077. dispose(): void;
  89078. /** @hidden */
  89079. loadNodeAsync(context: string, node: INode, assign: (babylonTransformNode: TransformNode) => void): Nullable<Promise<TransformNode>>;
  89080. /** @hidden */
  89081. loadCameraAsync(context: string, camera: ICamera, assign: (babylonCamera: Camera) => void): Nullable<Promise<Camera>>;
  89082. /** @hidden */
  89083. createMaterial(context: string, material: IMaterial, babylonDrawMode: number): Nullable<Material>;
  89084. }
  89085. }
  89086. declare module BABYLON {
  89087. /**
  89088. * Class reading and parsing the MTL file bundled with the obj file.
  89089. */
  89090. export class MTLFileLoader {
  89091. /**
  89092. * Invert Y-Axis of referenced textures on load
  89093. */
  89094. static INVERT_TEXTURE_Y: boolean;
  89095. /**
  89096. * All material loaded from the mtl will be set here
  89097. */
  89098. materials: StandardMaterial[];
  89099. /**
  89100. * This function will read the mtl file and create each material described inside
  89101. * This function could be improve by adding :
  89102. * -some component missing (Ni, Tf...)
  89103. * -including the specific options available
  89104. *
  89105. * @param scene defines the scene the material will be created in
  89106. * @param data defines the mtl data to parse
  89107. * @param rootUrl defines the rooturl to use in order to load relative dependencies
  89108. * @param forAssetContainer defines if the material should be registered in the scene
  89109. */
  89110. parseMTL(scene: Scene, data: string | ArrayBuffer, rootUrl: string, forAssetContainer: boolean): void;
  89111. /**
  89112. * Gets the texture for the material.
  89113. *
  89114. * If the material is imported from input file,
  89115. * We sanitize the url to ensure it takes the textre from aside the material.
  89116. *
  89117. * @param rootUrl The root url to load from
  89118. * @param value The value stored in the mtl
  89119. * @return The Texture
  89120. */
  89121. private static _getTexture;
  89122. }
  89123. }
  89124. declare module BABYLON {
  89125. /**
  89126. * Options for loading OBJ/MTL files
  89127. */
  89128. type MeshLoadOptions = {
  89129. /**
  89130. * Defines if UVs are optimized by default during load.
  89131. */
  89132. OptimizeWithUV: boolean;
  89133. /**
  89134. * Defines custom scaling of UV coordinates of loaded meshes.
  89135. */
  89136. UVScaling: Vector2;
  89137. /**
  89138. * Invert model on y-axis (does a model scaling inversion)
  89139. */
  89140. InvertY: boolean;
  89141. /**
  89142. * Invert Y-Axis of referenced textures on load
  89143. */
  89144. InvertTextureY: boolean;
  89145. /**
  89146. * Include in meshes the vertex colors available in some OBJ files. This is not part of OBJ standard.
  89147. */
  89148. ImportVertexColors: boolean;
  89149. /**
  89150. * Compute the normals for the model, even if normals are present in the file.
  89151. */
  89152. ComputeNormals: boolean;
  89153. /**
  89154. * Optimize the normals for the model. Lighting can be uneven if you use OptimizeWithUV = true because new vertices can be created for the same location if they pertain to different faces.
  89155. * Using OptimizehNormals = true will help smoothing the lighting by averaging the normals of those vertices.
  89156. */
  89157. OptimizeNormals: boolean;
  89158. /**
  89159. * Skip loading the materials even if defined in the OBJ file (materials are ignored).
  89160. */
  89161. SkipMaterials: boolean;
  89162. /**
  89163. * When a material fails to load OBJ loader will silently fail and onSuccess() callback will be triggered.
  89164. */
  89165. MaterialLoadingFailsSilently: boolean;
  89166. };
  89167. /**
  89168. * OBJ file type loader.
  89169. * This is a babylon scene loader plugin.
  89170. */
  89171. export class OBJFileLoader implements ISceneLoaderPluginAsync, ISceneLoaderPluginFactory {
  89172. /**
  89173. * Defines if UVs are optimized by default during load.
  89174. */
  89175. static OPTIMIZE_WITH_UV: boolean;
  89176. /**
  89177. * Invert model on y-axis (does a model scaling inversion)
  89178. */
  89179. static INVERT_Y: boolean;
  89180. /**
  89181. * Invert Y-Axis of referenced textures on load
  89182. */
  89183. static get INVERT_TEXTURE_Y(): boolean;
  89184. static set INVERT_TEXTURE_Y(value: boolean);
  89185. /**
  89186. * Include in meshes the vertex colors available in some OBJ files. This is not part of OBJ standard.
  89187. */
  89188. static IMPORT_VERTEX_COLORS: boolean;
  89189. /**
  89190. * Compute the normals for the model, even if normals are present in the file.
  89191. */
  89192. static COMPUTE_NORMALS: boolean;
  89193. /**
  89194. * Optimize the normals for the model. Lighting can be uneven if you use OptimizeWithUV = true because new vertices can be created for the same location if they pertain to different faces.
  89195. * Using OptimizehNormals = true will help smoothing the lighting by averaging the normals of those vertices.
  89196. */
  89197. static OPTIMIZE_NORMALS: boolean;
  89198. /**
  89199. * Defines custom scaling of UV coordinates of loaded meshes.
  89200. */
  89201. static UV_SCALING: Vector2;
  89202. /**
  89203. * Skip loading the materials even if defined in the OBJ file (materials are ignored).
  89204. */
  89205. static SKIP_MATERIALS: boolean;
  89206. /**
  89207. * When a material fails to load OBJ loader will silently fail and onSuccess() callback will be triggered.
  89208. *
  89209. * Defaults to true for backwards compatibility.
  89210. */
  89211. static MATERIAL_LOADING_FAILS_SILENTLY: boolean;
  89212. /**
  89213. * Defines the name of the plugin.
  89214. */
  89215. name: string;
  89216. /**
  89217. * Defines the extension the plugin is able to load.
  89218. */
  89219. extensions: string;
  89220. /** @hidden */
  89221. obj: RegExp;
  89222. /** @hidden */
  89223. group: RegExp;
  89224. /** @hidden */
  89225. mtllib: RegExp;
  89226. /** @hidden */
  89227. usemtl: RegExp;
  89228. /** @hidden */
  89229. smooth: RegExp;
  89230. /** @hidden */
  89231. vertexPattern: RegExp;
  89232. /** @hidden */
  89233. normalPattern: RegExp;
  89234. /** @hidden */
  89235. uvPattern: RegExp;
  89236. /** @hidden */
  89237. facePattern1: RegExp;
  89238. /** @hidden */
  89239. facePattern2: RegExp;
  89240. /** @hidden */
  89241. facePattern3: RegExp;
  89242. /** @hidden */
  89243. facePattern4: RegExp;
  89244. /** @hidden */
  89245. facePattern5: RegExp;
  89246. private _forAssetContainer;
  89247. private _meshLoadOptions;
  89248. /**
  89249. * Creates loader for .OBJ files
  89250. *
  89251. * @param meshLoadOptions options for loading and parsing OBJ/MTL files.
  89252. */
  89253. constructor(meshLoadOptions?: MeshLoadOptions);
  89254. private static get currentMeshLoadOptions();
  89255. /**
  89256. * Calls synchronously the MTL file attached to this obj.
  89257. * Load function or importMesh function don't enable to load 2 files in the same time asynchronously.
  89258. * Without this function materials are not displayed in the first frame (but displayed after).
  89259. * In consequence it is impossible to get material information in your HTML file
  89260. *
  89261. * @param url The URL of the MTL file
  89262. * @param rootUrl
  89263. * @param onSuccess Callback function to be called when the MTL file is loaded
  89264. * @private
  89265. */
  89266. private _loadMTL;
  89267. /**
  89268. * Instantiates a OBJ file loader plugin.
  89269. * @returns the created plugin
  89270. */
  89271. createPlugin(): ISceneLoaderPluginAsync | ISceneLoaderPlugin;
  89272. /**
  89273. * If the data string can be loaded directly.
  89274. *
  89275. * @param data string containing the file data
  89276. * @returns if the data can be loaded directly
  89277. */
  89278. canDirectLoad(data: string): boolean;
  89279. /**
  89280. * Imports one or more meshes from the loaded OBJ data and adds them to the scene
  89281. * @param meshesNames a string or array of strings of the mesh names that should be loaded from the file
  89282. * @param scene the scene the meshes should be added to
  89283. * @param data the OBJ data to load
  89284. * @param rootUrl root url to load from
  89285. * @param onProgress event that fires when loading progress has occured
  89286. * @param fileName Defines the name of the file to load
  89287. * @returns a promise containg the loaded meshes, particles, skeletons and animations
  89288. */
  89289. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string): Promise<ISceneLoaderAsyncResult>;
  89290. /**
  89291. * Imports all objects from the loaded OBJ data and adds them to the scene
  89292. * @param scene the scene the objects should be added to
  89293. * @param data the OBJ data to load
  89294. * @param rootUrl root url to load from
  89295. * @param onProgress event that fires when loading progress has occured
  89296. * @param fileName Defines the name of the file to load
  89297. * @returns a promise which completes when objects have been loaded to the scene
  89298. */
  89299. loadAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  89300. /**
  89301. * Load into an asset container.
  89302. * @param scene The scene to load into
  89303. * @param data The data to import
  89304. * @param rootUrl The root url for scene and resources
  89305. * @param onProgress The callback when the load progresses
  89306. * @param fileName Defines the name of the file to load
  89307. * @returns The loaded asset container
  89308. */
  89309. loadAssetContainerAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  89310. private _optimizeNormals;
  89311. /**
  89312. * Read the OBJ file and create an Array of meshes.
  89313. * Each mesh contains all information given by the OBJ and the MTL file.
  89314. * i.e. vertices positions and indices, optional normals values, optional UV values, optional material
  89315. *
  89316. * @param meshesNames
  89317. * @param scene Scene The scene where are displayed the data
  89318. * @param data String The content of the obj file
  89319. * @param rootUrl String The path to the folder
  89320. * @returns Array<AbstractMesh>
  89321. * @private
  89322. */
  89323. private _parseSolid;
  89324. }
  89325. }
  89326. declare module BABYLON {
  89327. /**
  89328. * STL file type loader.
  89329. * This is a babylon scene loader plugin.
  89330. */
  89331. export class STLFileLoader implements ISceneLoaderPlugin {
  89332. /** @hidden */
  89333. solidPattern: RegExp;
  89334. /** @hidden */
  89335. facetsPattern: RegExp;
  89336. /** @hidden */
  89337. normalPattern: RegExp;
  89338. /** @hidden */
  89339. vertexPattern: RegExp;
  89340. /**
  89341. * Defines the name of the plugin.
  89342. */
  89343. name: string;
  89344. /**
  89345. * Defines the extensions the stl loader is able to load.
  89346. * force data to come in as an ArrayBuffer
  89347. * we'll convert to string if it looks like it's an ASCII .stl
  89348. */
  89349. extensions: ISceneLoaderPluginExtensions;
  89350. /**
  89351. * Import meshes into a scene.
  89352. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  89353. * @param scene The scene to import into
  89354. * @param data The data to import
  89355. * @param rootUrl The root url for scene and resources
  89356. * @param meshes The meshes array to import into
  89357. * @param particleSystems The particle systems array to import into
  89358. * @param skeletons The skeletons array to import into
  89359. * @param onError The callback when import fails
  89360. * @returns True if successful or false otherwise
  89361. */
  89362. importMesh(meshesNames: any, scene: Scene, data: any, rootUrl: string, meshes: Nullable<AbstractMesh[]>, particleSystems: Nullable<IParticleSystem[]>, skeletons: Nullable<Skeleton[]>): boolean;
  89363. /**
  89364. * Load into a scene.
  89365. * @param scene The scene to load into
  89366. * @param data The data to import
  89367. * @param rootUrl The root url for scene and resources
  89368. * @param onError The callback when import fails
  89369. * @returns true if successful or false otherwise
  89370. */
  89371. load(scene: Scene, data: any, rootUrl: string): boolean;
  89372. /**
  89373. * Load into an asset container.
  89374. * @param scene The scene to load into
  89375. * @param data The data to import
  89376. * @param rootUrl The root url for scene and resources
  89377. * @param onError The callback when import fails
  89378. * @returns The loaded asset container
  89379. */
  89380. loadAssetContainer(scene: Scene, data: string, rootUrl: string, onError?: (message: string, exception?: any) => void): AssetContainer;
  89381. private _isBinary;
  89382. private _parseBinary;
  89383. private _parseASCII;
  89384. }
  89385. }
  89386. declare module BABYLON {
  89387. /**
  89388. * Class for generating OBJ data from a Babylon scene.
  89389. */
  89390. export class OBJExport {
  89391. /**
  89392. * Exports the geometry of a Mesh array in .OBJ file format (text)
  89393. * @param mesh defines the list of meshes to serialize
  89394. * @param materials defines if materials should be exported
  89395. * @param matlibname defines the name of the associated mtl file
  89396. * @param globalposition defines if the exported positions are globals or local to the exported mesh
  89397. * @returns the OBJ content
  89398. */
  89399. static OBJ(mesh: Mesh[], materials?: boolean, matlibname?: string, globalposition?: boolean): string;
  89400. /**
  89401. * Exports the material(s) of a mesh in .MTL file format (text)
  89402. * @param mesh defines the mesh to extract the material from
  89403. * @returns the mtl content
  89404. */
  89405. static MTL(mesh: Mesh): string;
  89406. }
  89407. }
  89408. declare module BABYLON {
  89409. /** @hidden */
  89410. export var __IGLTFExporterExtension: number;
  89411. /**
  89412. * Interface for extending the exporter
  89413. * @hidden
  89414. */
  89415. export interface IGLTFExporterExtension {
  89416. /**
  89417. * The name of this extension
  89418. */
  89419. readonly name: string;
  89420. /**
  89421. * Defines whether this extension is enabled
  89422. */
  89423. enabled: boolean;
  89424. /**
  89425. * Defines whether this extension is required
  89426. */
  89427. required: boolean;
  89428. }
  89429. }
  89430. declare module BABYLON.GLTF2.Exporter {
  89431. /** @hidden */
  89432. export var __IGLTFExporterExtensionV2: number;
  89433. /**
  89434. * Interface for a glTF exporter extension
  89435. * @hidden
  89436. */
  89437. export interface IGLTFExporterExtensionV2 extends IGLTFExporterExtension, IDisposable {
  89438. /**
  89439. * Define this method to modify the default behavior before exporting a texture
  89440. * @param context The context when loading the asset
  89441. * @param babylonTexture The Babylon.js texture
  89442. * @param mimeType The mime-type of the generated image
  89443. * @returns A promise that resolves with the exported texture
  89444. */
  89445. preExportTextureAsync?(context: string, babylonTexture: Nullable<Texture>, mimeType: ImageMimeType): Promise<Texture>;
  89446. /**
  89447. * Define this method to get notified when a texture info is created
  89448. * @param context The context when loading the asset
  89449. * @param textureInfo The glTF texture info
  89450. * @param babylonTexture The Babylon.js texture
  89451. */
  89452. postExportTexture?(context: string, textureInfo: ITextureInfo, babylonTexture: BaseTexture): void;
  89453. /**
  89454. * Define this method to modify the default behavior when exporting texture info
  89455. * @param context The context when loading the asset
  89456. * @param meshPrimitive glTF mesh primitive
  89457. * @param babylonSubMesh Babylon submesh
  89458. * @param binaryWriter glTF serializer binary writer instance
  89459. * @returns nullable IMeshPrimitive promise
  89460. */
  89461. postExportMeshPrimitiveAsync?(context: string, meshPrimitive: Nullable<IMeshPrimitive>, babylonSubMesh: SubMesh, binaryWriter: _BinaryWriter): Promise<IMeshPrimitive>;
  89462. /**
  89463. * Define this method to modify the default behavior when exporting a node
  89464. * @param context The context when exporting the node
  89465. * @param node glTF node
  89466. * @param babylonNode BabylonJS node
  89467. * @returns nullable INode promise
  89468. */
  89469. postExportNodeAsync?(context: string, node: Nullable<INode>, babylonNode: Node, nodeMap?: {
  89470. [key: number]: number;
  89471. }): Promise<Nullable<INode>>;
  89472. /**
  89473. * Define this method to modify the default behavior when exporting a material
  89474. * @param material glTF material
  89475. * @param babylonMaterial BabylonJS material
  89476. * @returns nullable IMaterial promise
  89477. */
  89478. postExportMaterialAsync?(context: string, node: Nullable<IMaterial>, babylonMaterial: Material): Promise<IMaterial>;
  89479. /**
  89480. * Define this method to return additional textures to export from a material
  89481. * @param material glTF material
  89482. * @param babylonMaterial BabylonJS material
  89483. * @returns List of textures
  89484. */
  89485. postExportMaterialAdditionalTextures?(context: string, node: IMaterial, babylonMaterial: Material): BaseTexture[];
  89486. /** Gets a boolean indicating that this extension was used */
  89487. wasUsed: boolean;
  89488. /** Gets a boolean indicating that this extension is required for the file to work */
  89489. required: boolean;
  89490. /**
  89491. * Called after the exporter state changes to EXPORTING
  89492. */
  89493. onExporting?(): void;
  89494. }
  89495. }
  89496. declare module BABYLON.GLTF2.Exporter {
  89497. /**
  89498. * Utility methods for working with glTF material conversion properties. This class should only be used internally
  89499. * @hidden
  89500. */
  89501. export class _GLTFMaterialExporter {
  89502. /**
  89503. * Represents the dielectric specular values for R, G and B
  89504. */
  89505. private static readonly _DielectricSpecular;
  89506. /**
  89507. * Allows the maximum specular power to be defined for material calculations
  89508. */
  89509. private static readonly _MaxSpecularPower;
  89510. /**
  89511. * Mapping to store textures
  89512. */
  89513. private _textureMap;
  89514. /**
  89515. * Numeric tolerance value
  89516. */
  89517. private static readonly _Epsilon;
  89518. /**
  89519. * Reference to the glTF Exporter
  89520. */
  89521. private _exporter;
  89522. constructor(exporter: _Exporter);
  89523. /**
  89524. * Specifies if two colors are approximately equal in value
  89525. * @param color1 first color to compare to
  89526. * @param color2 second color to compare to
  89527. * @param epsilon threshold value
  89528. */
  89529. private static FuzzyEquals;
  89530. /**
  89531. * Gets the materials from a Babylon scene and converts them to glTF materials
  89532. * @param scene babylonjs scene
  89533. * @param mimeType texture mime type
  89534. * @param images array of images
  89535. * @param textures array of textures
  89536. * @param materials array of materials
  89537. * @param imageData mapping of texture names to base64 textures
  89538. * @param hasTextureCoords specifies if texture coordinates are present on the material
  89539. */
  89540. _convertMaterialsToGLTFAsync(babylonMaterials: Material[], mimeType: ImageMimeType, hasTextureCoords: boolean): Promise<void>;
  89541. /**
  89542. * Makes a copy of the glTF material without the texture parameters
  89543. * @param originalMaterial original glTF material
  89544. * @returns glTF material without texture parameters
  89545. */
  89546. _stripTexturesFromMaterial(originalMaterial: IMaterial): IMaterial;
  89547. /**
  89548. * Specifies if the material has any texture parameters present
  89549. * @param material glTF Material
  89550. * @returns boolean specifying if texture parameters are present
  89551. */
  89552. _hasTexturesPresent(material: IMaterial): boolean;
  89553. /**
  89554. * Converts a Babylon StandardMaterial to a glTF Metallic Roughness Material
  89555. * @param babylonStandardMaterial
  89556. * @returns glTF Metallic Roughness Material representation
  89557. */
  89558. _convertToGLTFPBRMetallicRoughness(babylonStandardMaterial: StandardMaterial): IMaterialPbrMetallicRoughness;
  89559. /**
  89560. * Computes the metallic factor
  89561. * @param diffuse diffused value
  89562. * @param specular specular value
  89563. * @param oneMinusSpecularStrength one minus the specular strength
  89564. * @returns metallic value
  89565. */
  89566. static _SolveMetallic(diffuse: number, specular: number, oneMinusSpecularStrength: number): number;
  89567. /**
  89568. * Sets the glTF alpha mode to a glTF material from the Babylon Material
  89569. * @param glTFMaterial glTF material
  89570. * @param babylonMaterial Babylon material
  89571. */
  89572. private static _SetAlphaMode;
  89573. /**
  89574. * Converts a Babylon Standard Material to a glTF Material
  89575. * @param babylonStandardMaterial BJS Standard Material
  89576. * @param mimeType mime type to use for the textures
  89577. * @param images array of glTF image interfaces
  89578. * @param textures array of glTF texture interfaces
  89579. * @param materials array of glTF material interfaces
  89580. * @param imageData map of image file name to data
  89581. * @param hasTextureCoords specifies if texture coordinates are present on the submesh to determine if textures should be applied
  89582. */
  89583. _convertStandardMaterialAsync(babylonStandardMaterial: StandardMaterial, mimeType: ImageMimeType, hasTextureCoords: boolean): Promise<IMaterial>;
  89584. private _finishMaterial;
  89585. /**
  89586. * Converts a Babylon PBR Metallic Roughness Material to a glTF Material
  89587. * @param babylonPBRMetalRoughMaterial BJS PBR Metallic Roughness Material
  89588. * @param mimeType mime type to use for the textures
  89589. * @param images array of glTF image interfaces
  89590. * @param textures array of glTF texture interfaces
  89591. * @param materials array of glTF material interfaces
  89592. * @param imageData map of image file name to data
  89593. * @param hasTextureCoords specifies if texture coordinates are present on the submesh to determine if textures should be applied
  89594. */
  89595. _convertPBRMetallicRoughnessMaterialAsync(babylonPBRMetalRoughMaterial: PBRMetallicRoughnessMaterial, mimeType: ImageMimeType, hasTextureCoords: boolean): Promise<IMaterial>;
  89596. /**
  89597. * Converts an image typed array buffer to a base64 image
  89598. * @param buffer typed array buffer
  89599. * @param width width of the image
  89600. * @param height height of the image
  89601. * @param mimeType mimetype of the image
  89602. * @returns base64 image string
  89603. */
  89604. private _createBase64FromCanvasAsync;
  89605. /**
  89606. * Generates a white texture based on the specified width and height
  89607. * @param width width of the texture in pixels
  89608. * @param height height of the texture in pixels
  89609. * @param scene babylonjs scene
  89610. * @returns white texture
  89611. */
  89612. private _createWhiteTexture;
  89613. /**
  89614. * 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
  89615. * @param texture1 first texture to resize
  89616. * @param texture2 second texture to resize
  89617. * @param scene babylonjs scene
  89618. * @returns resized textures or null
  89619. */
  89620. private _resizeTexturesToSameDimensions;
  89621. /**
  89622. * Converts an array of pixels to a Float32Array
  89623. * Throws an error if the pixel format is not supported
  89624. * @param pixels - array buffer containing pixel values
  89625. * @returns Float32 of pixels
  89626. */
  89627. private _convertPixelArrayToFloat32;
  89628. /**
  89629. * Convert Specular Glossiness Textures to Metallic Roughness
  89630. * See link below for info on the material conversions from PBR Metallic/Roughness and Specular/Glossiness
  89631. * @link https://github.com/KhronosGroup/glTF/blob/master/extensions/2.0/Khronos/KHR_materials_pbrSpecularGlossiness/examples/convert-between-workflows-bjs/js/babylon.pbrUtilities.js
  89632. * @param diffuseTexture texture used to store diffuse information
  89633. * @param specularGlossinessTexture texture used to store specular and glossiness information
  89634. * @param factors specular glossiness material factors
  89635. * @param mimeType the mime type to use for the texture
  89636. * @returns pbr metallic roughness interface or null
  89637. */
  89638. private _convertSpecularGlossinessTexturesToMetallicRoughnessAsync;
  89639. /**
  89640. * Converts specular glossiness material properties to metallic roughness
  89641. * @param specularGlossiness interface with specular glossiness material properties
  89642. * @returns interface with metallic roughness material properties
  89643. */
  89644. private _convertSpecularGlossinessToMetallicRoughness;
  89645. /**
  89646. * Calculates the surface reflectance, independent of lighting conditions
  89647. * @param color Color source to calculate brightness from
  89648. * @returns number representing the perceived brightness, or zero if color is undefined
  89649. */
  89650. private _getPerceivedBrightness;
  89651. /**
  89652. * Returns the maximum color component value
  89653. * @param color
  89654. * @returns maximum color component value, or zero if color is null or undefined
  89655. */
  89656. private _getMaxComponent;
  89657. /**
  89658. * Convert a PBRMaterial (Metallic/Roughness) to Metallic Roughness factors
  89659. * @param babylonPBRMaterial BJS PBR Metallic Roughness Material
  89660. * @param mimeType mime type to use for the textures
  89661. * @param images array of glTF image interfaces
  89662. * @param textures array of glTF texture interfaces
  89663. * @param glTFPbrMetallicRoughness glTF PBR Metallic Roughness interface
  89664. * @param imageData map of image file name to data
  89665. * @param hasTextureCoords specifies if texture coordinates are present on the submesh to determine if textures should be applied
  89666. * @returns glTF PBR Metallic Roughness factors
  89667. */
  89668. private _convertMetalRoughFactorsToMetallicRoughnessAsync;
  89669. private _getGLTFTextureSampler;
  89670. private _getGLTFTextureWrapMode;
  89671. private _getGLTFTextureWrapModesSampler;
  89672. /**
  89673. * Convert a PBRMaterial (Specular/Glossiness) to Metallic Roughness factors
  89674. * @param babylonPBRMaterial BJS PBR Metallic Roughness Material
  89675. * @param mimeType mime type to use for the textures
  89676. * @param images array of glTF image interfaces
  89677. * @param textures array of glTF texture interfaces
  89678. * @param glTFPbrMetallicRoughness glTF PBR Metallic Roughness interface
  89679. * @param imageData map of image file name to data
  89680. * @param hasTextureCoords specifies if texture coordinates are present on the submesh to determine if textures should be applied
  89681. * @returns glTF PBR Metallic Roughness factors
  89682. */
  89683. private _convertSpecGlossFactorsToMetallicRoughnessAsync;
  89684. /**
  89685. * Converts a Babylon PBR Base Material to a glTF Material
  89686. * @param babylonPBRMaterial BJS PBR Base Material
  89687. * @param mimeType mime type to use for the textures
  89688. * @param images array of glTF image interfaces
  89689. * @param textures array of glTF texture interfaces
  89690. * @param materials array of glTF material interfaces
  89691. * @param imageData map of image file name to data
  89692. * @param hasTextureCoords specifies if texture coordinates are present on the submesh to determine if textures should be applied
  89693. */
  89694. _convertPBRMaterialAsync(babylonPBRMaterial: PBRBaseMaterial, mimeType: ImageMimeType, hasTextureCoords: boolean): Promise<IMaterial>;
  89695. private setMetallicRoughnessPbrMaterial;
  89696. private getPixelsFromTexture;
  89697. /**
  89698. * Extracts a texture from a Babylon texture into file data and glTF data
  89699. * @param babylonTexture Babylon texture to extract
  89700. * @param mimeType Mime Type of the babylonTexture
  89701. * @return glTF texture info, or null if the texture format is not supported
  89702. */
  89703. _exportTextureAsync(babylonTexture: BaseTexture, mimeType: ImageMimeType): Promise<Nullable<ITextureInfo>>;
  89704. _exportTextureInfoAsync(babylonTexture: BaseTexture, mimeType: ImageMimeType): Promise<Nullable<ITextureInfo>>;
  89705. /**
  89706. * Builds a texture from base64 string
  89707. * @param base64Texture base64 texture string
  89708. * @param baseTextureName Name to use for the texture
  89709. * @param mimeType image mime type for the texture
  89710. * @param images array of images
  89711. * @param textures array of textures
  89712. * @param imageData map of image data
  89713. * @returns glTF texture info, or null if the texture format is not supported
  89714. */
  89715. private _getTextureInfoFromBase64;
  89716. }
  89717. }
  89718. declare module BABYLON {
  89719. /**
  89720. * Class for holding and downloading glTF file data
  89721. */
  89722. export class GLTFData {
  89723. /**
  89724. * Object which contains the file name as the key and its data as the value
  89725. */
  89726. glTFFiles: {
  89727. [fileName: string]: string | Blob;
  89728. };
  89729. /**
  89730. * Initializes the glTF file object
  89731. */
  89732. constructor();
  89733. /**
  89734. * Downloads the glTF data as files based on their names and data
  89735. */
  89736. downloadFiles(): void;
  89737. }
  89738. }
  89739. declare module BABYLON {
  89740. /**
  89741. * Holds a collection of exporter options and parameters
  89742. */
  89743. export interface IExportOptions {
  89744. /**
  89745. * Function which indicates whether a babylon node should be exported or not
  89746. * @param node source Babylon node. It is used to check whether it should be exported to glTF or not
  89747. * @returns boolean, which indicates whether the node should be exported (true) or not (false)
  89748. */
  89749. shouldExportNode?(node: Node): boolean;
  89750. /**
  89751. * Function used to extract the part of node's metadata that will be exported into glTF node extras
  89752. * @param metadata source metadata to read from
  89753. * @returns the data to store to glTF node extras
  89754. */
  89755. metadataSelector?(metadata: any): any;
  89756. /**
  89757. * The sample rate to bake animation curves
  89758. */
  89759. animationSampleRate?: number;
  89760. /**
  89761. * Begin serialization without waiting for the scene to be ready
  89762. */
  89763. exportWithoutWaitingForScene?: boolean;
  89764. /**
  89765. * Indicates if coordinate system swapping root nodes should be included in export
  89766. */
  89767. includeCoordinateSystemConversionNodes?: boolean;
  89768. }
  89769. /**
  89770. * Class for generating glTF data from a Babylon scene.
  89771. */
  89772. export class GLTF2Export {
  89773. /**
  89774. * Exports the geometry of the scene to .gltf file format asynchronously
  89775. * @param scene Babylon scene with scene hierarchy information
  89776. * @param filePrefix File prefix to use when generating the glTF file
  89777. * @param options Exporter options
  89778. * @returns Returns an object with a .gltf file and associates texture names
  89779. * as keys and their data and paths as values
  89780. */
  89781. static GLTFAsync(scene: Scene, filePrefix: string, options?: IExportOptions): Promise<GLTFData>;
  89782. private static _PreExportAsync;
  89783. private static _PostExportAsync;
  89784. /**
  89785. * Exports the geometry of the scene to .glb file format asychronously
  89786. * @param scene Babylon scene with scene hierarchy information
  89787. * @param filePrefix File prefix to use when generating glb file
  89788. * @param options Exporter options
  89789. * @returns Returns an object with a .glb filename as key and data as value
  89790. */
  89791. static GLBAsync(scene: Scene, filePrefix: string, options?: IExportOptions): Promise<GLTFData>;
  89792. }
  89793. }
  89794. declare module BABYLON.GLTF2.Exporter {
  89795. /**
  89796. * @hidden
  89797. */
  89798. export class _GLTFUtilities {
  89799. /**
  89800. * Creates a buffer view based on the supplied arguments
  89801. * @param bufferIndex index value of the specified buffer
  89802. * @param byteOffset byte offset value
  89803. * @param byteLength byte length of the bufferView
  89804. * @param byteStride byte distance between conequential elements
  89805. * @param name name of the buffer view
  89806. * @returns bufferView for glTF
  89807. */
  89808. static _CreateBufferView(bufferIndex: number, byteOffset: number, byteLength: number, byteStride?: number, name?: string): IBufferView;
  89809. /**
  89810. * Creates an accessor based on the supplied arguments
  89811. * @param bufferviewIndex The index of the bufferview referenced by this accessor
  89812. * @param name The name of the accessor
  89813. * @param type The type of the accessor
  89814. * @param componentType The datatype of components in the attribute
  89815. * @param count The number of attributes referenced by this accessor
  89816. * @param byteOffset The offset relative to the start of the bufferView in bytes
  89817. * @param min Minimum value of each component in this attribute
  89818. * @param max Maximum value of each component in this attribute
  89819. * @returns accessor for glTF
  89820. */
  89821. static _CreateAccessor(bufferviewIndex: number, name: string, type: AccessorType, componentType: AccessorComponentType, count: number, byteOffset: Nullable<number>, min: Nullable<number[]>, max: Nullable<number[]>): IAccessor;
  89822. /**
  89823. * Calculates the minimum and maximum values of an array of position floats
  89824. * @param positions Positions array of a mesh
  89825. * @param vertexStart Starting vertex offset to calculate min and max values
  89826. * @param vertexCount Number of vertices to check for min and max values
  89827. * @returns min number array and max number array
  89828. */
  89829. static _CalculateMinMaxPositions(positions: FloatArray, vertexStart: number, vertexCount: number, convertToRightHandedSystem: boolean): {
  89830. min: number[];
  89831. max: number[];
  89832. };
  89833. /**
  89834. * Converts a new right-handed Vector3
  89835. * @param vector vector3 array
  89836. * @returns right-handed Vector3
  89837. */
  89838. static _GetRightHandedPositionVector3(vector: Vector3): Vector3;
  89839. /**
  89840. * Converts a Vector3 to right-handed
  89841. * @param vector Vector3 to convert to right-handed
  89842. */
  89843. static _GetRightHandedPositionVector3FromRef(vector: Vector3): void;
  89844. /**
  89845. * Converts a three element number array to right-handed
  89846. * @param vector number array to convert to right-handed
  89847. */
  89848. static _GetRightHandedPositionArray3FromRef(vector: number[]): void;
  89849. /**
  89850. * Converts a new right-handed Vector3
  89851. * @param vector vector3 array
  89852. * @returns right-handed Vector3
  89853. */
  89854. static _GetRightHandedNormalVector3(vector: Vector3): Vector3;
  89855. /**
  89856. * Converts a Vector3 to right-handed
  89857. * @param vector Vector3 to convert to right-handed
  89858. */
  89859. static _GetRightHandedNormalVector3FromRef(vector: Vector3): void;
  89860. /**
  89861. * Converts a three element number array to right-handed
  89862. * @param vector number array to convert to right-handed
  89863. */
  89864. static _GetRightHandedNormalArray3FromRef(vector: number[]): void;
  89865. /**
  89866. * Converts a Vector4 to right-handed
  89867. * @param vector Vector4 to convert to right-handed
  89868. */
  89869. static _GetRightHandedVector4FromRef(vector: Vector4): void;
  89870. /**
  89871. * Converts a Vector4 to right-handed
  89872. * @param vector Vector4 to convert to right-handed
  89873. */
  89874. static _GetRightHandedArray4FromRef(vector: number[]): void;
  89875. /**
  89876. * Converts a Quaternion to right-handed
  89877. * @param quaternion Source quaternion to convert to right-handed
  89878. */
  89879. static _GetRightHandedQuaternionFromRef(quaternion: Quaternion): void;
  89880. /**
  89881. * Converts a Quaternion to right-handed
  89882. * @param quaternion Source quaternion to convert to right-handed
  89883. */
  89884. static _GetRightHandedQuaternionArrayFromRef(quaternion: number[]): void;
  89885. static _NormalizeTangentFromRef(tangent: Vector4): void;
  89886. static _GetRightHandedMatrixFromRef(matrix: Matrix): void;
  89887. static _GetDataAccessorElementCount(accessorType: AccessorType): 1 | 3 | 2 | 4 | 9 | 16;
  89888. }
  89889. }
  89890. declare module BABYLON.GLTF2.Exporter {
  89891. /**
  89892. * Converts Babylon Scene into glTF 2.0.
  89893. * @hidden
  89894. */
  89895. export class _Exporter {
  89896. /**
  89897. * Stores the glTF to export
  89898. */
  89899. _glTF: IGLTF;
  89900. /**
  89901. * Stores all generated buffer views, which represents views into the main glTF buffer data
  89902. */
  89903. _bufferViews: IBufferView[];
  89904. /**
  89905. * Stores all the generated accessors, which is used for accessing the data within the buffer views in glTF
  89906. */
  89907. _accessors: IAccessor[];
  89908. /**
  89909. * Stores all the generated nodes, which contains transform and/or mesh information per node
  89910. */
  89911. _nodes: INode[];
  89912. /**
  89913. * Stores all the generated glTF scenes, which stores multiple node hierarchies
  89914. */
  89915. private _scenes;
  89916. /**
  89917. * Stores all the generated mesh information, each containing a set of primitives to render in glTF
  89918. */
  89919. private _meshes;
  89920. /**
  89921. * Stores all the generated material information, which represents the appearance of each primitive
  89922. */
  89923. _materials: IMaterial[];
  89924. _materialMap: {
  89925. [materialID: number]: number;
  89926. };
  89927. /**
  89928. * Stores all the generated texture information, which is referenced by glTF materials
  89929. */
  89930. _textures: ITexture[];
  89931. /**
  89932. * Stores all the generated image information, which is referenced by glTF textures
  89933. */
  89934. _images: IImage[];
  89935. /**
  89936. * Stores all the texture samplers
  89937. */
  89938. _samplers: ISampler[];
  89939. /**
  89940. * Stores all the generated glTF skins
  89941. */
  89942. _skins: ISkin[];
  89943. /**
  89944. * Stores all the generated animation samplers, which is referenced by glTF animations
  89945. */
  89946. /**
  89947. * Stores the animations for glTF models
  89948. */
  89949. private _animations;
  89950. /**
  89951. * Stores the total amount of bytes stored in the glTF buffer
  89952. */
  89953. private _totalByteLength;
  89954. /**
  89955. * Stores a reference to the Babylon scene containing the source geometry and material information
  89956. */
  89957. _babylonScene: Scene;
  89958. /**
  89959. * Stores a map of the image data, where the key is the file name and the value
  89960. * is the image data
  89961. */
  89962. _imageData: {
  89963. [fileName: string]: {
  89964. data: Uint8Array;
  89965. mimeType: ImageMimeType;
  89966. };
  89967. };
  89968. protected _orderedImageData: Array<{
  89969. data: Uint8Array;
  89970. mimeType: ImageMimeType;
  89971. }>;
  89972. /**
  89973. * Stores a map of the unique id of a node to its index in the node array
  89974. */
  89975. _nodeMap: {
  89976. [key: number]: number;
  89977. };
  89978. /**
  89979. * Specifies if the source Babylon scene was left handed, and needed conversion.
  89980. */
  89981. _convertToRightHandedSystem: boolean;
  89982. /**
  89983. * Specifies if a Babylon node should be converted to right-handed on export
  89984. */
  89985. _convertToRightHandedSystemMap: {
  89986. [nodeId: number]: boolean;
  89987. };
  89988. _includeCoordinateSystemConversionNodes: boolean;
  89989. /**
  89990. * Baked animation sample rate
  89991. */
  89992. private _animationSampleRate;
  89993. private _options;
  89994. private _localEngine;
  89995. _glTFMaterialExporter: _GLTFMaterialExporter;
  89996. private _extensions;
  89997. private static _ExtensionNames;
  89998. private static _ExtensionFactories;
  89999. private _applyExtension;
  90000. private _applyExtensions;
  90001. _extensionsPreExportTextureAsync(context: string, babylonTexture: Nullable<Texture>, mimeType: ImageMimeType): Promise<Nullable<BaseTexture>>;
  90002. _extensionsPostExportMeshPrimitiveAsync(context: string, meshPrimitive: IMeshPrimitive, babylonSubMesh: SubMesh, binaryWriter: _BinaryWriter): Promise<Nullable<IMeshPrimitive>>;
  90003. _extensionsPostExportNodeAsync(context: string, node: Nullable<INode>, babylonNode: Node, nodeMap?: {
  90004. [key: number]: number;
  90005. }): Promise<Nullable<INode>>;
  90006. _extensionsPostExportMaterialAsync(context: string, material: Nullable<IMaterial>, babylonMaterial: Material): Promise<Nullable<IMaterial>>;
  90007. _extensionsPostExportMaterialAdditionalTextures(context: string, material: IMaterial, babylonMaterial: Material): BaseTexture[];
  90008. _extensionsPostExportTextures(context: string, textureInfo: ITextureInfo, babylonTexture: BaseTexture): void;
  90009. private _forEachExtensions;
  90010. private _extensionsOnExporting;
  90011. /**
  90012. * Load glTF serializer extensions
  90013. */
  90014. private _loadExtensions;
  90015. /**
  90016. * Creates a glTF Exporter instance, which can accept optional exporter options
  90017. * @param babylonScene Babylon scene object
  90018. * @param options Options to modify the behavior of the exporter
  90019. */
  90020. constructor(babylonScene: Scene, options?: IExportOptions);
  90021. dispose(): void;
  90022. /**
  90023. * Registers a glTF exporter extension
  90024. * @param name Name of the extension to export
  90025. * @param factory The factory function that creates the exporter extension
  90026. */
  90027. static RegisterExtension(name: string, factory: (exporter: _Exporter) => IGLTFExporterExtensionV2): void;
  90028. /**
  90029. * Un-registers an exporter extension
  90030. * @param name The name fo the exporter extension
  90031. * @returns A boolean indicating whether the extension has been un-registered
  90032. */
  90033. static UnregisterExtension(name: string): boolean;
  90034. private reorderIndicesBasedOnPrimitiveMode;
  90035. /**
  90036. * Reorders the vertex attribute data based on the primitive mode. This is necessary when indices are not available and the winding order is
  90037. * clock-wise during export to glTF
  90038. * @param submesh BabylonJS submesh
  90039. * @param primitiveMode Primitive mode of the mesh
  90040. * @param sideOrientation the winding order of the submesh
  90041. * @param vertexBufferKind The type of vertex attribute
  90042. * @param meshAttributeArray The vertex attribute data
  90043. * @param byteOffset The offset to the binary data
  90044. * @param binaryWriter The binary data for the glTF file
  90045. * @param convertToRightHandedSystem Converts the values to right-handed
  90046. */
  90047. private reorderVertexAttributeDataBasedOnPrimitiveMode;
  90048. /**
  90049. * Reorders the vertex attributes in the correct triangle mode order . This is necessary when indices are not available and the winding order is
  90050. * clock-wise during export to glTF
  90051. * @param submesh BabylonJS submesh
  90052. * @param primitiveMode Primitive mode of the mesh
  90053. * @param sideOrientation the winding order of the submesh
  90054. * @param vertexBufferKind The type of vertex attribute
  90055. * @param meshAttributeArray The vertex attribute data
  90056. * @param byteOffset The offset to the binary data
  90057. * @param binaryWriter The binary data for the glTF file
  90058. * @param convertToRightHandedSystem Converts the values to right-handed
  90059. */
  90060. private reorderTriangleFillMode;
  90061. /**
  90062. * Reorders the vertex attributes in the correct triangle strip order. This is necessary when indices are not available and the winding order is
  90063. * clock-wise during export to glTF
  90064. * @param submesh BabylonJS submesh
  90065. * @param primitiveMode Primitive mode of the mesh
  90066. * @param sideOrientation the winding order of the submesh
  90067. * @param vertexBufferKind The type of vertex attribute
  90068. * @param meshAttributeArray The vertex attribute data
  90069. * @param byteOffset The offset to the binary data
  90070. * @param binaryWriter The binary data for the glTF file
  90071. * @param convertToRightHandedSystem Converts the values to right-handed
  90072. */
  90073. private reorderTriangleStripDrawMode;
  90074. /**
  90075. * Reorders the vertex attributes in the correct triangle fan order. This is necessary when indices are not available and the winding order is
  90076. * clock-wise during export to glTF
  90077. * @param submesh BabylonJS submesh
  90078. * @param primitiveMode Primitive mode of the mesh
  90079. * @param sideOrientation the winding order of the submesh
  90080. * @param vertexBufferKind The type of vertex attribute
  90081. * @param meshAttributeArray The vertex attribute data
  90082. * @param byteOffset The offset to the binary data
  90083. * @param binaryWriter The binary data for the glTF file
  90084. * @param convertToRightHandedSystem Converts the values to right-handed
  90085. */
  90086. private reorderTriangleFanMode;
  90087. /**
  90088. * Writes the vertex attribute data to binary
  90089. * @param vertices The vertices to write to the binary writer
  90090. * @param byteOffset The offset into the binary writer to overwrite binary data
  90091. * @param vertexAttributeKind The vertex attribute type
  90092. * @param meshAttributeArray The vertex attribute data
  90093. * @param binaryWriter The writer containing the binary data
  90094. * @param convertToRightHandedSystem Converts the values to right-handed
  90095. */
  90096. private writeVertexAttributeData;
  90097. /**
  90098. * Writes mesh attribute data to a data buffer
  90099. * Returns the bytelength of the data
  90100. * @param vertexBufferKind Indicates what kind of vertex data is being passed in
  90101. * @param meshAttributeArray Array containing the attribute data
  90102. * @param byteStride Specifies the space between data
  90103. * @param binaryWriter The buffer to write the binary data to
  90104. * @param convertToRightHandedSystem Converts the values to right-handed
  90105. */
  90106. writeAttributeData(vertexBufferKind: string, attributeComponentKind: AccessorComponentType, meshAttributeArray: FloatArray, stride: number, binaryWriter: _BinaryWriter, convertToRightHandedSystem: boolean, babylonTransformNode: TransformNode): void;
  90107. /**
  90108. * Writes mesh attribute data to a data buffer
  90109. * Returns the bytelength of the data
  90110. * @param vertexBufferKind Indicates what kind of vertex data is being passed in
  90111. * @param meshAttributeArray Array containing the attribute data
  90112. * @param byteStride Specifies the space between data
  90113. * @param binaryWriter The buffer to write the binary data to
  90114. * @param convertToRightHandedSystem Converts the values to right-handed
  90115. */
  90116. writeMorphTargetAttributeData(vertexBufferKind: string, attributeComponentKind: AccessorComponentType, meshPrimitive: SubMesh, morphTarget: MorphTarget, meshAttributeArray: FloatArray, morphTargetAttributeArray: FloatArray, stride: number, binaryWriter: _BinaryWriter, convertToRightHandedSystem: boolean, minMax?: any): void;
  90117. /**
  90118. * Generates glTF json data
  90119. * @param shouldUseGlb Indicates whether the json should be written for a glb file
  90120. * @param glTFPrefix Text to use when prefixing a glTF file
  90121. * @param prettyPrint Indicates whether the json file should be pretty printed (true) or not (false)
  90122. * @returns json data as string
  90123. */
  90124. private generateJSON;
  90125. /**
  90126. * Generates data for .gltf and .bin files based on the glTF prefix string
  90127. * @param glTFPrefix Text to use when prefixing a glTF file
  90128. * @param dispose Dispose the exporter
  90129. * @returns GLTFData with glTF file data
  90130. */
  90131. _generateGLTFAsync(glTFPrefix: string, dispose?: boolean): Promise<GLTFData>;
  90132. /**
  90133. * Creates a binary buffer for glTF
  90134. * @returns array buffer for binary data
  90135. */
  90136. private _generateBinaryAsync;
  90137. /**
  90138. * Pads the number to a multiple of 4
  90139. * @param num number to pad
  90140. * @returns padded number
  90141. */
  90142. private _getPadding;
  90143. /**
  90144. * @hidden
  90145. */
  90146. _generateGLBAsync(glTFPrefix: string, dispose?: boolean): Promise<GLTFData>;
  90147. /**
  90148. * Sets the TRS for each node
  90149. * @param node glTF Node for storing the transformation data
  90150. * @param babylonTransformNode Babylon mesh used as the source for the transformation data
  90151. * @param convertToRightHandedSystem Converts the values to right-handed
  90152. */
  90153. private setNodeTransformation;
  90154. private getVertexBufferFromMesh;
  90155. /**
  90156. * Creates a bufferview based on the vertices type for the Babylon mesh
  90157. * @param kind Indicates the type of vertices data
  90158. * @param componentType Indicates the numerical type used to store the data
  90159. * @param babylonTransformNode The Babylon mesh to get the vertices data from
  90160. * @param binaryWriter The buffer to write the bufferview data to
  90161. * @param convertToRightHandedSystem Converts the values to right-handed
  90162. */
  90163. private createBufferViewKind;
  90164. /**
  90165. * Creates a bufferview based on the vertices type for the Babylon mesh
  90166. * @param babylonSubMesh The Babylon submesh that the morph target is applied to
  90167. * @param babylonMorphTarget the morph target to be exported
  90168. * @param binaryWriter The buffer to write the bufferview data to
  90169. * @param convertToRightHandedSystem Converts the values to right-handed
  90170. */
  90171. private setMorphTargetAttributes;
  90172. /**
  90173. * The primitive mode of the Babylon mesh
  90174. * @param babylonMesh The BabylonJS mesh
  90175. */
  90176. private getMeshPrimitiveMode;
  90177. /**
  90178. * Sets the primitive mode of the glTF mesh primitive
  90179. * @param meshPrimitive glTF mesh primitive
  90180. * @param primitiveMode The primitive mode
  90181. */
  90182. private setPrimitiveMode;
  90183. /**
  90184. * Sets the vertex attribute accessor based of the glTF mesh primitive
  90185. * @param meshPrimitive glTF mesh primitive
  90186. * @param attributeKind vertex attribute
  90187. * @returns boolean specifying if uv coordinates are present
  90188. */
  90189. private setAttributeKind;
  90190. /**
  90191. * Sets data for the primitive attributes of each submesh
  90192. * @param mesh glTF Mesh object to store the primitive attribute information
  90193. * @param babylonTransformNode Babylon mesh to get the primitive attribute data from
  90194. * @param binaryWriter Buffer to write the attribute data to
  90195. * @param convertToRightHandedSystem Converts the values to right-handed
  90196. */
  90197. private setPrimitiveAttributesAsync;
  90198. /**
  90199. * Check if the node is used to convert its descendants from a right handed coordinate system to the Babylon scene's coordinate system.
  90200. * @param node The node to check
  90201. * @returns True if the node is used to convert its descendants from right-handed to left-handed. False otherwise
  90202. */
  90203. private isBabylonCoordinateSystemConvertingNode;
  90204. /**
  90205. * Creates a glTF scene based on the array of meshes
  90206. * Returns the the total byte offset
  90207. * @param babylonScene Babylon scene to get the mesh data from
  90208. * @param binaryWriter Buffer to write binary data to
  90209. */
  90210. private createSceneAsync;
  90211. /**
  90212. * Creates a mapping of Node unique id to node index and handles animations
  90213. * @param babylonScene Babylon Scene
  90214. * @param nodes Babylon transform nodes
  90215. * @param binaryWriter Buffer to write binary data to
  90216. * @returns Node mapping of unique id to index
  90217. */
  90218. private createNodeMapAndAnimationsAsync;
  90219. /**
  90220. * Creates a glTF node from a Babylon mesh
  90221. * @param babylonMesh Source Babylon mesh
  90222. * @param binaryWriter Buffer for storing geometry data
  90223. * @param convertToRightHandedSystem Converts the values to right-handed
  90224. * @param nodeMap Node mapping of unique id to glTF node index
  90225. * @returns glTF node
  90226. */
  90227. private createNodeAsync;
  90228. /**
  90229. * Creates a glTF skin from a Babylon skeleton
  90230. * @param babylonScene Babylon Scene
  90231. * @param nodes Babylon transform nodes
  90232. * @param binaryWriter Buffer to write binary data to
  90233. * @returns Node mapping of unique id to index
  90234. */
  90235. private createSkinsAsync;
  90236. }
  90237. /**
  90238. * @hidden
  90239. *
  90240. * Stores glTF binary data. If the array buffer byte length is exceeded, it doubles in size dynamically
  90241. */
  90242. export class _BinaryWriter {
  90243. /**
  90244. * Array buffer which stores all binary data
  90245. */
  90246. private _arrayBuffer;
  90247. /**
  90248. * View of the array buffer
  90249. */
  90250. private _dataView;
  90251. /**
  90252. * byte offset of data in array buffer
  90253. */
  90254. private _byteOffset;
  90255. /**
  90256. * Initialize binary writer with an initial byte length
  90257. * @param byteLength Initial byte length of the array buffer
  90258. */
  90259. constructor(byteLength: number);
  90260. /**
  90261. * Resize the array buffer to the specified byte length
  90262. * @param byteLength
  90263. */
  90264. private resizeBuffer;
  90265. /**
  90266. * Get an array buffer with the length of the byte offset
  90267. * @returns ArrayBuffer resized to the byte offset
  90268. */
  90269. getArrayBuffer(): ArrayBuffer;
  90270. /**
  90271. * Get the byte offset of the array buffer
  90272. * @returns byte offset
  90273. */
  90274. getByteOffset(): number;
  90275. /**
  90276. * Stores an UInt8 in the array buffer
  90277. * @param entry
  90278. * @param byteOffset If defined, specifies where to set the value as an offset.
  90279. */
  90280. setUInt8(entry: number, byteOffset?: number): void;
  90281. /**
  90282. * Stores an UInt16 in the array buffer
  90283. * @param entry
  90284. * @param byteOffset If defined, specifies where to set the value as an offset.
  90285. */
  90286. setUInt16(entry: number, byteOffset?: number): void;
  90287. /**
  90288. * Gets an UInt32 in the array buffer
  90289. * @param entry
  90290. * @param byteOffset If defined, specifies where to set the value as an offset.
  90291. */
  90292. getUInt32(byteOffset: number): number;
  90293. getVector3Float32FromRef(vector3: Vector3, byteOffset: number): void;
  90294. setVector3Float32FromRef(vector3: Vector3, byteOffset: number): void;
  90295. getVector4Float32FromRef(vector4: Vector4, byteOffset: number): void;
  90296. setVector4Float32FromRef(vector4: Vector4, byteOffset: number): void;
  90297. /**
  90298. * Stores a Float32 in the array buffer
  90299. * @param entry
  90300. */
  90301. setFloat32(entry: number, byteOffset?: number): void;
  90302. /**
  90303. * Stores an UInt32 in the array buffer
  90304. * @param entry
  90305. * @param byteOffset If defined, specifies where to set the value as an offset.
  90306. */
  90307. setUInt32(entry: number, byteOffset?: number): void;
  90308. }
  90309. }
  90310. declare module BABYLON.GLTF2.Exporter {
  90311. /**
  90312. * @hidden
  90313. * Interface to store animation data.
  90314. */
  90315. export interface _IAnimationData {
  90316. /**
  90317. * Keyframe data.
  90318. */
  90319. inputs: number[];
  90320. /**
  90321. * Value data.
  90322. */
  90323. outputs: number[][];
  90324. /**
  90325. * Animation interpolation data.
  90326. */
  90327. samplerInterpolation: AnimationSamplerInterpolation;
  90328. /**
  90329. * Minimum keyframe value.
  90330. */
  90331. inputsMin: number;
  90332. /**
  90333. * Maximum keyframe value.
  90334. */
  90335. inputsMax: number;
  90336. }
  90337. /**
  90338. * @hidden
  90339. */
  90340. export interface _IAnimationInfo {
  90341. /**
  90342. * The target channel for the animation
  90343. */
  90344. animationChannelTargetPath: AnimationChannelTargetPath;
  90345. /**
  90346. * The glTF accessor type for the data.
  90347. */
  90348. dataAccessorType: AccessorType.VEC3 | AccessorType.VEC4 | AccessorType.SCALAR;
  90349. /**
  90350. * Specifies if quaternions should be used.
  90351. */
  90352. useQuaternion: boolean;
  90353. }
  90354. /**
  90355. * @hidden
  90356. * Utility class for generating glTF animation data from BabylonJS.
  90357. */
  90358. export class _GLTFAnimation {
  90359. /**
  90360. * @ignore
  90361. *
  90362. * Creates glTF channel animation from BabylonJS animation.
  90363. * @param babylonTransformNode - BabylonJS mesh.
  90364. * @param animation - animation.
  90365. * @param animationChannelTargetPath - The target animation channel.
  90366. * @param convertToRightHandedSystem - Specifies if the values should be converted to right-handed.
  90367. * @param useQuaternion - Specifies if quaternions are used.
  90368. * @returns nullable IAnimationData
  90369. */
  90370. static _CreateNodeAnimation(babylonTransformNode: TransformNode, animation: Animation, animationChannelTargetPath: AnimationChannelTargetPath, convertToRightHandedSystem: boolean, useQuaternion: boolean, animationSampleRate: number): Nullable<_IAnimationData>;
  90371. private static _DeduceAnimationInfo;
  90372. /**
  90373. * @ignore
  90374. * Create node animations from the transform node animations
  90375. * @param babylonNode
  90376. * @param runtimeGLTFAnimation
  90377. * @param idleGLTFAnimations
  90378. * @param nodeMap
  90379. * @param nodes
  90380. * @param binaryWriter
  90381. * @param bufferViews
  90382. * @param accessors
  90383. * @param convertToRightHandedSystem
  90384. * @param animationSampleRate
  90385. */
  90386. static _CreateNodeAnimationFromNodeAnimations(babylonNode: Node, runtimeGLTFAnimation: IAnimation, idleGLTFAnimations: IAnimation[], nodeMap: {
  90387. [key: number]: number;
  90388. }, nodes: INode[], binaryWriter: _BinaryWriter, bufferViews: IBufferView[], accessors: IAccessor[], convertToRightHandedSystem: boolean, animationSampleRate: number): void;
  90389. /**
  90390. * @ignore
  90391. * Create individual morph animations from the mesh's morph target animation tracks
  90392. * @param babylonNode
  90393. * @param runtimeGLTFAnimation
  90394. * @param idleGLTFAnimations
  90395. * @param nodeMap
  90396. * @param nodes
  90397. * @param binaryWriter
  90398. * @param bufferViews
  90399. * @param accessors
  90400. * @param convertToRightHandedSystem
  90401. * @param animationSampleRate
  90402. */
  90403. static _CreateMorphTargetAnimationFromMorphTargetAnimations(babylonNode: Node, runtimeGLTFAnimation: IAnimation, idleGLTFAnimations: IAnimation[], nodeMap: {
  90404. [key: number]: number;
  90405. }, nodes: INode[], binaryWriter: _BinaryWriter, bufferViews: IBufferView[], accessors: IAccessor[], convertToRightHandedSystem: boolean, animationSampleRate: number): void;
  90406. /**
  90407. * @ignore
  90408. * Create node and morph animations from the animation groups
  90409. * @param babylonScene
  90410. * @param glTFAnimations
  90411. * @param nodeMap
  90412. * @param nodes
  90413. * @param binaryWriter
  90414. * @param bufferViews
  90415. * @param accessors
  90416. * @param convertToRightHandedSystemMap
  90417. * @param animationSampleRate
  90418. */
  90419. static _CreateNodeAndMorphAnimationFromAnimationGroups(babylonScene: Scene, glTFAnimations: IAnimation[], nodeMap: {
  90420. [key: number]: number;
  90421. }, nodes: INode[], binaryWriter: _BinaryWriter, bufferViews: IBufferView[], accessors: IAccessor[], convertToRightHandedSystemMap: {
  90422. [nodeId: number]: boolean;
  90423. }, animationSampleRate: number): void;
  90424. private static AddAnimation;
  90425. /**
  90426. * Create a baked animation
  90427. * @param babylonTransformNode BabylonJS mesh
  90428. * @param animation BabylonJS animation corresponding to the BabylonJS mesh
  90429. * @param animationChannelTargetPath animation target channel
  90430. * @param minFrame minimum animation frame
  90431. * @param maxFrame maximum animation frame
  90432. * @param fps frames per second of the animation
  90433. * @param inputs input key frames of the animation
  90434. * @param outputs output key frame data of the animation
  90435. * @param convertToRightHandedSystem converts the values to right-handed
  90436. * @param useQuaternion specifies if quaternions should be used
  90437. */
  90438. private static _CreateBakedAnimation;
  90439. private static _ConvertFactorToVector3OrQuaternion;
  90440. private static _SetInterpolatedValue;
  90441. /**
  90442. * Creates linear animation from the animation key frames
  90443. * @param babylonTransformNode BabylonJS mesh
  90444. * @param animation BabylonJS animation
  90445. * @param animationChannelTargetPath The target animation channel
  90446. * @param frameDelta The difference between the last and first frame of the animation
  90447. * @param inputs Array to store the key frame times
  90448. * @param outputs Array to store the key frame data
  90449. * @param convertToRightHandedSystem Specifies if the position data should be converted to right handed
  90450. * @param useQuaternion Specifies if quaternions are used in the animation
  90451. */
  90452. private static _CreateLinearOrStepAnimation;
  90453. /**
  90454. * Creates cubic spline animation from the animation key frames
  90455. * @param babylonTransformNode BabylonJS mesh
  90456. * @param animation BabylonJS animation
  90457. * @param animationChannelTargetPath The target animation channel
  90458. * @param frameDelta The difference between the last and first frame of the animation
  90459. * @param inputs Array to store the key frame times
  90460. * @param outputs Array to store the key frame data
  90461. * @param convertToRightHandedSystem Specifies if the position data should be converted to right handed
  90462. * @param useQuaternion Specifies if quaternions are used in the animation
  90463. */
  90464. private static _CreateCubicSplineAnimation;
  90465. private static _GetBasePositionRotationOrScale;
  90466. /**
  90467. * Adds a key frame value
  90468. * @param keyFrame
  90469. * @param animation
  90470. * @param outputs
  90471. * @param animationChannelTargetPath
  90472. * @param basePositionRotationOrScale
  90473. * @param convertToRightHandedSystem
  90474. * @param useQuaternion
  90475. */
  90476. private static _AddKeyframeValue;
  90477. /**
  90478. * Determine the interpolation based on the key frames
  90479. * @param keyFrames
  90480. * @param animationChannelTargetPath
  90481. * @param useQuaternion
  90482. */
  90483. private static _DeduceInterpolation;
  90484. /**
  90485. * Adds an input tangent or output tangent to the output data
  90486. * If an input tangent or output tangent is missing, it uses the zero vector or zero quaternion
  90487. * @param tangentType Specifies which type of tangent to handle (inTangent or outTangent)
  90488. * @param outputs The animation data by keyframe
  90489. * @param animationChannelTargetPath The target animation channel
  90490. * @param interpolation The interpolation type
  90491. * @param keyFrame The key frame with the animation data
  90492. * @param frameDelta Time difference between two frames used to scale the tangent by the frame delta
  90493. * @param useQuaternion Specifies if quaternions are used
  90494. * @param convertToRightHandedSystem Specifies if the values should be converted to right-handed
  90495. */
  90496. private static AddSplineTangent;
  90497. /**
  90498. * Get the minimum and maximum key frames' frame values
  90499. * @param keyFrames animation key frames
  90500. * @returns the minimum and maximum key frame value
  90501. */
  90502. private static calculateMinMaxKeyFrames;
  90503. }
  90504. }
  90505. declare module BABYLON.GLTF2.Exporter {
  90506. /** @hidden */
  90507. export var textureTransformPixelShader: {
  90508. name: string;
  90509. shader: string;
  90510. };
  90511. }
  90512. declare module BABYLON.GLTF2.Exporter.Extensions {
  90513. /**
  90514. * @hidden
  90515. */
  90516. export class KHR_texture_transform implements IGLTFExporterExtensionV2 {
  90517. private _recordedTextures;
  90518. /** Name of this extension */
  90519. readonly name: string;
  90520. /** Defines whether this extension is enabled */
  90521. enabled: boolean;
  90522. /** Defines whether this extension is required */
  90523. required: boolean;
  90524. /** Reference to the glTF exporter */
  90525. private _wasUsed;
  90526. constructor(exporter: _Exporter);
  90527. dispose(): void;
  90528. /** @hidden */
  90529. get wasUsed(): boolean;
  90530. postExportTexture?(context: string, textureInfo: ITextureInfo, babylonTexture: Texture): void;
  90531. preExportTextureAsync(context: string, babylonTexture: Texture, mimeType: ImageMimeType): Promise<Texture>;
  90532. /**
  90533. * Transform the babylon texture by the offset, rotation and scale parameters using a procedural texture
  90534. * @param babylonTexture
  90535. * @param offset
  90536. * @param rotation
  90537. * @param scale
  90538. * @param scene
  90539. */
  90540. private _textureTransformTextureAsync;
  90541. }
  90542. }
  90543. declare module BABYLON.GLTF2.Exporter.Extensions {
  90544. /**
  90545. * [Specification](https://github.com/KhronosGroup/glTF/blob/master/extensions/2.0/Khronos/KHR_lights_punctual/README.md)
  90546. */
  90547. export class KHR_lights_punctual implements IGLTFExporterExtensionV2 {
  90548. /** The name of this extension. */
  90549. readonly name: string;
  90550. /** Defines whether this extension is enabled. */
  90551. enabled: boolean;
  90552. /** Defines whether this extension is required */
  90553. required: boolean;
  90554. /** Reference to the glTF exporter */
  90555. private _exporter;
  90556. private _lights;
  90557. /** @hidden */
  90558. constructor(exporter: _Exporter);
  90559. /** @hidden */
  90560. dispose(): void;
  90561. /** @hidden */
  90562. get wasUsed(): boolean;
  90563. /** @hidden */
  90564. onExporting(): void;
  90565. /**
  90566. * Define this method to modify the default behavior when exporting a node
  90567. * @param context The context when exporting the node
  90568. * @param node glTF node
  90569. * @param babylonNode BabylonJS node
  90570. * @param nodeMap Node mapping of unique id to glTF node index
  90571. * @returns nullable INode promise
  90572. */
  90573. postExportNodeAsync(context: string, node: Nullable<INode>, babylonNode: Node, nodeMap?: {
  90574. [key: number]: number;
  90575. }): Promise<Nullable<INode>>;
  90576. }
  90577. }
  90578. declare module BABYLON.GLTF2.Exporter.Extensions {
  90579. /**
  90580. * @hidden
  90581. */
  90582. export class KHR_materials_sheen implements IGLTFExporterExtensionV2 {
  90583. /** Name of this extension */
  90584. readonly name: string;
  90585. /** Defines whether this extension is enabled */
  90586. enabled: boolean;
  90587. /** Defines whether this extension is required */
  90588. required: boolean;
  90589. /** Reference to the glTF exporter */
  90590. private _textureInfos;
  90591. private _exportedTextures;
  90592. private _wasUsed;
  90593. constructor(exporter: _Exporter);
  90594. dispose(): void;
  90595. /** @hidden */
  90596. get wasUsed(): boolean;
  90597. private _getTextureIndex;
  90598. postExportTexture?(context: string, textureInfo: ITextureInfo, babylonTexture: Texture): void;
  90599. postExportMaterialAdditionalTextures?(context: string, node: IMaterial, babylonMaterial: Material): BaseTexture[];
  90600. postExportMaterialAsync?(context: string, node: IMaterial, babylonMaterial: Material): Promise<IMaterial>;
  90601. }
  90602. }
  90603. declare module BABYLON.GLTF2.Exporter.Extensions {
  90604. /**
  90605. * @hidden
  90606. */
  90607. export class KHR_materials_unlit implements IGLTFExporterExtensionV2 {
  90608. /** Name of this extension */
  90609. readonly name: string;
  90610. /** Defines whether this extension is enabled */
  90611. enabled: boolean;
  90612. /** Defines whether this extension is required */
  90613. required: boolean;
  90614. private _wasUsed;
  90615. constructor(exporter: _Exporter);
  90616. /** @hidden */
  90617. get wasUsed(): boolean;
  90618. dispose(): void;
  90619. postExportMaterialAsync?(context: string, node: IMaterial, babylonMaterial: Material): Promise<IMaterial>;
  90620. }
  90621. }
  90622. declare module BABYLON {
  90623. /**
  90624. * Class for generating STL data from a Babylon scene.
  90625. */
  90626. export class STLExport {
  90627. /**
  90628. * Exports the geometry of a Mesh array in .STL file format (ASCII)
  90629. * @param meshes list defines the mesh to serialize
  90630. * @param download triggers the automatic download of the file.
  90631. * @param fileName changes the downloads fileName.
  90632. * @param binary changes the STL to a binary type.
  90633. * @param isLittleEndian toggle for binary type exporter.
  90634. * @param doNotBakeTransform toggle if meshes transforms should be baked or not.
  90635. * @returns the STL as UTF8 string
  90636. */
  90637. static CreateSTL(meshes: Mesh[], download?: boolean, fileName?: string, binary?: boolean, isLittleEndian?: boolean, doNotBakeTransform?: boolean): any;
  90638. }
  90639. }
  90640. declare module "babylonjs-gltf2interface" {
  90641. export = BABYLON.GLTF2;
  90642. }
  90643. /**
  90644. * Module for glTF 2.0 Interface
  90645. */
  90646. declare module BABYLON.GLTF2 {
  90647. /**
  90648. * The datatype of the components in the attribute
  90649. */
  90650. const enum AccessorComponentType {
  90651. /**
  90652. * Byte
  90653. */
  90654. BYTE = 5120,
  90655. /**
  90656. * Unsigned Byte
  90657. */
  90658. UNSIGNED_BYTE = 5121,
  90659. /**
  90660. * Short
  90661. */
  90662. SHORT = 5122,
  90663. /**
  90664. * Unsigned Short
  90665. */
  90666. UNSIGNED_SHORT = 5123,
  90667. /**
  90668. * Unsigned Int
  90669. */
  90670. UNSIGNED_INT = 5125,
  90671. /**
  90672. * Float
  90673. */
  90674. FLOAT = 5126,
  90675. }
  90676. /**
  90677. * Specifies if the attirbute is a scalar, vector, or matrix
  90678. */
  90679. const enum AccessorType {
  90680. /**
  90681. * Scalar
  90682. */
  90683. SCALAR = "SCALAR",
  90684. /**
  90685. * Vector2
  90686. */
  90687. VEC2 = "VEC2",
  90688. /**
  90689. * Vector3
  90690. */
  90691. VEC3 = "VEC3",
  90692. /**
  90693. * Vector4
  90694. */
  90695. VEC4 = "VEC4",
  90696. /**
  90697. * Matrix2x2
  90698. */
  90699. MAT2 = "MAT2",
  90700. /**
  90701. * Matrix3x3
  90702. */
  90703. MAT3 = "MAT3",
  90704. /**
  90705. * Matrix4x4
  90706. */
  90707. MAT4 = "MAT4",
  90708. }
  90709. /**
  90710. * The name of the node's TRS property to modify, or the weights of the Morph Targets it instantiates
  90711. */
  90712. const enum AnimationChannelTargetPath {
  90713. /**
  90714. * Translation
  90715. */
  90716. TRANSLATION = "translation",
  90717. /**
  90718. * Rotation
  90719. */
  90720. ROTATION = "rotation",
  90721. /**
  90722. * Scale
  90723. */
  90724. SCALE = "scale",
  90725. /**
  90726. * Weights
  90727. */
  90728. WEIGHTS = "weights",
  90729. }
  90730. /**
  90731. * Interpolation algorithm
  90732. */
  90733. const enum AnimationSamplerInterpolation {
  90734. /**
  90735. * The animated values are linearly interpolated between keyframes
  90736. */
  90737. LINEAR = "LINEAR",
  90738. /**
  90739. * The animated values remain constant to the output of the first keyframe, until the next keyframe
  90740. */
  90741. STEP = "STEP",
  90742. /**
  90743. * The animation's interpolation is computed using a cubic spline with specified tangents
  90744. */
  90745. CUBICSPLINE = "CUBICSPLINE",
  90746. }
  90747. /**
  90748. * A camera's projection. A node can reference a camera to apply a transform to place the camera in the scene
  90749. */
  90750. const enum CameraType {
  90751. /**
  90752. * A perspective camera containing properties to create a perspective projection matrix
  90753. */
  90754. PERSPECTIVE = "perspective",
  90755. /**
  90756. * An orthographic camera containing properties to create an orthographic projection matrix
  90757. */
  90758. ORTHOGRAPHIC = "orthographic",
  90759. }
  90760. /**
  90761. * The mime-type of the image
  90762. */
  90763. const enum ImageMimeType {
  90764. /**
  90765. * JPEG Mime-type
  90766. */
  90767. JPEG = "image/jpeg",
  90768. /**
  90769. * PNG Mime-type
  90770. */
  90771. PNG = "image/png",
  90772. }
  90773. /**
  90774. * The alpha rendering mode of the material
  90775. */
  90776. const enum MaterialAlphaMode {
  90777. /**
  90778. * The alpha value is ignored and the rendered output is fully opaque
  90779. */
  90780. OPAQUE = "OPAQUE",
  90781. /**
  90782. * The rendered output is either fully opaque or fully transparent depending on the alpha value and the specified alpha cutoff value
  90783. */
  90784. MASK = "MASK",
  90785. /**
  90786. * 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)
  90787. */
  90788. BLEND = "BLEND",
  90789. }
  90790. /**
  90791. * The type of the primitives to render
  90792. */
  90793. const enum MeshPrimitiveMode {
  90794. /**
  90795. * Points
  90796. */
  90797. POINTS = 0,
  90798. /**
  90799. * Lines
  90800. */
  90801. LINES = 1,
  90802. /**
  90803. * Line Loop
  90804. */
  90805. LINE_LOOP = 2,
  90806. /**
  90807. * Line Strip
  90808. */
  90809. LINE_STRIP = 3,
  90810. /**
  90811. * Triangles
  90812. */
  90813. TRIANGLES = 4,
  90814. /**
  90815. * Triangle Strip
  90816. */
  90817. TRIANGLE_STRIP = 5,
  90818. /**
  90819. * Triangle Fan
  90820. */
  90821. TRIANGLE_FAN = 6,
  90822. }
  90823. /**
  90824. * Magnification filter. Valid values correspond to WebGL enums: 9728 (NEAREST) and 9729 (LINEAR)
  90825. */
  90826. const enum TextureMagFilter {
  90827. /**
  90828. * Nearest
  90829. */
  90830. NEAREST = 9728,
  90831. /**
  90832. * Linear
  90833. */
  90834. LINEAR = 9729,
  90835. }
  90836. /**
  90837. * Minification filter. All valid values correspond to WebGL enums
  90838. */
  90839. const enum TextureMinFilter {
  90840. /**
  90841. * Nearest
  90842. */
  90843. NEAREST = 9728,
  90844. /**
  90845. * Linear
  90846. */
  90847. LINEAR = 9729,
  90848. /**
  90849. * Nearest Mip-Map Nearest
  90850. */
  90851. NEAREST_MIPMAP_NEAREST = 9984,
  90852. /**
  90853. * Linear Mipmap Nearest
  90854. */
  90855. LINEAR_MIPMAP_NEAREST = 9985,
  90856. /**
  90857. * Nearest Mipmap Linear
  90858. */
  90859. NEAREST_MIPMAP_LINEAR = 9986,
  90860. /**
  90861. * Linear Mipmap Linear
  90862. */
  90863. LINEAR_MIPMAP_LINEAR = 9987,
  90864. }
  90865. /**
  90866. * S (U) wrapping mode. All valid values correspond to WebGL enums
  90867. */
  90868. const enum TextureWrapMode {
  90869. /**
  90870. * Clamp to Edge
  90871. */
  90872. CLAMP_TO_EDGE = 33071,
  90873. /**
  90874. * Mirrored Repeat
  90875. */
  90876. MIRRORED_REPEAT = 33648,
  90877. /**
  90878. * Repeat
  90879. */
  90880. REPEAT = 10497,
  90881. }
  90882. /**
  90883. * glTF Property
  90884. */
  90885. interface IProperty {
  90886. /**
  90887. * Dictionary object with extension-specific objects
  90888. */
  90889. extensions?: {
  90890. [key: string]: any;
  90891. };
  90892. /**
  90893. * Application-Specific data
  90894. */
  90895. extras?: any;
  90896. }
  90897. /**
  90898. * glTF Child of Root Property
  90899. */
  90900. interface IChildRootProperty extends IProperty {
  90901. /**
  90902. * The user-defined name of this object
  90903. */
  90904. name?: string;
  90905. }
  90906. /**
  90907. * Indices of those attributes that deviate from their initialization value
  90908. */
  90909. interface IAccessorSparseIndices extends IProperty {
  90910. /**
  90911. * The index of the bufferView with sparse indices. Referenced bufferView can't have ARRAY_BUFFER or ELEMENT_ARRAY_BUFFER target
  90912. */
  90913. bufferView: number;
  90914. /**
  90915. * The offset relative to the start of the bufferView in bytes. Must be aligned
  90916. */
  90917. byteOffset?: number;
  90918. /**
  90919. * The indices data type. Valid values correspond to WebGL enums: 5121 (UNSIGNED_BYTE), 5123 (UNSIGNED_SHORT), 5125 (UNSIGNED_INT)
  90920. */
  90921. componentType: AccessorComponentType;
  90922. }
  90923. /**
  90924. * Array of size accessor.sparse.count times number of components storing the displaced accessor attributes pointed by accessor.sparse.indices
  90925. */
  90926. interface IAccessorSparseValues extends IProperty {
  90927. /**
  90928. * The index of the bufferView with sparse values. Referenced bufferView can't have ARRAY_BUFFER or ELEMENT_ARRAY_BUFFER target
  90929. */
  90930. bufferView: number;
  90931. /**
  90932. * The offset relative to the start of the bufferView in bytes. Must be aligned
  90933. */
  90934. byteOffset?: number;
  90935. }
  90936. /**
  90937. * Sparse storage of attributes that deviate from their initialization value
  90938. */
  90939. interface IAccessorSparse extends IProperty {
  90940. /**
  90941. * The number of attributes encoded in this sparse accessor
  90942. */
  90943. count: number;
  90944. /**
  90945. * Index array of size count that points to those accessor attributes that deviate from their initialization value. Indices must strictly increase
  90946. */
  90947. indices: IAccessorSparseIndices;
  90948. /**
  90949. * 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
  90950. */
  90951. values: IAccessorSparseValues;
  90952. }
  90953. /**
  90954. * 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
  90955. */
  90956. interface IAccessor extends IChildRootProperty {
  90957. /**
  90958. * The index of the bufferview
  90959. */
  90960. bufferView?: number;
  90961. /**
  90962. * The offset relative to the start of the bufferView in bytes
  90963. */
  90964. byteOffset?: number;
  90965. /**
  90966. * The datatype of components in the attribute
  90967. */
  90968. componentType: AccessorComponentType;
  90969. /**
  90970. * Specifies whether integer data values should be normalized
  90971. */
  90972. normalized?: boolean;
  90973. /**
  90974. * The number of attributes referenced by this accessor
  90975. */
  90976. count: number;
  90977. /**
  90978. * Specifies if the attribute is a scalar, vector, or matrix
  90979. */
  90980. type: AccessorType;
  90981. /**
  90982. * Maximum value of each component in this attribute
  90983. */
  90984. max?: number[];
  90985. /**
  90986. * Minimum value of each component in this attribute
  90987. */
  90988. min?: number[];
  90989. /**
  90990. * Sparse storage of attributes that deviate from their initialization value
  90991. */
  90992. sparse?: IAccessorSparse;
  90993. }
  90994. /**
  90995. * Targets an animation's sampler at a node's property
  90996. */
  90997. interface IAnimationChannel extends IProperty {
  90998. /**
  90999. * The index of a sampler in this animation used to compute the value for the target
  91000. */
  91001. sampler: number;
  91002. /**
  91003. * The index of the node and TRS property to target
  91004. */
  91005. target: IAnimationChannelTarget;
  91006. }
  91007. /**
  91008. * The index of the node and TRS property that an animation channel targets
  91009. */
  91010. interface IAnimationChannelTarget extends IProperty {
  91011. /**
  91012. * The index of the node to target
  91013. */
  91014. node: number;
  91015. /**
  91016. * The name of the node's TRS property to modify, or the weights of the Morph Targets it instantiates
  91017. */
  91018. path: AnimationChannelTargetPath;
  91019. }
  91020. /**
  91021. * Combines input and output accessors with an interpolation algorithm to define a keyframe graph (but not its target)
  91022. */
  91023. interface IAnimationSampler extends IProperty {
  91024. /**
  91025. * The index of an accessor containing keyframe input values, e.g., time
  91026. */
  91027. input: number;
  91028. /**
  91029. * Interpolation algorithm
  91030. */
  91031. interpolation?: AnimationSamplerInterpolation;
  91032. /**
  91033. * The index of an accessor, containing keyframe output values
  91034. */
  91035. output: number;
  91036. }
  91037. /**
  91038. * A keyframe animation
  91039. */
  91040. interface IAnimation extends IChildRootProperty {
  91041. /**
  91042. * An array of channels, each of which targets an animation's sampler at a node's property
  91043. */
  91044. channels: IAnimationChannel[];
  91045. /**
  91046. * An array of samplers that combines input and output accessors with an interpolation algorithm to define a keyframe graph (but not its target)
  91047. */
  91048. samplers: IAnimationSampler[];
  91049. }
  91050. /**
  91051. * Metadata about the glTF asset
  91052. */
  91053. interface IAsset extends IChildRootProperty {
  91054. /**
  91055. * A copyright message suitable for display to credit the content creator
  91056. */
  91057. copyright?: string;
  91058. /**
  91059. * Tool that generated this glTF model. Useful for debugging
  91060. */
  91061. generator?: string;
  91062. /**
  91063. * The glTF version that this asset targets
  91064. */
  91065. version: string;
  91066. /**
  91067. * The minimum glTF version that this asset targets
  91068. */
  91069. minVersion?: string;
  91070. }
  91071. /**
  91072. * A buffer points to binary geometry, animation, or skins
  91073. */
  91074. interface IBuffer extends IChildRootProperty {
  91075. /**
  91076. * 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
  91077. */
  91078. uri?: string;
  91079. /**
  91080. * The length of the buffer in bytes
  91081. */
  91082. byteLength: number;
  91083. }
  91084. /**
  91085. * A view into a buffer generally representing a subset of the buffer
  91086. */
  91087. interface IBufferView extends IChildRootProperty {
  91088. /**
  91089. * The index of the buffer
  91090. */
  91091. buffer: number;
  91092. /**
  91093. * The offset into the buffer in bytes
  91094. */
  91095. byteOffset?: number;
  91096. /**
  91097. * The lenth of the bufferView in bytes
  91098. */
  91099. byteLength: number;
  91100. /**
  91101. * The stride, in bytes
  91102. */
  91103. byteStride?: number;
  91104. }
  91105. /**
  91106. * An orthographic camera containing properties to create an orthographic projection matrix
  91107. */
  91108. interface ICameraOrthographic extends IProperty {
  91109. /**
  91110. * The floating-point horizontal magnification of the view. Must not be zero
  91111. */
  91112. xmag: number;
  91113. /**
  91114. * The floating-point vertical magnification of the view. Must not be zero
  91115. */
  91116. ymag: number;
  91117. /**
  91118. * The floating-point distance to the far clipping plane. zfar must be greater than znear
  91119. */
  91120. zfar: number;
  91121. /**
  91122. * The floating-point distance to the near clipping plane
  91123. */
  91124. znear: number;
  91125. }
  91126. /**
  91127. * A perspective camera containing properties to create a perspective projection matrix
  91128. */
  91129. interface ICameraPerspective extends IProperty {
  91130. /**
  91131. * The floating-point aspect ratio of the field of view
  91132. */
  91133. aspectRatio?: number;
  91134. /**
  91135. * The floating-point vertical field of view in radians
  91136. */
  91137. yfov: number;
  91138. /**
  91139. * The floating-point distance to the far clipping plane
  91140. */
  91141. zfar?: number;
  91142. /**
  91143. * The floating-point distance to the near clipping plane
  91144. */
  91145. znear: number;
  91146. }
  91147. /**
  91148. * A camera's projection. A node can reference a camera to apply a transform to place the camera in the scene
  91149. */
  91150. interface ICamera extends IChildRootProperty {
  91151. /**
  91152. * An orthographic camera containing properties to create an orthographic projection matrix
  91153. */
  91154. orthographic?: ICameraOrthographic;
  91155. /**
  91156. * A perspective camera containing properties to create a perspective projection matrix
  91157. */
  91158. perspective?: ICameraPerspective;
  91159. /**
  91160. * Specifies if the camera uses a perspective or orthographic projection
  91161. */
  91162. type: CameraType;
  91163. }
  91164. /**
  91165. * Image data used to create a texture. Image can be referenced by URI or bufferView index. mimeType is required in the latter case
  91166. */
  91167. interface IImage extends IChildRootProperty {
  91168. /**
  91169. * 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
  91170. */
  91171. uri?: string;
  91172. /**
  91173. * The image's MIME type
  91174. */
  91175. mimeType?: ImageMimeType;
  91176. /**
  91177. * The index of the bufferView that contains the image. Use this instead of the image's uri property
  91178. */
  91179. bufferView?: number;
  91180. }
  91181. /**
  91182. * Material Normal Texture Info
  91183. */
  91184. interface IMaterialNormalTextureInfo extends ITextureInfo {
  91185. /**
  91186. * The scalar multiplier applied to each normal vector of the normal texture
  91187. */
  91188. scale?: number;
  91189. }
  91190. /**
  91191. * Material Occlusion Texture Info
  91192. */
  91193. interface IMaterialOcclusionTextureInfo extends ITextureInfo {
  91194. /**
  91195. * A scalar multiplier controlling the amount of occlusion applied
  91196. */
  91197. strength?: number;
  91198. }
  91199. /**
  91200. * A set of parameter values that are used to define the metallic-roughness material model from Physically-Based Rendering (PBR) methodology
  91201. */
  91202. interface IMaterialPbrMetallicRoughness {
  91203. /**
  91204. * The material's base color factor
  91205. */
  91206. baseColorFactor?: number[];
  91207. /**
  91208. * The base color texture
  91209. */
  91210. baseColorTexture?: ITextureInfo;
  91211. /**
  91212. * The metalness of the material
  91213. */
  91214. metallicFactor?: number;
  91215. /**
  91216. * The roughness of the material
  91217. */
  91218. roughnessFactor?: number;
  91219. /**
  91220. * The metallic-roughness texture
  91221. */
  91222. metallicRoughnessTexture?: ITextureInfo;
  91223. }
  91224. /**
  91225. * The material appearance of a primitive
  91226. */
  91227. interface IMaterial extends IChildRootProperty {
  91228. /**
  91229. * 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
  91230. */
  91231. pbrMetallicRoughness?: IMaterialPbrMetallicRoughness;
  91232. /**
  91233. * The normal map texture
  91234. */
  91235. normalTexture?: IMaterialNormalTextureInfo;
  91236. /**
  91237. * The occlusion map texture
  91238. */
  91239. occlusionTexture?: IMaterialOcclusionTextureInfo;
  91240. /**
  91241. * The emissive map texture
  91242. */
  91243. emissiveTexture?: ITextureInfo;
  91244. /**
  91245. * 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
  91246. */
  91247. emissiveFactor?: number[];
  91248. /**
  91249. * The alpha rendering mode of the material
  91250. */
  91251. alphaMode?: MaterialAlphaMode;
  91252. /**
  91253. * The alpha cutoff value of the material
  91254. */
  91255. alphaCutoff?: number;
  91256. /**
  91257. * Specifies whether the material is double sided
  91258. */
  91259. doubleSided?: boolean;
  91260. }
  91261. /**
  91262. * Geometry to be rendered with the given material
  91263. */
  91264. interface IMeshPrimitive extends IProperty {
  91265. /**
  91266. * A dictionary object, where each key corresponds to mesh attribute semantic and each value is the index of the accessor containing attribute's data
  91267. */
  91268. attributes: {
  91269. [name: string]: number;
  91270. };
  91271. /**
  91272. * The index of the accessor that contains the indices
  91273. */
  91274. indices?: number;
  91275. /**
  91276. * The index of the material to apply to this primitive when rendering
  91277. */
  91278. material?: number;
  91279. /**
  91280. * The type of primitives to render. All valid values correspond to WebGL enums
  91281. */
  91282. mode?: MeshPrimitiveMode;
  91283. /**
  91284. * 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
  91285. */
  91286. targets?: {
  91287. [name: string]: number;
  91288. }[];
  91289. }
  91290. /**
  91291. * A set of primitives to be rendered. A node can contain one mesh. A node's transform places the mesh in the scene
  91292. */
  91293. interface IMesh extends IChildRootProperty {
  91294. /**
  91295. * An array of primitives, each defining geometry to be rendered with a material
  91296. */
  91297. primitives: IMeshPrimitive[];
  91298. /**
  91299. * Array of weights to be applied to the Morph Targets
  91300. */
  91301. weights?: number[];
  91302. }
  91303. /**
  91304. * A node in the node hierarchy
  91305. */
  91306. interface INode extends IChildRootProperty {
  91307. /**
  91308. * The index of the camera referenced by this node
  91309. */
  91310. camera?: number;
  91311. /**
  91312. * The indices of this node's children
  91313. */
  91314. children?: number[];
  91315. /**
  91316. * The index of the skin referenced by this node
  91317. */
  91318. skin?: number;
  91319. /**
  91320. * A floating-point 4x4 transformation matrix stored in column-major order
  91321. */
  91322. matrix?: number[];
  91323. /**
  91324. * The index of the mesh in this node
  91325. */
  91326. mesh?: number;
  91327. /**
  91328. * The node's unit quaternion rotation in the order (x, y, z, w), where w is the scalar
  91329. */
  91330. rotation?: number[];
  91331. /**
  91332. * The node's non-uniform scale, given as the scaling factors along the x, y, and z axes
  91333. */
  91334. scale?: number[];
  91335. /**
  91336. * The node's translation along the x, y, and z axes
  91337. */
  91338. translation?: number[];
  91339. /**
  91340. * The weights of the instantiated Morph Target. Number of elements must match number of Morph Targets of used mesh
  91341. */
  91342. weights?: number[];
  91343. }
  91344. /**
  91345. * Texture sampler properties for filtering and wrapping modes
  91346. */
  91347. interface ISampler extends IChildRootProperty {
  91348. /**
  91349. * Magnification filter. Valid values correspond to WebGL enums: 9728 (NEAREST) and 9729 (LINEAR)
  91350. */
  91351. magFilter?: TextureMagFilter;
  91352. /**
  91353. * Minification filter. All valid values correspond to WebGL enums
  91354. */
  91355. minFilter?: TextureMinFilter;
  91356. /**
  91357. * S (U) wrapping mode. All valid values correspond to WebGL enums
  91358. */
  91359. wrapS?: TextureWrapMode;
  91360. /**
  91361. * T (V) wrapping mode. All valid values correspond to WebGL enums
  91362. */
  91363. wrapT?: TextureWrapMode;
  91364. }
  91365. /**
  91366. * The root nodes of a scene
  91367. */
  91368. interface IScene extends IChildRootProperty {
  91369. /**
  91370. * The indices of each root node
  91371. */
  91372. nodes: number[];
  91373. }
  91374. /**
  91375. * Joints and matrices defining a skin
  91376. */
  91377. interface ISkin extends IChildRootProperty {
  91378. /**
  91379. * 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
  91380. */
  91381. inverseBindMatrices?: number;
  91382. /**
  91383. * The index of the node used as a skeleton root. When undefined, joints transforms resolve to scene root
  91384. */
  91385. skeleton?: number;
  91386. /**
  91387. * 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)
  91388. */
  91389. joints: number[];
  91390. }
  91391. /**
  91392. * A texture and its sampler
  91393. */
  91394. interface ITexture extends IChildRootProperty {
  91395. /**
  91396. * The index of the sampler used by this texture. When undefined, a sampler with repeat wrapping and auto filtering should be used
  91397. */
  91398. sampler?: number;
  91399. /**
  91400. * The index of the image used by this texture
  91401. */
  91402. source: number;
  91403. }
  91404. /**
  91405. * Reference to a texture
  91406. */
  91407. interface ITextureInfo extends IProperty {
  91408. /**
  91409. * The index of the texture
  91410. */
  91411. index: number;
  91412. /**
  91413. * The set index of texture's TEXCOORD attribute used for texture coordinate mapping
  91414. */
  91415. texCoord?: number;
  91416. }
  91417. /**
  91418. * The root object for a glTF asset
  91419. */
  91420. interface IGLTF extends IProperty {
  91421. /**
  91422. * An array of accessors. An accessor is a typed view into a bufferView
  91423. */
  91424. accessors?: IAccessor[];
  91425. /**
  91426. * An array of keyframe animations
  91427. */
  91428. animations?: IAnimation[];
  91429. /**
  91430. * Metadata about the glTF asset
  91431. */
  91432. asset: IAsset;
  91433. /**
  91434. * An array of buffers. A buffer points to binary geometry, animation, or skins
  91435. */
  91436. buffers?: IBuffer[];
  91437. /**
  91438. * An array of bufferViews. A bufferView is a view into a buffer generally representing a subset of the buffer
  91439. */
  91440. bufferViews?: IBufferView[];
  91441. /**
  91442. * An array of cameras
  91443. */
  91444. cameras?: ICamera[];
  91445. /**
  91446. * Names of glTF extensions used somewhere in this asset
  91447. */
  91448. extensionsUsed?: string[];
  91449. /**
  91450. * Names of glTF extensions required to properly load this asset
  91451. */
  91452. extensionsRequired?: string[];
  91453. /**
  91454. * An array of images. An image defines data used to create a texture
  91455. */
  91456. images?: IImage[];
  91457. /**
  91458. * An array of materials. A material defines the appearance of a primitive
  91459. */
  91460. materials?: IMaterial[];
  91461. /**
  91462. * An array of meshes. A mesh is a set of primitives to be rendered
  91463. */
  91464. meshes?: IMesh[];
  91465. /**
  91466. * An array of nodes
  91467. */
  91468. nodes?: INode[];
  91469. /**
  91470. * An array of samplers. A sampler contains properties for texture filtering and wrapping modes
  91471. */
  91472. samplers?: ISampler[];
  91473. /**
  91474. * The index of the default scene
  91475. */
  91476. scene?: number;
  91477. /**
  91478. * An array of scenes
  91479. */
  91480. scenes?: IScene[];
  91481. /**
  91482. * An array of skins. A skin is defined by joints and matrices
  91483. */
  91484. skins?: ISkin[];
  91485. /**
  91486. * An array of textures
  91487. */
  91488. textures?: ITexture[];
  91489. }
  91490. /**
  91491. * The glTF validation results
  91492. * @ignore
  91493. */
  91494. interface IGLTFValidationResults {
  91495. info: {
  91496. generator: string;
  91497. hasAnimations: boolean;
  91498. hasDefaultScene: boolean;
  91499. hasMaterials: boolean;
  91500. hasMorphTargets: boolean;
  91501. hasSkins: boolean;
  91502. hasTextures: boolean;
  91503. maxAttributesUsed: number;
  91504. primitivesCount: number
  91505. };
  91506. issues: {
  91507. messages: Array<string>;
  91508. numErrors: number;
  91509. numHints: number;
  91510. numInfos: number;
  91511. numWarnings: number;
  91512. truncated: boolean
  91513. };
  91514. mimeType: string;
  91515. uri: string;
  91516. validatedAt: string;
  91517. validatorVersion: string;
  91518. }
  91519. /**
  91520. * The glTF validation options
  91521. */
  91522. interface IGLTFValidationOptions {
  91523. /** Uri to use */
  91524. uri?: string;
  91525. /** Function used to load external resources */
  91526. externalResourceFunction?: (uri: string) => Promise<Uint8Array>;
  91527. /** Boolean indicating that we need to validate accessor data */
  91528. validateAccessorData?: boolean;
  91529. /** max number of issues allowed */
  91530. maxIssues?: number;
  91531. /** Ignored issues */
  91532. ignoredIssues?: Array<string>;
  91533. /** Value to override severy settings */
  91534. severityOverrides?: Object;
  91535. }
  91536. /**
  91537. * The glTF validator object
  91538. * @ignore
  91539. */
  91540. interface IGLTFValidator {
  91541. validateBytes: (data: Uint8Array, options?: IGLTFValidationOptions) => Promise<IGLTFValidationResults>;
  91542. validateString: (json: string, options?: IGLTFValidationOptions) => Promise<IGLTFValidationResults>;
  91543. }
  91544. /**
  91545. * Interfaces from the EXT_lights_image_based extension
  91546. */
  91547. /** @hidden */
  91548. interface IEXTLightsImageBased_LightReferenceImageBased {
  91549. light: number;
  91550. }
  91551. /** @hidden */
  91552. interface IEXTLightsImageBased_LightImageBased extends IChildRootProperty {
  91553. intensity: number;
  91554. rotation: number[];
  91555. specularImageSize: number;
  91556. specularImages: number[][];
  91557. irradianceCoefficients: number[][];
  91558. }
  91559. /** @hidden */
  91560. interface IEXTLightsImageBased {
  91561. lights: IEXTLightsImageBased_LightImageBased[];
  91562. }
  91563. /**
  91564. * Interfaces from the EXT_mesh_gpu_instancing extension
  91565. * !!! Experimental Extension Subject to Changes !!!
  91566. */
  91567. /** @hidden */
  91568. interface IEXTMeshGpuInstancing {
  91569. mesh?: number;
  91570. attributes: { [name: string]: number };
  91571. }
  91572. /**
  91573. * Interfaces from the KHR_draco_mesh_compression extension
  91574. */
  91575. /** @hidden */
  91576. interface IKHRDracoMeshCompression {
  91577. bufferView: number;
  91578. attributes: { [name: string]: number };
  91579. }
  91580. /**
  91581. * Interfaces from the KHR_lights_punctual extension
  91582. */
  91583. /** @hidden */
  91584. const enum IKHRLightsPunctual_LightType {
  91585. DIRECTIONAL = "directional",
  91586. POINT = "point",
  91587. SPOT = "spot"
  91588. }
  91589. /** @hidden */
  91590. interface IKHRLightsPunctual_LightReference {
  91591. light: number;
  91592. }
  91593. /** @hidden */
  91594. interface IKHRLightsPunctual_Light extends IChildRootProperty {
  91595. type: IKHRLightsPunctual_LightType;
  91596. color?: number[];
  91597. intensity?: number;
  91598. range?: number;
  91599. spot?: {
  91600. innerConeAngle?: number;
  91601. outerConeAngle?: number;
  91602. };
  91603. }
  91604. /** @hidden */
  91605. interface IKHRLightsPunctual {
  91606. lights: IKHRLightsPunctual_Light[];
  91607. }
  91608. /**
  91609. * Interfaces from the KHR_materials_clearcoat extension
  91610. * !!! Experimental Extension Subject to Changes !!!
  91611. */
  91612. /** @hidden */
  91613. interface IKHRMaterialsClearcoat {
  91614. clearcoatFactor: number;
  91615. clearcoatTexture: ITextureInfo;
  91616. clearcoatRoughnessFactor: number;
  91617. clearcoatRoughnessTexture: ITextureInfo;
  91618. clearcoatNormalTexture: IMaterialNormalTextureInfo;
  91619. }
  91620. /**
  91621. * Interfaces from the KHR_materials_ior extension
  91622. * !!! Experimental Extension Subject to Changes !!!
  91623. */
  91624. /** @hidden */
  91625. interface IKHRMaterialsIor {
  91626. ior: number;
  91627. }
  91628. /**
  91629. * Interfaces from the KHR_materials_pbrSpecularGlossiness extension
  91630. */
  91631. /** @hidden */
  91632. interface IKHRMaterialsPbrSpecularGlossiness {
  91633. diffuseFactor: number[];
  91634. diffuseTexture: ITextureInfo;
  91635. specularFactor: number[];
  91636. glossinessFactor: number;
  91637. specularGlossinessTexture: ITextureInfo;
  91638. }
  91639. /**
  91640. * Interfaces from the KHR_materials_sheen extension
  91641. * !!! Experimental Extension Subject to Changes !!!
  91642. */
  91643. /** @hidden */
  91644. interface IKHRMaterialsSheen {
  91645. sheenColorFactor?: number[];
  91646. sheenColorTexture?: ITextureInfo;
  91647. sheenRoughnessFactor?: number;
  91648. sheenRoughnessTexture?: ITextureInfo;
  91649. }
  91650. /**
  91651. * Interfaces from the KHR_materials_specular extension
  91652. * !!! Experimental Extension Subject to Changes !!!
  91653. */
  91654. /** @hidden */
  91655. interface IKHRMaterialsSpecular {
  91656. specularFactor: number;
  91657. specularColorFactor: number[];
  91658. specularTexture: ITextureInfo;
  91659. }
  91660. /**
  91661. * Interfaces from the KHR_materials_transmission extension
  91662. * !!! Experimental Extension Subject to Changes !!!
  91663. */
  91664. /** @hidden */
  91665. interface IKHRMaterialsTransmission {
  91666. transmissionFactor?: number;
  91667. transmissionTexture?: ITextureInfo;
  91668. }
  91669. /**
  91670. * Interfaces from the KHR_materials_translucency extension
  91671. * !!! Experimental Extension Subject to Changes !!!
  91672. */
  91673. /** @hidden */
  91674. interface IKHRMaterialsTranslucency {
  91675. translucencyFactor?: number;
  91676. translucencyTexture?: ITextureInfo;
  91677. }
  91678. /**
  91679. * Interfaces from the KHR_materials_variants extension
  91680. * !!! Experimental Extension Subject to Changes !!!
  91681. */
  91682. /** @hidden */
  91683. interface IKHRMaterialVariants_Mapping extends IProperty {
  91684. mappings: Array<{
  91685. variants: number[];
  91686. material: number;
  91687. }>;
  91688. }
  91689. /** @hidden */
  91690. interface IKHRMaterialVariants_Variant extends IProperty {
  91691. name: string;
  91692. }
  91693. /** @hidden */
  91694. interface IKHRMaterialVariants_Variants extends IChildRootProperty {
  91695. variants: Array<IKHRMaterialVariants_Variant>;
  91696. }
  91697. /**
  91698. * Interfaces from the KHR_texture_basisu extension
  91699. * !!! Experimental Extension Subject to Changes !!!
  91700. */
  91701. /** @hidden */
  91702. interface IKHRTextureBasisU {
  91703. source: number;
  91704. }
  91705. /**
  91706. * Interfaces from the EXT_texture_webp extension
  91707. */
  91708. /** @hidden */
  91709. interface IEXTTextureWebP {
  91710. source: number;
  91711. }
  91712. /**
  91713. * Interfaces from the KHR_texture_transform extension
  91714. */
  91715. /** @hidden */
  91716. interface IKHRTextureTransform {
  91717. offset?: number[];
  91718. rotation?: number;
  91719. scale?: number[];
  91720. texCoord?: number;
  91721. }
  91722. /**
  91723. * Interfaces from the KHR_xmp_json_ld extension
  91724. * !!! Experimental Extension Subject to Changes !!!
  91725. */
  91726. /** @hidden */
  91727. interface IKHRXmpJsonLd_Gltf {
  91728. packets: Array<{
  91729. [key: string]: unknown;
  91730. }>;
  91731. }
  91732. /** @hidden */
  91733. interface IKHRXmpJsonLd_Node {
  91734. packet: number;
  91735. }
  91736. /**
  91737. * Interfaces from the MSFT_audio_emitter extension
  91738. */
  91739. /** @hidden */
  91740. interface IMSFTAudioEmitter_ClipReference {
  91741. clip: number;
  91742. weight?: number;
  91743. }
  91744. /** @hidden */
  91745. interface IMSFTAudioEmitter_EmittersReference {
  91746. emitters: number[];
  91747. }
  91748. /** @hidden */
  91749. const enum IMSFTAudioEmitter_DistanceModel {
  91750. linear = "linear",
  91751. inverse = "inverse",
  91752. exponential = "exponential",
  91753. }
  91754. /** @hidden */
  91755. interface IMSFTAudioEmitter_Emitter {
  91756. name?: string;
  91757. distanceModel?: IMSFTAudioEmitter_DistanceModel;
  91758. refDistance?: number;
  91759. maxDistance?: number;
  91760. rolloffFactor?: number;
  91761. innerAngle?: number;
  91762. outerAngle?: number;
  91763. loop?: boolean;
  91764. volume?: number;
  91765. clips: IMSFTAudioEmitter_ClipReference[];
  91766. }
  91767. /** @hidden */
  91768. const enum IMSFTAudioEmitter_AudioMimeType {
  91769. WAV = "audio/wav",
  91770. }
  91771. /** @hidden */
  91772. interface IMSFTAudioEmitter_Clip extends IProperty {
  91773. uri?: string;
  91774. bufferView?: number;
  91775. mimeType?: IMSFTAudioEmitter_AudioMimeType;
  91776. }
  91777. /** @hidden */
  91778. const enum IMSFTAudioEmitter_AnimationEventAction {
  91779. play = "play",
  91780. pause = "pause",
  91781. stop = "stop",
  91782. }
  91783. /** @hidden */
  91784. interface IMSFTAudioEmitter_AnimationEvent {
  91785. action: IMSFTAudioEmitter_AnimationEventAction;
  91786. emitter: number;
  91787. time: number;
  91788. startOffset?: number;
  91789. }
  91790. /**
  91791. * Interfaces from the MSFT_lod extension
  91792. */
  91793. /** @hidden */
  91794. interface IMSFTLOD {
  91795. ids: number[];
  91796. }
  91797. /**
  91798. * Interfaces from the EXT_meshopt_compression extension
  91799. */
  91800. /** @hidden */
  91801. interface IEXTMeshoptCompression {
  91802. buffer: number;
  91803. byteOffset?: number;
  91804. byteLength: number;
  91805. byteStride: number;
  91806. count: number;
  91807. mode: "ATTRIBUTES" | "TRIANGLES" | "INDICES";
  91808. filter?: "NONE" | "OCTAHEDRAL" | "QUATERNION" | "EXPONENTIAL";
  91809. }
  91810. }
  91811. declare module BABYLON {
  91812. /** @hidden */
  91813. export var cellPixelShader: {
  91814. name: string;
  91815. shader: string;
  91816. };
  91817. }
  91818. declare module BABYLON {
  91819. /** @hidden */
  91820. export var cellVertexShader: {
  91821. name: string;
  91822. shader: string;
  91823. };
  91824. }
  91825. declare module BABYLON {
  91826. export class CellMaterial extends BABYLON.PushMaterial {
  91827. private _diffuseTexture;
  91828. diffuseTexture: BABYLON.BaseTexture;
  91829. diffuseColor: BABYLON.Color3;
  91830. _computeHighLevel: boolean;
  91831. computeHighLevel: boolean;
  91832. private _disableLighting;
  91833. disableLighting: boolean;
  91834. private _maxSimultaneousLights;
  91835. maxSimultaneousLights: number;
  91836. constructor(name: string, scene: BABYLON.Scene);
  91837. needAlphaBlending(): boolean;
  91838. needAlphaTesting(): boolean;
  91839. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  91840. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  91841. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  91842. getAnimatables(): BABYLON.IAnimatable[];
  91843. getActiveTextures(): BABYLON.BaseTexture[];
  91844. hasTexture(texture: BABYLON.BaseTexture): boolean;
  91845. dispose(forceDisposeEffect?: boolean): void;
  91846. getClassName(): string;
  91847. clone(name: string): CellMaterial;
  91848. serialize(): any;
  91849. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): CellMaterial;
  91850. }
  91851. }
  91852. declare module BABYLON {
  91853. export class CustomShaderStructure {
  91854. FragmentStore: string;
  91855. VertexStore: string;
  91856. constructor();
  91857. }
  91858. export class ShaderSpecialParts {
  91859. constructor();
  91860. Fragment_Begin: string;
  91861. Fragment_Definitions: string;
  91862. Fragment_MainBegin: string;
  91863. Fragment_Custom_Diffuse: string;
  91864. Fragment_Before_Lights: string;
  91865. Fragment_Before_Fog: string;
  91866. Fragment_Custom_Alpha: string;
  91867. Fragment_Before_FragColor: string;
  91868. Vertex_Begin: string;
  91869. Vertex_Definitions: string;
  91870. Vertex_MainBegin: string;
  91871. Vertex_Before_PositionUpdated: string;
  91872. Vertex_Before_NormalUpdated: string;
  91873. Vertex_After_WorldPosComputed: string;
  91874. Vertex_MainEnd: string;
  91875. }
  91876. export class CustomMaterial extends BABYLON.StandardMaterial {
  91877. static ShaderIndexer: number;
  91878. CustomParts: ShaderSpecialParts;
  91879. _isCreatedShader: boolean;
  91880. _createdShaderName: string;
  91881. _customUniform: string[];
  91882. _newUniforms: string[];
  91883. _newUniformInstances: {
  91884. [name: string]: any;
  91885. };
  91886. _newSamplerInstances: {
  91887. [name: string]: BABYLON.Texture;
  91888. };
  91889. _customAttributes: string[];
  91890. FragmentShader: string;
  91891. VertexShader: string;
  91892. AttachAfterBind(mesh: BABYLON.Mesh, effect: BABYLON.Effect): void;
  91893. ReviewUniform(name: string, arr: string[]): string[];
  91894. Builder(shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: BABYLON.MaterialDefines | string[], attributes?: string[]): string;
  91895. constructor(name: string, scene: BABYLON.Scene);
  91896. AddUniform(name: string, kind: string, param: any): CustomMaterial;
  91897. AddAttribute(name: string): CustomMaterial;
  91898. Fragment_Begin(shaderPart: string): CustomMaterial;
  91899. Fragment_Definitions(shaderPart: string): CustomMaterial;
  91900. Fragment_MainBegin(shaderPart: string): CustomMaterial;
  91901. Fragment_Custom_Diffuse(shaderPart: string): CustomMaterial;
  91902. Fragment_Custom_Alpha(shaderPart: string): CustomMaterial;
  91903. Fragment_Before_Lights(shaderPart: string): CustomMaterial;
  91904. Fragment_Before_Fog(shaderPart: string): CustomMaterial;
  91905. Fragment_Before_FragColor(shaderPart: string): CustomMaterial;
  91906. Vertex_Begin(shaderPart: string): CustomMaterial;
  91907. Vertex_Definitions(shaderPart: string): CustomMaterial;
  91908. Vertex_MainBegin(shaderPart: string): CustomMaterial;
  91909. Vertex_Before_PositionUpdated(shaderPart: string): CustomMaterial;
  91910. Vertex_Before_NormalUpdated(shaderPart: string): CustomMaterial;
  91911. Vertex_After_WorldPosComputed(shaderPart: string): CustomMaterial;
  91912. Vertex_MainEnd(shaderPart: string): CustomMaterial;
  91913. }
  91914. }
  91915. declare module BABYLON {
  91916. export class ShaderAlebdoParts {
  91917. constructor();
  91918. Fragment_Begin: string;
  91919. Fragment_Definitions: string;
  91920. Fragment_MainBegin: string;
  91921. Fragment_Custom_Albedo: string;
  91922. Fragment_Before_Lights: string;
  91923. Fragment_Custom_MetallicRoughness: string;
  91924. Fragment_Custom_MicroSurface: string;
  91925. Fragment_Before_Fog: string;
  91926. Fragment_Custom_Alpha: string;
  91927. Fragment_Before_FragColor: string;
  91928. Vertex_Begin: string;
  91929. Vertex_Definitions: string;
  91930. Vertex_MainBegin: string;
  91931. Vertex_Before_PositionUpdated: string;
  91932. Vertex_Before_NormalUpdated: string;
  91933. Vertex_After_WorldPosComputed: string;
  91934. Vertex_MainEnd: string;
  91935. }
  91936. export class PBRCustomMaterial extends BABYLON.PBRMaterial {
  91937. static ShaderIndexer: number;
  91938. CustomParts: ShaderAlebdoParts;
  91939. _isCreatedShader: boolean;
  91940. _createdShaderName: string;
  91941. _customUniform: string[];
  91942. _newUniforms: string[];
  91943. _newUniformInstances: {
  91944. [name: string]: any;
  91945. };
  91946. _newSamplerInstances: {
  91947. [name: string]: BABYLON.Texture;
  91948. };
  91949. _customAttributes: string[];
  91950. FragmentShader: string;
  91951. VertexShader: string;
  91952. AttachAfterBind(mesh: BABYLON.Mesh, effect: BABYLON.Effect): void;
  91953. ReviewUniform(name: string, arr: string[]): string[];
  91954. Builder(shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: BABYLON.MaterialDefines | string[], attributes?: string[], options?: BABYLON.ICustomShaderNameResolveOptions): string;
  91955. constructor(name: string, scene: BABYLON.Scene);
  91956. AddUniform(name: string, kind: string, param: any): PBRCustomMaterial;
  91957. AddAttribute(name: string): PBRCustomMaterial;
  91958. Fragment_Begin(shaderPart: string): PBRCustomMaterial;
  91959. Fragment_Definitions(shaderPart: string): PBRCustomMaterial;
  91960. Fragment_MainBegin(shaderPart: string): PBRCustomMaterial;
  91961. Fragment_Custom_Albedo(shaderPart: string): PBRCustomMaterial;
  91962. Fragment_Custom_Alpha(shaderPart: string): PBRCustomMaterial;
  91963. Fragment_Before_Lights(shaderPart: string): PBRCustomMaterial;
  91964. Fragment_Custom_MetallicRoughness(shaderPart: string): PBRCustomMaterial;
  91965. Fragment_Custom_MicroSurface(shaderPart: string): PBRCustomMaterial;
  91966. Fragment_Before_Fog(shaderPart: string): PBRCustomMaterial;
  91967. Fragment_Before_FragColor(shaderPart: string): PBRCustomMaterial;
  91968. Vertex_Begin(shaderPart: string): PBRCustomMaterial;
  91969. Vertex_Definitions(shaderPart: string): PBRCustomMaterial;
  91970. Vertex_MainBegin(shaderPart: string): PBRCustomMaterial;
  91971. Vertex_Before_PositionUpdated(shaderPart: string): PBRCustomMaterial;
  91972. Vertex_Before_NormalUpdated(shaderPart: string): PBRCustomMaterial;
  91973. Vertex_After_WorldPosComputed(shaderPart: string): PBRCustomMaterial;
  91974. Vertex_MainEnd(shaderPart: string): PBRCustomMaterial;
  91975. }
  91976. }
  91977. declare module BABYLON {
  91978. /** @hidden */
  91979. export var firePixelShader: {
  91980. name: string;
  91981. shader: string;
  91982. };
  91983. }
  91984. declare module BABYLON {
  91985. /** @hidden */
  91986. export var fireVertexShader: {
  91987. name: string;
  91988. shader: string;
  91989. };
  91990. }
  91991. declare module BABYLON {
  91992. export class FireMaterial extends BABYLON.PushMaterial {
  91993. private _diffuseTexture;
  91994. diffuseTexture: BABYLON.Nullable<BABYLON.BaseTexture>;
  91995. private _distortionTexture;
  91996. distortionTexture: BABYLON.Nullable<BABYLON.BaseTexture>;
  91997. private _opacityTexture;
  91998. opacityTexture: BABYLON.Nullable<BABYLON.BaseTexture>;
  91999. diffuseColor: BABYLON.Color3;
  92000. speed: number;
  92001. private _scaledDiffuse;
  92002. private _lastTime;
  92003. constructor(name: string, scene: BABYLON.Scene);
  92004. needAlphaBlending(): boolean;
  92005. needAlphaTesting(): boolean;
  92006. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  92007. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  92008. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  92009. getAnimatables(): BABYLON.IAnimatable[];
  92010. getActiveTextures(): BABYLON.BaseTexture[];
  92011. hasTexture(texture: BABYLON.BaseTexture): boolean;
  92012. getClassName(): string;
  92013. dispose(forceDisposeEffect?: boolean): void;
  92014. clone(name: string): FireMaterial;
  92015. serialize(): any;
  92016. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): FireMaterial;
  92017. }
  92018. }
  92019. declare module BABYLON {
  92020. /** @hidden */
  92021. export var furPixelShader: {
  92022. name: string;
  92023. shader: string;
  92024. };
  92025. }
  92026. declare module BABYLON {
  92027. /** @hidden */
  92028. export var furVertexShader: {
  92029. name: string;
  92030. shader: string;
  92031. };
  92032. }
  92033. declare module BABYLON {
  92034. export class FurMaterial extends BABYLON.PushMaterial {
  92035. private _diffuseTexture;
  92036. diffuseTexture: BABYLON.BaseTexture;
  92037. private _heightTexture;
  92038. heightTexture: BABYLON.BaseTexture;
  92039. diffuseColor: BABYLON.Color3;
  92040. furLength: number;
  92041. furAngle: number;
  92042. furColor: BABYLON.Color3;
  92043. furOffset: number;
  92044. furSpacing: number;
  92045. furGravity: BABYLON.Vector3;
  92046. furSpeed: number;
  92047. furDensity: number;
  92048. furOcclusion: number;
  92049. furTexture: BABYLON.DynamicTexture;
  92050. private _disableLighting;
  92051. disableLighting: boolean;
  92052. private _maxSimultaneousLights;
  92053. maxSimultaneousLights: number;
  92054. highLevelFur: boolean;
  92055. _meshes: BABYLON.AbstractMesh[];
  92056. private _furTime;
  92057. constructor(name: string, scene: BABYLON.Scene);
  92058. get furTime(): number;
  92059. set furTime(furTime: number);
  92060. needAlphaBlending(): boolean;
  92061. needAlphaTesting(): boolean;
  92062. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  92063. updateFur(): void;
  92064. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  92065. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  92066. getAnimatables(): BABYLON.IAnimatable[];
  92067. getActiveTextures(): BABYLON.BaseTexture[];
  92068. hasTexture(texture: BABYLON.BaseTexture): boolean;
  92069. dispose(forceDisposeEffect?: boolean): void;
  92070. clone(name: string): FurMaterial;
  92071. serialize(): any;
  92072. getClassName(): string;
  92073. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): FurMaterial;
  92074. static GenerateTexture(name: string, scene: BABYLON.Scene): BABYLON.DynamicTexture;
  92075. static FurifyMesh(sourceMesh: BABYLON.Mesh, quality: number): BABYLON.Mesh[];
  92076. }
  92077. }
  92078. declare module BABYLON {
  92079. /** @hidden */
  92080. export var gradientPixelShader: {
  92081. name: string;
  92082. shader: string;
  92083. };
  92084. }
  92085. declare module BABYLON {
  92086. /** @hidden */
  92087. export var gradientVertexShader: {
  92088. name: string;
  92089. shader: string;
  92090. };
  92091. }
  92092. declare module BABYLON {
  92093. export class GradientMaterial extends BABYLON.PushMaterial {
  92094. private _maxSimultaneousLights;
  92095. maxSimultaneousLights: number;
  92096. topColor: BABYLON.Color3;
  92097. topColorAlpha: number;
  92098. bottomColor: BABYLON.Color3;
  92099. bottomColorAlpha: number;
  92100. offset: number;
  92101. scale: number;
  92102. smoothness: number;
  92103. private _disableLighting;
  92104. disableLighting: boolean;
  92105. constructor(name: string, scene: BABYLON.Scene);
  92106. needAlphaBlending(): boolean;
  92107. needAlphaTesting(): boolean;
  92108. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  92109. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  92110. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  92111. getAnimatables(): BABYLON.IAnimatable[];
  92112. dispose(forceDisposeEffect?: boolean): void;
  92113. clone(name: string): GradientMaterial;
  92114. serialize(): any;
  92115. getClassName(): string;
  92116. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): GradientMaterial;
  92117. }
  92118. }
  92119. declare module BABYLON {
  92120. /** @hidden */
  92121. export var gridPixelShader: {
  92122. name: string;
  92123. shader: string;
  92124. };
  92125. }
  92126. declare module BABYLON {
  92127. /** @hidden */
  92128. export var gridVertexShader: {
  92129. name: string;
  92130. shader: string;
  92131. };
  92132. }
  92133. declare module BABYLON {
  92134. /**
  92135. * The grid materials allows you to wrap any shape with a grid.
  92136. * Colors are customizable.
  92137. */
  92138. export class GridMaterial extends BABYLON.PushMaterial {
  92139. /**
  92140. * Main color of the grid (e.g. between lines)
  92141. */
  92142. mainColor: BABYLON.Color3;
  92143. /**
  92144. * Color of the grid lines.
  92145. */
  92146. lineColor: BABYLON.Color3;
  92147. /**
  92148. * The scale of the grid compared to unit.
  92149. */
  92150. gridRatio: number;
  92151. /**
  92152. * Allows setting an offset for the grid lines.
  92153. */
  92154. gridOffset: BABYLON.Vector3;
  92155. /**
  92156. * The frequency of thicker lines.
  92157. */
  92158. majorUnitFrequency: number;
  92159. /**
  92160. * The visibility of minor units in the grid.
  92161. */
  92162. minorUnitVisibility: number;
  92163. /**
  92164. * The grid opacity outside of the lines.
  92165. */
  92166. opacity: number;
  92167. /**
  92168. * Determine RBG output is premultiplied by alpha value.
  92169. */
  92170. preMultiplyAlpha: boolean;
  92171. private _opacityTexture;
  92172. opacityTexture: BABYLON.BaseTexture;
  92173. private _gridControl;
  92174. /**
  92175. * constructor
  92176. * @param name The name given to the material in order to identify it afterwards.
  92177. * @param scene The scene the material is used in.
  92178. */
  92179. constructor(name: string, scene: BABYLON.Scene);
  92180. /**
  92181. * Returns wehter or not the grid requires alpha blending.
  92182. */
  92183. needAlphaBlending(): boolean;
  92184. needAlphaBlendingForMesh(mesh: BABYLON.AbstractMesh): boolean;
  92185. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  92186. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  92187. /**
  92188. * Dispose the material and its associated resources.
  92189. * @param forceDisposeEffect will also dispose the used effect when true
  92190. */
  92191. dispose(forceDisposeEffect?: boolean): void;
  92192. clone(name: string): GridMaterial;
  92193. serialize(): any;
  92194. getClassName(): string;
  92195. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): GridMaterial;
  92196. }
  92197. }
  92198. declare module BABYLON {
  92199. /** @hidden */
  92200. export var lavaPixelShader: {
  92201. name: string;
  92202. shader: string;
  92203. };
  92204. }
  92205. declare module BABYLON {
  92206. /** @hidden */
  92207. export var lavaVertexShader: {
  92208. name: string;
  92209. shader: string;
  92210. };
  92211. }
  92212. declare module BABYLON {
  92213. export class LavaMaterial extends BABYLON.PushMaterial {
  92214. private _diffuseTexture;
  92215. diffuseTexture: BABYLON.BaseTexture;
  92216. noiseTexture: BABYLON.BaseTexture;
  92217. fogColor: BABYLON.Color3;
  92218. speed: number;
  92219. movingSpeed: number;
  92220. lowFrequencySpeed: number;
  92221. fogDensity: number;
  92222. private _lastTime;
  92223. diffuseColor: BABYLON.Color3;
  92224. private _disableLighting;
  92225. disableLighting: boolean;
  92226. private _unlit;
  92227. unlit: boolean;
  92228. private _maxSimultaneousLights;
  92229. maxSimultaneousLights: number;
  92230. private _scaledDiffuse;
  92231. constructor(name: string, scene: BABYLON.Scene);
  92232. needAlphaBlending(): boolean;
  92233. needAlphaTesting(): boolean;
  92234. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  92235. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  92236. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  92237. getAnimatables(): BABYLON.IAnimatable[];
  92238. getActiveTextures(): BABYLON.BaseTexture[];
  92239. hasTexture(texture: BABYLON.BaseTexture): boolean;
  92240. dispose(forceDisposeEffect?: boolean): void;
  92241. clone(name: string): LavaMaterial;
  92242. serialize(): any;
  92243. getClassName(): string;
  92244. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): LavaMaterial;
  92245. }
  92246. }
  92247. declare module BABYLON {
  92248. /** @hidden */
  92249. export var mixPixelShader: {
  92250. name: string;
  92251. shader: string;
  92252. };
  92253. }
  92254. declare module BABYLON {
  92255. /** @hidden */
  92256. export var mixVertexShader: {
  92257. name: string;
  92258. shader: string;
  92259. };
  92260. }
  92261. declare module BABYLON {
  92262. export class MixMaterial extends BABYLON.PushMaterial {
  92263. /**
  92264. * Mix textures
  92265. */
  92266. private _mixTexture1;
  92267. mixTexture1: BABYLON.BaseTexture;
  92268. private _mixTexture2;
  92269. mixTexture2: BABYLON.BaseTexture;
  92270. /**
  92271. * Diffuse textures
  92272. */
  92273. private _diffuseTexture1;
  92274. diffuseTexture1: BABYLON.Texture;
  92275. private _diffuseTexture2;
  92276. diffuseTexture2: BABYLON.Texture;
  92277. private _diffuseTexture3;
  92278. diffuseTexture3: BABYLON.Texture;
  92279. private _diffuseTexture4;
  92280. diffuseTexture4: BABYLON.Texture;
  92281. private _diffuseTexture5;
  92282. diffuseTexture5: BABYLON.Texture;
  92283. private _diffuseTexture6;
  92284. diffuseTexture6: BABYLON.Texture;
  92285. private _diffuseTexture7;
  92286. diffuseTexture7: BABYLON.Texture;
  92287. private _diffuseTexture8;
  92288. diffuseTexture8: BABYLON.Texture;
  92289. /**
  92290. * Uniforms
  92291. */
  92292. diffuseColor: BABYLON.Color3;
  92293. specularColor: BABYLON.Color3;
  92294. specularPower: number;
  92295. private _disableLighting;
  92296. disableLighting: boolean;
  92297. private _maxSimultaneousLights;
  92298. maxSimultaneousLights: number;
  92299. constructor(name: string, scene: BABYLON.Scene);
  92300. needAlphaBlending(): boolean;
  92301. needAlphaTesting(): boolean;
  92302. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  92303. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  92304. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  92305. getAnimatables(): BABYLON.IAnimatable[];
  92306. getActiveTextures(): BABYLON.BaseTexture[];
  92307. hasTexture(texture: BABYLON.BaseTexture): boolean;
  92308. dispose(forceDisposeEffect?: boolean): void;
  92309. clone(name: string): MixMaterial;
  92310. serialize(): any;
  92311. getClassName(): string;
  92312. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): MixMaterial;
  92313. }
  92314. }
  92315. declare module BABYLON {
  92316. /** @hidden */
  92317. export var normalPixelShader: {
  92318. name: string;
  92319. shader: string;
  92320. };
  92321. }
  92322. declare module BABYLON {
  92323. /** @hidden */
  92324. export var normalVertexShader: {
  92325. name: string;
  92326. shader: string;
  92327. };
  92328. }
  92329. declare module BABYLON {
  92330. export class NormalMaterial extends BABYLON.PushMaterial {
  92331. private _diffuseTexture;
  92332. diffuseTexture: BABYLON.BaseTexture;
  92333. diffuseColor: BABYLON.Color3;
  92334. private _disableLighting;
  92335. disableLighting: boolean;
  92336. private _maxSimultaneousLights;
  92337. maxSimultaneousLights: number;
  92338. constructor(name: string, scene: BABYLON.Scene);
  92339. needAlphaBlending(): boolean;
  92340. needAlphaBlendingForMesh(mesh: BABYLON.AbstractMesh): boolean;
  92341. needAlphaTesting(): boolean;
  92342. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  92343. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  92344. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  92345. getAnimatables(): BABYLON.IAnimatable[];
  92346. getActiveTextures(): BABYLON.BaseTexture[];
  92347. hasTexture(texture: BABYLON.BaseTexture): boolean;
  92348. dispose(forceDisposeEffect?: boolean): void;
  92349. clone(name: string): NormalMaterial;
  92350. serialize(): any;
  92351. getClassName(): string;
  92352. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): NormalMaterial;
  92353. }
  92354. }
  92355. declare module BABYLON {
  92356. /** @hidden */
  92357. export var shadowOnlyPixelShader: {
  92358. name: string;
  92359. shader: string;
  92360. };
  92361. }
  92362. declare module BABYLON {
  92363. /** @hidden */
  92364. export var shadowOnlyVertexShader: {
  92365. name: string;
  92366. shader: string;
  92367. };
  92368. }
  92369. declare module BABYLON {
  92370. export class ShadowOnlyMaterial extends BABYLON.PushMaterial {
  92371. private _activeLight;
  92372. private _needAlphaBlending;
  92373. constructor(name: string, scene: BABYLON.Scene);
  92374. shadowColor: BABYLON.Color3;
  92375. needAlphaBlending(): boolean;
  92376. needAlphaTesting(): boolean;
  92377. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  92378. get activeLight(): BABYLON.IShadowLight;
  92379. set activeLight(light: BABYLON.IShadowLight);
  92380. private _getFirstShadowLightForMesh;
  92381. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  92382. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  92383. clone(name: string): ShadowOnlyMaterial;
  92384. serialize(): any;
  92385. getClassName(): string;
  92386. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): ShadowOnlyMaterial;
  92387. }
  92388. }
  92389. declare module BABYLON {
  92390. /** @hidden */
  92391. export var simplePixelShader: {
  92392. name: string;
  92393. shader: string;
  92394. };
  92395. }
  92396. declare module BABYLON {
  92397. /** @hidden */
  92398. export var simpleVertexShader: {
  92399. name: string;
  92400. shader: string;
  92401. };
  92402. }
  92403. declare module BABYLON {
  92404. export class SimpleMaterial extends BABYLON.PushMaterial {
  92405. private _diffuseTexture;
  92406. diffuseTexture: BABYLON.BaseTexture;
  92407. diffuseColor: BABYLON.Color3;
  92408. private _disableLighting;
  92409. disableLighting: boolean;
  92410. private _maxSimultaneousLights;
  92411. maxSimultaneousLights: number;
  92412. constructor(name: string, scene: BABYLON.Scene);
  92413. needAlphaBlending(): boolean;
  92414. needAlphaTesting(): boolean;
  92415. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  92416. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  92417. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  92418. getAnimatables(): BABYLON.IAnimatable[];
  92419. getActiveTextures(): BABYLON.BaseTexture[];
  92420. hasTexture(texture: BABYLON.BaseTexture): boolean;
  92421. dispose(forceDisposeEffect?: boolean): void;
  92422. clone(name: string): SimpleMaterial;
  92423. serialize(): any;
  92424. getClassName(): string;
  92425. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): SimpleMaterial;
  92426. }
  92427. }
  92428. declare module BABYLON {
  92429. /** @hidden */
  92430. export var skyPixelShader: {
  92431. name: string;
  92432. shader: string;
  92433. };
  92434. }
  92435. declare module BABYLON {
  92436. /** @hidden */
  92437. export var skyVertexShader: {
  92438. name: string;
  92439. shader: string;
  92440. };
  92441. }
  92442. declare module BABYLON {
  92443. /**
  92444. * This is the sky material which allows to create dynamic and texture free effects for skyboxes.
  92445. * @see https://doc.babylonjs.com/extensions/sky
  92446. */
  92447. export class SkyMaterial extends BABYLON.PushMaterial {
  92448. /**
  92449. * Defines the overall luminance of sky in interval ]0, 1[.
  92450. */
  92451. luminance: number;
  92452. /**
  92453. * Defines the amount (scattering) of haze as opposed to molecules in atmosphere.
  92454. */
  92455. turbidity: number;
  92456. /**
  92457. * Defines the sky appearance (light intensity).
  92458. */
  92459. rayleigh: number;
  92460. /**
  92461. * Defines the mieCoefficient in interval [0, 0.1] which affects the property .mieDirectionalG.
  92462. */
  92463. mieCoefficient: number;
  92464. /**
  92465. * Defines the amount of haze particles following the Mie scattering theory.
  92466. */
  92467. mieDirectionalG: number;
  92468. /**
  92469. * Defines the distance of the sun according to the active scene camera.
  92470. */
  92471. distance: number;
  92472. /**
  92473. * Defines the sun inclination, in interval [-0.5, 0.5]. When the inclination is not 0, the sun is said
  92474. * "inclined".
  92475. */
  92476. inclination: number;
  92477. /**
  92478. * Defines the solar azimuth in interval [0, 1]. The azimuth is the angle in the horizontal plan between
  92479. * an object direction and a reference direction.
  92480. */
  92481. azimuth: number;
  92482. /**
  92483. * Defines the sun position in the sky on (x,y,z). If the property .useSunPosition is set to false, then
  92484. * the property is overriden by the inclination and the azimuth and can be read at any moment.
  92485. */
  92486. sunPosition: BABYLON.Vector3;
  92487. /**
  92488. * Defines if the sun position should be computed (inclination and azimuth) according to the given
  92489. * .sunPosition property.
  92490. */
  92491. useSunPosition: boolean;
  92492. /**
  92493. * Defines an offset vector used to get a horizon offset.
  92494. * @example skyMaterial.cameraOffset.y = camera.globalPosition.y // Set horizon relative to 0 on the Y axis
  92495. */
  92496. cameraOffset: BABYLON.Vector3;
  92497. /**
  92498. * Defines the vector the skyMaterial should consider as up. (default is BABYLON.Vector3(0, 1, 0) as returned by BABYLON.Vector3.Up())
  92499. */
  92500. up: BABYLON.Vector3;
  92501. private _cameraPosition;
  92502. private _skyOrientation;
  92503. /**
  92504. * Instantiates a new sky material.
  92505. * This material allows to create dynamic and texture free
  92506. * effects for skyboxes by taking care of the atmosphere state.
  92507. * @see https://doc.babylonjs.com/extensions/sky
  92508. * @param name Define the name of the material in the scene
  92509. * @param scene Define the scene the material belong to
  92510. */
  92511. constructor(name: string, scene: BABYLON.Scene);
  92512. /**
  92513. * Specifies if the material will require alpha blending
  92514. * @returns a boolean specifying if alpha blending is needed
  92515. */
  92516. needAlphaBlending(): boolean;
  92517. /**
  92518. * Specifies if this material should be rendered in alpha test mode
  92519. * @returns false as the sky material doesn't need alpha testing.
  92520. */
  92521. needAlphaTesting(): boolean;
  92522. /**
  92523. * Get the texture used for alpha test purpose.
  92524. * @returns null as the sky material has no texture.
  92525. */
  92526. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  92527. /**
  92528. * Get if the submesh is ready to be used and all its information available.
  92529. * Child classes can use it to update shaders
  92530. * @param mesh defines the mesh to check
  92531. * @param subMesh defines which submesh to check
  92532. * @param useInstances specifies that instances should be used
  92533. * @returns a boolean indicating that the submesh is ready or not
  92534. */
  92535. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  92536. /**
  92537. * Binds the submesh to this material by preparing the effect and shader to draw
  92538. * @param world defines the world transformation matrix
  92539. * @param mesh defines the mesh containing the submesh
  92540. * @param subMesh defines the submesh to bind the material to
  92541. */
  92542. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  92543. /**
  92544. * Get the list of animatables in the material.
  92545. * @returns the list of animatables object used in the material
  92546. */
  92547. getAnimatables(): BABYLON.IAnimatable[];
  92548. /**
  92549. * Disposes the material
  92550. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  92551. */
  92552. dispose(forceDisposeEffect?: boolean): void;
  92553. /**
  92554. * Makes a duplicate of the material, and gives it a new name
  92555. * @param name defines the new name for the duplicated material
  92556. * @returns the cloned material
  92557. */
  92558. clone(name: string): SkyMaterial;
  92559. /**
  92560. * Serializes this material in a JSON representation
  92561. * @returns the serialized material object
  92562. */
  92563. serialize(): any;
  92564. /**
  92565. * Gets the current class name of the material e.g. "SkyMaterial"
  92566. * Mainly use in serialization.
  92567. * @returns the class name
  92568. */
  92569. getClassName(): string;
  92570. /**
  92571. * Creates a sky material from parsed material data
  92572. * @param source defines the JSON representation of the material
  92573. * @param scene defines the hosting scene
  92574. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  92575. * @returns a new sky material
  92576. */
  92577. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): SkyMaterial;
  92578. }
  92579. }
  92580. declare module BABYLON {
  92581. /** @hidden */
  92582. export var terrainPixelShader: {
  92583. name: string;
  92584. shader: string;
  92585. };
  92586. }
  92587. declare module BABYLON {
  92588. /** @hidden */
  92589. export var terrainVertexShader: {
  92590. name: string;
  92591. shader: string;
  92592. };
  92593. }
  92594. declare module BABYLON {
  92595. export class TerrainMaterial extends BABYLON.PushMaterial {
  92596. private _mixTexture;
  92597. mixTexture: BABYLON.BaseTexture;
  92598. private _diffuseTexture1;
  92599. diffuseTexture1: BABYLON.Texture;
  92600. private _diffuseTexture2;
  92601. diffuseTexture2: BABYLON.Texture;
  92602. private _diffuseTexture3;
  92603. diffuseTexture3: BABYLON.Texture;
  92604. private _bumpTexture1;
  92605. bumpTexture1: BABYLON.Texture;
  92606. private _bumpTexture2;
  92607. bumpTexture2: BABYLON.Texture;
  92608. private _bumpTexture3;
  92609. bumpTexture3: BABYLON.Texture;
  92610. diffuseColor: BABYLON.Color3;
  92611. specularColor: BABYLON.Color3;
  92612. specularPower: number;
  92613. private _disableLighting;
  92614. disableLighting: boolean;
  92615. private _maxSimultaneousLights;
  92616. maxSimultaneousLights: number;
  92617. constructor(name: string, scene: BABYLON.Scene);
  92618. needAlphaBlending(): boolean;
  92619. needAlphaTesting(): boolean;
  92620. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  92621. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  92622. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  92623. getAnimatables(): BABYLON.IAnimatable[];
  92624. getActiveTextures(): BABYLON.BaseTexture[];
  92625. hasTexture(texture: BABYLON.BaseTexture): boolean;
  92626. dispose(forceDisposeEffect?: boolean): void;
  92627. clone(name: string): TerrainMaterial;
  92628. serialize(): any;
  92629. getClassName(): string;
  92630. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): TerrainMaterial;
  92631. }
  92632. }
  92633. declare module BABYLON {
  92634. /** @hidden */
  92635. export var triplanarPixelShader: {
  92636. name: string;
  92637. shader: string;
  92638. };
  92639. }
  92640. declare module BABYLON {
  92641. /** @hidden */
  92642. export var triplanarVertexShader: {
  92643. name: string;
  92644. shader: string;
  92645. };
  92646. }
  92647. declare module BABYLON {
  92648. export class TriPlanarMaterial extends BABYLON.PushMaterial {
  92649. mixTexture: BABYLON.BaseTexture;
  92650. private _diffuseTextureX;
  92651. diffuseTextureX: BABYLON.BaseTexture;
  92652. private _diffuseTextureY;
  92653. diffuseTextureY: BABYLON.BaseTexture;
  92654. private _diffuseTextureZ;
  92655. diffuseTextureZ: BABYLON.BaseTexture;
  92656. private _normalTextureX;
  92657. normalTextureX: BABYLON.BaseTexture;
  92658. private _normalTextureY;
  92659. normalTextureY: BABYLON.BaseTexture;
  92660. private _normalTextureZ;
  92661. normalTextureZ: BABYLON.BaseTexture;
  92662. tileSize: number;
  92663. diffuseColor: BABYLON.Color3;
  92664. specularColor: BABYLON.Color3;
  92665. specularPower: number;
  92666. private _disableLighting;
  92667. disableLighting: boolean;
  92668. private _maxSimultaneousLights;
  92669. maxSimultaneousLights: number;
  92670. constructor(name: string, scene: BABYLON.Scene);
  92671. needAlphaBlending(): boolean;
  92672. needAlphaTesting(): boolean;
  92673. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  92674. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  92675. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  92676. getAnimatables(): BABYLON.IAnimatable[];
  92677. getActiveTextures(): BABYLON.BaseTexture[];
  92678. hasTexture(texture: BABYLON.BaseTexture): boolean;
  92679. dispose(forceDisposeEffect?: boolean): void;
  92680. clone(name: string): TriPlanarMaterial;
  92681. serialize(): any;
  92682. getClassName(): string;
  92683. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): TriPlanarMaterial;
  92684. }
  92685. }
  92686. declare module BABYLON {
  92687. /** @hidden */
  92688. export var waterPixelShader: {
  92689. name: string;
  92690. shader: string;
  92691. };
  92692. }
  92693. declare module BABYLON {
  92694. /** @hidden */
  92695. export var waterVertexShader: {
  92696. name: string;
  92697. shader: string;
  92698. };
  92699. }
  92700. declare module BABYLON {
  92701. export class WaterMaterial extends BABYLON.PushMaterial {
  92702. renderTargetSize: BABYLON.Vector2;
  92703. private _bumpTexture;
  92704. bumpTexture: BABYLON.BaseTexture;
  92705. diffuseColor: BABYLON.Color3;
  92706. specularColor: BABYLON.Color3;
  92707. specularPower: number;
  92708. private _disableLighting;
  92709. disableLighting: boolean;
  92710. private _maxSimultaneousLights;
  92711. maxSimultaneousLights: number;
  92712. /**
  92713. * Defines the wind force.
  92714. */
  92715. windForce: number;
  92716. /**
  92717. * Defines the direction of the wind in the plane (X, Z).
  92718. */
  92719. windDirection: BABYLON.Vector2;
  92720. /**
  92721. * Defines the height of the waves.
  92722. */
  92723. waveHeight: number;
  92724. /**
  92725. * Defines the bump height related to the bump map.
  92726. */
  92727. bumpHeight: number;
  92728. /**
  92729. * Defines wether or not: to add a smaller moving bump to less steady waves.
  92730. */
  92731. private _bumpSuperimpose;
  92732. bumpSuperimpose: boolean;
  92733. /**
  92734. * Defines wether or not color refraction and reflection differently with .waterColor2 and .colorBlendFactor2. Non-linear (physically correct) fresnel.
  92735. */
  92736. private _fresnelSeparate;
  92737. fresnelSeparate: boolean;
  92738. /**
  92739. * Defines wether or not bump Wwves modify the reflection.
  92740. */
  92741. private _bumpAffectsReflection;
  92742. bumpAffectsReflection: boolean;
  92743. /**
  92744. * Defines the water color blended with the refraction (near).
  92745. */
  92746. waterColor: BABYLON.Color3;
  92747. /**
  92748. * Defines the blend factor related to the water color.
  92749. */
  92750. colorBlendFactor: number;
  92751. /**
  92752. * Defines the water color blended with the reflection (far).
  92753. */
  92754. waterColor2: BABYLON.Color3;
  92755. /**
  92756. * Defines the blend factor related to the water color (reflection, far).
  92757. */
  92758. colorBlendFactor2: number;
  92759. /**
  92760. * Defines the maximum length of a wave.
  92761. */
  92762. waveLength: number;
  92763. /**
  92764. * Defines the waves speed.
  92765. */
  92766. waveSpeed: number;
  92767. /**
  92768. * 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.
  92769. */
  92770. waveCount: number;
  92771. /**
  92772. * Sets or gets whether or not automatic clipping should be enabled or not. Setting to true will save performances and
  92773. * will avoid calculating useless pixels in the pixel shader of the water material.
  92774. */
  92775. disableClipPlane: boolean;
  92776. protected _renderTargets: BABYLON.SmartArray<BABYLON.RenderTargetTexture>;
  92777. private _mesh;
  92778. private _refractionRTT;
  92779. private _reflectionRTT;
  92780. private _reflectionTransform;
  92781. private _lastTime;
  92782. private _lastDeltaTime;
  92783. private _useLogarithmicDepth;
  92784. private _waitingRenderList;
  92785. private _imageProcessingConfiguration;
  92786. private _imageProcessingObserver;
  92787. /**
  92788. * Gets a boolean indicating that current material needs to register RTT
  92789. */
  92790. get hasRenderTargetTextures(): boolean;
  92791. /**
  92792. * Constructor
  92793. */
  92794. constructor(name: string, scene: BABYLON.Scene, renderTargetSize?: BABYLON.Vector2);
  92795. get useLogarithmicDepth(): boolean;
  92796. set useLogarithmicDepth(value: boolean);
  92797. get refractionTexture(): BABYLON.Nullable<BABYLON.RenderTargetTexture>;
  92798. get reflectionTexture(): BABYLON.Nullable<BABYLON.RenderTargetTexture>;
  92799. addToRenderList(node: any): void;
  92800. enableRenderTargets(enable: boolean): void;
  92801. getRenderList(): BABYLON.Nullable<BABYLON.AbstractMesh[]>;
  92802. get renderTargetsEnabled(): boolean;
  92803. needAlphaBlending(): boolean;
  92804. needAlphaTesting(): boolean;
  92805. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  92806. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  92807. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  92808. private _createRenderTargets;
  92809. getAnimatables(): BABYLON.IAnimatable[];
  92810. getActiveTextures(): BABYLON.BaseTexture[];
  92811. hasTexture(texture: BABYLON.BaseTexture): boolean;
  92812. dispose(forceDisposeEffect?: boolean): void;
  92813. clone(name: string): WaterMaterial;
  92814. serialize(): any;
  92815. getClassName(): string;
  92816. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): WaterMaterial;
  92817. static CreateDefaultMesh(name: string, scene: BABYLON.Scene): BABYLON.Mesh;
  92818. }
  92819. }
  92820. declare module BABYLON {
  92821. /** @hidden */
  92822. export var asciiartPixelShader: {
  92823. name: string;
  92824. shader: string;
  92825. };
  92826. }
  92827. declare module BABYLON {
  92828. /**
  92829. * AsciiArtFontTexture is the helper class used to easily create your ascii art font texture.
  92830. *
  92831. * It basically takes care rendering the font front the given font size to a texture.
  92832. * This is used later on in the postprocess.
  92833. */
  92834. export class AsciiArtFontTexture extends BABYLON.BaseTexture {
  92835. private _font;
  92836. private _text;
  92837. private _charSize;
  92838. /**
  92839. * Gets the size of one char in the texture (each char fits in size * size space in the texture).
  92840. */
  92841. get charSize(): number;
  92842. /**
  92843. * Create a new instance of the Ascii Art FontTexture class
  92844. * @param name the name of the texture
  92845. * @param font the font to use, use the W3C CSS notation
  92846. * @param text the caracter set to use in the rendering.
  92847. * @param scene the scene that owns the texture
  92848. */
  92849. constructor(name: string, font: string, text: string, scene?: BABYLON.Nullable<BABYLON.Scene>);
  92850. /**
  92851. * Gets the max char width of a font.
  92852. * @param font the font to use, use the W3C CSS notation
  92853. * @return the max char width
  92854. */
  92855. private getFontWidth;
  92856. /**
  92857. * Gets the max char height of a font.
  92858. * @param font the font to use, use the W3C CSS notation
  92859. * @return the max char height
  92860. */
  92861. private getFontHeight;
  92862. /**
  92863. * Clones the current AsciiArtTexture.
  92864. * @return the clone of the texture.
  92865. */
  92866. clone(): AsciiArtFontTexture;
  92867. /**
  92868. * Parses a json object representing the texture and returns an instance of it.
  92869. * @param source the source JSON representation
  92870. * @param scene the scene to create the texture for
  92871. * @return the parsed texture
  92872. */
  92873. static Parse(source: any, scene: BABYLON.Scene): AsciiArtFontTexture;
  92874. }
  92875. /**
  92876. * Option available in the Ascii Art Post Process.
  92877. */
  92878. export interface IAsciiArtPostProcessOptions {
  92879. /**
  92880. * The font to use following the w3c font definition.
  92881. */
  92882. font?: string;
  92883. /**
  92884. * The character set to use in the postprocess.
  92885. */
  92886. characterSet?: string;
  92887. /**
  92888. * This defines the amount you want to mix the "tile" or caracter space colored in the ascii art.
  92889. * This number is defined between 0 and 1;
  92890. */
  92891. mixToTile?: number;
  92892. /**
  92893. * This defines the amount you want to mix the normal rendering pass in the ascii art.
  92894. * This number is defined between 0 and 1;
  92895. */
  92896. mixToNormal?: number;
  92897. }
  92898. /**
  92899. * AsciiArtPostProcess helps rendering everithing in Ascii Art.
  92900. *
  92901. * Simmply add it to your scene and let the nerd that lives in you have fun.
  92902. * Example usage: var pp = new AsciiArtPostProcess("myAscii", "20px Monospace", camera);
  92903. */
  92904. export class AsciiArtPostProcess extends BABYLON.PostProcess {
  92905. /**
  92906. * The font texture used to render the char in the post process.
  92907. */
  92908. private _asciiArtFontTexture;
  92909. /**
  92910. * This defines the amount you want to mix the "tile" or caracter space colored in the ascii art.
  92911. * This number is defined between 0 and 1;
  92912. */
  92913. mixToTile: number;
  92914. /**
  92915. * This defines the amount you want to mix the normal rendering pass in the ascii art.
  92916. * This number is defined between 0 and 1;
  92917. */
  92918. mixToNormal: number;
  92919. /**
  92920. * Instantiates a new Ascii Art Post Process.
  92921. * @param name the name to give to the postprocess
  92922. * @camera the camera to apply the post process to.
  92923. * @param options can either be the font name or an option object following the IAsciiArtPostProcessOptions format
  92924. */
  92925. constructor(name: string, camera: BABYLON.Camera, options?: string | IAsciiArtPostProcessOptions);
  92926. }
  92927. }
  92928. declare module BABYLON {
  92929. /** @hidden */
  92930. export var digitalrainPixelShader: {
  92931. name: string;
  92932. shader: string;
  92933. };
  92934. }
  92935. declare module BABYLON {
  92936. /**
  92937. * DigitalRainFontTexture is the helper class used to easily create your digital rain font texture.
  92938. *
  92939. * It basically takes care rendering the font front the given font size to a texture.
  92940. * This is used later on in the postprocess.
  92941. */
  92942. export class DigitalRainFontTexture extends BABYLON.BaseTexture {
  92943. private _font;
  92944. private _text;
  92945. private _charSize;
  92946. /**
  92947. * Gets the size of one char in the texture (each char fits in size * size space in the texture).
  92948. */
  92949. get charSize(): number;
  92950. /**
  92951. * Create a new instance of the Digital Rain FontTexture class
  92952. * @param name the name of the texture
  92953. * @param font the font to use, use the W3C CSS notation
  92954. * @param text the caracter set to use in the rendering.
  92955. * @param scene the scene that owns the texture
  92956. */
  92957. constructor(name: string, font: string, text: string, scene?: BABYLON.Nullable<BABYLON.Scene>);
  92958. /**
  92959. * Gets the max char width of a font.
  92960. * @param font the font to use, use the W3C CSS notation
  92961. * @return the max char width
  92962. */
  92963. private getFontWidth;
  92964. /**
  92965. * Gets the max char height of a font.
  92966. * @param font the font to use, use the W3C CSS notation
  92967. * @return the max char height
  92968. */
  92969. private getFontHeight;
  92970. /**
  92971. * Clones the current DigitalRainFontTexture.
  92972. * @return the clone of the texture.
  92973. */
  92974. clone(): DigitalRainFontTexture;
  92975. /**
  92976. * Parses a json object representing the texture and returns an instance of it.
  92977. * @param source the source JSON representation
  92978. * @param scene the scene to create the texture for
  92979. * @return the parsed texture
  92980. */
  92981. static Parse(source: any, scene: BABYLON.Scene): DigitalRainFontTexture;
  92982. }
  92983. /**
  92984. * Option available in the Digital Rain Post Process.
  92985. */
  92986. export interface IDigitalRainPostProcessOptions {
  92987. /**
  92988. * The font to use following the w3c font definition.
  92989. */
  92990. font?: string;
  92991. /**
  92992. * This defines the amount you want to mix the "tile" or caracter space colored in the digital rain.
  92993. * This number is defined between 0 and 1;
  92994. */
  92995. mixToTile?: number;
  92996. /**
  92997. * This defines the amount you want to mix the normal rendering pass in the digital rain.
  92998. * This number is defined between 0 and 1;
  92999. */
  93000. mixToNormal?: number;
  93001. }
  93002. /**
  93003. * DigitalRainPostProcess helps rendering everithing in digital rain.
  93004. *
  93005. * Simmply add it to your scene and let the nerd that lives in you have fun.
  93006. * Example usage: var pp = new DigitalRainPostProcess("digitalRain", "20px Monospace", camera);
  93007. */
  93008. export class DigitalRainPostProcess extends BABYLON.PostProcess {
  93009. /**
  93010. * The font texture used to render the char in the post process.
  93011. */
  93012. private _digitalRainFontTexture;
  93013. /**
  93014. * This defines the amount you want to mix the "tile" or caracter space colored in the digital rain.
  93015. * This number is defined between 0 and 1;
  93016. */
  93017. mixToTile: number;
  93018. /**
  93019. * This defines the amount you want to mix the normal rendering pass in the digital rain.
  93020. * This number is defined between 0 and 1;
  93021. */
  93022. mixToNormal: number;
  93023. /**
  93024. * Instantiates a new Digital Rain Post Process.
  93025. * @param name the name to give to the postprocess
  93026. * @camera the camera to apply the post process to.
  93027. * @param options can either be the font name or an option object following the IDigitalRainPostProcessOptions format
  93028. */
  93029. constructor(name: string, camera: BABYLON.Camera, options?: string | IDigitalRainPostProcessOptions);
  93030. }
  93031. }
  93032. declare module BABYLON {
  93033. /** @hidden */
  93034. export var brickProceduralTexturePixelShader: {
  93035. name: string;
  93036. shader: string;
  93037. };
  93038. }
  93039. declare module BABYLON {
  93040. export class BrickProceduralTexture extends BABYLON.ProceduralTexture {
  93041. private _numberOfBricksHeight;
  93042. private _numberOfBricksWidth;
  93043. private _jointColor;
  93044. private _brickColor;
  93045. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  93046. updateShaderUniforms(): void;
  93047. get numberOfBricksHeight(): number;
  93048. set numberOfBricksHeight(value: number);
  93049. get numberOfBricksWidth(): number;
  93050. set numberOfBricksWidth(value: number);
  93051. get jointColor(): BABYLON.Color3;
  93052. set jointColor(value: BABYLON.Color3);
  93053. get brickColor(): BABYLON.Color3;
  93054. set brickColor(value: BABYLON.Color3);
  93055. /**
  93056. * Serializes this brick procedural texture
  93057. * @returns a serialized brick procedural texture object
  93058. */
  93059. serialize(): any;
  93060. /**
  93061. * Creates a Brick Procedural BABYLON.Texture from parsed brick procedural texture data
  93062. * @param parsedTexture defines parsed texture data
  93063. * @param scene defines the current scene
  93064. * @param rootUrl defines the root URL containing brick procedural texture information
  93065. * @returns a parsed Brick Procedural BABYLON.Texture
  93066. */
  93067. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): BrickProceduralTexture;
  93068. }
  93069. }
  93070. declare module BABYLON {
  93071. /** @hidden */
  93072. export var cloudProceduralTexturePixelShader: {
  93073. name: string;
  93074. shader: string;
  93075. };
  93076. }
  93077. declare module BABYLON {
  93078. export class CloudProceduralTexture extends BABYLON.ProceduralTexture {
  93079. private _skyColor;
  93080. private _cloudColor;
  93081. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  93082. updateShaderUniforms(): void;
  93083. get skyColor(): BABYLON.Color4;
  93084. set skyColor(value: BABYLON.Color4);
  93085. get cloudColor(): BABYLON.Color4;
  93086. set cloudColor(value: BABYLON.Color4);
  93087. /**
  93088. * Serializes this cloud procedural texture
  93089. * @returns a serialized cloud procedural texture object
  93090. */
  93091. serialize(): any;
  93092. /**
  93093. * Creates a Cloud Procedural BABYLON.Texture from parsed cloud procedural texture data
  93094. * @param parsedTexture defines parsed texture data
  93095. * @param scene defines the current scene
  93096. * @param rootUrl defines the root URL containing cloud procedural texture information
  93097. * @returns a parsed Cloud Procedural BABYLON.Texture
  93098. */
  93099. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): CloudProceduralTexture;
  93100. }
  93101. }
  93102. declare module BABYLON {
  93103. /** @hidden */
  93104. export var fireProceduralTexturePixelShader: {
  93105. name: string;
  93106. shader: string;
  93107. };
  93108. }
  93109. declare module BABYLON {
  93110. export class FireProceduralTexture extends BABYLON.ProceduralTexture {
  93111. private _time;
  93112. private _speed;
  93113. private _autoGenerateTime;
  93114. private _fireColors;
  93115. private _alphaThreshold;
  93116. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  93117. updateShaderUniforms(): void;
  93118. render(useCameraPostProcess?: boolean): void;
  93119. static get PurpleFireColors(): BABYLON.Color3[];
  93120. static get GreenFireColors(): BABYLON.Color3[];
  93121. static get RedFireColors(): BABYLON.Color3[];
  93122. static get BlueFireColors(): BABYLON.Color3[];
  93123. get autoGenerateTime(): boolean;
  93124. set autoGenerateTime(value: boolean);
  93125. get fireColors(): BABYLON.Color3[];
  93126. set fireColors(value: BABYLON.Color3[]);
  93127. get time(): number;
  93128. set time(value: number);
  93129. get speed(): BABYLON.Vector2;
  93130. set speed(value: BABYLON.Vector2);
  93131. get alphaThreshold(): number;
  93132. set alphaThreshold(value: number);
  93133. /**
  93134. * Serializes this fire procedural texture
  93135. * @returns a serialized fire procedural texture object
  93136. */
  93137. serialize(): any;
  93138. /**
  93139. * Creates a Fire Procedural BABYLON.Texture from parsed fire procedural texture data
  93140. * @param parsedTexture defines parsed texture data
  93141. * @param scene defines the current scene
  93142. * @param rootUrl defines the root URL containing fire procedural texture information
  93143. * @returns a parsed Fire Procedural BABYLON.Texture
  93144. */
  93145. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): FireProceduralTexture;
  93146. }
  93147. }
  93148. declare module BABYLON {
  93149. /** @hidden */
  93150. export var grassProceduralTexturePixelShader: {
  93151. name: string;
  93152. shader: string;
  93153. };
  93154. }
  93155. declare module BABYLON {
  93156. export class GrassProceduralTexture extends BABYLON.ProceduralTexture {
  93157. private _grassColors;
  93158. private _groundColor;
  93159. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  93160. updateShaderUniforms(): void;
  93161. get grassColors(): BABYLON.Color3[];
  93162. set grassColors(value: BABYLON.Color3[]);
  93163. get groundColor(): BABYLON.Color3;
  93164. set groundColor(value: BABYLON.Color3);
  93165. /**
  93166. * Serializes this grass procedural texture
  93167. * @returns a serialized grass procedural texture object
  93168. */
  93169. serialize(): any;
  93170. /**
  93171. * Creates a Grass Procedural BABYLON.Texture from parsed grass procedural texture data
  93172. * @param parsedTexture defines parsed texture data
  93173. * @param scene defines the current scene
  93174. * @param rootUrl defines the root URL containing grass procedural texture information
  93175. * @returns a parsed Grass Procedural BABYLON.Texture
  93176. */
  93177. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): GrassProceduralTexture;
  93178. }
  93179. }
  93180. declare module BABYLON {
  93181. /** @hidden */
  93182. export var marbleProceduralTexturePixelShader: {
  93183. name: string;
  93184. shader: string;
  93185. };
  93186. }
  93187. declare module BABYLON {
  93188. export class MarbleProceduralTexture extends BABYLON.ProceduralTexture {
  93189. private _numberOfTilesHeight;
  93190. private _numberOfTilesWidth;
  93191. private _amplitude;
  93192. private _jointColor;
  93193. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  93194. updateShaderUniforms(): void;
  93195. get numberOfTilesHeight(): number;
  93196. set numberOfTilesHeight(value: number);
  93197. get amplitude(): number;
  93198. set amplitude(value: number);
  93199. get numberOfTilesWidth(): number;
  93200. set numberOfTilesWidth(value: number);
  93201. get jointColor(): BABYLON.Color3;
  93202. set jointColor(value: BABYLON.Color3);
  93203. /**
  93204. * Serializes this marble procedural texture
  93205. * @returns a serialized marble procedural texture object
  93206. */
  93207. serialize(): any;
  93208. /**
  93209. * Creates a Marble Procedural BABYLON.Texture from parsed marble procedural texture data
  93210. * @param parsedTexture defines parsed texture data
  93211. * @param scene defines the current scene
  93212. * @param rootUrl defines the root URL containing marble procedural texture information
  93213. * @returns a parsed Marble Procedural BABYLON.Texture
  93214. */
  93215. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): MarbleProceduralTexture;
  93216. }
  93217. }
  93218. declare module BABYLON {
  93219. /** @hidden */
  93220. export var normalMapProceduralTexturePixelShader: {
  93221. name: string;
  93222. shader: string;
  93223. };
  93224. }
  93225. declare module BABYLON {
  93226. export class NormalMapProceduralTexture extends BABYLON.ProceduralTexture {
  93227. private _baseTexture;
  93228. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  93229. updateShaderUniforms(): void;
  93230. render(useCameraPostProcess?: boolean): void;
  93231. resize(size: any, generateMipMaps: any): void;
  93232. isReady(): boolean;
  93233. get baseTexture(): BABYLON.Texture;
  93234. set baseTexture(texture: BABYLON.Texture);
  93235. /**
  93236. * Serializes this normal map procedural texture
  93237. * @returns a serialized normal map procedural texture object
  93238. */
  93239. serialize(): any;
  93240. /**
  93241. * Creates a Normal Map Procedural BABYLON.Texture from parsed normal map procedural texture data
  93242. * @param parsedTexture defines parsed texture data
  93243. * @param scene defines the current scene
  93244. * @param rootUrl defines the root URL containing normal map procedural texture information
  93245. * @returns a parsed Normal Map Procedural BABYLON.Texture
  93246. */
  93247. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): NormalMapProceduralTexture;
  93248. }
  93249. }
  93250. declare module BABYLON {
  93251. /** @hidden */
  93252. export var perlinNoiseProceduralTexturePixelShader: {
  93253. name: string;
  93254. shader: string;
  93255. };
  93256. }
  93257. declare module BABYLON {
  93258. export class PerlinNoiseProceduralTexture extends BABYLON.ProceduralTexture {
  93259. time: number;
  93260. timeScale: number;
  93261. translationSpeed: number;
  93262. private _currentTranslation;
  93263. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  93264. updateShaderUniforms(): void;
  93265. render(useCameraPostProcess?: boolean): void;
  93266. resize(size: any, generateMipMaps: any): void;
  93267. /**
  93268. * Serializes this perlin noise procedural texture
  93269. * @returns a serialized perlin noise procedural texture object
  93270. */
  93271. serialize(): any;
  93272. /**
  93273. * Creates a Perlin Noise Procedural BABYLON.Texture from parsed perlin noise procedural texture data
  93274. * @param parsedTexture defines parsed texture data
  93275. * @param scene defines the current scene
  93276. * @param rootUrl defines the root URL containing perlin noise procedural texture information
  93277. * @returns a parsed Perlin Noise Procedural BABYLON.Texture
  93278. */
  93279. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): PerlinNoiseProceduralTexture;
  93280. }
  93281. }
  93282. declare module BABYLON {
  93283. /** @hidden */
  93284. export var roadProceduralTexturePixelShader: {
  93285. name: string;
  93286. shader: string;
  93287. };
  93288. }
  93289. declare module BABYLON {
  93290. export class RoadProceduralTexture extends BABYLON.ProceduralTexture {
  93291. private _roadColor;
  93292. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  93293. updateShaderUniforms(): void;
  93294. get roadColor(): BABYLON.Color3;
  93295. set roadColor(value: BABYLON.Color3);
  93296. /**
  93297. * Serializes this road procedural texture
  93298. * @returns a serialized road procedural texture object
  93299. */
  93300. serialize(): any;
  93301. /**
  93302. * Creates a Road Procedural BABYLON.Texture from parsed road procedural texture data
  93303. * @param parsedTexture defines parsed texture data
  93304. * @param scene defines the current scene
  93305. * @param rootUrl defines the root URL containing road procedural texture information
  93306. * @returns a parsed Road Procedural BABYLON.Texture
  93307. */
  93308. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): RoadProceduralTexture;
  93309. }
  93310. }
  93311. declare module BABYLON {
  93312. /** @hidden */
  93313. export var starfieldProceduralTexturePixelShader: {
  93314. name: string;
  93315. shader: string;
  93316. };
  93317. }
  93318. declare module BABYLON {
  93319. export class StarfieldProceduralTexture extends BABYLON.ProceduralTexture {
  93320. private _time;
  93321. private _alpha;
  93322. private _beta;
  93323. private _zoom;
  93324. private _formuparam;
  93325. private _stepsize;
  93326. private _tile;
  93327. private _brightness;
  93328. private _darkmatter;
  93329. private _distfading;
  93330. private _saturation;
  93331. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  93332. updateShaderUniforms(): void;
  93333. get time(): number;
  93334. set time(value: number);
  93335. get alpha(): number;
  93336. set alpha(value: number);
  93337. get beta(): number;
  93338. set beta(value: number);
  93339. get formuparam(): number;
  93340. set formuparam(value: number);
  93341. get stepsize(): number;
  93342. set stepsize(value: number);
  93343. get zoom(): number;
  93344. set zoom(value: number);
  93345. get tile(): number;
  93346. set tile(value: number);
  93347. get brightness(): number;
  93348. set brightness(value: number);
  93349. get darkmatter(): number;
  93350. set darkmatter(value: number);
  93351. get distfading(): number;
  93352. set distfading(value: number);
  93353. get saturation(): number;
  93354. set saturation(value: number);
  93355. /**
  93356. * Serializes this starfield procedural texture
  93357. * @returns a serialized starfield procedural texture object
  93358. */
  93359. serialize(): any;
  93360. /**
  93361. * Creates a Starfield Procedural BABYLON.Texture from parsed startfield procedural texture data
  93362. * @param parsedTexture defines parsed texture data
  93363. * @param scene defines the current scene
  93364. * @param rootUrl defines the root URL containing startfield procedural texture information
  93365. * @returns a parsed Starfield Procedural BABYLON.Texture
  93366. */
  93367. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): StarfieldProceduralTexture;
  93368. }
  93369. }
  93370. declare module BABYLON {
  93371. /** @hidden */
  93372. export var woodProceduralTexturePixelShader: {
  93373. name: string;
  93374. shader: string;
  93375. };
  93376. }
  93377. declare module BABYLON {
  93378. export class WoodProceduralTexture extends BABYLON.ProceduralTexture {
  93379. private _ampScale;
  93380. private _woodColor;
  93381. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  93382. updateShaderUniforms(): void;
  93383. get ampScale(): number;
  93384. set ampScale(value: number);
  93385. get woodColor(): BABYLON.Color3;
  93386. set woodColor(value: BABYLON.Color3);
  93387. /**
  93388. * Serializes this wood procedural texture
  93389. * @returns a serialized wood procedural texture object
  93390. */
  93391. serialize(): any;
  93392. /**
  93393. * Creates a Wood Procedural BABYLON.Texture from parsed wood procedural texture data
  93394. * @param parsedTexture defines parsed texture data
  93395. * @param scene defines the current scene
  93396. * @param rootUrl defines the root URL containing wood procedural texture information
  93397. * @returns a parsed Wood Procedural BABYLON.Texture
  93398. */
  93399. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): WoodProceduralTexture;
  93400. }
  93401. }